/* =========================================================
   Reagent CRM — 全局样式
   配色：蓝灰商务风（#3498db / #2c3e50）
   结构：变量层 → reset → 登录页 → 主布局 → 通用组件 → 仪表盘 → 响应式
   ========================================================= */

/* ── 设计 Token ── */
:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --primary-light: #ebf5fb;
    --text: #2c3e50;
    --text-light: #1a2733;
    --muted: #8a94a6;
    --muted-2: #7f8c8d;
    --border: #e3e8ee;
    --border-light: #ecf0f1;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --sidebar-bg: #2c3e50;
    --sidebar-dark: #34495e;
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 10px;
    --shadow: 0 1px 3px rgba(20,40,80,0.06);
    --shadow-md: 0 2px 8px rgba(20,40,80,0.06);
    --shadow-hover: 0 6px 18px rgba(20,40,80,0.10);
    --danger: #e74c3c;
    --danger-dark: #c0392b;
    --danger-light: #fdeaea;
    --success: #27ae60;
    --success-dark: #229954;
    --success-light: #e6f7ed;
    --warning: #e67e22;
    --warning-dark: #d35400;
    --warning-light: #fef5e0;
    --font-sans: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }

/* ── 登录页 ── */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea, #764ba2);
}
.login-card {
    background: white;
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    width: 380px;
}
.login-card h1 {
    font-size: 22px;
    text-align: center;
    margin-bottom: 6px;
    color: var(--text-light);
    font-weight: 700;
}
.login-card .subtitle {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 28px;
}
.login-card form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.login-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--muted-2);
    font-weight: 500;
}
.login-card input {
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}
.login-card button {
    margin-top: 8px;
    padding: 12px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s;
}
.login-card button:hover { background-color: var(--primary-dark); }
.alert-error {
    background-color: var(--danger-light);
    color: var(--danger-dark);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    text-align: center;
}
.login-card .hint {
    text-align: center;
    font-size: 12px;
    color: #95a5a6;
    margin-top: 16px;
}

/* ── 主布局 ── */
.layout {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 210px;
    background-color: var(--sidebar-bg);
    color: #ecf0f1;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.brand {
    padding: 18px 20px;
    font-size: 16px;
    font-weight: 700;
    border-bottom: 1px solid var(--sidebar-dark);
    color: white;
    letter-spacing: 0.3px;
}
.sidebar nav {
    display: flex;
    flex-direction: column;
    padding: 6px 0;
    flex: 1;
}
.nav-group-title {
    padding: 12px 20px 4px;
    font-size: 10px;
    font-weight: 700;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.sidebar nav a,
.sidebar nav .nav-pending {
    display: block;
    padding: 9px 20px;
    color: #bdc3c7;
    text-decoration: none;
    font-size: 13px;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background-color 0.12s, color 0.12s;
}
.sidebar nav a:hover {
    background-color: var(--sidebar-dark);
    color: white;
}
.sidebar nav a.active {
    background-color: var(--sidebar-dark);
    border-left-color: var(--primary);
    color: white;
    font-weight: 500;
}
.sidebar nav .nav-pending {
    color: #7f8c8d;
    cursor: not-allowed;
}
.sidebar nav .nav-pending em {
    font-style: normal;
    font-size: 11px;
    color: var(--warning);
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.topbar {
    height: 54px;
    background-color: white;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    position: sticky;
    top: 0;
    z-index: 10;
}
.page-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-light);
}
.user-info {
    display: flex;
    gap: 14px;
    align-items: center;
    font-size: 13px;
    color: var(--muted-2);
}
.user-info .avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}
.user-info a {
    color: var(--primary);
    text-decoration: none;
}
.user-info a:hover { text-decoration: underline; }
.content {
    flex: 1;
    padding: 22px 24px;
    overflow-y: auto;
}

/* ── 页面头部（业务页通用） ── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}
.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: -0.2px;
}
.page-header .sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}
.page-header .actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── 通用工具栏 ── */
.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.toolbar .search-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.toolbar input[type="text"],
.toolbar input[type="number"],
.toolbar select,
.toolbar input[type="date"] {
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: white;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.toolbar input[type="text"] { min-width: 220px; }
.toolbar input:focus,
.toolbar select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.12);
}
.toolbar .spacer { flex: 1; }

/* ── 按钮 ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    color: white;
    transition: background-color 0.15s, transform 0.05s, box-shadow 0.15s;
    line-height: 1.4;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.btn-primary { background-color: var(--primary); }
.btn-primary:hover { background-color: var(--primary-dark); }
.btn-success { background-color: var(--success); }
.btn-success:hover { background-color: var(--success-dark); }
.btn-warning { background-color: var(--warning); }
.btn-warning:hover { background-color: var(--warning-dark); }
.btn-danger { background-color: var(--danger); }
.btn-danger:hover { background-color: var(--danger-dark); }
.btn-secondary { background-color: #95a5a6; }
.btn-secondary:hover { background-color: #7f8c8d; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-link {
    background: none;
    color: var(--primary);
    text-decoration: none;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}
.btn-link:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
}
.btn-link-danger {
    background: none;
    color: var(--danger);
    text-decoration: none;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}
.btn-link-danger:hover {
    background: var(--danger-light);
    color: var(--danger-dark);
}
.btn-link-success {
    background: none;
    color: var(--success);
    text-decoration: none;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}
.btn-link-success:hover {
    background: var(--success-light);
    color: var(--success-dark);
}

/* ── 表格 ── */
.table-wrap {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 13px;
}
table.data-table th {
    background-color: #f8fafc;
    padding: 11px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    letter-spacing: 0.2px;
}
table.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
    vertical-align: middle;
}
table.data-table tbody tr {
    transition: background-color 0.1s;
}
table.data-table tbody tr:hover { background-color: #fafbfc; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table .col-id { width: 56px; color: var(--muted); }
table.data-table .col-short { width: 60px; }
table.data-table .col-tiny { width: 80px; }
table.data-table .col-medium { width: 140px; }
table.data-table .col-check { width: 100px; }
table.data-table .col-actions { width: 200px; }
.row-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
}

/* ── 空状态 ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    font-size: 14px;
}
.empty-row td {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted);
    font-size: 13px;
}
.overdue-row {
    background: #ffe0e0;
}
.hint {
    font-size: 11px;
    color: var(--muted);
}

/* ── 表单 ── */
.form-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 640px;
}
.form-card.wide { max-width: 900px; }
.form-card h2 {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}
.form-card h3 {
    font-size: 16px;
    color: var(--text);
    margin-bottom: 18px;
}
.page-subtitle {
    font-size: 16px;
    color: var(--text);
    margin: 14px 0 6px;
}
.form-row {
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-row label {
    font-size: 12px;
    color: var(--muted-2);
    font-weight: 600;
    letter-spacing: 0.2px;
}
.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="date"],
.form-row input[type="password"],
.form-row select,
.form-row textarea {
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.12);
}
.form-row textarea { min-height: 80px; resize: vertical; }
.form-row .hint { font-size: 11px; color: var(--muted); }
.form-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 18px;
}
.form-card fieldset {
    margin-bottom: 14px;
    padding: 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}
.form-card fieldset legend {
    font-weight: bold;
    padding: 0 6px;
}
.form-card .info-box {
    margin-bottom: 14px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: var(--radius-sm);
    font-size: 13px;
}
.form-card .info-box .info-title { font-weight: bold; }
.form-card .info-box .info-sub { color: #7f8c8d; margin-top: 4px; }
/* ── 标签胶囊 ── */
.tag-pill {
    background: #ecf0f1;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tag-remove {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-weight: bold;
    padding: 0;
    font-size: 14px;
    line-height: 1;
}
.tag-remove:hover { color: #c0392b; }
/* ── 状态徽章 ── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
}
.badge-success { color: #27ae60; }
.badge-danger { color: #e74c3c; }
.badge-warning { color: #f39c12; }
.badge-muted { color: #7f8c8d; }
.td-muted { font-size: 12px; color: #7f8c8d; }
.row-warning { background: #fff3f3; }
/* ── 文字色 ── */
.text-success { color: #27ae60; font-weight: bold; }
.text-danger { color: #e74c3c; font-weight: bold; }
/* ── 信用评级 ── */
.credit-rating {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
}
.credit-rating-A { background: #d4edda; color: #155724; }
.credit-rating-B { background: #fff3cd; color: #856404; }
.credit-rating-C { background: #f8d7da; color: #721c24; }
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

/* ── 子表区域 ── */
.sub-section {
    margin-top: 24px;
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.sub-section h3 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text-light);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
    font-weight: 600;
}

/* ── 徽章 / 标签 ── */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: #f0f2f5;
    color: var(--muted-2);
}
.tag-success { background: var(--success-light); color: var(--success-dark); }
.tag-warning { background: var(--warning-light); color: var(--warning-dark); }
.tag-danger  { background: var(--danger-light);  color: var(--danger-dark); }
.tag-muted   { background: #f0f2f5; color: var(--muted-2); }
.tag-primary { background: var(--primary-light); color: var(--primary-dark); }

/* ── 漏斗卡片（lead/opportunity） ── */
.funnel-row {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.funnel-card {
    flex: 1;
    min-width: 110px;
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    color: #fff;
}
.funnel-card .funnel-stage {
    font-size: 12px;
    font-weight: bold;
    color: rgba(255,255,255,0.85);
}
.funnel-card .funnel-count {
    font-size: 22px;
    font-weight: bold;
    margin-top: 4px;
}

/* ── 任务统计卡片 ── */
.stat-row {
    display: flex;
    gap: 15px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.stat-card {
    flex: 1;
    min-width: 130px;
    padding: 14px 18px;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--muted);
}
.stat-card .stat-label {
    color: var(--muted-2);
    font-size: 12px;
    margin-bottom: 4px;
}
.stat-card .stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--text);
}

/* ── 仪表盘专用样式 ── */
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.dash-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: -0.3px;
}
.dash-header .sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}
.dash-header .meta {
    text-align: right;
    font-size: 12px;
    color: var(--muted);
}
.dash-header .meta strong {
    display: block;
    font-size: 15px;
    color: var(--text);
    margin-top: 2px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}
.kpi-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}
.kpi-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent, var(--muted));
}
.kpi-card .kpi-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 8px;
}
.kpi-card .kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-light);
    line-height: 1.1;
}
.kpi-card .kpi-delta {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 10px;
    font-weight: 600;
}
.kpi-delta.up   { background: var(--success-light); color: var(--success-dark); }
.kpi-delta.down { background: var(--danger-light);  color: var(--danger-dark); }
.kpi-delta.flat { background: #f0f2f5; color: var(--muted-2); }

.tile-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
.tile {
    background: #fff;
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
}
.tile .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tile .tile-label {
    font-size: 11px;
    color: var(--muted);
    display: block;
}
.tile .tile-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.panel-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}
.panel-row.split {
    grid-template-columns: 1fr 1fr;
}
.panel {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.panel-head h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    margin: 0;
}
.panel-head .sub {
    font-size: 11px;
    color: var(--muted);
}

/* 销售趋势条形图 */
.trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    height: 200px;
    padding: 12px 4px 0;
    border-bottom: 1px dashed var(--border);
}
.trend-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    position: relative;
}
.trend-col .bar {
    width: 70%;
    background: linear-gradient(180deg, #5b8def, #2c5dd8);
    border-radius: 6px 6px 0 0;
    min-height: 4px;
    transition: opacity 0.15s;
    position: relative;
}
.trend-col:hover .bar { opacity: 0.85; }
.trend-col .bar .tip {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-light);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
    pointer-events: none;
}
.trend-col:hover .bar .tip { opacity: 1; }
.trend-col.current .bar {
    background: linear-gradient(180deg, #4ade80, #16a34a);
}
.trend-labels {
    display: flex;
    gap: 14px;
    padding: 6px 4px 0;
}
.trend-labels span {
    flex: 1;
    text-align: center;
    font-size: 11px;
    color: var(--muted);
}
.trend-labels span small {
    display: block;
    color: #c5cbd3;
    font-size: 10px;
    margin-top: 2px;
}

/* 分布条 */
.dist-row {
    margin-bottom: 14px;
}
.dist-row:last-child { margin-bottom: 0; }
.dist-row .dist-head {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #5a6473;
    margin-bottom: 4px;
}
.dist-row .dist-head .v {
    font-weight: 600;
    color: var(--text);
}
.dist-bar {
    height: 6px;
    background: #f0f2f5;
    border-radius: 3px;
    overflow: hidden;
}
.dist-bar > div {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

/* 警告标签 */
.severity-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.severity-red    { background: var(--danger-light);  color: var(--danger-dark); }
.severity-yellow { background: var(--warning-light); color: #b8860b; }
.severity-green  { background: var(--success-light); color: var(--success-dark); }

/* 达成率进度条 */
.achv-bar-wrap {
    background: #f0f2f5;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
}
.achv-bar-wrap > div {
    height: 100%;
    border-radius: 4px;
}

@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .tile-grid { grid-template-columns: repeat(2, 1fr); }
    .panel-row, .panel-row.split { grid-template-columns: 1fr; }
    .form-grid-2col { grid-template-columns: 1fr; }
}
