:root {
  --ink: #1E2A4A;        /* 丝印靛蓝：主文字、主按钮 */
  --ink-2: #4A5677;      /* 次要文字 */
  --ink-3: #7D879F;      /* 弱文字 */
  --paper: #F4F6F9;      /* 底色 */
  --sheet: #FFFFFF;      /* 面板 */
  --cotton: #E2E6ED;     /* 分隔线 */
  --cotton-2: #EEF1F5;
  --hi: #C81E5B;         /* 高：印花洋红 */
  --mid: #D98A00;        /* 中：琥珀 */
  --lo: #6B7A99;         /* 低 */
  --ok: #0B8A73;         /* 好：青绿 */
  --focus: #3D6BE0;
  --bar: #1E2A4A;
  --bar-muted: #C9D0DD;
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --num: "SF Pro Display", "Segoe UI", "Roboto", "Helvetica Neue", var(--font);
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E6EAF3; --ink-2: #AEB7CB; --ink-3: #7F8AA3;
    --paper: #12161F; --sheet: #1A202C; --cotton: #2A3242; --cotton-2: #222A38;
    --hi: #FF5C8A; --mid: #F2B33D; --lo: #8D9AB5; --ok: #34C3A6; --focus: #7FA2FF;
    --bar: #C7D2EA; --bar-muted: #3A4458;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--focus); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }

/* ---------- 布局 ---------- */
.shell { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
.nav { background: var(--sheet); border-right: 1px solid var(--cotton); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; font-weight: 600; font-size: 15px; }
.brand i { width: 22px; height: 22px; border-radius: 5px; background: var(--ink); display: inline-block; position: relative; }
.brand i::after { content: ""; position: absolute; left: 5px; right: 5px; top: 6px; height: 3px; background: var(--hi); border-radius: 2px; box-shadow: 0 5px 0 var(--mid), 0 10px 0 var(--ok); }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: var(--r); color: var(--ink-2); text-decoration: none; margin-bottom: 1px; }
.nav a:hover { background: var(--cotton-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--sheet); }
.nav .count { font-family: var(--num); font-size: 12px; min-width: 20px; text-align: center; border-radius: 10px; padding: 0 6px; background: var(--hi); color: #fff; }
.nav .sep { height: 1px; background: var(--cotton); margin: 10px 8px; }
.nav .me { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--cotton); font-size: 13px; color: var(--ink-2); }
.nav .me button { background: none; border: 0; padding: 0; color: var(--focus); cursor: pointer; margin-right: 10px; }

.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 16px; padding: 14px 28px; border-bottom: 1px solid var(--cotton); background: var(--sheet); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.top h1 { font-size: 17px; margin: 0; font-weight: 600; }
.top .spacer { flex: 1; }
.agent { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lo); flex: none; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--hi); } .dot.warn { background: var(--mid); }
.page { padding: 22px 28px 60px; max-width: 1400px; }

/* ---------- 控件 ---------- */
.btn { border: 1px solid var(--cotton); background: var(--sheet); border-radius: var(--r); padding: 6px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.btn.danger { color: var(--hi); border-color: color-mix(in srgb, var(--hi) 40%, transparent); }
.btn:disabled { opacity: .45; cursor: default; }
.field { border: 1px solid var(--cotton); background: var(--sheet); border-radius: var(--r); padding: 6px 10px; min-width: 0; }
.tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; border: 1px solid var(--cotton); border-radius: var(--r); overflow: hidden; }
.seg button { border: 0; background: var(--sheet); padding: 6px 12px; cursor: pointer; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }

/* ---------- 今日 ---------- */
.today { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.lede { font-size: 20px; line-height: 1.5; margin: 2px 0 22px; max-width: 46em; font-weight: 500; }
.lede .num { font-weight: 600; }
.figs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--cotton); border-radius: var(--r); background: var(--sheet); margin-bottom: 22px; }
.fig { padding: 16px 18px; border-left: 1px solid var(--cotton); }
.fig:first-child { border-left: 0; }
.fig .k { color: var(--ink-3); font-size: 13px; }
.fig .v { font-family: var(--num); font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; margin: 4px 0 2px; }
.fig .d { font-size: 12.5px; color: var(--ink-3); }
.up { color: var(--ok); } .down { color: var(--hi); }

.panel { background: var(--sheet); border: 1px solid var(--cotton); border-radius: var(--r); padding: 18px 20px; margin-bottom: 22px; }
.panel h2 { font-size: 15px; margin: 0 0 2px; font-weight: 600; }
.panel .note { color: var(--ink-3); font-size: 12.5px; margin: 0 0 14px; }
.twocol { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 22px; }
.twocol .panel { margin-bottom: 0; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--ink-3); font-size: 11px; font-family: var(--num); }
.tip { position: absolute; pointer-events: none; background: var(--sheet); border: 1px solid var(--cotton); border-radius: var(--r); padding: 6px 10px; font-size: 12.5px; box-shadow: 0 4px 16px rgba(20, 30, 60, .12); white-space: nowrap; display: none; z-index: 3; }
.tip b { font-family: var(--num); }
.hbar { display: grid; grid-template-columns: max-content 1fr max-content; gap: 6px 12px; align-items: center; font-size: 13px; }
.hbar .track { height: 10px; background: var(--cotton-2); border-radius: 5px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--bar); border-radius: 5px; }
.hbar .fill.muted { background: var(--bar-muted); }
.hbar .val { font-family: var(--num); font-variant-numeric: tabular-nums; color: var(--ink-2); text-align: right; }

/* 需要你处理：工单队列（本页最突出的元素） */
.queue { position: sticky; top: 76px; }
.queue h2 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: baseline; gap: 8px; }
.queue h2 .num { color: var(--ink-3); font-weight: 400; font-size: 13px; }
.ticket { position: relative; background: var(--sheet); border: 1px solid var(--cotton); border-radius: var(--r); padding: 12px 14px 12px 20px; margin-bottom: 8px; overflow: hidden; }
.ticket::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--lo); }
.ticket.hi::before { background: var(--hi); } .ticket.mid::before { background: var(--mid); } .ticket.approve::before { background: repeating-linear-gradient(180deg, var(--ink) 0 6px, transparent 6px 10px); }
.ticket .t { font-weight: 600; font-size: 13.5px; }
.ticket .s { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.ticket .a { color: var(--ink-3); font-size: 12.5px; margin-top: 6px; }
.ticket .acts { display: flex; gap: 8px; margin-top: 10px; }
.ticket .kind { font-size: 12px; color: var(--ink-3); }
.empty { color: var(--ink-3); padding: 18px 0; }
.report { white-space: normal; font-size: 13.5px; }
.report p { margin: 0 0 6px; } .report ul { margin: 0 0 8px; padding-left: 20px; }
details summary { cursor: pointer; color: var(--ink-2); }

/* ---------- 表格 ---------- */
.tablebox { background: var(--sheet); border: 1px solid var(--cotton); border-radius: var(--r); overflow: auto; max-height: calc(100vh - 210px); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; background: var(--sheet); text-align: left; font-weight: 500; color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--cotton); white-space: nowrap; cursor: pointer; user-select: none; z-index: 1; }
th[aria-sort="ascending"]::after { content: " ↑"; } th[aria-sort="descending"]::after { content: " ↓"; }
td { padding: 8px 12px; border-bottom: 1px solid var(--cotton-2); vertical-align: top; }
td.n, th.n { text-align: right; font-family: var(--num); font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--cotton-2); }
.chip { display: inline-block; padding: 0 8px; border-radius: 10px; font-size: 12px; line-height: 20px; white-space: nowrap; background: var(--cotton-2); color: var(--ink-2); }
.chip.hi { background: color-mix(in srgb, var(--hi) 14%, transparent); color: var(--hi); }
.chip.mid { background: color-mix(in srgb, var(--mid) 18%, transparent); color: color-mix(in srgb, var(--mid) 80%, var(--ink)); }
.chip.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.muted { color: var(--ink-3); }
.wrap { white-space: normal; min-width: 240px; }

/* ---------- 抽屉 / 对话框 ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(15, 20, 35, .35); z-index: 20; display: flex; justify-content: flex-end; }
.drawer { width: min(720px, 100%); height: 100%; background: var(--sheet); overflow: auto; padding: 22px 26px; box-shadow: -8px 0 30px rgba(10, 15, 30, .2); }
@media (prefers-reduced-motion: no-preference) { .drawer { animation: slide .18s ease-out; } @keyframes slide { from { transform: translateX(24px); opacity: .6; } } }
.drawer h2 { margin: 0 0 4px; font-size: 18px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; margin: 14px 0; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; }
textarea.field { width: 100%; min-height: 70px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--sheet); padding: 9px 18px; border-radius: var(--r); z-index: 40; font-size: 13.5px; }
.toast.err { background: var(--hi); color: #fff; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--cotton-2); padding: 2px 6px; border-radius: 4px; word-break: break-all; }
.json { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; width: 100%; min-height: 420px; }

/* ---------- 登录 ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(360px, 100%); background: var(--sheet); border: 1px solid var(--cotton); border-radius: 10px; padding: 28px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { color: var(--ink-3); margin: 0 0 20px; font-size: 13px; }
.login label { display: block; font-size: 13px; color: var(--ink-2); margin: 12px 0 4px; }
.login .field { width: 100%; padding: 9px 12px; }
.login .btn { width: 100%; margin-top: 20px; padding: 9px; }
.login .err { color: var(--hi); font-size: 13px; margin-top: 10px; min-height: 1em; }

/* ---------- 窄屏 ---------- */
@media (max-width: 1100px) { .today { grid-template-columns: 1fr; } .queue { position: static; order: -1; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 10px; border-right: 0; border-bottom: 1px solid var(--cotton); }
  .nav .brand { width: 100%; padding-bottom: 8px; } .nav .sep, .nav .me { display: none; }
  .top { padding: 12px 16px; position: static; } .page { padding: 16px; }
  .figs { grid-template-columns: repeat(2, 1fr); } .fig:nth-child(3) { border-left: 0; } .fig:nth-child(n+3) { border-top: 1px solid var(--cotton); }
  .lede { font-size: 17px; }
}
