:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e6e9ee;
  --brand: #0f766e;
  --brand-2: #14b8a6;
  --brand-soft: #ecfdf5;
  --danger: #e11d48;
  --warn: #f59e0b;
  --side: #0b1220;
  --side-2: #101c2e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 13.5px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- login ---------------- */
.login-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr;
  background: radial-gradient(1200px 600px at 20% 10%, #0f2b2a 0%, #0b1220 55%, #070d18 100%);
}
.login-art { padding: 64px; color: #dbeafe; display: flex; flex-direction: column; justify-content: space-between; }
.login-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; letter-spacing: .04em; }
.login-brand .mark { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #14b8a6, #0f766e); display: grid; place-items: center; font-size: 18px; color: #04211d; }
.login-headline { font-size: 38px; line-height: 1.25; margin: 48px 0 14px; font-weight: 680; color: #f8fafc; letter-spacing: -.02em; }
.login-sub { color: #94a3b8; max-width: 460px; font-size: 14px; }
.login-points { margin-top: 36px; display: grid; gap: 14px; max-width: 470px; }
.login-point { display: flex; gap: 12px; align-items: flex-start; color: #cbd5e1; font-size: 13px; }
.login-point b { color: #f1f5f9; font-weight: 600; }
.login-dot { width: 26px; height: 26px; border-radius: 8px; background: rgba(20, 184, 166, .14); color: #5eead4; display: grid; place-items: center; flex: 0 0 auto; font-size: 12px; }
.login-card-wrap { display: grid; place-items: center; padding: 40px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 34px; box-shadow: 0 30px 80px -20px rgba(2, 6, 23, .6); }
.login-card h2 { font-size: 21px; margin-bottom: 6px; }
.login-card p { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: #475569; margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid #d7dce3; border-radius: 10px; padding: 10px 12px; background: #fff; outline: none; transition: .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(20, 184, 166, .13); }
.login-hint { margin-top: 18px; font-size: 11.5px; color: #94a3b8; line-height: 1.7; border-top: 1px dashed #e2e8f0; padding-top: 14px; }
.login-err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; padding: 9px 12px; border-radius: 9px; font-size: 12.5px; margin-bottom: 14px; }

/* ---------------- shell ---------------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 232px; flex: 0 0 232px; background: linear-gradient(180deg, var(--side), var(--side-2));
  color: #94a3b8; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 20;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px; color: #f1f5f9; font-weight: 700; letter-spacing: .02em; }
.side-brand .mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #14b8a6, #0f766e); display: grid; place-items: center; color: #04211d; font-size: 15px; font-weight: 800; }
.side-brand small { display: block; font-size: 10px; color: #64748b; font-weight: 500; letter-spacing: .12em; margin-top: 1px; }
.side-nav { padding: 8px 10px; display: grid; gap: 2px; }
.side-label { font-size: 10px; letter-spacing: .14em; color: #475569; padding: 14px 10px 6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 9px; color: #94a3b8;
  font-size: 13px; cursor: pointer; transition: .14s; position: relative; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(148, 163, 184, .09); color: #e2e8f0; }
.nav-item.active { background: rgba(20, 184, 166, .14); color: #5eead4; font-weight: 600; }
.nav-item .ico { width: 17px; text-align: center; font-size: 14px; opacity: .9; }
.nav-item .count { margin-left: auto; background: #e11d48; color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 20px; font-weight: 700; }
.side-foot { margin-top: auto; padding: 14px; border-top: 1px solid rgba(148, 163, 184, .1); }
.side-user { display: flex; align-items: center; gap: 10px; }
.side-user .avatar { background: #1e293b; color: #5eead4; }
.side-user .meta { min-width: 0; }
.side-user .nm { color: #e2e8f0; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .rl { color: #64748b; font-size: 10.5px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  height: 62px; background: rgba(255, 255, 255, .82); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px;
  padding: 0 26px; position: sticky; top: 0; z-index: 15;
}
.top h1 { font-size: 16.5px; }
.top .sub { color: var(--muted); font-size: 12px; margin-left: 2px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.view { padding: 24px 26px 60px; max-width: 1460px; width: 100%; }

/* ---------------- atoms ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid #d8dde5; background: #fff; color: #1e293b; border-radius: 9px;
  padding: 7px 13px; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: .14s; white-space: nowrap;
}
.btn:hover { border-color: #b9c2cf; background: #fafbfc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0b5f59; }
.btn.danger { color: #be123c; border-color: #fecdd3; background: #fff1f2; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 9px; font-size: 11.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px; color: var(--c, #64748b);
  background: color-mix(in srgb, var(--c, #64748b) 11%, white);
  border: 1px solid color-mix(in srgb, var(--c, #64748b) 22%, white);
  white-space: nowrap;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 12px; color: #475569; transition: .14s;
}
.chip:hover { border-color: #cbd5e1; }
.chip.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.chip .n { opacity: .6; font-size: 11px; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: 0 0 auto;
}
.avatar.lg { width: 52px; height: 52px; font-size: 17px; border-radius: 14px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.card-h h3 { font-size: 13.5px; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-b { padding: 16px 18px; }

.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; align-content: start; }

/* ---------------- KPI ---------------- */
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .k-lab { color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
.kpi .k-val { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 2px; }
.kpi .k-sub { color: var(--muted); font-size: 11.5px; }
.kpi .k-sub b { color: var(--brand); }
.kpi::after { content: ''; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: var(--brand-soft); opacity: .7; }
.kpi.warn::after { background: #fff7ed; }
.kpi.danger::after { background: #fff1f2; }

/* ---------------- table ---------------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase;
  color: #94a3b8; font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfc;
}
.table td { padding: 11px 14px; border-bottom: 1px solid #f1f4f7; vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: .1s; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .nm { font-weight: 600; }
.table .sm { color: var(--muted); font-size: 11.5px; }

/* ---------------- funnel ---------------- */
.funnel { display: grid; gap: 10px; padding: 4px 0; }
.funnel-row { display: grid; grid-template-columns: 92px 1fr 52px; align-items: center; gap: 10px; font-size: 12px; }
.funnel-bar { height: 26px; border-radius: 7px; background: #f1f5f9; overflow: hidden; }
.funnel-bar i { display: block; height: 100%; border-radius: 7px; transition: width .5s ease; }
.funnel-row .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------- task list ---------------- */
.task { display: flex; gap: 11px; padding: 11px 0; border-bottom: 1px dashed #eef1f5; align-items: flex-start; }
.task:last-child { border-bottom: none; }
.task .tick {
  width: 17px; height: 17px; border-radius: 5px; border: 1.5px solid #cbd5e1; margin-top: 2px;
  cursor: pointer; flex: 0 0 auto; display: grid; place-items: center; font-size: 10px; color: transparent; transition: .12s;
}
.task .tick:hover { border-color: var(--brand-2); }
.task.done .tick { background: var(--brand); border-color: var(--brand); color: #fff; }
.task.done .t-title { text-decoration: line-through; color: #94a3b8; }
.task .t-title { font-size: 12.8px; font-weight: 550; }
.task .t-meta { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.task .overdue { color: var(--danger); font-weight: 700; }

/* ---------------- timeline ---------------- */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 1.5px; background: #e8edf3; }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before {
  content: ''; position: absolute; left: -18px; top: 5px; width: 8px; height: 8px; border-radius: 50%;
  background: #cbd5e1; border: 2px solid #fff; box-shadow: 0 0 0 2px #eef2f6;
}
.tl-item.out::before { background: var(--brand-2); }
.tl-item.in::before { background: #60a5fa; }
.tl-item.system::before { background: #f59e0b; }
.tl-top { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.tl-top b { color: #334155; font-size: 11.5px; }
.tl-body { font-size: 12.8px; margin-top: 3px; white-space: pre-wrap; color: #1e293b; }
.tl-bubble { background: #f8fafc; border: 1px solid #eef2f6; border-radius: 10px; padding: 8px 11px; margin-top: 5px; }

/* ---------------- tabs ---------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 4px; overflow-x: auto; }
.tab {
  padding: 10px 14px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer;
  border: none; background: none; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: #334155; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab .n { background: #eef2f6; border-radius: 20px; padding: 0 6px; font-size: 10.5px; margin-left: 4px; }

/* ---------------- detail header ---------------- */
.detail-head { display: flex; gap: 16px; align-items: flex-start; }
.detail-head .who { min-width: 0; flex: 1; }
.detail-head h2 { font-size: 20px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-head .line { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.fact .f-l { font-size: 10.5px; color: #94a3b8; letter-spacing: .05em; text-transform: uppercase; }
.fact .f-v { font-size: 12.8px; font-weight: 550; margin-top: 1px; word-break: break-word; }

/* ---------------- misc ---------------- */
.progress-ring { display: flex; align-items: center; gap: 10px; }
.pbar { height: 6px; background: #eef2f6; border-radius: 6px; overflow: hidden; }
.pbar i { display: block; height: 100%; border-radius: 6px; }
.empty { text-align: center; padding: 34px 10px; color: #94a3b8; }
.empty-ico { font-size: 26px; opacity: .5; }
.empty-t { font-weight: 600; color: #64748b; margin-top: 6px; font-size: 13px; }
.empty-s { font-size: 11.5px; margin-top: 3px; }

.overlay {
  position: fixed; inset: 0; background: rgba(8, 15, 30, .48); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px; z-index: 100; animation: fade .15s ease;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 520px; max-height: 88vh; overflow: auto;
  box-shadow: 0 40px 100px -30px rgba(2, 6, 23, .5); animation: pop .18s ease;
}
.modal.wide { max-width: 760px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; border-radius: 16px 16px 0 0; }
.modal-h h3 { font-size: 14.5px; }
.modal-h .x { margin-left: auto; cursor: pointer; color: #94a3b8; font-size: 18px; line-height: 1; padding: 4px; }
.modal-b { padding: 18px 20px; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: 0; background: #fff; border-radius: 0 0 16px 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: .6; } }

.toast-root { position: fixed; bottom: 22px; right: 22px; display: grid; gap: 8px; z-index: 200; }
.toast {
  background: #0f172a; color: #f8fafc; padding: 11px 16px; border-radius: 10px; font-size: 12.5px;
  box-shadow: 0 12px 30px -8px rgba(2, 6, 23, .5); transform: translateY(8px); opacity: 0; transition: .22s; max-width: 380px;
}
.toast.show { transform: none; opacity: 1; }
.toast.err { background: #9f1239; }

.pwd-warn { display: flex; align-items: center; gap: 12px; padding: 9px 26px; background: #fffbeb; border-bottom: 1px solid #fde68a; color: #92400e; font-size: 12.5px; }
.pwd-warn .btn { margin-left: auto; }

.section-title { font-size: 12px; color: #94a3b8; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; margin: 4px 0 10px; }
.hr { height: 1px; background: var(--line); margin: 14px 0; border: 0; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }

.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed #f0f3f7; font-size: 12.5px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; font-variant-numeric: tabular-nums; }

.totals { background: #f8fafc; border: 1px solid #eef2f6; border-radius: 11px; padding: 12px 14px; }
.totals .row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 3px 0; }
.totals .row.total { font-size: 15px; font-weight: 700; border-top: 1px solid #e2e8f0; margin-top: 6px; padding-top: 8px; }
.totals .row.total .v { color: var(--brand); }

.drift { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 9px; padding: 9px 12px; font-size: 11.8px; }

.ai-box { border: 1px solid #d7e3ff; background: linear-gradient(180deg, #f5f8ff, #fff); border-radius: 12px; padding: 14px; }
.ai-text { white-space: pre-wrap; font-size: 13px; line-height: 1.65; background: #fff; border: 1px solid #e6ecf7; border-radius: 10px; padding: 13px 14px; min-height: 120px; }
.ai-notes { margin-top: 10px; display: grid; gap: 5px; }
.ai-note { font-size: 11.5px; color: #7c5a13; background: #fffbeb; border: 1px solid #fde68a; border-radius: 7px; padding: 6px 9px; }

.wa-preview { background: #e5ddd5; border-radius: 12px; padding: 12px; }
.wa-bubble { background: #dcf8c6; border-radius: 10px 10px 2px 10px; padding: 10px 12px; font-size: 12.8px; white-space: pre-wrap; max-width: 92%; margin-left: auto; box-shadow: 0 1px 1px rgba(0,0,0,.08); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search { position: relative; }
.search input { width: 260px; padding: 8px 12px 8px 32px; border: 1px solid var(--line); border-radius: 9px; background: #fff; outline: none; }
.search input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(20,184,166,.1); }
.search::before { content: '⌕'; position: absolute; left: 11px; top: 6px; color: #94a3b8; font-size: 15px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }

.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 70px; gap: 10px; align-items: center; font-size: 12px; }
.bar-track { height: 9px; background: #f1f5f9; border-radius: 6px; overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 6px; }

.country-flag { font-size: 13px; margin-right: 4px; }
.cc { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .05em; color: #64748b; background: #eef2f6; border-radius: 4px; padding: 1px 5px; margin-right: 6px; vertical-align: 1px; }

@media print {
  .side, .top, .toolbar, .detail-actions, .tabs, .modal-f, .toast-root { display: none !important; }
  body { background: #fff; }
  .main { margin: 0; }
  .view { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
  .split { display: block; }
}

@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .side { width: 62px; flex-basis: 62px; }
  .side-brand span, .side-label, .nav-item .txt, .side-user .meta { display: none; }
  .nav-item { justify-content: center; }
  .view { padding: 16px; }
  .g-3, .g-2, .g-4 { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .search input { width: 170px; }
}
