/*
 * 企业微信售后协同系统 v2.0 - Premium Dashboard Styles
 * 设计哲学: 简洁专业、信息密度适中、微交互精致
 * 支持: Light / Dark / System 主题
 */

/* ============= CSS Variables ============= */
:root {
    /* Brand Colors */
    --color-primary: #2563EB;
    --color-primary-light: #3B82F6;
    --color-primary-dark: #1D4ED8;
    --color-primary-bg: #EFF6FF;
    --color-primary-soft: #DBEAFE;

    /* Status Colors */
    --color-success: #059669;
    --color-success-bg: #ECFDF5;
    --color-success-soft: #D1FAE5;
    --color-warning: #D97706;
    --color-warning-bg: #FFFBEB;
    --color-warning-soft: #FEF3C7;
    --color-danger: #DC2626;
    --color-danger-bg: #FEF2F2;
    --color-danger-soft: #FEE2E2;
    --color-info: #6366F1;
    --color-info-bg: #EEF2FF;
    --color-info-soft: #E0E7FF;

    /* Neutral Colors (Light) */
    --color-bg: #F8FAFC;
    --color-bg-alt: #F1F5F9;
    --color-surface: #FFFFFF;
    --color-surface-hover: #F8FAFC;
    --color-border: #E2E8F0;
    --color-border-light: #F1F5F9;
    --color-text: #0F172A;
    --color-text-secondary: #475569;
    --color-text-muted: #94A3B8;
    --color-text-inverse: #FFFFFF;

    /* Sidebar */
    --color-sidebar-bg: #0F172A;
    --color-sidebar-text: #CBD5E1;
    --color-sidebar-active: #2563EB;
    --color-sidebar-hover: #1E293B;

    /* Shadows (Light) */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 25px 50px rgba(0, 0, 0, 0.15);
    --shadow-input: 0 0 0 3px var(--color-primary-bg);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

    /* Spacing */
    --sidebar-width: 240px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
    --transition-normal: 250ms cubic-bezier(0.16, 1, 0.3, 1);
    --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============= Dark Theme ============= */
[data-theme="dark"] {
    --color-bg: #0F172A;
    --color-bg-alt: #1E293B;
    --color-surface: #1E293B;
    --color-surface-hover: #334155;
    --color-border: #334155;
    --color-border-light: #1E293B;
    --color-text: #F1F5F9;
    --color-text-secondary: #CBD5E1;
    --color-text-muted: #64748B;
    --color-text-inverse: #0F172A;

    --color-primary: #3B82F6;
    --color-primary-dark: #2563EB;
    --color-primary-bg: #1E3A5F;
    --color-primary-soft: #1E3A5F;

    --color-success-bg: #064E3B;
    --color-success-soft: #064E3B;
    --color-warning-bg: #78350F;
    --color-warning-soft: #78350F;
    --color-danger-bg: #450A0A;
    --color-danger-soft: #450A0A;
    --color-info-bg: #1E1B4B;
    --color-info-soft: #1E1B4B;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 25px 50px rgba(0, 0, 0, 0.5);
    --shadow-input: 0 0 0 3px rgba(59, 130, 246, 0.25);

    --topbar-bg: rgba(30, 41, 59, 0.9);
}

/* Apply theme to body for inherited styles */
[data-theme="dark"] body {
    background: var(--color-bg);
    color: var(--color-text);
}

[data-theme="dark"] .topbar {
    background: var(--topbar-bg);
}

[data-theme="dark"] table th {
    background: var(--color-bg-alt);
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea {
    background: var(--color-bg-alt);
    color: var(--color-text);
}

[data-theme="dark"] .modal-close {
    background: var(--color-bg-alt);
}

[data-theme="dark"] .btn-secondary {
    background: var(--color-bg-alt);
    color: var(--color-text);
}
[data-theme="dark"] .btn-secondary:hover {
    background: var(--color-surface-hover);
}

/* Dark theme for V3.0 automation panels */
[data-theme="dark"] .worker-toggle {
    background: var(--color-bg-alt);
}
[data-theme="dark"] .worker-toggle.running {
    background: rgba(5, 150, 105, 0.15);
}
[data-theme="dark"] .worker-toggle.paused {
    background: rgba(217, 119, 6, 0.15);
}
[data-theme="dark"] .live-feed-tag.system {
    background: #334155; color: #CBD5E1;
}
[data-theme="dark"] .sim-card:hover {
    background: var(--color-bg-alt);
}
[data-theme="dark"] .worker-stat {
    background: var(--color-bg-alt);
}


/* ============= Reset & Base ============= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background var(--transition-normal), color var(--transition-normal);
}

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

/* ============= Layout ============= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    position: fixed; top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; gap: 12px;
}
.sidebar-brand-icon {
    width: 36px; height: 36px;
    background: var(--color-primary);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; color: white; flex-shrink: 0;
}
.sidebar-brand-text h1 {
    font-size: 15px; font-weight: 600; color: #F1F5F9; line-height: 1.3;
}
.sidebar-brand-text span {
    font-size: 11px; color: #64748B;
}

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-nav-section { margin-bottom: 20px; }
.sidebar-nav-label {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
    color: #475569; padding: 0 12px; margin-bottom: 8px; font-weight: 600;
}
.sidebar-nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    cursor: pointer; transition: all var(--transition-fast);
    font-size: 13px; color: #94A3B8; user-select: none; margin-bottom: 2px;
}
.sidebar-nav-item:hover { background: var(--color-sidebar-hover); color: #E2E8F0; }
.sidebar-nav-item.active { background: var(--color-sidebar-active); color: white; }
.sidebar-nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.sidebar-nav-item.active .nav-icon { opacity: 1; }
.sidebar-nav-item .nav-badge {
    margin-left: auto; background: var(--color-danger); color: white;
    font-size: 10px; padding: 1px 7px; border-radius: 10px; font-weight: 600;
}
.sidebar-footer {
    padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 11px; color: #475569;
}

/* Main Content */
.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; }
.main-content.no-sidebar { margin-left: 0; }

.topbar {
    background: rgba(255,255,255,0.85);
    border-bottom: 1px solid var(--color-border);
    padding: 14px 28px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
    backdrop-filter: blur(12px);
    transition: background var(--transition-normal), border-color var(--transition-normal);
}
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-time { font-size: 12px; color: var(--color-text-muted); }

/* Theme Toggle */
.theme-toggle {
    width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid var(--color-border); background: var(--color-surface);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast); color: var(--color-text-secondary);
    position: relative;
}
.theme-toggle:hover { border-color: var(--color-primary); color: var(--color-primary); }
.theme-toggle-menu {
    position: absolute; top: 44px; right: 0;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    padding: 6px; min-width: 160px; z-index: 300;
    display: none; animation: slideDown 0.15s ease;
}
.theme-toggle-menu.show { display: block; }
.theme-option {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-radius: var(--radius-sm);
    font-size: 13px; cursor: pointer; transition: background var(--transition-fast);
}
.theme-option:hover { background: var(--color-bg); }
.theme-option.active { background: var(--color-primary-bg); color: var(--color-primary); font-weight: 600; }
.theme-option-icon { font-size: 16px; }

/* Content Area */
.content-area { padding: 28px; }
.page-section { display: none; }
.page-section.active { display: block; }

/* ============= Login Page ============= */
.login-container {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
    padding: 20px;
}
.login-card {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-xl);
    padding: 40px; width: 100%; max-width: 420px;
    box-shadow: 0 50px 100px rgba(0,0,0,0.3);
    animation: fadeIn 0.4s ease;
}
.login-logo {
    text-align: center; margin-bottom: 32px;
}
.login-logo-icon {
    width: 56px; height: 56px; background: var(--color-primary);
    border-radius: var(--radius-lg); display: inline-flex;
    align-items: center; justify-content: center;
    font-size: 24px; font-weight: 700; color: white; margin-bottom: 16px;
}
.login-logo h1 { font-size: 20px; color: #F1F5F9; font-weight: 600; }
.login-logo p { font-size: 13px; color: #64748B; margin-top: 4px; }
.login-form .form-group { margin-bottom: 20px; }
.login-form .form-label { color: #94A3B8; }
.login-form .form-input {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #F1F5F9; border-radius: var(--radius-md); padding: 12px 16px; font-size: 14px;
}
.login-form .form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.3);
    background: rgba(255,255,255,0.12);
}
.login-form .form-input::placeholder { color: #475569; }
.login-btn {
    width: 100%; padding: 12px; background: var(--color-primary);
    color: white; border: none; border-radius: var(--radius-md);
    font-size: 15px; font-weight: 600; cursor: pointer;
    transition: all var(--transition-fast);
}
.login-btn:hover { background: var(--color-primary-dark); transform: translateY(-1px); }
.login-btn:active { transform: translateY(0); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.login-error {
    background: rgba(220,38,38,0.15); border: 1px solid rgba(220,38,38,0.3);
    color: #FCA5A5; padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: 13px; margin-bottom: 16px; display: none;
}
.login-error.show { display: block; }

/* ============= Components ============= */

/* Stat Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }

.stat-card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 20px 24px;
    transition: all var(--transition-fast); cursor: default;
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0;
    width: 4px; height: 100%; border-radius: 4px 0 0 4px;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card.primary::before { background: var(--color-primary); }
.stat-card.success::before { background: var(--color-success); }
.stat-card.warning::before { background: var(--color-warning); }
.stat-card.danger::before { background: var(--color-danger); }
.stat-card.info::before { background: var(--color-info); }
.stat-card-label {
    font-size: 12px; color: var(--color-text-muted); font-weight: 500;
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em;
}
.stat-card-value {
    font-size: 28px; font-weight: 700; color: var(--color-text);
    line-height: 1.2; font-variant-numeric: tabular-nums;
}
.stat-card-change { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

/* Panel / Card */
.panel {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); overflow: hidden;
}
.panel-header {
    padding: 18px 24px; border-bottom: 1px solid var(--color-border-light);
    display: flex; align-items: center; justify-content: space-between;
}
.panel-title { font-size: 15px; font-weight: 600; }
.panel-body { padding: 20px 24px; }
.panel-body.no-padding { padding: 0; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: 1px solid transparent;
    border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all var(--transition-fast);
    font-family: var(--font-sans); line-height: 1.4; white-space: nowrap;
    position: relative;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading::after {
    content: ''; position: absolute; width: 16px; height: 16px;
    border: 2px solid transparent; border-top-color: currentColor;
    border-radius: 50%; animation: spin 0.6s linear infinite;
}

.btn-primary { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-success { background: var(--color-success); color: white; }
.btn-success:hover { background: #047857; }
.btn-warning { background: var(--color-warning); color: white; }
.btn-warning:hover { background: #B45309; }
.btn-danger { background: var(--color-danger); color: white; }
.btn-danger:hover { background: #B91C1C; }
.btn-ghost { background: transparent; color: var(--color-text-secondary); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--color-bg); border-color: var(--color-border); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* Form Elements */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--color-text-secondary); margin-bottom: 6px;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.form-label .required { color: var(--color-danger); margin-left: 2px; }

/* 字段说明与配置引导 */
.field-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 5px; line-height: 1.6; }
.field-hint b { color: var(--color-text-secondary); font-weight: 600; }
.field-hint.warn { color: var(--color-warning); }

.guide-card { background: var(--color-info-bg); border: 1px solid #C7D2FE; border-radius: var(--radius-lg); padding: 16px 20px; margin-bottom: 20px; }
.guide-card-title { font-size: 14px; font-weight: 700; color: var(--color-text); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.guide-card-desc { font-size: 13px; color: var(--color-text-secondary); line-height: 1.7; margin-bottom: 14px; }
.guide-steps { display: flex; flex-direction: column; gap: 10px; }
.guide-step { display: flex; gap: 12px; align-items: flex-start; font-size: 13px; color: var(--color-text-secondary); line-height: 1.6; }
.guide-step-num { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--color-primary); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.form-error {
    font-size: 12px; color: var(--color-danger); margin-top: 4px; display: none;
}
.form-group.has-error .form-input,
.form-group.has-error .form-select,
.form-group.has-error .form-textarea { border-color: var(--color-danger); }
.form-group.has-error .form-error { display: block; }

.form-input, .form-select, .form-textarea {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    font-size: 13px; font-family: var(--font-sans);
    color: var(--color-text); background: var(--color-surface);
    transition: all var(--transition-fast); outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--color-primary); box-shadow: var(--shadow-input);
}
.form-textarea { resize: vertical; min-height: 80px; }

/* 工单回传弹窗：客户原消息引用块 + 快捷话术按钮 */
.quote-block {
    background: var(--color-bg); border-left: 3px solid var(--color-primary);
    padding: 8px 12px; border-radius: var(--radius-sm);
    font-size: 12px; color: var(--color-text-muted);
    white-space: pre-wrap; word-break: break-all; line-height: 1.6;
}
.template-btns { display: flex; flex-wrap: wrap; gap: 4px; min-height: 26px; }
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th {
    padding: 12px 16px; text-align: left;
    font-size: 11px; font-weight: 600; color: var(--color-text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 2px solid var(--color-border);
    background: var(--color-bg-alt); white-space: nowrap;
}
table td {
    padding: 12px 16px; font-size: 13px;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text); vertical-align: middle;
}
table tbody tr { transition: background var(--transition-fast); }
table tbody tr:hover { background: var(--color-primary-bg); }
table tbody tr.selected { background: var(--color-primary-soft); }

/* Checkbox column */
.check-col { width: 40px; text-align: center; }
.check-col input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--color-primary); }

/* Status Badges */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.badge-pending { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-processing { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-reviewing { background: var(--color-info-soft); color: var(--color-info); }
.badge-round { background: #FFF7E6; color: #D48806; }
[data-theme="dark"] .badge-round { background: #3A2E12; color: #F5C15C; }
.badge-completed { background: var(--color-success-soft); color: var(--color-success); }
.badge-closed { background: #F3F4F6; color: #6B7280; }
[data-theme="dark"] .badge-closed { background: #334155; color: #94A3B8; }
.badge-info { background: var(--color-info-soft); color: var(--color-info); }

/* ============= Pagination ============= */
.pagination {
    display: flex; align-items: center; justify-content: center; gap: 4px;
    padding: 16px 0;
}
.pagination-btn {
    min-width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    background: var(--color-surface); color: var(--color-text-secondary);
    font-size: 13px; cursor: pointer; transition: all var(--transition-fast);
}
.pagination-btn:hover:not(:disabled) { border-color: var(--color-primary); color: var(--color-primary); }
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination-btn.active { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.pagination-info { font-size: 12px; color: var(--color-text-muted); margin: 0 12px; }

/* ============= Modal ============= */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 200; animation: fadeIn 0.2s ease;
}
.modal {
    background: var(--color-surface); border-radius: var(--radius-xl);
    width: 90%; max-width: 640px; max-height: 85vh; overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.sm { max-width: 420px; }
.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--color-border-light);
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; background: var(--color-surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0; z-index: 1;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border: none; background: var(--color-bg); border-radius: var(--radius-sm);
    cursor: pointer; font-size: 18px; color: var(--color-text-muted);
    transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--color-border); color: var(--color-text); }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px; border-top: 1px solid var(--color-border-light);
    display: flex; justify-content: flex-end; gap: 10px;
}

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--color-border-light); gap: 0; margin-bottom: 20px; }
.tab-item {
    padding: 10px 20px; cursor: pointer; font-size: 13px; font-weight: 500;
    color: var(--color-text-muted); border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all var(--transition-fast);
}
.tab-item:hover { color: var(--color-text); }
.tab-item.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* Action Bar */
.action-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.action-bar .form-select { width: auto; min-width: 140px; }
.batch-actions { display: none; align-items: center; gap: 8px; }
.batch-actions.show { display: flex; }
.batch-count { font-size: 13px; color: var(--color-text-muted); font-weight: 500; }

/* Search */
.search-box { position: relative; flex: 1; max-width: 320px; }
.search-box input { padding-left: 36px; }
.search-box .search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--color-text-muted); pointer-events: none;
}

/* Detail View */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.detail-item { display: flex; flex-direction: column; }
.detail-label {
    font-size: 11px; color: var(--color-text-muted);
    text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; margin-bottom: 2px;
}
.detail-value { font-size: 13px; color: var(--color-text); }

/* Timeline */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--color-border); }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item::before { content: ''; position: absolute; left: -16px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--color-primary); border: 2px solid var(--color-surface); }
.timeline-time { font-size: 11px; color: var(--color-text-muted); }
.timeline-content { font-size: 13px; color: var(--color-text); margin-top: 2px; }

/* Alerts */
.alert {
    padding: 12px 16px; border-radius: var(--radius-sm);
    font-size: 13px; margin-bottom: 12px;
    display: flex; align-items: center; gap: 10px;
}
.alert-info { background: var(--color-info-bg); color: var(--color-info); border: 1px solid #C7D2FE; }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid #FDE68A; }
.alert-danger { background: var(--color-danger-bg); color: var(--color-danger); border: 1px solid #FECACA; }
.alert-success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid #A7F3D0; }

/* Empty State */
.empty-state { text-align: center; padding: 48px 24px; color: var(--color-text-muted); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state h3 { font-size: 15px; color: var(--color-text-secondary); margin-bottom: 4px; }
.empty-state p { font-size: 13px; }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--color-border); border-top: 3px solid var(--color-primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }

/* Toast */
.toast-container {
    position: fixed; top: 20px; right: 20px;
    z-index: 999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 12px 20px; border-radius: var(--radius-md);
    background: var(--color-surface); box-shadow: var(--shadow-lg);
    font-size: 13px; min-width: 280px;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; align-items: center; gap: 10px; border-left: 4px solid var(--color-primary);
}
.toast.success { border-left-color: var(--color-success); }
.toast.error { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }
.toast .toast-close {
    margin-left: auto; cursor: pointer; opacity: 0.5; font-size: 16px; line-height: 1;
}
.toast .toast-close:hover { opacity: 1; }

/* Confirm Dialog */
.confirm-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 250; animation: fadeIn 0.15s ease;
}
.confirm-dialog {
    background: var(--color-surface); border-radius: var(--radius-xl);
    padding: 32px; max-width: 400px; width: 90%;
    box-shadow: var(--shadow-xl); text-align: center;
    animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.confirm-icon { font-size: 40px; margin-bottom: 16px; }
.confirm-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.confirm-message { font-size: 13px; color: var(--color-text-secondary); margin-bottom: 24px; }
.confirm-actions { display: flex; gap: 12px; justify-content: center; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .content-area { padding: 16px; }
    .detail-grid { grid-template-columns: 1fr; }
    .topbar { padding: 12px 16px; }
    .mobile-menu-btn { display: flex !important; }
    .action-bar { flex-direction: column; align-items: stretch; }
    .search-box { max-width: none; }
    .modal { width: 95%; max-height: 90vh; }
}

.mobile-menu-btn {
    display: none; width: 36px; height: 36px;
    align-items: center; justify-content: center;
    border: none; background: var(--color-bg);
    border-radius: var(--radius-sm); cursor: pointer; color: var(--color-text);
}

.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.3); z-index: 99;
}
@media (max-width: 768px) { .sidebar-overlay.show { display: block; } }

/* ============= Animations ============= */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============= V3.0 Worker / Automation Panel ============= */

/* Worker Toggle in Topbar */
.worker-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 14px 6px 6px;
    border-radius: 20px; border: 1px solid var(--color-border);
    background: var(--color-surface); cursor: pointer;
    font-size: 12px; font-weight: 600; color: var(--color-text-secondary);
    transition: all var(--transition-fast);
    user-select: none;
}
.worker-toggle:hover { border-color: var(--color-primary); }
.worker-toggle.running { border-color: var(--color-success); background: var(--color-success-bg); }
.worker-toggle.running .worker-dot { background: var(--color-success); box-shadow: 0 0 8px var(--color-success); }
.worker-toggle.paused { border-color: var(--color-warning); background: var(--color-warning-bg); }
.worker-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--color-text-muted);
    transition: all var(--transition-fast);
}
.worker-dot.pulse { animation: pulse 2s infinite; }

/* Live Feed Panel */
.live-feed {
    margin-top: 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    overflow: hidden;
}
.live-feed-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--color-border-light);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--color-bg-alt);
}
.live-feed-title {
    font-size: 13px; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}
.live-feed-status {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--color-text-muted);
}
.live-feed-status.connected { background: var(--color-success); }
.live-feed-status.disconnected { background: var(--color-danger); }
.live-feed-body {
    max-height: 320px; overflow-y: auto;
    font-family: var(--font-mono); font-size: 12px;
}
.live-feed-item {
    padding: 8px 20px; border-bottom: 1px solid var(--color-border-light);
    display: flex; align-items: flex-start; gap: 10px;
    transition: background var(--transition-fast);
    animation: fadeIn 0.2s ease;
}
.live-feed-item:hover { background: var(--color-bg); }
.live-feed-time {
    color: var(--color-text-muted); white-space: nowrap;
    font-size: 11px; min-width: 50px;
}
.live-feed-tag {
    padding: 1px 6px; border-radius: 3px; font-size: 10px;
    font-weight: 600; white-space: nowrap; text-transform: uppercase;
}
.live-feed-tag.ticket { background: var(--color-primary-soft); color: var(--color-primary); }
.live-feed-tag.forward { background: var(--color-info-soft); color: var(--color-info); }
.live-feed-tag.complete { background: var(--color-success-soft); color: var(--color-success); }
.live-feed-tag.reply { background: var(--color-warning-soft); color: var(--color-warning); }
.live-feed-tag.alert { background: var(--color-danger-soft); color: var(--color-danger); }
.live-feed-tag.system { background: #F3F4F6; color: #6B7280; }
.live-feed-detail { flex: 1; line-height: 1.5; }
.live-feed-empty {
    padding: 40px; text-align: center; color: var(--color-text-muted);
    font-size: 13px; font-family: var(--font-sans);
}

/* Automation Test Panel */
.automation-test {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
@media (max-width: 768px) { .automation-test { grid-template-columns: 1fr; } }

.sim-card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 16px; cursor: pointer;
    transition: all var(--transition-fast);
}
.sim-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.sim-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sim-card-icon { font-size: 20px; }
.sim-card-title { font-size: 13px; font-weight: 600; }
.sim-card-desc { font-size: 12px; color: var(--color-text-muted); margin-bottom: 12px; line-height: 1.5; }

/* Worker Stats Mini */
.worker-stats {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 12px; margin-bottom: 16px;
}
@media (max-width: 768px) { .worker-stats { grid-template-columns: repeat(2, 1fr); } }
.worker-stat {
    background: var(--color-bg-alt); border-radius: var(--radius-md);
    padding: 12px 16px; text-align: center;
}
.worker-stat-value { font-size: 20px; font-weight: 700; color: var(--color-text); }
.worker-stat-label { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }

/* Animation for pulsing dot */
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

/* ==================== 配置指引页 ==================== */
.guide-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.guide-progress-title { font-size: 16px; font-weight: 700; color: var(--color-text); }
.guide-progress-right { display: flex; align-items: center; gap: 12px; }
.guide-progress-num { font-size: 22px; font-weight: 800; color: var(--color-primary); font-family: var(--font-mono); }
.guide-progress-bar { height: 8px; background: var(--color-bg-alt); border-radius: 4px; margin-top: 12px; overflow: hidden; }
.guide-progress-fill { height: 100%; background: var(--color-primary); border-radius: 4px; transition: width .4s ease; }

.guide-step {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}
.guide-step-done { border-color: var(--color-success-soft); background: linear-gradient(0deg, var(--color-surface), var(--color-surface)), var(--color-success-bg); }
.guide-step-done .guide-step-num { background: var(--color-success); }
.guide-step-optional { border-style: dashed; }
.guide-step-head { display: flex; align-items: center; gap: 10px; }
.guide-step-num {
    width: 26px; height: 26px; border-radius: 50%; background: var(--color-primary);
    color: #fff; font-weight: 700; font-size: 13px; display: inline-flex;
    align-items: center; justify-content: center; flex-shrink: 0;
}
.guide-step-optional .guide-step-num { background: var(--color-text-muted); }
.guide-step-title { font-size: 15px; font-weight: 600; color: var(--color-text); flex: 1; }
.guide-badge { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; flex-shrink: 0; }
.guide-badge-done { background: var(--color-success-bg); color: var(--color-success); }
.guide-badge-todo { background: var(--color-warning-bg); color: var(--color-warning); }
.guide-badge-opt { background: var(--color-bg-alt); color: var(--color-text-muted); }
.guide-step-body { margin-top: 10px; font-size: 13px; color: var(--color-text-secondary); line-height: 1.7; }
.guide-step-body a { color: var(--color-primary); }
.guide-ol { margin: 4px 0 4px 18px; padding: 0; }
.guide-ol li { margin: 4px 0; }
.guide-kv {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    background: var(--color-bg-alt); border-radius: var(--radius-sm);
    padding: 6px 10px; margin: 6px 0;
}
.guide-kv > span:first-child { font-weight: 600; color: var(--color-text); flex-shrink: 0; }
.guide-kv code {
    font-family: var(--font-mono); font-size: 12px; color: var(--color-primary-dark);
    word-break: break-all; background: var(--color-surface); padding: 2px 8px; border-radius: 4px;
    border: 1px solid var(--color-border);
}
.guide-status-row { margin: 4px 0; font-size: 13px; }
.guide-warn { color: var(--color-warning); background: var(--color-warning-bg); border-radius: var(--radius-sm); padding: 6px 10px; margin-top: 6px; font-size: 13px; }
.guide-ok { color: var(--color-success); background: var(--color-success-bg); border-radius: var(--radius-sm); padding: 6px 10px; margin-top: 6px; font-size: 13px; }
.guide-muted { color: var(--color-text-muted); font-size: 12px; }
.guide-step-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.btn-xs { padding: 2px 10px; font-size: 12px; height: auto; line-height: 1.6; }

/* Print */
@media print {
    .sidebar, .topbar, .modal-overlay, .btn { display: none !important; }
    .main-content { margin-left: 0; }
    .content-area { padding: 0; }
}
