/* AI-ads 投放中枢 — design system
   Pine & mineral palette. Bahnschrift numerals. Hatched texture = unknown data. */
:root {
  --ink: #13201b;
  --ink-2: #3c4c45;
  --ink-3: #66766f;
  --ink-4: #98a69f;
  --canvas: #f2f5f3;
  --surface: #ffffff;
  --surface-2: #f7faf8;
  --surface-3: #eef3f0;
  --line: #dbe4df;
  --line-2: #e8eeeb;
  --nav: #0f2a21;
  --nav-2: #163a2d;
  --nav-3: #1f4b3b;
  --nav-ink: #b6cbc1;
  --mint: #7fd3a8;
  --primary: #1f6b4e;
  --primary-hover: #185a41;
  --primary-soft: #e2efe8;
  --primary-ring: rgba(31, 107, 78, 0.26);
  --ok: #2b8754; --ok-soft: #e3f2e9;
  --run: #2f6fdb; --run-soft: #e7eefc;
  --queue: #5f6f86; --queue-soft: #edf1f6;
  --fail: #c03d36; --fail-soft: #fbe9e7;
  --warn: #b5761a; --warn-soft: #fbf0dc;
  --pause: #76689b; --pause-soft: #efecf6;
  --yield: #19858f; --yield-soft: #e2f3f4;
  --c-spend: #2f6fdb;
  --c-value: #e8891c;
  --c-count: #2e9b5c;
  --c-dspend: #7c5cd6;
  --c-dvalue: #9c4f2e;
  --c-dcount: #1c9aa8;
  --r-lg: 14px;
  --r-md: 9px;
  --r-sm: 6px;
  --shadow-pop: 0 12px 32px -8px rgba(15, 42, 33, 0.22), 0 2px 6px rgba(15, 42, 33, 0.08);
  --font-ui: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif;
  --font-num: "Bahnschrift", "DIN Alternate", "Barlow", "Roboto Condensed", "Segoe UI", var(--font-ui);
  --hatch: repeating-linear-gradient(135deg, transparent 0 4px, rgba(102, 118, 111, 0.2) 4px 5px);
  --nav-w: 228px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--canvas);
  color: var(--ink);
  font: 13px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: 0.01em; }
p { margin: 0; }
.num, .tnum { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.muted { color: var(--ink-3); }
.faint { color: var(--ink-4); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
svg.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.banner svg.icon { margin-top: 2px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(127, 211, 168, 0.45); }

/* ---------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; transition: grid-template-columns 0.25s var(--ease); }
.app.nav-collapsed { --nav-w: 68px; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow: hidden auto;
  background: linear-gradient(180deg, #123227 0%, var(--nav) 38%, #0c231b 100%);
  color: var(--nav-ink); display: flex; flex-direction: column; padding: 18px 12px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; color: #fff; }
.brand-mark { width: 30px; height: 30px; flex: none; border-radius: 9px; background: var(--mint); position: relative; overflow: hidden; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; left: 6px; right: 6px; height: 5px; border-radius: 3px; background: var(--nav); }
.brand-mark::before { top: 8px; right: 12px; }
.brand-mark::after { top: 17px; }
.brand-mark.lg { width: 44px; height: 44px; border-radius: 12px; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; }
.brand-sub { font-size: 11px; color: #8fb3a3; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--nav-ink);
  text-decoration: none; font-size: 13.5px; white-space: nowrap; position: relative; transition: background 0.15s, color 0.15s;
}
.nav a svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: var(--nav-2); color: #e6f1ec; }
.nav a.active { background: var(--nav-3); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--mint); }
.nav .count { margin-left: auto; font-family: var(--font-num); font-size: 11px; background: rgba(127, 211, 168, 0.16); color: var(--mint); padding: 1px 7px; border-radius: 10px; }
/* AI-ads 覆盖层：导航分组标题 */
.nav-group { padding: 16px 12px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; color: #6e9184; text-transform: uppercase; }
.nav-group:first-child { padding-top: 4px; }
.app.nav-collapsed .nav-group { padding: 12px 6px 4px; text-align: center; font-size: 9px; overflow: hidden; white-space: nowrap; color: #4f6d61; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; font-size: 11.5px; line-height: 1.7; color: #7f9e91; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.sidebar-foot b { color: #cfe3d9; font-weight: 600; }
.collapse-btn { margin-top: 10px; display: flex; align-items: center; gap: 8px; background: none; border: 0; color: #7f9e91; cursor: pointer; padding: 6px 4px; border-radius: 8px; }
.collapse-btn:hover { color: #e6f1ec; }
.collapse-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; transition: transform 0.25s; }
.app.nav-collapsed .brand-text, .app.nav-collapsed .nav-label, .app.nav-collapsed .nav .count, .app.nav-collapsed .sidebar-foot .foot-text, .app.nav-collapsed .collapse-label { display: none; }
.app.nav-collapsed .collapse-btn svg { transform: rotate(180deg); }
.app.nav-collapsed .nav a { justify-content: center; padding: 10px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 12px 26px;
  background: rgba(242, 245, 243, 0.86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-2);
}
.page-title { font-size: 19px; font-weight: 700; }
.page-sub { color: var(--ink-3); font-size: 12px; margin-left: 2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; padding: 0 6px; }
.clock .t { font-family: var(--font-num); font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.clock .d { font-size: 11px; color: var(--ink-3); }
.pill-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; transition: border-color 0.15s, background 0.15s;
}
.pill-btn:hover { border-color: #b9c9c1; background: var(--surface-2); }
.pill-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.pill-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.pill-btn.bad { border-color: #f0c4bf; background: var(--fail-soft); color: var(--fail); }
.pill-btn.bad .dot { background: var(--fail); }
.pill-btn.busy .dot { background: var(--run); animation: pulse 1.6s infinite; }
.bell { position: relative; }
.search-btn { color: var(--ink-3); padding: 0 10px 0 11px; }
.search-btn kbd, .palette kbd { font: 600 10.5px/1 var(--font-num); padding: 3px 5px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-3); }
@media (max-width: 1480px) { .search-btn .search-label { display: none; } }

/* Ctrl+K quick search (P6) */
.palette-scrim { z-index: 140; }
.palette {
  position: fixed; z-index: 150; left: 50%; top: 12vh; transform: translateX(-50%); width: min(640px, calc(100vw - 32px));
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-pop); overflow: hidden; animation: dialog-in 0.2s var(--ease);
  display: flex; flex-direction: column; max-height: 72vh;
}
.palette-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.palette-head svg { width: 18px; height: 18px; stroke: var(--primary); fill: none; stroke-width: 2; flex: none; }
.palette-input { flex: 1; border: 0; outline: 0; font: 15px var(--font-ui); color: var(--ink); background: transparent; min-width: 0; }
.palette-input::-webkit-search-cancel-button { display: none; }
.palette-list { overflow: auto; padding: 6px; }
.palette-group { padding: 10px 12px 4px; font-size: 11px; font-weight: 600; color: var(--ink-4); letter-spacing: 0.04em; }
.palette-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; cursor: pointer; }
.palette-item > svg { width: 17px; height: 17px; stroke: var(--ink-3); fill: none; stroke-width: 1.8; flex: none; }
.palette-item.on { background: var(--primary-soft); }
.palette-item.on > svg { stroke: var(--primary); }
.pi-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pi-main b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-sub { font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin: 0 4px; }
.pi-dot.s-ok { background: var(--ok); }
.pi-dot.s-bad { background: var(--fail); }
.pi-actions { display: none; gap: 4px; flex: none; }
.palette-item.on .pi-actions { display: inline-flex; }
.palette-empty { padding: 28px; text-align: center; color: var(--ink-3); font-size: 13px; }
.palette-hint { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 18px; border-top: 1px solid var(--line-2); background: var(--surface-2); font-size: 11.5px; color: var(--ink-3); }
.palette-hint kbd { margin: 0 2px; }
.badge-count { position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--fail); color: #fff; font: 600 10.5px/17px var(--font-num); text-align: center; box-shadow: 0 0 0 2px var(--canvas); }
.content { padding: 22px 26px 60px; display: flex; flex-direction: column; gap: 18px; }
.page { display: flex; flex-direction: column; gap: 18px; animation: page-in 0.32s var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.banner { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--r-md); font-size: 12.5px; border: 1px solid; }
.banner.warn { background: var(--warn-soft); border-color: #efd7a8; color: #7a4f0e; }
.banner.bad { background: var(--fail-soft); border-color: #f2c6c1; color: #8c2a24; }
.banner.info { background: var(--primary-soft); border-color: #c8e0d3; color: #1b4f3b; }
.banner b { font-weight: 700; }

/* ---------------------------------------------------------------- panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15px; }
.panel-head h3 { font-size: 14px; }
.panel-head .desc { color: var(--ink-3); font-size: 12px; flex-basis: 100%; margin-top: -6px; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 0 18px 16px; }
.panel-body.flush { padding: 0; }
.panel-foot { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.section-title { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.split { display: grid; gap: 18px; }
.divider { height: 1px; background: var(--line-2); margin: 4px 0; }

/* collapsible panel */
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: var(--r-lg); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .chev { margin-left: auto; width: 16px; height: 16px; stroke: var(--ink-3); fill: none; stroke-width: 2; transition: transform 0.25s var(--ease); }
details.fold[open] > summary .chev { transform: rotate(180deg); }
details.fold > summary:hover { background: var(--surface-2); }
details.fold .fold-body { padding: 0 18px 16px; animation: fold-in 0.25s var(--ease); }
@keyframes fold-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.08s;
}
.btn:hover:not(:disabled) { border-color: #b4c6bd; background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn.soft:hover:not(:disabled) { background: #d4e8dd; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); }
.btn.danger { color: var(--fail); border-color: #efc9c5; }
.btn.danger:hover:not(:disabled) { background: var(--fail-soft); border-color: #e7aaa3; }
.btn.danger.solid { background: var(--fail); color: #fff; border-color: var(--fail); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.xs { height: 24px; padding: 0 8px; font-size: 11.5px; border-radius: 6px; font-weight: 600; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.btn.meta-call::after { content: "请求 Meta"; font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 8px; background: rgba(255, 255, 255, 0.18); }
.btn.soft.meta-call::after, .btn.meta-call:not(.primary)::after { background: var(--warn-soft); color: var(--warn); }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field > .label { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.input, .select {
  height: 34px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: 0 11px; min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s; outline: none;
}
.input:hover, .select:hover { border-color: #bfcfc7; }
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.input.sm, .select.sm { height: 28px; font-size: 12px; padding: 0 8px; border-radius: 7px; }
.select.sm { padding-right: 24px; background-position: right 8px center; }
.select { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2366766f' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; cursor: pointer; }
.input[type="date"] { font-family: var(--font-num); font-size: 13.5px; }
.input.search { padding-left: 32px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2398a69f' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 11px center; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { appearance: none; width: 16px; height: 16px; margin: 0; border: 1.5px solid #a9b8b1; border-radius: 4.5px; background: #fff; cursor: pointer; display: grid; place-content: center; flex: none; transition: background 0.12s, border-color 0.12s; }
.check input::after { content: ""; width: 8px; height: 4.5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px) scale(0); transition: transform 0.12s var(--ease); }
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.check input:indeterminate { background: var(--primary); border-color: var(--primary); }
.check input:indeterminate::after { width: 8px; height: 0; border-left: 0; transform: none; border-bottom-width: 2px; }
.check input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; white-space: nowrap; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 11px; background: #c6d2cc; position: relative; cursor: pointer; margin: 0; flex: none; transition: background 0.2s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform 0.2s var(--ease); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(16px); }
.switch.sm input { width: 30px; height: 17px; }
.switch.sm input::after { width: 13px; height: 13px; }
.switch.sm input:checked::after { transform: translateX(13px); }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 10px; border: 1px solid var(--line-2); }
.seg button { border: 0; background: transparent; padding: 0 13px; height: 28px; border-radius: 7px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); font-weight: 600; transition: background 0.15s, color 0.15s, box-shadow 0.15s; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: 0 1px 2px rgba(15, 42, 33, 0.12), 0 0 0 1px var(--line-2); }
.seg.sm button { height: 24px; padding: 0 10px; font-size: 12px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 18px; }
.tabs button { position: relative; border: 0; background: none; padding: 10px 14px; cursor: pointer; font-size: 13px; color: var(--ink-3); font-weight: 600; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--primary); }
.tabs button.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary); }
.tabs .tab-count { font-family: var(--font-num); font-size: 11px; color: var(--ink-4); margin-left: 4px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }

/* chips & status */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); }
.chip.owned { background: #e3efe9; color: #1f6b4e; }
.chip.client { background: #e7eefc; color: #2b5bb7; }
.chip.unknown { background: var(--hatch), #f3f5f4; color: var(--ink-3); }
.chip.cur { background: transparent; border: 1px solid var(--line); color: var(--ink-3); font-family: var(--font-num); }
.chip.group { background: #f4efe6; color: #7b5b2b; }
.chip.tz { background: transparent; border: 1px dashed var(--line); color: var(--ink-3); }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.st.ok { color: var(--ok); } .st.run { color: var(--run); } .st.run::before { animation: pulse 1.4s infinite; }
.st.queue { color: var(--queue); } .st.fail { color: var(--fail); } .st.warn { color: var(--warn); }
.st.pause { color: var(--pause); } .st.yield { color: var(--yield); } .st.idle { color: var(--ink-4); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11px; font-weight: 700; }
.tag.manual { background: #e7eefc; color: #2b5bb7; }
.tag.startup { background: #f4efe6; color: #7b5b2b; }
.tag.automatic { background: #e3efe9; color: #1f6b4e; }

/* honest data: unknown / partial */
.unk { display: inline-flex; align-items: center; height: 19px; padding: 0 7px; border-radius: 5px; background: var(--hatch), #f4f6f5; color: var(--ink-3); font-size: 11px; font-weight: 600; font-family: var(--font-ui); white-space: nowrap; }
.part { position: relative; }
.part::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); margin-left: 4px; vertical-align: 2px; }
.zero-ok { color: var(--ink-3); }
.neg { color: var(--fail); }
.posd { color: var(--ok); }

/* ---------------------------------------------------------------- KPI band */
.kpi-band { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.kpi { padding: 14px 18px 15px; border-right: 1px solid var(--line-2); min-width: 0; position: relative; }
.kpi:last-child { border-right: 0; }
.kpi .k { font-size: 12px; color: var(--ink-3); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.kpi .v { font-family: var(--font-num); font-size: 25px; font-weight: 600; line-height: 1.25; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v.multi { font-size: 16px; line-height: 1.5; }
.kpi .v .cur { font-size: 12px; color: var(--ink-3); font-weight: 500; margin-left: 4px; font-family: var(--font-ui); }
.kpi .s { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.kpi.accent { background: linear-gradient(180deg, #f3faf6, #fff); }
.kpi.accent::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow: auto; position: relative; max-width: 100%; }
.table-wrap.tall { max-height: 640px; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.data th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--ink-3); font-weight: 600; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--ink); }
table.data th .arrow { display: inline-block; width: 8px; margin-left: 4px; color: var(--primary); }
table.data th .resizer { position: absolute; right: 0; top: 6px; bottom: 6px; width: 6px; cursor: col-resize; border-right: 1px solid transparent; }
table.data th:hover .resizer { border-right-color: var(--line); }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; background: var(--surface); }
table.data tr:hover td { background: #f6faf8; }
table.data tr.selected td { background: #eef6f1; }
table.data .num { text-align: right; white-space: nowrap; }
table.data th.num { text-align: right; }
table.data .sticky-1 { position: sticky; left: 0; z-index: 1; }
table.data th.sticky-1 { z-index: 3; }
table.data .sticky-2 { position: sticky; z-index: 1; box-shadow: 1px 0 0 var(--line-2); }
table.data th.sticky-2 { z-index: 3; }
table.data td.name-cell { min-width: 220px; max-width: 360px; }
.cell-title { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; max-width: 100%; }
.cell-title.link { cursor: pointer; }
.cell-title.link:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.cell-sub { font-size: 11.5px; color: var(--ink-4); font-family: var(--font-num); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.empty { padding: 36px 20px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink-2); font-size: 14px; margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--ink-3); }
.pager .grow { flex: 1; }
.pager .pg { font-family: var(--font-num); min-width: 64px; text-align: center; color: var(--ink-2); }
.col-chooser { display: grid; grid-template-columns: repeat(2, minmax(110px, 1fr)); gap: 6px 14px; padding: 4px 2px; }

/* skeleton */
.skel { background: linear-gradient(90deg, #edf2ef 0%, #f6f9f7 40%, #edf2ef 80%); background-size: 200% 100%; animation: skel 1.3s infinite linear; border-radius: 6px; }
@keyframes skel { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.skel-row { height: 14px; margin: 12px 18px; }

/* progress */
.bar { display: flex; height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; min-width: 120px; }
.bar i { display: block; height: 100%; transition: width 0.4s var(--ease); }
.bar i.ok { background: var(--ok); } .bar i.fail { background: var(--fail); } .bar i.cancel { background: #b8c2bd; }
.bar i.run { background: repeating-linear-gradient(-45deg, var(--run) 0 6px, #5a8ee6 6px 12px); background-size: 17px 17px; animation: bar-move 0.9s linear infinite; }
@keyframes bar-move { to { background-position: 17px 0; } }
.legend-inline { display: inline-flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-3); }
.legend-inline span { display: inline-flex; align-items: center; gap: 5px; }
.legend-inline i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* ---------------------------------------------------------------- overlays */
.toast-host { position: fixed; right: 22px; bottom: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; max-width: 420px; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: #13261f; color: #e8f2ed; box-shadow: var(--shadow-pop); font-size: 12.5px; animation: toast-in 0.28s var(--ease); }
.toast .ic { width: 18px; height: 18px; border-radius: 50%; flex: none; display: grid; place-content: center; font-size: 11px; font-weight: 700; margin-top: 1px; }
.toast.ok .ic { background: var(--mint); color: var(--nav); }
.toast.err .ic { background: #f07a72; color: #fff; }
.toast.info .ic { background: #8fb0ff; color: #13261f; }
.toast.out { animation: toast-out 0.22s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
.scrim { position: fixed; inset: 0; background: rgba(12, 31, 24, 0.36); z-index: 120; animation: fade-in 0.2s; }
@keyframes fade-in { from { opacity: 0; } }
.dialog { position: fixed; z-index: 130; left: 50%; top: 18vh; transform: translateX(-50%); width: min(480px, calc(100vw - 32px)); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-pop); padding: 20px 22px 18px; animation: dialog-in 0.24s var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translate(-50%, 8px) scale(0.98); } }
.dialog h3 { font-size: 16px; margin-bottom: 8px; }
.dialog .body { color: var(--ink-2); font-size: 13px; line-height: 1.7; }
.dialog .body ul { margin: 8px 0 0; padding-left: 18px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.drawer { position: fixed; z-index: 125; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); background: var(--canvas); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; animation: drawer-in 0.28s var(--ease); }
@keyframes drawer-in { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 22px; background: var(--surface); border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 16px; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 22px 40px; display: flex; flex-direction: column; gap: 16px; }
.popover { position: fixed; z-index: 140; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 12px; min-width: 220px; max-width: 460px; animation: fade-in 0.15s; }
.tip { position: fixed; z-index: 150; pointer-events: none; background: #13261f; color: #e8f2ed; padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.55; max-width: 360px; box-shadow: var(--shadow-pop); white-space: pre-line; }

/* ---------------------------------------------------------------- charts */
.chart { position: relative; width: 100%; user-select: none; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: #e7eeea; stroke-width: 1; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--font-num); }
.chart .axis .unit { fill: var(--ink-4); font-family: var(--font-ui); font-size: 10.5px; }
.chart .series path.line { fill: none; stroke-linejoin: round; stroke-linecap: round; transition: opacity 0.2s; }
.chart .series.dim { opacity: 0.12; }
.chart .series path.area { opacity: 0.08; }
.chart .series circle { transition: r 0.12s; }
.chart .gap-band { fill: url(#hatch); opacity: 0.9; }
.chart .cross line { stroke: #8fa39a; stroke-dasharray: 3 3; stroke-width: 1; }
.chart .hover-dot { stroke: #fff; stroke-width: 2; }
.chart.draw .series path.line { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 0.9s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; background: rgba(19, 38, 31, 0.96); color: #eaf3ee; border-radius: 10px; padding: 9px 11px; font-size: 12px; line-height: 1.6; min-width: 170px; box-shadow: var(--shadow-pop); transition: left 0.06s linear, top 0.06s linear; }
.chart-tip .tt { font-weight: 700; margin-bottom: 3px; color: #fff; }
.chart-tip .row { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.chart-tip .row i { width: 10px; height: 3px; border-radius: 2px; flex: none; }
.chart-tip .row .val { margin-left: auto; font-family: var(--font-num); font-variant-numeric: tabular-nums; padding-left: 14px; }
.chart-tip .note { color: #a9c3b7; font-size: 11px; margin-top: 3px; white-space: normal; max-width: 280px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); }
.chart-legend button { display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; cursor: pointer; padding: 3px 6px; border-radius: 6px; color: inherit; font-size: 12px; }
.chart-legend button:hover { background: var(--surface-3); }
.chart-legend button.off { opacity: 0.4; }
.chart-legend svg { width: 22px; height: 10px; }
.chart-empty { display: grid; place-content: center; text-align: center; color: var(--ink-3); background: var(--hatch), var(--surface-2); border-radius: 10px; font-size: 12.5px; }

/* ---------------------------------------------------------------- account picker */
.picker { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.picker-filters { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.picker-owners { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.picker-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.picker-list { border: 1px solid var(--line); border-radius: 12px; max-height: 360px; overflow: auto; background: var(--surface-2); }
.bm-group { border-bottom: 1px solid var(--line-2); }
.bm-group:last-child { border-bottom: 0; }
.bm-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #f1f6f3; cursor: pointer; }
.bm-head .name { font-weight: 700; font-size: 12.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-head .cnt { font-family: var(--font-num); font-size: 11.5px; color: var(--ink-3); }
.bm-head .chev { width: 14px; height: 14px; stroke: var(--ink-3); fill: none; stroke-width: 2; transition: transform 0.2s; }
.bm-group.collapsed .bm-head .chev { transform: rotate(-90deg); }
.bm-group.collapsed .bm-items { display: none; }
.acct-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 7px 12px 7px 14px; background: var(--surface); border-top: 1px solid var(--line-2); cursor: pointer; }
.acct-item:hover { background: #f6faf8; }
.acct-item.on { background: #eef6f1; }
.acct-item .meta { display: flex; gap: 5px; align-items: center; }

/* ---------------------------------------------------------------- misc layout helpers */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 12.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.note { font-size: 12px; color: var(--ink-3); line-height: 1.65; }
.stat-inline { display: inline-flex; align-items: baseline; gap: 6px; }
.stat-inline b { font-family: var(--font-num); font-size: 18px; font-weight: 600; }
.counter-strip { display: flex; gap: 22px; flex-wrap: wrap; }
.counter-strip .c { display: flex; flex-direction: column; }
.counter-strip .c b { font-family: var(--font-num); font-size: 22px; font-weight: 600; line-height: 1.2; }
.counter-strip .c span { font-size: 11.5px; color: var(--ink-3); }

/* login */
.login-body { display: grid; place-content: center; min-height: 100vh; background: radial-gradient(circle at 30% 20%, #1c4536, var(--nav)); }
.login-card { width: 340px; background: var(--surface); border-radius: 18px; padding: 30px 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-pop); }
.login-card h1 { font-size: 19px; margin-top: 6px; }
.login-card p { color: var(--ink-3); }
.login-card input { height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.login-card .btn { height: 40px; }
.login-error { color: var(--fail); font-size: 12px; min-height: 16px; }

@media (max-width: 1100px) {
  .app { --nav-w: 68px; }
  .brand-text, .nav-label, .nav .count, .foot-text, .collapse-label { display: none; }
  .nav a { justify-content: center; padding: 10px; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
