/* Pool console — dark operations UI.
   Series colors follow the validated dark categorical order (blue, orange,
   aqua); status colors are reserved for state and always ship with a label. */
:root {
  color-scheme: dark;
  --bg: #0a0c0f;
  --bg-grid: rgba(255, 255, 255, .025);
  --surface: #111418;
  --surface-2: #161a1f;
  --surface-3: #1c2127;
  --line: #232931;
  --line-strong: #2e3640;
  --text: #e9edf1;
  --text-2: #a7b0ba;
  --muted: #6c7682;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --good: #0ca30c;
  --good-text: #3fcf5a;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-text: #ff7a7a;
  --accent: #3987e5;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    linear-gradient(var(--bg-grid) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px) 0 0 / 32px 32px,
    radial-gradient(1200px 600px at 70% -10%, rgba(57, 135, 229, .08), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 13px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--series-1); text-decoration: none; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.dim { color: var(--text-2); }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 20px 12px 16px; border-right: 1px solid var(--line); background: rgba(10, 12, 15, .82);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: conic-gradient(from 210deg, #3987e5, #199e70, #3987e5); color: #fff; font: 700 12px var(--mono);
  box-shadow: 0 0 24px rgba(57, 135, 229, .35);
}
.brand b { display: block; font-size: 14px; }
.brand small { color: var(--muted); font-size: 11px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-2);
  border: 1px solid transparent; background: none; text-align: left; width: 100%;
}
.nav-link svg { width: 16px; height: 16px; flex: none; opacity: .8; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.nav-link.active svg { color: var(--series-1); opacity: 1; }
.nav-link kbd { margin-left: auto; }
.nav-badge { margin-left: auto; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--critical); color: #fff; font: 600 11px/18px var(--mono); text-align: center; }
.rail-foot { margin-top: auto; display: grid; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.live { display: flex; align-items: center; gap: 8px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); position: relative; flex: none; }
.pulse.on { background: var(--good); }
.pulse.on::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid var(--good); animation: ping 2s infinite; }
.pulse.warn { background: var(--warning); }
@keyframes ping { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.8); opacity: 0; } }
kbd { font: 10px/16px var(--mono); padding: 0 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); background: var(--surface); }

.main { min-width: 0; padding: 22px 28px 64px; max-width: 1560px; width: 100%; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.topbar .crumb { color: var(--muted); font: 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.topbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font-size: 12px; white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.good { color: var(--good-text); border-color: rgba(12, 163, 12, .45); }
.chip.warning { color: var(--warning); border-color: rgba(250, 178, 25, .45); }
.chip.critical { color: var(--critical-text); border-color: rgba(208, 59, 59, .55); }
.chip.info { color: #8cbcf5; border-color: rgba(57, 135, 229, .45); }
.btn {
  height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--text); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: #46515e; background: var(--surface-3); }
.btn.primary { background: #1d4f8c; border-color: #2f6fbf; }
.btn.primary:hover { background: #245fa6; }
.btn.danger { background: #3a1c1c; border-color: #7a3434; color: #ffc9c9; }
.btn.ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 14px; height: 14px; }

/* ---------- panels ---------- */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.row-2 { grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr); align-items: start; }
.row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 14px; }
.grid > *, .stack > * { min-width: 0; }
.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, .018), transparent 120px), var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; position: relative;
}
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; }
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-head .sub { color: var(--muted); font-size: 12px; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 12px 16px 16px; }
.eyebrow { font: 600 10px var(--mono); letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }

.kpi { padding: 14px 16px 12px; min-height: 128px; display: flex; flex-direction: column; overflow: hidden; }
.kpi .label { color: var(--text-2); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font: 600 28px/1.15 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.03em; margin-top: 10px; white-space: nowrap; }
.kpi .value small { font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.kpi .foot { margin-top: auto; padding-top: 8px; color: var(--muted); font-size: 11.5px; display: flex; gap: 8px; align-items: center; min-height: 22px; }
.kpi .spark { margin-top: 8px; height: 28px; }
.kpi.alert { border-color: rgba(208, 59, 59, .6); box-shadow: inset 0 0 0 1px rgba(208, 59, 59, .25), 0 0 32px rgba(208, 59, 59, .08); }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; }
.status svg { width: 12px; height: 12px; }
.status.good { color: var(--good-text); }
.status.warning { color: var(--warning); }
.status.serious { color: var(--serious); }
.status.critical { color: var(--critical-text); }
.meter { position: relative; height: 6px; border-radius: 3px; background: var(--surface-3); margin-top: 10px; overflow: visible; }
.meter > i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--series-1); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.meter > b { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text-2); border-radius: 1px; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font: 10.5px var(--mono); }
.chart .now-line { stroke: var(--text-2); stroke-dasharray: 2 3; }
.chart .zone { fill: rgba(208, 59, 59, .07); }
.chart .zone-label { fill: var(--critical-text); font: 10px var(--sans); }
.chart .crosshair { stroke: var(--text-2); stroke-width: 1; }
.chart .hit { fill: transparent; touch-action: pan-y; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 14px; height: 2px; border-radius: 1px; vertical-align: middle; margin-right: 6px; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important; height: 2px; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 20; min-width: 150px; padding: 8px 10px; border-radius: 8px;
  background: rgba(22, 26, 31, .96); border: 1px solid var(--line-strong); box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
  font-size: 12px; transform: translate(-50%, -100%); white-space: nowrap;
}
.tooltip .t { color: var(--muted); font: 11px var(--mono); margin-bottom: 4px; }
.tooltip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .r span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip .r b { font: 600 12px var(--mono); color: var(--text); }
.tooltip .sw { width: 8px; height: 8px; border-radius: 2px; }
.empty { color: var(--muted); font-size: 12px; padding: 28px 0; text-align: center; }

/* ---------- account table ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th { text-align: left; font: 600 10.5px var(--mono); letter-spacing: .08em; color: var(--muted); text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 8px 10px; border-bottom: 1px solid rgba(35, 41, 49, .6); white-space: nowrap; vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.expiring td { background: rgba(208, 59, 59, .06); }
table.data tr.fresh td:first-child { box-shadow: inset 2px 0 0 var(--series-3); }
table.data .r { text-align: right; }
.bar { position: relative; height: 8px; border-radius: 4px; background: var(--surface-3); min-width: 90px; overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.cell-bar { display: grid; grid-template-columns: minmax(90px, 1fr) auto; align-items: center; gap: 8px; }
.life { position: relative; height: 14px; min-width: 180px; }
.life .track { position: absolute; inset: 6px 0; border-radius: 1px; background: var(--surface-3); }
.life .lead { position: absolute; top: 2px; bottom: 2px; left: 0; background: rgba(208, 59, 59, .1); border-right: 1px dashed rgba(208, 59, 59, .5); }
.life .seg { position: absolute; top: 3px; bottom: 3px; left: 0; border-radius: 4px; transition: width .6s; }
.prio { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 5px; font: 600 11px/18px var(--mono); text-align: center; background: var(--surface-3); color: var(--text-2); }
.prio.p1 { background: rgba(57, 135, 229, .18); color: #8cbcf5; }

.acc-cards { display: none; }
.acc-card { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); display: grid; gap: 8px; }
.acc-card.expiring { border-color: rgba(208, 59, 59, .6); background: rgba(208, 59, 59, .06); }
.acc-top { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.acc-left { margin-left: auto; font-size: 16px; font-weight: 600; }
.acc-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.acc-meta b { color: var(--text); font-weight: 500; }
.acc-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acc-bars .bar { min-width: 0; height: 6px; }

/* ---------- replenish panel ---------- */
.equation { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 12px; }
.equation .k { color: var(--muted); }
.equation .v { font-family: var(--mono); }
.equation .big { font: 600 15px var(--mono); }
.pipeline { display: grid; gap: 6px; margin-top: 12px; }
.order { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.order .id { font: 12px var(--mono); }
.order .meta { font-size: 11px; color: var(--muted); }
.steps { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
.steps i { height: 4px; border-radius: 2px; background: var(--surface-3); }
.steps i.done { background: var(--series-3); }
.steps i.cur { background: var(--series-1); animation: glow 1.4s ease-in-out infinite; }
.steps i.fail { background: var(--critical); }
@keyframes glow { 50% { opacity: .45; } }
.feed { display: grid; gap: 0; margin-top: 12px; max-height: 248px; overflow: auto; }
.feed-item { display: grid; grid-template-columns: 52px 18px 1fr; gap: 6px; padding: 6px 0; border-top: 1px solid rgba(35, 41, 49, .6); font-size: 12px; }
.feed-item:first-child { border-top: 0; }
.feed-item time { color: var(--muted); font: 11px var(--mono); }
.feed-item svg { width: 14px; height: 14px; margin-top: 2px; }
.feed-item .msg { color: var(--text-2); white-space: normal; word-break: break-all; }

/* ---------- segmented / forms ---------- */
.seg { display: inline-flex; padding: 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); }
.seg button { border: 0; background: none; padding: 3px 10px; border-radius: 6px; color: var(--text-2); font-size: 12px; }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field > span { font-size: 12px; color: var(--text-2); }
.field > small { font-size: 11px; color: var(--muted); }
.input, select.input {
  height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: #0d1013; width: 100%; outline: none;
}
.input:focus { border-color: var(--series-1); box-shadow: 0 0 0 3px rgba(57, 135, 229, .18); }
.switch { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); cursor: pointer; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--line-strong); position: relative; flex: none; margin: 1px 0 0; cursor: pointer; transition: .2s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: .2s; }
.switch input:checked { background: #1d4f8c; border-color: #2f6fbf; }
.switch input:checked::after { left: 16px; background: #fff; }
.switch b { display: block; font-size: 13px; font-weight: 600; }
.switch small { color: var(--muted); font-size: 11.5px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.form-note { font-size: 12px; color: var(--text-2); }
.form-note.ok { color: var(--good-text); }
.form-note.err { color: var(--critical-text); }

/* ---------- alerts ---------- */
.alert-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); align-items: start; }
.alert-row:first-child { border-top: 0; }
.alert-row h3 { margin: 0 0 4px; font-size: 13px; }
.alert-row pre { margin: 0; font: 12px/1.55 var(--sans); color: var(--text-2); white-space: pre-wrap; }
.alert-row .when { font: 11px var(--mono); color: var(--muted); margin-top: 6px; }

/* ---------- login / palette / toast ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); padding: 28px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.login-card h1 { margin: 18px 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card .btn { width: 100%; justify-content: center; margin-top: 14px; height: 36px; }
.palette-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); backdrop-filter: blur(3px); z-index: 50; display: grid; place-items: start center; padding-top: 14vh; }
.palette { width: min(560px, calc(100vw - 32px)); border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); overflow: hidden; }
.palette input { width: 100%; height: 48px; padding: 0 16px; border: 0; border-bottom: 1px solid var(--line); background: none; outline: none; font-size: 15px; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 340px; overflow: auto; }
.palette li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-2); cursor: pointer; }
.palette li.on { background: var(--surface-3); color: var(--text); }
.palette li kbd { margin-left: auto; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface-2); box-shadow: 0 12px 32px rgba(0, 0, 0, .5); font-size: 12.5px; max-width: 420px; animation: rise .25s ease-out; }
.toast.err { border-color: rgba(208, 59, 59, .6); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .row-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav-link span { white-space: nowrap; }
  .topbar { flex-wrap: wrap; }
  .topbar .spacer { display: none; }
  .rail { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px 0 0; }
  .brand div { display: none; }
  .nav-link { width: auto; }
  .nav-link kbd, .rail-foot { display: none; }
  .main { padding: 16px 16px 48px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-3, .form { grid-template-columns: minmax(0, 1fr); }
  .kpi .value { font-size: 22px; }
  .kpi { min-height: 112px; padding: 12px; }
  #accounts table.data, #c-table table.data th:nth-child(4), #c-table table.data td:nth-child(4) { display: none; }
  .acc-cards { display: grid; gap: 8px; }
  .panel-head { flex-wrap: wrap; }
  .panel-body { padding: 10px 12px 14px; }
  .equation { grid-template-columns: 1fr; gap: 2px; }
  .equation .k { margin-top: 6px; }
  .alert-row { grid-template-columns: 1fr; gap: 6px; }
  .tooltip { min-width: 0; max-width: calc(100vw - 32px); white-space: normal; }
}
@media (prefers-reduced-motion: reduce) { *, *::after { animation: none !important; transition: none !important; } }
