:root {
    --ct-blue: #1a3a6b;
    --ct-blue-dark: #142d52;
    --ct-blue-light: #2a5290;
    --ct-red: #c4161c;
    --bg: #f5f7fa;
    --card: #ffffff;
    --text: #1f1f1f;
    --text-muted: #595959;
    --border: #e3e8ef;
    --success: #2e7d32;
    --warn: #ed6c02;
    --zero: #f2f2f2;
}

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

body {
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* 登录页 */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--ct-blue) 0%, var(--ct-blue-dark) 100%);
    padding: 20px;
}

.login-card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-card .brand {
    text-align: center;
    margin-bottom: 30px;
}

.login-card .brand h1 {
    color: var(--ct-blue);
    font-size: 22px;
    margin-bottom: 6px;
}

.login-card .brand .sub {
    color: var(--text-muted);
    font-size: 13px;
}

.login-card .brand .logo {
    width: 56px;
    height: 56px;
    background: var(--ct-blue);
    border-radius: 50%;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    font-weight: bold;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--ct-blue-light);
    box-shadow: 0 0 0 3px rgba(42, 82, 144, 0.1);
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    text-align: center;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--ct-blue);
    color: #fff;
    width: 100%;
}

.btn-primary:hover { background: var(--ct-blue-dark); }

.btn-red { background: var(--ct-red); color: #fff; }
.btn-red:hover { background: #a01015; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover { background: var(--bg); }

.login-error {
    background: #fff4e5;
    border: 1px solid #ffd6a8;
    color: var(--ct-red);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 18px;
}

.login-tip {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

/* 主布局 */
.app-header {
    background: var(--ct-blue);
    color: #fff;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.app-header .title {
    font-size: 17px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header .title .dot {
    width: 8px;
    height: 8px;
    background: var(--ct-red);
    border-radius: 50%;
}

.app-header .user-area {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
}

.app-header .user-area .role-tag {
    background: rgba(255, 255, 255, 0.15);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.app-header .user-area .role-tag.admin {
    background: var(--ct-red);
}

.app-header .logout {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 13px;
}

.app-header .logout:hover { color: #fff; }

.app-nav {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    gap: 4px;
}

.app-nav a {
    padding: 14px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.app-nav a:hover { color: var(--ct-blue); }

.app-nav a.active {
    color: var(--ct-blue);
    border-bottom-color: var(--ct-blue);
    font-weight: 500;
}

.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* 卡片 */
.card {
    background: var(--card);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-head h2 {
    font-size: 16px;
    color: var(--ct-blue);
    font-weight: 600;
}

.card-head .meta {
    font-size: 12px;
    color: var(--text-muted);
}

.card-body { padding: 20px; }

/* 数字概览 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.stat-box {
    background: var(--bg);
    border-radius: 8px;
    padding: 18px;
    text-align: center;
}

.stat-box .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--ct-blue);
    line-height: 1.2;
}

.stat-box .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.stat-box.highlight .stat-value { color: var(--ct-red); }

.stat-box .stat-unit {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-muted);
}

/* 表格 */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table th, table td {
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

table th {
    background: #f0f4f9;
    color: var(--ct-blue);
    font-weight: 600;
    font-size: 13px;
}

table td:first-child, table th:first-child { text-align: left; }

table tr.zero-row { background: var(--zero); color: var(--text-muted); }

table tr.top-row { background: #fff4e5; }

table tr:hover { background: #f7f9fc; }

table tr.zero-row:hover { background: #ececec; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.tag-zero { background: #ffe0e0; color: var(--ct-red); }
.tag-open { background: #e0f2e0; color: var(--success); }

/* 提示 */
.toast {
    position: fixed;
    top: 80px;
    right: 24px;
    background: var(--ct-blue);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.toast.error { background: var(--ct-red); }

.toast.success { background: var(--success); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty .icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

/* 上传区 */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 50px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--ct-blue-light);
    background: #f7f9fc;
}

.upload-zone .icon {
    font-size: 40px;
    color: var(--ct-blue-light);
    margin-bottom: 12px;
}

.upload-zone .hint {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 6px;
}

.flash-msg {
    background: #fff4e5;
    border-left: 3px solid var(--warn);
    padding: 10px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    border-radius: 4px;
}

/* 响应式 */
@media (max-width: 640px) {
    .app-main { padding: 16px; }
    .app-nav { overflow-x: auto; }
    .app-nav a { padding: 12px 14px; white-space: nowrap; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    table { font-size: 12px; }
    table th, table td { padding: 8px 6px; }
}

/* ============ 排名板块（两表平铺） ============ */
.rk-card .card-body { padding-top: 18px; }

.rk-tables {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    align-items: start;
}
.rk-table-block {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.rk-table-title {
    background: linear-gradient(90deg, #f5f7fa, #eef2f7);
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ct-blue-dark);
    border-bottom: 1px solid var(--border);
}
.rk-empty {
    padding: 28px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.me-legend {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    font-size: 12px;
    color: var(--ct-red);
    font-weight: 600;
}
.me-legend .me-dot {
    display: inline-block;
    width: 10px; height: 10px;
    background: #fff5f5;
    border: 1px solid var(--ct-red);
    border-radius: 2px;
    margin-right: 4px;
    vertical-align: middle;
}

/* 排行榜表格 */
.rk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.rk-table thead th {
    text-align: left;
    padding: 9px 10px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    background: #f5f7fa;
    border-bottom: 1px solid var(--border);
}
.rk-table tbody td {
    padding: 9px 10px;
    border-bottom: 1px solid #f0f2f5;
    color: var(--text);
    vertical-align: middle;
}
.rk-table tbody tr:last-child td { border-bottom: none; }
.rk-table tbody tr:hover td { background: #fafbfc; }

/* 当前员工高亮：粉色背景 + 加粗姓名 + 左侧红色色条 */
.rk-table tbody tr.me td {
    background: #fff5f5;
    border-left: none;
    position: relative;
}
.rk-table tbody tr.me td:first-child {
    box-shadow: inset 3px 0 0 var(--ct-red);
}
.rk-table tbody tr.me td.col-name {
    font-weight: 700;
    color: var(--ct-red);
}
.rk-table .col-rank { width: 56px; text-align: center; }
.rk-table .col-name { min-width: 80px; }
.rk-table .col-total { width: 80px; text-align: right; }
.rk-table .col-bar { width: auto; }
.rk-table .col-pct { width: 56px; text-align: right; color: var(--text-muted); font-size: 12px; }

/* 当前员工姓名前的箭头 */
.me-arrow {
    display: inline-block;
    color: var(--ct-red);
    font-size: 11px;
    margin-right: 4px;
    animation: rkArrowPulse 1.6s ease-in-out infinite;
}
@keyframes rkArrowPulse {
    0%, 100% { opacity: 1; transform: translateX(0); }
    50% { opacity: .5; transform: translateX(-2px); }
}

/* 条形图 */
.bar-track {
    width: 100%;
    height: 10px;
    background: #eef0f3;
    border-radius: 5px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #c7d4ea, #1a3a6b);
    border-radius: 5px;
    transition: width .4s ease;
}
.bar-fill.me {
    background: linear-gradient(90deg, #f0a8ab, #c4161c);
}

@media (max-width: 760px) {
    .rk-tables { grid-template-columns: 1fr; }
    .rk-table .col-pct { display: none; }
}

/* ============ 工作指导意见板块 ============ */
.guidance-card .card-head { border-bottom-color: #fde8e9; }
.guidance-summary {
    font-size: 15px;
    color: var(--ct-blue-dark);
    background: #f0f4fa;
    border-left: 3px solid var(--ct-blue);
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 14px;
}
.guidance-list {
    margin: 0;
    padding-left: 22px;
}
.guidance-list li {
    font-size: 14px;
    color: var(--text);
    line-height: 1.8;
    margin-bottom: 10px;
}
.guidance-list li:last-child { margin-bottom: 0; }
.priority-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}
.priority-tag.high {
    background: #fde8e9;
    color: var(--ct-red);
}
.priority-tag.medium {
    background: #e8f0fd;
    color: var(--ct-blue);
}

/* ============ 数字可点击 ============ */
.stat-box.clickable {
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
}
.stat-box.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 58, 107, 0.10);
}
.stat-box.clickable::after {
    content: '🔍';
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 11px;
    opacity: 0.4;
}
.stat-box { position: relative; }

/* ============ 明细弹窗 ============ */
.dm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 25, 45, 0.45);
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 14px;
    overflow-y: auto;
    animation: dmFade .18s ease;
}
@keyframes dmFade { from { opacity: 0; } to { opacity: 1; } }

.dm-dialog {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 1180px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.22);
    overflow: hidden;
    margin: auto 0;
}
.dm-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #f5f7fa, #fff);
}
.dm-head h3 {
    margin: 0;
    color: var(--ct-blue);
    font-size: 17px;
    font-weight: 600;
}
.dm-close {
    appearance: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 26px;
    cursor: pointer;
    line-height: 1;
    padding: 0 6px;
}
.dm-close:hover { color: var(--ct-red); }
.dm-body {
    padding: 18px 22px 26px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}
.dm-loading, .dm-error, .dm-empty {
    padding: 40px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}
.dm-error { color: var(--ct-red); }
.dm-meta {
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px dashed var(--border);
}
.dm-meta-name {
    font-size: 14px;
    color: var(--ct-blue-dark);
    font-weight: 600;
    margin-bottom: 4px;
}
.dm-meta-time {
    font-size: 12px;
    color: var(--text-muted);
}
.dm-section { margin-bottom: 24px; }
.dm-section:last-child { margin-bottom: 0; }
.dm-section-title {
    font-size: 14px;
    color: var(--ct-blue-dark);
    font-weight: 600;
    margin-bottom: 8px;
    padding-left: 8px;
    border-left: 3px solid var(--ct-red);
}
.dm-table-wrap { overflow-x: auto; }
.dm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 880px;
}
.dm-table thead th {
    text-align: left;
    padding: 8px 10px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    background: #f5f7fa;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.dm-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid #f0f2f5;
    color: var(--text);
    vertical-align: top;
}
.dm-table tbody tr:hover td { background: #fafbfc; }
.dm-table .td-num { text-align: right; font-variant-numeric: tabular-nums; }
.dm-table .td-name { min-width: 140px; word-break: break-all; }

@media (max-width: 760px) {
    .dm-overlay { padding: 12px 6px; }
    .dm-dialog { max-width: 100%; }
    .dm-body { padding: 14px 12px 22px; max-height: calc(100vh - 110px); }
    .dm-head { padding: 12px 16px; }
    .dm-head h3 { font-size: 15px; }
}

/* ===== 支局排名胶囊 ===== */
.branch-rank-row {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-top: 14px; padding-top: 14px;
    border-top: 1px dashed #e4e7ed;
}
.rank-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 12px; border-radius: 16px;
    background: linear-gradient(135deg, #f0f5ff 0%, #e8effb 100%);
    border: 1px solid #d6e0f5;
    color: #1a3a6b; font-size: 12px; font-weight: 500;
}
.rank-pill strong { color: #c4161c; font-size: 14px; }

/* ===== 全员业绩可点击姓名/数字 ===== */
.emp-link, .num-link {
    color: #1a3a6b; text-decoration: none;
    cursor: pointer; border-bottom: 1px dashed transparent;
    transition: color .12s, border-color .12s;
}
.emp-link:hover, .num-link:hover {
    color: #c4161c; border-bottom-color: #c4161c;
}
.emp-link { font-weight: 600; }
.num-link { font-variant-numeric: tabular-nums; }
.zero-row .emp-link, .zero-row .num-link { color: #909399; }

/* ===== 下一步工作指导 ===== */
.guide-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 10px;
}
.guide-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; border-radius: 8px;
    font-size: 13.5px; line-height: 1.6; color: #2c3e50;
}
.guide-icon {
    flex: 0 0 22px; height: 22px; border-radius: 50%;
    background: #fff; display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.guide-text { flex: 1; min-width: 0; }
.guide-text strong { color: #1a3a6b; font-weight: 600; }
