/* 数据看板 v2 — 紧凑版（卡片密度对标 sub2api 仪表盘）。无内联样式 / 无外部资源，兼容 CSP (style-src 'self')。
   深色模式 = <html class="dark">。
   配色：Token 类型色沿用 sub2api 的色相语言（输入=蓝、输出=绿、缓存读=青、缓存写=琥珀、命中率=紫），
   取 Tailwind 阶梯里能通过 dataviz 六项检查的那一档（浅/深色底：相邻色色盲 ΔE≥19、常人视觉 ΔE≥24、对比度≥3:1）。
   实体色板 --s1..--s8（模型 / 分组）同样是 sub2api 色相，已按固定顺序校验（相邻 ΔE≥11 / 常人≥20）。 */

:root {
  color-scheme: light;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f3f6fb;
  --bg-bottom: #f6f8fc;
  --glow-a: rgba(45, 212, 191, .24);   /* 薄荷 */
  --glow-b: rgba(129, 140, 248, .17);  /* 靛蓝 */
  --card: #ffffff;
  --card-2: #f4f6fa;
  --line: rgba(15, 23, 42, .08);
  --line-strong: rgba(15, 23, 42, .14);
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #64748b;
  --accent: #0d9488;
  --accent-2: #14b8a6;
  --accent-ink: #0f766e;
  --accent-soft: rgba(20, 184, 166, .13);
  --purple-ink: #7c3aed;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 14px -8px rgba(15, 23, 42, .10);
  --grid: #e9edf3;
  --axis: #cfd6e1;
  --hover: rgba(15, 23, 42, .035);
  --tip-bg: #0f172a;
  --tip-fg: #f1f5f9;
  --warn-bg: rgba(245, 158, 11, .12);
  --warn-line: rgba(245, 158, 11, .38);
  --warn-ink: #92400e;
  --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  /* Token 类型色（趋势图 / 提示 / 圆点共用） */
  --tk-in: #3b82f6;     /* 输入   blue-500 */
  --tk-out: #059669;    /* 输出   emerald-600 */
  --tk-read: #0891b2;   /* 缓存读 cyan-600 */
  --tk-write: #d97706;  /* 缓存写 amber-600 */
  --hit: #8b5cf6;       /* 缓存命中率 violet-500 */
  --hit-soft: rgba(139, 92, 246, .15);
  --cost: #0d9488;      /* 消费趋势 teal-600 */
  /* 实体色板（模型 / 分组环形图与圆点）。第 2 位取 emerald-700：600 与相邻的 amber-600 在红绿色盲下 ΔE 仅 7.9 */
  --s1: #3b82f6; --s2: #047857; --s3: #d97706; --s4: #ec4899;
  --s5: #8b5cf6; --s6: #ef4444; --s7: #0891b2; --s8: #ea580c; --s-other: #94a3b8;
  /* 图标底色（柔和色块） */
  --c-blue-bg: #e1ecff;   --c-blue: #2563eb;
  --c-green-bg: #dcf7e6;  --c-green: #16a34a;
  --c-orange-bg: #fff0d6; --c-orange: #d97706;
  --c-purple-bg: #f1e7ff; --c-purple: #9333ea;
  --c-indigo-bg: #e4e8ff; --c-indigo: #4f46e5;
  --c-red-bg: #ffe3e7;    --c-red: #e11d48;
  --c-teal-bg: #d6f5ef;   --c-teal: #0d9488;
  --c-cyan-bg: #d9f3fb;   --c-cyan: #0891b2;
  --c-violet-bg: #ece6ff; --c-violet: #7c3aed;
}

html.dark {
  color-scheme: dark;
  --bg: #0b0f17;
  --bg-bottom: #0d121b;
  --glow-a: rgba(20, 184, 166, .14);
  --glow-b: rgba(99, 102, 241, .14);
  --card: #161b25;
  --card-2: #1d2430;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .15);
  --ink: #eef2f7;
  --ink-2: #b6c0cf;
  --muted: #8d99ab;
  --accent: #2dd4bf;
  --accent-2: #14b8a6;
  --accent-ink: #5eead4;
  --accent-soft: rgba(45, 212, 191, .16);
  --purple-ink: #c4b5fd;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px -10px rgba(0, 0, 0, .55);
  --grid: #252d3a;
  --axis: #3a4455;
  --hover: rgba(255, 255, 255, .04);
  --tip-bg: #e8edf5;
  --tip-fg: #0f172a;
  --warn-bg: rgba(245, 158, 11, .14);
  --warn-line: rgba(245, 158, 11, .4);
  --warn-ink: #fcd34d;
  --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d99ab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  /* 深色底：色相不变，同一组色阶已在 #161b25 上通过校验（亮度带 / 对比度 / 相邻色分离） */
  --hit-soft: rgba(139, 92, 246, .24);
  --s-other: #6b7686;
  --c-blue-bg: rgba(59, 130, 246, .18);   --c-blue: #7db0ff;
  --c-green-bg: rgba(34, 197, 94, .17);   --c-green: #6ee7a0;
  --c-orange-bg: rgba(245, 158, 11, .18); --c-orange: #fbbf5a;
  --c-purple-bg: rgba(168, 85, 247, .19); --c-purple: #cfa2ff;
  --c-indigo-bg: rgba(99, 102, 241, .22); --c-indigo: #a5b0ff;
  --c-red-bg: rgba(244, 63, 94, .18);     --c-red: #ff8da1;
  --c-teal-bg: rgba(45, 212, 191, .17);   --c-teal: #5eead4;
  --c-cyan-bg: rgba(34, 211, 238, .16);   --c-cyan: #67e8f9;
  --c-violet-bg: rgba(139, 92, 246, .22); --c-violet: #c4b5fd;
}

/* ---------- 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(980px 400px at 90% -8%, var(--glow-a), transparent 66%),
    radial-gradient(820px 400px at 2% -6%, var(--glow-b), transparent 64%),
    linear-gradient(180deg, transparent 0, transparent 55%, var(--bg-bottom) 100%);
}
h1, h2, p { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 50; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 10px; text-decoration: none; }
.skip:focus { top: 10px; }
.ic { display: block; flex: none; }
.wrap { max-width: 1360px; margin: 0 auto; padding: 16px 16px 44px; }
main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px 18px; flex-wrap: wrap; margin-bottom: 12px; }
.titlebox { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo { display: block; flex: none; border-radius: 10px; line-height: 0; box-shadow: 0 5px 14px -8px rgba(15, 23, 42, .5); }
.logo img { width: 34px; height: 34px; border-radius: 10px; }
.titles h1 { font-size: 19px; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
.titles p { font-size: 12.5px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 500;
  text-decoration: none; color: var(--ink-2); background: var(--card); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); cursor: pointer;
}
.pill:hover { color: var(--accent-ink); border-color: var(--accent); }
.user { display: flex; align-items: center; gap: 9px; margin-left: 4px; }
.bal { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; cursor: default; }
.bal b { font-weight: 700; font-variant-numeric: tabular-nums; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: #fff; font-size: 12.5px; font-weight: 700; background: linear-gradient(135deg, #14b8a6, #0d9488); }
.uname { display: grid; line-height: 1.25; min-width: 0; }
.uname b { font-size: 13px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uname small { font-size: 11px; color: var(--muted); }

/* ---------- 状态卡（未登录 / 错误） ---------- */
.state { display: grid; justify-items: center; gap: 10px; width: 100%; max-width: 640px; margin: 28px auto 0; padding: 44px 24px; text-align: center; }
.state-ic { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--accent-soft); color: var(--accent-ink); }
.state h2 { font-size: 18px; }
.state p { max-width: 460px; color: var(--ink-2); }
.state-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* ---------- 按钮 / 表单控件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: 9px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); text-decoration: none; transition: border-color .15s, color .15s, box-shadow .15s, transform .1s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn:active { transform: translateY(1px); }
.btn-sm { height: 30px; padding: 0 11px; }
.btn-primary { color: #fff; border-color: transparent; background: linear-gradient(135deg, #19c3ac, #0d9488); box-shadow: 0 6px 14px -8px rgba(13, 148, 136, .65); }
.btn-primary:hover { color: #fff; border-color: transparent; filter: brightness(1.06); }
select, input[type="date"] {
  height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; border: 1px solid var(--line-strong); background-color: var(--card); color: var(--ink);
}
select { appearance: none; -webkit-appearance: none; min-width: 148px; max-width: 100%; padding-right: 30px; background-image: var(--caret); background-repeat: no-repeat; background-position: right 9px center; background-size: 14px; cursor: pointer; }
select:hover, input[type="date"]:hover { border-color: var(--accent); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line); }
.seg button { height: 26px; padding: 0 11px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--accent-ink); font-weight: 600; box-shadow: 0 1px 3px rgba(15, 23, 42, .14); }
html.dark .seg button[aria-pressed="true"] { background: var(--line-strong); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.seg-sm button { height: 24px; padding: 0 9px; font-size: 12px; }
.mini { height: 26px; padding: 0 10px; font-size: 12px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--card-2); color: var(--ink-2); }
.mini:hover, .mini[aria-pressed="true"] { color: var(--accent-ink); border-color: var(--accent); }

/* ---------- 栅格 / KPI ---------- */
.grid12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; }
.col2 { grid-column: span 2; } .col3 { grid-column: span 3; } .col4 { grid-column: span 4; } .col6 { grid-column: span 6; } .col12 { grid-column: span 12; }
.kpi { display: flex; align-items: center; gap: 10px; padding: 8px 12px 9px; min-width: 0; }
.kpi-body { min-width: 0; flex: 1; }
.chip { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px; }
.c-blue { background: var(--c-blue-bg); color: var(--c-blue); } .c-green { background: var(--c-green-bg); color: var(--c-green); }
.c-orange { background: var(--c-orange-bg); color: var(--c-orange); } .c-purple { background: var(--c-purple-bg); color: var(--c-purple); }
.c-indigo { background: var(--c-indigo-bg); color: var(--c-indigo); } .c-red { background: var(--c-red-bg); color: var(--c-red); }
.c-teal { background: var(--c-teal-bg); color: var(--c-teal); } .c-cyan { background: var(--c-cyan-bg); color: var(--c-cyan); }
.c-violet { background: var(--c-violet-bg); color: var(--c-violet); }
.kpi-label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); line-height: 1.35; }
.kpi-value { margin-top: 1px; font-size: 20px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; overflow-wrap: anywhere; }
.kpi-value small { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; white-space: nowrap; }
.kpi-value .v-green { color: var(--accent-ink); } .kpi-value .v-purple { color: var(--purple-ink); }
.kpi-sub { margin-top: 1px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.kpi-sub b { font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tb { display: inline-block; margin-right: 9px; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; vertical-align: 0; background: var(--s-other); }
.dot.s1 { background: var(--s1); } .dot.s2 { background: var(--s2); } .dot.s3 { background: var(--s3); } .dot.s4 { background: var(--s4); }
.dot.s5 { background: var(--s5); } .dot.s6 { background: var(--s6); } .dot.s7 { background: var(--s7); } .dot.s8 { background: var(--s8); } .dot.other { background: var(--s-other); }
.dot.k-in, .sw.k-in { background: var(--tk-in); } .dot.k-out, .sw.k-out { background: var(--tk-out); }
.dot.k-read, .sw.k-read { background: var(--tk-read); } .dot.k-write, .sw.k-write { background: var(--tk-write); }
.dot.k-hit, .sw.k-hit { background: var(--hit); } .sw.k-cost { background: var(--cost); }
.perf { display: flex; align-items: baseline; gap: 6px; font-size: 18px; font-weight: 700; line-height: 1.3; }
.perf small { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.meter { height: 6px; margin: 6px 0 5px; border-radius: 99px; background: var(--hit-soft); overflow: hidden; }
.meter i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--hit); transition: width .4s ease; }
.kpi .meter { margin: 4px 0 3px; height: 5px; }

/* ---------- 缓存命中率条（本小时 / 今日 / 近 7 天，无需悬停即可看到） ---------- */
.hit { display: grid; grid-template-columns: minmax(176px, .85fr) repeat(3, minmax(0, 1fr)) minmax(236px, 1.45fr); overflow: hidden; }
.hit > * { min-width: 0; padding: 10px 16px 11px; }
.hit > * + * { border-left: 1px solid var(--line); }
.hit-head { display: flex; align-items: center; gap: 11px; background: linear-gradient(135deg, var(--hit-soft), transparent 70%); }
.hit-title h2 { display: flex; align-items: center; gap: 5px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.hit-title p { margin-top: 2px; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.hs-label { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 7px; font-size: 12.5px; line-height: 1.4; color: var(--ink-2); }
.hs-label b { font-weight: 600; color: var(--ink); }
.hs-label small { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hs-value { margin-top: 1px; font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
.hs-value.na { color: var(--muted); font-weight: 600; }
.hs-sub { font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.hs-sub b { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.hs-sub .full, .hs-sub .cnt { display: block; }
.hs-note { display: block; color: var(--muted); }
.hs-note.warn { color: var(--warn-ink); }
.hit-trend { display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.ht-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 11.5px; color: var(--muted); }
.ht-title b { font-weight: 600; color: var(--ink-2); font-size: 12.5px; }
.spark { display: block; width: 100%; height: 44px; overflow: visible; }
.spark .col { cursor: default; }
.spark .b { fill: var(--hit); opacity: .5; }
html.dark .spark .b { opacity: .62; }
.spark .col:hover .b, .spark .cur .b { opacity: 1; }
.spark .n { fill: var(--axis); }
.spark .hot { fill: transparent; }
.ht-axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); line-height: 1.2; }

/* ---------- 提示气泡（说明文字） ---------- */
.tip { display: inline-grid; place-items: center; color: var(--muted); cursor: help; border-radius: 50%; }
.tip:hover, .tip:focus-visible { color: var(--accent-ink); }
#tip {
  position: fixed; z-index: 1000; max-width: min(320px, calc(100vw - 16px)); padding: 9px 12px; border-radius: 10px; pointer-events: none;
  background: var(--tip-bg); color: var(--tip-fg); font-size: 12px; line-height: 1.6; white-space: pre-line; box-shadow: 0 12px 30px -8px rgba(0, 0, 0, .4);
}

/* ---------- 图表悬停提示（HTML，缓存命中率置顶） ---------- */
#ctip {
  position: fixed; z-index: 900; left: 0; top: 0; width: 232px; padding: 9px 12px 9px; border-radius: 12px; pointer-events: none;
  background: var(--card); color: var(--ink); border: 1px solid var(--line-strong); font-size: 12px; line-height: 1.5;
  box-shadow: 0 16px 36px -12px rgba(15, 23, 42, .38), 0 2px 6px rgba(15, 23, 42, .08);
}
html.dark #ctip { box-shadow: 0 16px 36px -10px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .04); }
.ct-title { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.ct-title .dot { margin: 0; flex: none; }
.ct-hero { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 5px; }
.ct-hl { font-size: 12px; color: var(--ink-2); }
.ct-hv { font-size: 23px; line-height: 1.1; font-weight: 700; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
#ctip .meter { margin: 5px 0 3px; }
#ctip .meter i { transition: none; }
.ct-note { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.ct-empty { margin-top: 6px; color: var(--muted); font-size: 12px; }
.ct-rows { margin: 6px 0 0; padding: 6px 0 0; border-top: 1px solid var(--line); display: grid; gap: 1px; }
.ct-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ct-row dt { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.ct-row dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.ct-row.strong dt { color: var(--ink); font-weight: 600; }
.ct-row small { margin-left: 5px; font-weight: 400; font-size: 11px; color: var(--muted); }
.ct-foot { margin: 5px 0 0; padding: 5px 0 0; border-top: 1px solid var(--line); display: grid; gap: 1px; }
.sw { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--s-other); }
.sw.line { width: 14px; height: 3px; border-radius: 2px; }
.sw.none { background: transparent; }

/* ---------- 控制区 ---------- */
.controls { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; padding: 8px 14px 9px; }
.ctl-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.field { display: flex; align-items: center; gap: 7px; min-width: 0; }
.field.push { margin-left: auto; }
.lbl { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.custom { gap: 6px; }
.custom .to { color: var(--muted); }
.btns { gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.load-text { font-size: 12px; color: var(--muted); }
.load-bar { position: absolute; left: 14px; right: 14px; bottom: 0; height: 3px; border-radius: 3px; overflow: hidden; background: var(--accent-soft); }
.load-bar i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .25s ease; }
.notice { padding: 9px 13px; border-radius: 10px; font-size: 13px; background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); }
#dash { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; transition: opacity .2s; }
#dash.loading { opacity: .55; }
#dash.loading .btn-primary, #dash.loading #btn-refresh { pointer-events: none; }

/* ---------- 图表卡片 ---------- */
.charts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.chart { display: flex; flex-direction: column; min-width: 0; container-type: inline-size; }
.card-h { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 12px; padding: 10px 14px 2px; }
.card-h h2 { font-size: 14px; font-weight: 700; line-height: 1.4; }
.card-h .mini, .card-h .seg { margin-left: auto; }
.card-h .hint + .mini { margin-left: 0; }
.rate-chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px 0 8px; border-radius: 99px; font-size: 12px; color: var(--ink-2); background: var(--hit-soft); white-space: nowrap; }
.rate-chip b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.legend-row { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 14px; flex-basis: 100%; order: 3; min-height: 22px; }
.legend { display: flex; align-items: center; flex-wrap: wrap; gap: 0 4px; }
.lg { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 7px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.lg:hover { background: var(--hover); color: var(--ink); }
.lg[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.lg[aria-pressed="false"] .sw { opacity: .3; }
.lg-static { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 7px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.fold-note { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; color: var(--muted); background: var(--card-2); cursor: help; white-space: nowrap; }
.fold-note .brk { position: relative; display: inline-block; width: 10px; height: 10px; }
.fold-note .brk::before, .fold-note .brk::after { content: ""; position: absolute; top: 0; width: 1.4px; height: 11px; background: currentColor; transform: rotate(24deg); }
.fold-note .brk::before { left: 2px; } .fold-note .brk::after { left: 6px; }
.hint { margin-left: auto; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.hint .tap { display: none; }
.chart.no-data .legend-row, .chart.no-data .hint, .chart.no-data .rate-chip { display: none; }
.chart.is-table .legend-row, .chart.is-table .hint { display: none; }
.chart.is-table .hint + .mini { margin-left: auto; }
.card-b { position: relative; flex: 1; padding: 2px 10px 10px; min-height: 0; }
.plot { position: relative; height: 280px; }
.plot canvas { touch-action: pan-y; }
.plot canvas:focus-visible { outline-offset: -2px; }
.tview { max-height: 280px; overflow: auto; }
.donut-b { display: flex; flex: 1; align-items: center; gap: 14px; padding: 6px 14px 14px; min-height: 280px; }
.donut { position: relative; flex: none; width: 216px; height: 216px; }
@container (min-width: 561px) and (max-width: 700px) {
  .donut-b { gap: 8px; padding-left: 8px; padding-right: 8px; }
  .donut { width: 176px; height: 176px; }
  .mini-table th, .mini-table td { padding-left: 4px; padding-right: 4px; }
  .mini-table td:first-child { max-width: 104px; }
}
@container (max-width: 560px) {
  .donut-b { flex-direction: column; align-items: stretch; gap: 8px; min-height: 0; }
  .donut { align-self: center; width: 200px; height: 200px; }
}
@container (max-width: 480px) {
  .mini-table .opt { display: none; }
  .mini-table td:first-child { max-width: 128px; }
  .mini-table th, .mini-table td { padding-left: 4px; padding-right: 4px; }
}
.dist { flex: 1; min-width: 0; max-height: 252px; overflow: auto; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 220px; color: var(--muted); font-size: 14px; }
.empty > i { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px; background: var(--card-2); }
.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini-table th { padding: 5px 6px; text-align: left; font-weight: 500; color: var(--muted); white-space: nowrap; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; }
.mini-table td { padding: 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.mini-table tr:last-child td { border-bottom: 0; }
.mini-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.mini-table td:first-child { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 明细表 ---------- */
.table-card { overflow: hidden; }
.table-card .card-h { padding: 11px 14px 8px; }
.count { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.data th { padding: 0 10px; height: 36px; text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); white-space: nowrap; background: var(--card-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.data th.num, .data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.th-btn { display: inline-flex; align-items: center; gap: 2px; padding: 0; border: 0; background: none; color: inherit; font-size: inherit; font-weight: inherit; }
.th-btn:hover { color: var(--ink); }
th[aria-sort="ascending"] .th-btn, th[aria-sort="descending"] .th-btn { color: var(--accent-ink); font-weight: 600; }
.arrow { display: inline-flex; width: 14px; }
.data td { padding: 0 10px; height: 38px; white-space: nowrap; border-bottom: 1px solid var(--line); max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.data tbody tr:hover { background: var(--hover); }
.table-card .empty { display: none; }
.table-card.is-empty .empty { display: flex; }
.table-card.is-empty .table-wrap { display: none; }
.pager { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; padding: 12px; }
.pager:empty { display: none; }
.pg { min-width: 32px; height: 30px; padding: 0 9px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--card); font-size: 13px; }
.pg:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-ink); }
.pg.on { color: #fff; border-color: transparent; background: linear-gradient(135deg, #19c3ac, #0d9488); }
.pg:disabled { opacity: .4; cursor: not-allowed; }
.gap { color: var(--muted); padding: 0 2px; }

/* ---------- 响应式 ---------- */
@media (min-width: 1100px) {
  .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1239px) {
  .col2 { grid-column: span 4; }
}
@media (max-width: 1179px) {
  /* 命中率条：头部 + 三个窗口一行，近 24 小时迷你柱图落到下一行 */
  .hit { grid-template-columns: minmax(150px, .7fr) repeat(3, minmax(0, 1fr)); }
  .hit-trend { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .hit-title p { display: none; }
}
@media (max-width: 1100px) {
  .field.push { margin-left: 0; }
}
@media (max-width: 900px) {
  .col3 { grid-column: span 6; }
  .col2 { grid-column: span 6; }
}
@media (max-width: 759px) {
  .hit { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hit-head { grid-column: 1 / -1; border-left: 0; padding-bottom: 9px; }
  .hit-title p { display: block; }
  .hit-seg { border-top: 1px solid var(--line); }
  #hit-hour { border-left: 0; }
}
@media (max-width: 760px) {
  .wrap { padding: 12px 12px 40px; }
  .top-actions { width: 100%; }
  .user { margin-left: 0; }
  .plot { height: 250px; }
  .tview { max-height: 250px; }
  .donut-b { flex-direction: column; align-items: stretch; min-height: 0; }
  .donut { align-self: center; }
  .btns { width: 100%; justify-content: flex-start; }
  .load-text { flex-basis: 100%; }
  /* 明细表 -> 卡片列表 */
  .data thead { display: none; }
  .data, .data tbody { display: block; }
  .data tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; margin: 10px 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; }
  .data td { display: flex; justify-content: space-between; gap: 10px; height: auto; padding: 0; max-width: none; border: 0; white-space: normal; text-align: right; }
  .data td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 12px; text-align: left; }
  .data td:nth-child(-n+3) { grid-column: 1 / -1; }
  .data td:first-child { font-weight: 600; }
}
@media (max-width: 560px) {
  .grid12 { gap: 8px; }
  .col3, .col2 { grid-column: span 6; }
  .col6 { grid-column: span 12; }
  .kpi { gap: 8px; padding: 9px 10px 10px; }
  .kpi-value { font-size: 18px; }
  .chip { width: 30px; height: 30px; border-radius: 9px; }
  .chip .ic { width: 17px; height: 17px; }
  .field { flex-wrap: wrap; }
  .filters label.field { flex: 1 1 100%; flex-wrap: nowrap; }
  .filters label.field > .lbl { flex: none; width: 60px; }
  .filters select { flex: 1; width: auto; min-width: 0; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 0 6px; }
  .card-h .seg { width: auto; }
  .card-h .seg button { flex: none; }
  .uname b { max-width: 96px; }
  .hit > * { padding: 10px 11px 11px; }
  .hs-value { font-size: 22px; }
  .hs-label { font-size: 12px; }
  .hs-label small { flex-basis: 100%; }
  .hs-sub .full { display: none; }
  .hint { display: none; }
  .card-h .hint + .mini { margin-left: auto; }
}
@media (hover: none) {
  .hint .hov { display: none; }
  .hint .tap { display: inline; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- API 地址卡片（/api/status → api_info）与公告块 ---------- */
:root {
  --c-pink: #db2777; --c-amber: #b45309; --c-yellow: #a16207; --c-lime: #4d7c0f; --c-slate: #64748b;
}
html.dark {
  --c-pink: #f472b6; --c-amber: #fbbf24; --c-yellow: #facc15; --c-lime: #a3e635; --c-slate: #94a3b8;
}
.tone-blue { --tone: var(--c-blue); } .tone-green { --tone: var(--c-green); } .tone-cyan { --tone: var(--c-cyan); }
.tone-purple { --tone: var(--c-purple); } .tone-pink { --tone: var(--c-pink); } .tone-red { --tone: var(--c-red); }
.tone-orange { --tone: var(--c-orange); } .tone-amber { --tone: var(--c-amber); } .tone-yellow { --tone: var(--c-yellow); }
.tone-lime { --tone: var(--c-lime); } .tone-teal { --tone: var(--c-teal); } .tone-indigo { --tone: var(--c-indigo); }
.tone-violet { --tone: var(--c-violet); } .tone-slate { --tone: var(--c-slate); }
.tone-default { --tone: var(--c-slate); } .tone-ongoing { --tone: var(--c-blue); } .tone-success { --tone: var(--c-green); }
.tone-warning { --tone: var(--c-orange); } .tone-error { --tone: var(--c-red); }

/* 与上面的命中率条同一套列宽：左侧标题格对齐，右侧一行一个地址 */
.api-card { display: grid; grid-template-columns: minmax(176px, .85fr) minmax(0, 4.45fr); overflow: hidden; }
.api-card > * { min-width: 0; padding: 10px 16px 11px; }
.api-card > * + * { border-left: 1px solid var(--line); }
.api-head { display: flex; align-items: center; gap: 11px; background: linear-gradient(135deg, var(--c-blue-bg), transparent 72%); }
.api-title h2 { font-size: 14px; font-weight: 700; white-space: nowrap; }
.api-title p { margin-top: 2px; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.api-list { display: grid; align-content: center; margin: 0; padding-top: 6px; padding-bottom: 6px; list-style: none; }
.api-row { display: grid; grid-template-columns: auto minmax(0, max-content) auto minmax(0, 1fr); align-items: center; gap: 4px 12px; padding: 5px 0; }
.api-row + .api-row { border-top: 1px solid var(--line); }
.api-label { display: inline-flex; align-items: center; gap: 7px; min-width: 0; font-size: 13px; font-weight: 600; }
.api-label .dot { flex: none; margin: 0; background: var(--tone); }
.api-route { min-width: 0; max-width: 24em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.api-url {
  padding: 4px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--card-2); overflow-wrap: anywhere; user-select: all;
  font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
.api-copy { gap: 5px; min-width: 78px; }
.api-copy-ic { display: inline-grid; }
.api-copy.done { color: var(--accent-ink); border-color: var(--accent); }
.api-copy.fail { color: var(--warn-ink); border-color: var(--warn-line); }
.api-desc { min-width: 0; font-size: 12px; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }
.copy-sink { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }

.ann-card { overflow: hidden; }
.ann-head { display: flex; align-items: center; gap: 10px; padding: 9px 14px; }
.ann-head .chip { width: 30px; height: 30px; border-radius: 9px; }
.ann-head h2 { font-size: 14px; font-weight: 700; }
.ann-count { font-size: 12px; color: var(--muted); }
.ann-toggle { margin-left: auto; }
.ann-body { display: grid; gap: 8px; padding: 0 14px 12px; }
.ann { display: grid; gap: 3px; padding: 8px 12px 9px 11px; border-radius: 9px; border-left: 3px solid var(--tone); background: var(--card-2); }
.ann-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 11.5px; color: var(--muted); }
.ann-tag { display: inline-flex; align-items: center; gap: 5px; height: 19px; padding: 0 8px 0 7px; border-radius: 99px; font-weight: 600; color: var(--ink-2); background: var(--card); border: 1px solid var(--line); }
.ann-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--tone); }
.ann-date { font-variant-numeric: tabular-nums; }
.ann-text { font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.ann-text p { margin: 0; }
.ann-text p + p { margin-top: 5px; }
.ann-text a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.ann-text strong { font-weight: 700; }
.ann-extra { font-size: 12px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.ann-more { justify-self: start; }

@media (max-width: 1179px) {
  .api-card { grid-template-columns: minmax(150px, .7fr) minmax(0, 3.3fr); }
  .api-title p { display: none; }
}
@media (max-width: 900px) {
  .api-card { grid-template-columns: minmax(0, 1fr); }
  .api-card > * + * { border-left: 0; border-top: 1px solid var(--line); }
  .api-title p { display: block; }
  .api-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .api-desc { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .api-card > * { padding: 10px 11px 11px; }
  .api-row { grid-template-columns: minmax(0, 1fr) auto; }
  .api-label { grid-column: 1; grid-row: 1; }
  .api-copy { grid-column: 2; grid-row: 1; }
  .api-url { grid-column: 1 / -1; grid-row: 2; }
  .api-desc { grid-row: 3; }
  .ann-head { padding: 9px 11px; }
  .ann-body { padding: 0 11px 11px; }
}
