/* Tunnel LB panel. Colors are tokens; dark values are their own steps. */
:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --surface-3: #e9e8e3;
  --border: rgba(11, 11, 11, 0.09);
  --border-strong: rgba(11, 11, 11, 0.17);
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e7e6e0;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --good: #0ca30c;
  --good-text: #006300;
  --warn: #fab219;
  --serious: #ec835a;
  --crit: #d03b3b;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 10px rgba(0, 0, 0, 0.035);
  --shadow-pop: 0 8px 28px rgba(0, 0, 0, 0.14), 0 1px 3px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --topbar-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --surface-3: #2c2c2a;
    --border: rgba(255, 255, 255, 0.09); --border-strong: rgba(255, 255, 255, 0.17);
    --text: #f0efec; --text-2: #c3c2b7; --muted: #898781; --grid: #2a2a28; --axis: #383835;
    --accent: #3987e5; --accent-wash: rgba(57, 135, 229, 0.16); --good-text: #2fbf2f;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --surface-3: #2c2c2a;
  --border: rgba(255, 255, 255, 0.09); --border-strong: rgba(255, 255, 255, 0.17);
  --text: #f0efec; --text-2: #c3c2b7; --muted: #898781; --grid: #2a2a28; --axis: #383835;
  --accent: #3987e5; --accent-wash: rgba(57, 135, 229, 0.16); --good-text: #2fbf2f;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--page); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.005em; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
svg { flex: none; }
::selection { background: var(--accent-wash); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 14px 12px;
  background: var(--surface); border-right: 1px solid var(--border); z-index: 45; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; padding: 4px 8px 14px; }
.brand-lg { font-size: 20px; padding: 0 0 4px; }
.brand-mark { width: 24px; height: 24px; border-radius: 7px; background-color: var(--accent);
  background-image: linear-gradient(#fff, #fff), linear-gradient(#fff, #fff), linear-gradient(#fff, #fff);
  background-size: 3px 12px, 3px 15px, 3px 9px; background-position: 6px 7px, 11px 4px, 16px 10px; background-repeat: no-repeat; flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a svg { width: 18px; height: 18px; fill: currentColor; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-wash); color: var(--accent); }
.nav-badge { margin-left: auto; background: var(--crit); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 700; line-height: 18px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 10px; }
.sidebar-foot .btn { justify-content: flex-start; }
.sidebar-meta { font-size: 11.5px; color: var(--muted); padding: 4px 10px 0; line-height: 1.5; }
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 44; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; min-height: var(--topbar-h); padding: 10px 24px;
  background: color-mix(in srgb, var(--page) 86%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 18px; white-space: nowrap; }
.topbar-pills { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.menu-btn { display: none; }
.view { padding: 20px 24px 56px; outline: none; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
#banner:empty { display: none; }
#banner { padding: 14px 24px 0; display: flex; flex-direction: column; gap: 8px; }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; width: 264px; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-pop); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 8px 14px; gap: 8px; }
  .topbar h1 { font-size: 17px; }
  .view { padding: 14px 12px 48px; gap: 12px; }
  #banner { padding: 12px 12px 0; }
}
@media (max-width: 600px) {
  .topbar-pills .pill:not(.pill-crit):not(.pill-warn) { display: none; }
  .live span:last-child { display: none; }
}

/* ---------- primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; position: relative; }
.card-h { display: flex; align-items: center; gap: 8px 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; min-height: 50px; }
.card-h .titles { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.card-h .sub { color: var(--muted); font-size: 12px; line-height: 1.35; }
.card-h .right { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card-b { padding: 14px 16px; }
.grid { display: grid; gap: 16px; min-width: 0; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.span-all { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
@media (max-width: 960px) { .grid { gap: 12px; } .card-h { padding: 11px 13px; } .card-b { padding: 12px 13px; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s; -webkit-tap-highlight-color: transparent; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .chip:focus-visible, .cl-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; fill: currentColor; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); }
.btn-danger { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--crit) 10%, transparent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn-icon svg { width: 18px; height: 18px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { border: 0; background: transparent; color: var(--text-2); padding: 0 11px; height: 30px; font: inherit; font-size: 13px; cursor: pointer;
  border-right: 1px solid var(--border); flex: none; font-variant-numeric: tabular-nums; }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); color: var(--text); }
.seg button.on { background: var(--accent-wash); color: var(--accent); font-weight: 600; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 10px; min-height: 34px; max-width: 100%; }
@media (max-width: 960px) { input, select, textarea { font-size: 16px; } }
textarea { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; width: 100%; resize: vertical; }
input[type="checkbox"] { min-height: auto; width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); font-weight: 500; }
label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }

.pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 12px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.pill svg { width: 13px; height: 13px; fill: currentColor; }
.pill-accent { background: var(--accent-wash); color: var(--accent); border-color: transparent; }
.pill-warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--text); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.pill-crit { background: color-mix(in srgb, var(--crit) 14%, transparent); color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, transparent); }
.pill-good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good-text); border-color: color-mix(in srgb, var(--good) 35%, transparent); }

/* status badge: shape + label, never color alone */
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.status i { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.status.up i { background: var(--good); }
.status.degraded i { background: var(--warn); border-radius: 2px; transform: rotate(45deg); width: 8px; height: 8px; }
.status.down i { background: var(--crit); border-radius: 1px; }
.status.up { color: var(--good-text); }
.status.degraded { color: var(--text); }
.status.down { color: var(--crit); }

.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.on .dot { background: var(--good); animation: pulse 2s infinite; }
.live.off .dot { background: var(--crit); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 10px; border: 1px solid; font-weight: 500; line-height: 1.45; }
.banner > svg { width: 18px; height: 18px; fill: currentColor; margin-top: 1px; }
.banner-crit { background: color-mix(in srgb, var(--crit) 9%, var(--surface)); border-color: color-mix(in srgb, var(--crit) 32%, transparent); }
.banner-crit > svg { color: var(--crit); }
.banner-warn { background: color-mix(in srgb, var(--warn) 11%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 42%, transparent); }
.banner-warn > svg { color: color-mix(in srgb, var(--warn) 70%, var(--text)); }
.banner-info { background: var(--accent-wash); border-color: transparent; }
.banner b { font-weight: 700; }
.banner .muted { font-weight: 400; }

/* ---------- KPI tiles ---------- */
.kpi { padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.kpi .k { font-size: 12px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 26px; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi .v small { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 3px; letter-spacing: 0; }
.kpi .s { font-size: 12px; color: var(--muted); min-height: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sp { height: 34px; margin: 6px -2px 0; }
.spark { width: 100%; height: 100%; display: block; overflow: visible; }
.kpi-status { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- split bar ---------- */
.split { display: flex; height: 30px; gap: 2px; border-radius: 7px; overflow: hidden; background: var(--surface-2); }
.split > div { min-width: 3px; transition: flex-grow .6s ease; position: relative; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 650; overflow: hidden; white-space: nowrap; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; font-size: 13px; }
.legend > span { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.legend b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- path cards ---------- */
.pcard { display: flex; flex-direction: column; }
.pcard .swatch, .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; display: inline-block; }
.pcard .name { font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .big { font-size: 28px; font-weight: 650; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.pcard .sp { height: 44px; }
.kv { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 5px 14px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); white-space: nowrap; }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); overflow-wrap: anywhere; }
.meter { position: relative; height: 8px; border-radius: 4px; background: var(--surface-3); }
.meter > b { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--accent); transition: width .6s ease; max-width: 100%; }
.meter > u { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-2); border-radius: 1px; }
.meter-label { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.mini-legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); }
.mini-legend i { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 4px; border-radius: 1px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
thead th { font-size: 12px; color: var(--text-2); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sorted::after { content: " ↓"; }
th.sorted.asc::after { content: " ↑"; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
tr.expand td { white-space: normal; background: var(--surface-2); }
td.wrap { white-space: normal; min-width: 260px; }
td .sp { width: 96px; height: 24px; }
.clickable { cursor: pointer; }

/* Responsive table: rows become cards on phones. */
@media (max-width: 700px) {
  table.rtable thead { display: none; }
  table.rtable, table.rtable tbody, table.rtable tr, table.rtable td { display: block; width: 100%; }
  table.rtable tr { padding: 10px 13px; border-bottom: 1px solid var(--border); }
  table.rtable tr:last-child { border-bottom: 0; }
  table.rtable td { border: 0; padding: 3px 0; white-space: normal; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.rtable td::before { content: attr(data-label); color: var(--muted); font-weight: 500; text-align: left; flex: none; }
  table.rtable td.r { text-align: right; }
  table.rtable td.wrap { min-width: 0; display: block; text-align: left; }
  table.rtable td.wrap::before { display: block; margin-bottom: 2px; }
  table.rtable td.nolabel::before { display: none; }
  table.rtable td.full { display: block; text-align: left; }
  table.rtable tr.expand td { display: block; }
}

/* ---------- charts ---------- */
.chart-card .card-b { padding: 6px 10px 6px 8px; }
.chart { width: 100%; min-height: 120px; position: relative; }
.chart-ph { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 6px 0; }
.chart-empty { color: var(--muted); font-size: 13px; }
.chart-empty svg { width: 28px; height: 28px; fill: currentColor; opacity: .45; }
.cl { position: relative; }
.cl-legend { display: flex; flex-wrap: wrap; gap: 2px 4px; padding: 4px 4px 6px 6px; min-height: 30px; }
.cl-item { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 12px;
  padding: 3px 8px; border-radius: 6px; cursor: pointer; max-width: 100%; -webkit-tap-highlight-color: transparent; }
.cl-item:hover { background: var(--surface-2); }
.cl-item i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.cl-item .cl-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-item .cl-val { color: var(--text); font-weight: 600; white-space: nowrap; }
.cl-item.off { opacity: .45; }
.cl-item.off i { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--muted); }
.cl-item.off .cl-lbl { text-decoration: line-through; }
.cl-plot { position: relative; }
.cl-plot .u-over { touch-action: pan-y; }
.cl-tip { position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 9px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow-pop); min-width: 150px; max-width: min(320px, calc(100% - 8px)); will-change: transform; }
.cl-tip-t { font-weight: 600; color: var(--text-2); margin-bottom: 5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cl-tip-r { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 2px 8px; line-height: 1.6; }
.cl-tip-r i { width: 9px; height: 9px; border-radius: 2px; }
.cl-tip-r span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.cl-tip-r b { font-weight: 650; text-align: right; white-space: nowrap; }
.cl-tip-r .cl-rng { grid-column: 2 / 4; font-size: 11px; color: var(--muted); margin-top: -3px; text-align: right; }
.cl-tip-sum { border-top: 1px solid var(--border); margin-top: 3px; padding-top: 3px; }
.cl-tip-ev { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 5px; color: var(--text-2); display: flex; flex-direction: column; gap: 3px; }
.cl-tip-ev div { display: flex; gap: 6px; align-items: baseline; white-space: normal; line-height: 1.35; }
.cl-tip-ev i { width: 7px; height: 7px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.timeline .cl-tip-r { grid-template-columns: minmax(0, 1fr) auto; }
.uplot { font-family: var(--font); }
.u-select { background: var(--accent-wash); border-left: 1px solid var(--accent); border-right: 1px solid var(--accent); }
.u-cursor-x { border-right: 1px dashed var(--muted) !important; }
.u-cursor-y { border-bottom: 1px dashed color-mix(in srgb, var(--muted) 60%, transparent) !important; }
.timeline { position: relative; padding: 6px 4px 0; }
.timeline canvas { display: block; width: 100%; }
.tl-legend { display: flex; gap: 6px 14px; font-size: 12px; color: var(--text-2); padding: 8px 2px 4px; flex-wrap: wrap; }
.tl-nodata { display: inline-flex; align-items: center; gap: 6px; }
.tl-nodata i { width: 10px; height: 10px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 2px; }

/* ---------- toolbars, chips, tabs, menus ---------- */
.toolbar { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 20; }
.toolbar .card-b { display: flex; flex-direction: column; gap: 10px; }
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
.statusline { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
@media (max-width: 960px) { .toolbar { position: static; } }
.chips { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 14px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; -webkit-tap-highlight-color: transparent; white-space: nowrap; }
.chip:hover { background: var(--surface-2); }
.chip i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chip.off { color: var(--muted); }
.chip.off i { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--muted); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin-bottom: -4px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 500; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; flex: none; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.pop { position: fixed; z-index: 80; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-pop);
  padding: 6px; min-width: 190px; max-width: calc(100vw - 16px); }
.pop .mi { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 13px;
  padding: 8px 10px; border-radius: 7px; cursor: pointer; text-align: left; white-space: nowrap; }
.pop .mi:hover { background: var(--surface-2); }
.pop .mi svg { width: 16px; height: 16px; fill: var(--text-2); }
.pop .mi.danger { color: var(--crit); }
.pop .mi.danger svg { fill: var(--crit); }
.pop hr { border: 0; border-top: 1px solid var(--border); margin: 5px 2px; }
.pop .pop-b { padding: 8px; display: flex; flex-direction: column; gap: 10px; }
.pop label.inline { padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.pop label.inline:hover { background: var(--surface-2); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 16px 18px; }
.field .help { font-weight: 400; color: var(--muted); font-size: 12px; line-height: 1.4; }
.field .label-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.field .unit { color: var(--muted); font-size: 12px; font-weight: 400; }
.field.check { flex-direction: row; align-items: flex-start; gap: 10px; cursor: pointer; }
.field.check input { margin-top: 2px; }
.field.check > div { display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.field.invalid input, .field.invalid select { border-color: var(--crit); }
.field .err { color: var(--crit); font-size: 12px; font-weight: 500; }
.field .err:empty { display: none; }
.field .multi { display: flex; gap: 6px 14px; flex-wrap: wrap; font-weight: 400; min-height: 34px; align-items: center; }
.field .multi label { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.group-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 20px 0 2px; grid-column: 1 / -1;
  padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.group-title:first-child { margin-top: 0; }
.list-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface-2); position: relative; }
.list-item + .list-item { margin-top: 12px; }
.list-item .li-h { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-weight: 600; flex-wrap: wrap; }
.form-error { color: var(--crit); font-size: 13px; min-height: 1em; margin: 0; }
.dirty-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); display: inline-block; }
.errors { margin: 0; padding: 10px 14px 10px 30px; border-radius: 8px; background: color-mix(in srgb, var(--crit) 10%, var(--surface)); color: var(--text); }
.diff { font-family: var(--mono); font-size: 12px; max-height: 52vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.diff div { padding: 0 10px; white-space: pre; }
.diff .add { background: color-mix(in srgb, var(--good) 16%, transparent); }
.diff .del { background: color-mix(in srgb, var(--crit) 14%, transparent); }
.diff .ctx { color: var(--muted); }
.actionbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (max-width: 700px) {
  .actionbar-sticky { position: sticky; bottom: 0; z-index: 15; background: var(--surface); border-top: 1px solid var(--border); margin: 0 -12px -48px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 14px rgba(0,0,0,0.06); }
  .actionbar-sticky .btn { flex: 1; }
}

/* ---------- login / modal / toast / drawer ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; background: var(--surface); padding: 28px;
  border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow-pop); }
.login-card p { margin: 0; }
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .42); display: grid; place-items: center; padding: 16px; }
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; }
.modal.wide { width: min(980px, 100%); }
.modal-h { padding: 15px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-b { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.modal-f { padding: 12px 20px 16px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--border); }
@media (max-width: 600px) {
  .modal-back { place-items: end stretch; padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-f { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .modal-f .btn { flex: 1; }
}
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: var(--text); color: var(--page); padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow-pop); font-weight: 500; max-width: min(420px, calc(100vw - 32px));
  animation: toast-in .18s ease; }
.toast.err { background: var(--crit); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
@media (max-width: 600px) { .toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); align-items: stretch; } .toast { max-width: none; } }
.drawer-back { position: fixed; inset: 0; z-index: 49; background: rgba(0, 0, 0, .3); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(820px, 100%); background: var(--page); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-pop); overflow-y: auto; display: flex; flex-direction: column; animation: drawer-in .2s ease; }
@keyframes drawer-in { from { transform: translateX(30px); opacity: 0; } }
.drawer-h { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.drawer-h h2 { font-size: 17px; }
.drawer-b { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 600px) { .drawer-b { padding: 12px; gap: 12px; } }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite linear; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.stat-grid > div { background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-grid .k { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.stat-grid .v { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* config action bar: sticky on top (desktop), fixed at the bottom (phones) */
.cfg-bar { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 20; }
.cfg-file { min-width: 0; }
.cfg-file code { overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .cfg-bar { position: fixed; left: 0; right: 0; bottom: 0; top: auto; border-radius: 14px 14px 0 0; box-shadow: var(--shadow-pop); }
  .cfg-bar .card-b { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .cfg-bar .cfg-file, .cfg-bar .spacer { display: none; }
  .cfg-bar .btn { flex: 1; }
  .cfg-bar #cfg-dirty { flex-basis: 100%; justify-content: center; }
  .view.has-bar { padding-bottom: 150px; }
}

/* ---------- polish: KPI grid, toolbar density, statusline ---------- */
.grid-kpi { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1360px) { .grid-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 11px 12px 10px; }
  .kpi .v { font-size: 21px; }
  .kpi .s { white-space: normal; font-size: 11.5px; line-height: 1.35; }
  .kpi .sp { height: 28px; }
}
.statusline > span:empty { display: none; }
#an-res::before, #an-upd::before { content: "·"; margin-right: 6px; color: var(--muted); }
@media (max-width: 600px) {
  .toolbar .seg { display: flex; width: 100%; }
  .toolbar .seg button { flex: 1 1 0; padding: 0 2px; min-width: 0; }
  .toolbar .card-b { gap: 8px; }
  .statusline { font-size: 11.5px; gap: 2px 10px; }
  #an-upd { display: none; }
}
.drawer .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 600px) { .drawer .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Tabs wrap on wide screens; on phones they scroll with a fade hinting at more. */
@media (min-width: 961px) { .tabs { flex-wrap: wrap; overflow: visible; } }
@media (max-width: 960px) {
  .tabs { padding-right: 32px; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); }
}
@media (max-width: 600px) { #an-res::before { content: none; } }

/* ---------- resources tab ---------- */
.res-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.res-grid > div > .muted { line-height: 1.35; }
.res-tables { padding: 0 16px 16px; gap: 16px; }
.res-h { font-size: 12.5px; font-weight: 600; color: var(--text-2); margin: 2px 0 8px; }
.res-h .muted { font-weight: 400; }
.res-tables .table-wrap { border: 1px solid var(--border); border-radius: var(--radius); }
@media (max-width: 960px) { .res-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .res-tables { padding: 0 13px 13px; } }
/* Chart headers: the menu stays on the title row however long the subtitle. */
.chart-card .card-h { flex-wrap: nowrap; align-items: flex-start; }
.chart-card .card-h .titles { flex: 1 1 0; }
.chart-card .card-h .right { flex: none; flex-wrap: nowrap; }
/* Compact tables that stay tables on phones. */
table.ctable th, table.ctable td { padding: 8px 12px; }
@media (max-width: 700px) {
  table.ctable th, table.ctable td { padding: 7px 8px; font-size: 12.5px; }
  table.ctable .hide-m { display: none; }
  table.ctable .mono { font-size: 11.5px; }
}

/* ---------- setup wizard ---------- */
.wiz-head .card-b { display: flex; flex-direction: column; gap: 14px; }
.wiz-title h2 { margin: 0 0 4px; font-size: 19px; }
.wiz-title p { margin: 0; }
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; counter-reset: s; }
.stepper li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); color: var(--muted); font-size: 13px; font-weight: 600; min-width: 0; }
.stepper li .n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); font-size: 12px; }
.stepper li .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper li.on { border-color: var(--accent); color: var(--text); background: var(--accent-wash); }
.stepper li.on .n { background: var(--accent); color: #fff; }
.stepper li.done { color: var(--text-2); cursor: pointer; }
.stepper li.done .n { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good-text); }
.wiz-body { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.wiz-body .field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
.wiz-note { margin-top: 16px; }
.mode-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.mode-card { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 8px; padding: 16px; border: 1.5px solid var(--border-strong);
  border-radius: 12px; background: var(--surface); color: var(--text); transition: border-color .15s, background .15s; }
.mode-card:hover { border-color: var(--accent); }
.mode-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode-card.on { border-color: var(--accent); background: var(--accent-wash); }
.mode-card .mc-h { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.mode-card .radio { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; }
.mode-card.on .radio { border-color: var(--accent); background: radial-gradient(var(--accent) 0 4px, transparent 5px); }
.mode-card .mc-t { color: var(--text-2); font-size: 13.5px; line-height: 1.5; }
.mode-card .mc-flow { font-family: var(--mono); font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 7px 9px; line-height: 1.5; }
.tuns { display: flex; flex-direction: column; gap: 12px; }
.tun { padding: 12px 14px; box-shadow: none; }
.tun-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tun-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px 14px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; }
.copy-kv, .review-kv { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.copy-kv > div, .review-kv > div { display: grid; grid-template-columns: minmax(130px, 34%) minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.review-kv > div { grid-template-columns: minmax(130px, 34%) minmax(0, 1fr); }
.copy-kv > div:last-child, .review-kv > div:last-child { border-bottom: 0; }
.copy-kv span, .review-kv span { color: var(--muted); }
.copy-kv b, .review-kv b { overflow-wrap: anywhere; }
.go-live { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; align-items: flex-start !important; }
.go-live input { margin-top: 3px; }
.wiz-hint { font-size: 12.5px; }
.nav a.setup-link { color: var(--accent); font-weight: 600; }
@media (max-width: 700px) {
  .mode-cards { grid-template-columns: minmax(0, 1fr); }
  .stepper { gap: 4px; }
  .stepper li { flex-direction: column; gap: 4px; padding: 6px 2px; font-size: 11px; text-align: center; }
  .copy-kv > div { grid-template-columns: minmax(0, 1fr) auto; }
  .copy-kv > div > span:first-child { grid-column: 1 / -1; }
  .review-kv > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .wiz-hint { display: none; }
}
@media (max-width: 700px) { .hide-m { display: none !important; } }
/* Wizard action bar: pinned to the bottom of the viewport on desktop too. */
.wiz-bar { position: sticky; top: auto; bottom: 12px; margin-top: 16px; box-shadow: var(--shadow-pop); }
.wiz-bar .btn { min-width: 96px; }
@media (max-width: 700px) { .wiz-bar { position: fixed; bottom: 0; margin: 0; } .wiz-bar .btn { min-width: 0; } }
/* path editor modal */
.pe-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 14px 16px; }
.pe-grid .field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
