/* =============== 客户售后跟踪系统 - 全局样式 =============== */
:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --primary-light: #eef1ff;
    --success: #2ec4b6;
    --danger: #e71d36;
    --warning: #ff9f1c;
    --info: #4cc9f0;
    --bg: #f5f7fa;
    --bg-white: #ffffff;
    --text: #2d3436;
    --text-light: #636e72;
    --text-muted: #b2bec3;
    --border: #dfe6e9;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --radius: 8px;
    --sidebar-w: 240px;
    --header-h: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
}

a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* =============== 登录页 =============== */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: linear-gradient(135deg, #4361ee 0%, #3a56d4 50%, #2b3a9e 100%);
}
.login-box {
    background: #fff; border-radius: 12px; padding: 40px; width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.login-box h1 {
    text-align: center; font-size: 24px; color: var(--text); margin-bottom: 8px;
}
.login-box .subtitle {
    text-align: center; color: var(--text-light); font-size: 13px; margin-bottom: 32px;
}
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; font-size: 13px; color: var(--text-light); margin-bottom: 6px; font-weight: 500;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 14px; transition: border-color 0.2s; outline: none; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group textarea { resize: vertical; min-height: 80px; }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 20px; border: none; border-radius: 6px; font-size: 14px;
    cursor: pointer; transition: all 0.2s; font-weight: 500; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { opacity: 0.9; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-default { background: #f1f3f5; color: var(--text); }
.btn-default:hover { background: var(--border); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* =============== 主布局 =============== */
.main-layout {
    display: flex; min-height: 100vh;
}
.sidebar {
    width: var(--sidebar-w); background: #1a1d29; color: #e0e0e0;
    position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto;
    z-index: 100; transition: transform 0.3s;
}
.sidebar-logo {
    height: var(--header-h); display: flex; align-items: center; padding: 0 20px;
    font-size: 18px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
    padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; gap: 10px;
}
.sidebar-user .avatar {
    width: 36px; height: 36px; background: var(--primary); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 14px;
}
.sidebar-user .info { flex: 1; min-width: 0; }
.sidebar-user .name { font-size: 13px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .role { font-size: 11px; color: #9ca3af; }
.sidebar-menu { padding: 12px 0; }
.sidebar-menu .menu-group { margin-bottom: 4px; }
.sidebar-menu .menu-group-title {
    padding: 8px 20px; font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: 1px;
}
.sidebar-menu .menu-item {
    display: flex; align-items: center; gap: 10px; padding: 11px 20px;
    color: #c0c0c0; cursor: pointer; transition: all 0.2s; font-size: 14px;
}
.sidebar-menu .menu-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-menu .menu-item.active { background: var(--primary); color: #fff; }
.sidebar-menu .menu-item .icon { width: 20px; text-align: center; font-size: 16px; }

.main-content {
    flex: 1; margin-left: var(--sidebar-w); padding: 0;
}
.page-header {
    height: var(--header-h); display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; background: var(--bg-white); border-bottom: 1px solid var(--border);
}
.page-header h2 { font-size: 18px; font-weight: 600; }
.page-header .actions { display: flex; gap: 8px; }
.page-body { padding: 24px; }

/* =============== 卡片 =============== */
.card {
    background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow);
    border: 1px solid var(--border); margin-bottom: 20px;
}
.card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* 统计小卡片 */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: var(--bg-white); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); border: 1px solid var(--border); display: flex; align-items: center; gap: 16px;
}
.stat-card .icon-wrap {
    width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.stat-card .icon-wrap.blue { background: #eef1ff; color: var(--primary); }
.stat-card .icon-wrap.green { background: #e6faf7; color: var(--success); }
.stat-card .icon-wrap.orange { background: #fff5eb; color: var(--warning); }
.stat-card .icon-wrap.red { background: #fde8ec; color: var(--danger); }
.stat-card .info .num { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-card .info .label { font-size: 13px; color: var(--text-light); margin-top: 4px; }

/* =============== 表格 =============== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px;
}
.data-table th { background: #f8f9fa; font-weight: 600; color: var(--text-light); white-space: nowrap; }
.data-table tr:hover td { background: #f8f9fa; }

/* 状态标签 */
.status-tag {
    display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500;
}
.status-tag.pending_assign { background: #fff3cd; color: #856404; }
.status-tag.processing { background: #cce5ff; color: #004085; }
.status-tag.pending_review { background: #e2d5f1; color: #6f42c1; }
.status-tag.finished { background: #d4edda; color: #155724; }
.status-tag.canceled { background: #f8d7da; color: #721c24; }
.status-tag.archived { background: #e2e3e5; color: #383d41; }

/* 优先级标签 */
.priority-tag {
    display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px;
}
.priority-tag.high { background: #fde8ec; color: var(--danger); }
.priority-tag.mid { background: #fff3cd; color: #856404; }
.priority-tag.low { background: #e2e3e5; color: #383d41; }

/* =============== 筛选栏 =============== */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px;
}
.filter-bar .form-group { margin-bottom: 0; flex: 0 0 auto; }
.filter-bar .form-group input, .filter-bar .form-group select {
    padding: 8px 12px; font-size: 13px; min-width: 140px;
}
.filter-bar .form-group label { font-size: 12px; margin-bottom: 4px; }

/* =============== 分页 =============== */
.pagination {
    display: flex; align-items: center; justify-content: center; gap: 4px; padding: 16px 0;
}
.pagination button {
    padding: 6px 12px; border: 1px solid var(--border); background: #fff; border-radius: 4px;
    cursor: pointer; font-size: 13px; color: var(--text);
}
.pagination button:hover { background: var(--bg); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* =============== 弹窗 =============== */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #fff; border-radius: 12px; width: 90%; max-width: 600px; max-height: 85vh;
    overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal.lg { max-width: 800px; }
.modal-header {
    padding: 16px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; }
.modal-header .close-btn {
    background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-light);
}
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 8px;
}

/* =============== 图表容器 =============== */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.chart-box {
    background: var(--bg-white); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); border: 1px solid var(--border);
}
.chart-box h4 { font-size: 14px; margin-bottom: 16px; color: var(--text-light); }

/* =============== 看板卡片 =============== */
.kanban-section { margin-bottom: 24px; }
.kanban-section h3 {
    font-size: 16px; font-weight: 600; margin-bottom: 12px; color: var(--text);
    display: flex; align-items: center; gap: 8px;
}
.kanban-section h3 .badge {
    font-size: 12px; background: var(--primary); color: #fff; padding: 2px 10px;
    border-radius: 12px; font-weight: 500;
}
.kanban-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

/* ===== 工单卡片 ===== */
.order-card {
    background: var(--bg-white); border-radius: 10px; padding: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06); border-left: 5px solid #ccc;
    cursor: pointer; transition: all 0.2s; position: relative;
}
.order-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.order-card .card-status {
    position: absolute; top: 12px; right: 12px; font-size: 11px;
    padding: 2px 8px; border-radius: 10px; font-weight: 500;
}
.order-card .card-code { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; font-family: monospace; }
.order-card .card-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.order-card .card-problem {
    font-size: 13px; color: var(--text-light); margin-bottom: 8px;
    display: flex; flex-wrap: wrap; gap: 4px;
}
.order-card .card-problem .tag {
    font-size: 11px; padding: 1px 8px; border-radius: 10px; background: #f0f0f0; color: #636e72;
}
.order-card .card-meta {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12px; color: var(--text-muted); border-top: 1px solid #f0f0f0; padding-top: 10px; margin-top: 8px;
}
.order-card .card-actions { display: flex; gap: 6px; }
.order-card .card-actions button {
    font-size: 11px; padding: 3px 10px; border-radius: 4px; border: none; cursor: pointer; transition: all 0.2s;
}
.order-card .btn-reassign { background: #4361ee; color: #fff; }
.order-card .btn-reassign:hover { background: #3651d4; }
.order-card .btn-detail { background: #f0f0f0; color: #636e72; }
.order-card .btn-detail:hover { background: #e0e0e0; }

/* 工单状态颜色 */
.order-card.status-pending { border-left-color: #ff9f1c; }
.order-card.status-pending .card-status { background: #fff5eb; color: #ff9f1c; }
.order-card.status-processing { border-left-color: #4361ee; }
.order-card.status-processing .card-status { background: #eef1ff; color: #4361ee; }
.order-card.status-review { border-left-color: #6f42c1; }
.order-card.status-review .card-status { background: #f3eeff; color: #6f42c1; }
.order-card.status-finished { border-left-color: #2ec4b6; }
.order-card.status-finished .card-status { background: #e6faf7; color: #2ec4b6; }
.order-card.status-canceled { border-left-color: #b2bec3; }
.order-card.status-canceled .card-status { background: #f5f5f5; color: #636e72; }

/* ===== 技术员卡片 ===== */
.tech-card {
    background: var(--bg-white); border-radius: 10px; padding: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06); border-left: 5px solid #ccc;
    transition: all 0.2s; display: flex; align-items: center; gap: 14px;
}
.tech-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.tech-card .tech-avatar {
    width: 48px; height: 48px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-size: 20px; font-weight: 700;
    flex-shrink: 0;
}
.tech-card .tech-info { flex: 1; min-width: 0; }
.tech-card .tech-name { font-size: 15px; font-weight: 600; color: var(--text); }
.tech-card .tech-phone { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.tech-card .tech-stats { display: flex; gap: 12px; margin-top: 6px; font-size: 12px; }
.tech-card .tech-stats span { color: var(--text-muted); }
.tech-card .tech-stats .num { font-weight: 600; }
.tech-card .tech-status {
    font-size: 12px; padding: 3px 10px; border-radius: 10px; font-weight: 500; flex-shrink: 0;
}
.tech-card.idle { border-left-color: #2ec4b6; }
.tech-card.idle .tech-avatar { background: #e6faf7; color: #2ec4b6; }
.tech-card.idle .tech-status { background: #e6faf7; color: #2ec4b6; }
.tech-card.busy { border-left-color: #ff9f1c; }
.tech-card.busy .tech-avatar { background: #fff5eb; color: #ff9f1c; }
.tech-card.busy .tech-status { background: #fff5eb; color: #ff9f1c; }

/* ===== 转派弹窗 ===== */
.reassign-modal .tech-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.reassign-modal .tech-option {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px;
    border-radius: 8px; border: 1px solid var(--border); cursor: pointer; transition: all 0.2s;
}
.reassign-modal .tech-option:hover { border-color: var(--primary); background: var(--primary-light); }
.reassign-modal .tech-option .dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.reassign-modal .tech-option .dot.idle { background: #2ec4b6; }
.reassign-modal .tech-option .dot.busy { background: #ff9f1c; }
.reassign-modal .tech-option .name { font-weight: 500; }
.reassign-modal .tech-option .status-text { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.reassign-modal .tech-option.current { opacity: 0.4; pointer-events: none; }

/* 响应式看板 */
@media (max-width: 768px) {
    .kanban-grid { grid-template-columns: 1fr; }
}

/* =============== 跟进记录时间线 =============== */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
    content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before {
    content: ''; position: absolute; left: -20px; top: 4px; width: 10px; height: 10px;
    border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--primary);
}
.timeline-item .time { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.timeline-item .user { font-size: 13px; font-weight: 600; color: var(--primary); margin-bottom: 6px; }
.timeline-item .content { background: #f8f9fa; padding: 12px; border-radius: 6px; font-size: 13px; }
.timeline-item .meta { margin-top: 6px; font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; }

/* =============== 消息提示 =============== */
.toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 12px 20px; border-radius: 6px; color: #fff; font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: slideIn 0.3s ease; max-width: 380px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* =============== 空状态 =============== */
.empty-state {
    text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* =============== 加载状态 =============== */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.loading::after { content: '...'; animation: dots 1.5s infinite; }
@keyframes dots { 0%{content:'.'} 33%{content:'..'} 66%{content:'...'} }

/* =============== 响应式 =============== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .chart-row { grid-template-columns: 1fr; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .filter-bar { flex-direction: column; }
}

/* =============== 问题类型多选标签 =============== */
.prob-tags {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.prob-tag {
    display: inline-block; padding: 6px 14px; border: 1px solid var(--border);
    border-radius: 20px; cursor: pointer; font-size: 13px; color: var(--text-light);
    background: var(--bg-white); transition: all 0.2s; user-select: none;
}
.prob-tag:hover { border-color: var(--primary); color: var(--primary); }
.prob-tag.active {
    background: var(--primary); color: #fff; border-color: var(--primary);
}

/* =============== 上传区域 =============== */
.upload-area {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 20px; text-align: center; cursor: pointer; transition: all 0.2s;
}
.upload-area:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-hint { color: var(--text-muted); font-size: 13px; }
.upload-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.file-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; background: #f0f4ff; border-radius: 4px;
    font-size: 12px; color: var(--primary);
}

/* =============== 通用 =============== */
.red { color: var(--danger); }
.hint { font-size: 12px; color: var(--text-muted); margin-left: 8px; }
