/* Layout + shell v2. Tokens in packages/ui/src/tokens.css, widgets in components.css. */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg-0); color: var(--fg); font-family: var(--font-ui); font-size: var(--fs-md); line-height: var(--lh-body); }
body {
  min-height: 100dvh; overflow-x: hidden; -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1100px 620px at 8% -10%, rgba(124, 92, 255, 0.16), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(34, 211, 238, 0.08), transparent 55%),
    var(--bg-0);
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); letter-spacing: -0.02em; }
.muted { color: var(--fg-dim); font-size: var(--fs-sm); }
.small { font-size: var(--fs-xs); }
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }

/* ——— app shell ————————————————————————————————————— */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100dvh; }

/* sidebar */
.side {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(16, 22, 39, 0.96), rgba(8, 12, 21, 0.98));
  border-right: 1px solid var(--line); z-index: var(--z-nav); backdrop-filter: blur(14px);
}
.side-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s4) var(--s3); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand-400), var(--brand-600)); box-shadow: var(--shadow-brand); color: #fff;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text b { font-size: var(--fs-md); letter-spacing: -0.01em; }
.brand-text span { font-size: var(--fs-2xs); color: var(--fg-faint); text-transform: uppercase; letter-spacing: 0.14em; }
.side-collapse { margin-left: auto; }
.btn.side-collapse { min-width: 40px; min-height: 40px; padding: 0; }
.side-close {
  display: none; align-items: center; justify-content: center; width: var(--tap, 44px); height: var(--tap, 44px);
  margin-left: auto; padding: 0; border: 1px solid var(--line); background: var(--glass); color: var(--fg-2);
  border-radius: var(--r-sm); font-size: 22px; line-height: 1; cursor: pointer;
}

.side-search {
  margin: 0 var(--s3) var(--s3); display: flex; align-items: center; gap: var(--s2);
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px var(--s3); color: var(--fg-dim); font-size: var(--fs-sm); cursor: pointer; width: calc(100% - var(--s3) * 2); min-height: 40px;
}
.side-search:hover { border-color: var(--line-strong); color: var(--fg-2); }
.side-search::before { content: "⌕"; display: none; font-size: 18px; line-height: 1; }
.side-search kbd { margin-left: auto; font: inherit; font-size: var(--fs-2xs); color: var(--fg-faint); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; }

.nav {
  flex: 1; overflow-y: auto; padding: 0 var(--s2) var(--s4); scrollbar-width: thin;
  -webkit-mask-image: linear-gradient(180deg, #000 0, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(180deg, #000 0, #000 calc(100% - 24px), transparent);
}
.nav-group + .nav-group { margin-top: var(--s3); }
.nav-label { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.16em; color: var(--fg-faint); padding: var(--s2) var(--s3) 3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px var(--s3); border-radius: var(--r-sm);
  color: var(--fg-2); font-size: var(--fs-sm); position: relative; min-height: 38px;
  transition: background var(--t-micro) var(--ease), color var(--t-micro) var(--ease);
}
.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: 0.75; }
.nav-item:hover { background: var(--glass); color: var(--fg); }
.nav-item:hover svg { opacity: 1; }
.nav-item.is-active { color: #fff; background: linear-gradient(90deg, var(--brand-soft), rgba(124, 92, 255, 0.05)); box-shadow: inset 0 0 0 1px var(--line-brand); }
.nav-item.is-active svg { opacity: 1; color: var(--brand-300); }
.nav-item.is-active::before { content: ""; position: absolute; left: -8px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: linear-gradient(180deg, var(--brand-400), var(--brand-600)); }

.side-foot { border-top: 1px solid var(--line); padding: var(--s3) var(--s4); display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); color: var(--fg-dim); }
.side-foot .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); }

/* top bar */
.main-col { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: var(--z-sticky); height: var(--top-h);
  display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s5);
  background: rgba(5, 7, 13, 0.72); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line);
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.top-actions .btn { min-height: 38px; min-width: 38px; }
.top-meta {
  font-size: var(--fs-2xs); color: var(--fg-faint); letter-spacing: 0.12em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.hamburger {
  display: none; align-items: center; justify-content: center; width: var(--tap, 44px); height: var(--tap, 44px);
  padding: 0; border: 1px solid var(--line); background: var(--glass); color: var(--fg-2);
  border-radius: var(--r-sm); font-size: 17px; line-height: 1; cursor: pointer;
}
.hamburger:active { background: var(--glass-2); color: var(--fg); }

.banner { background: color-mix(in srgb, var(--warn) 14%, var(--bg-1)); border-bottom: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); padding: 10px var(--s5); font-size: var(--fs-sm); }
.banner[hidden] { display: none; }

main { padding: var(--s6) var(--s5) var(--s8); width: 100%; max-width: var(--content-max); margin: 0 auto; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.crumb { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.16em; color: var(--brand-300); opacity: 0.85; }
.page-title h1 { font-size: var(--fs-2xl); font-weight: 650; margin-top: 6px; }
.page-title p { margin: 6px 0 0; color: var(--fg-dim); font-size: var(--fs-sm); max-width: 76ch; }
.page-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }

/* grids */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s3); margin-bottom: var(--s5); }
@media (min-width: 1500px) { .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.row { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s4); }
.search {
  background: var(--glass); border: 1px solid var(--line); color: var(--fg); border-radius: var(--r-sm);
  padding: 9px var(--s3); min-height: 38px; font-size: var(--fs-sm); font: inherit; min-width: 180px;
}
.search::placeholder { color: var(--fg-faint); }
.search:focus { border-color: var(--line-brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.table-wrap { overflow-x: auto; border-radius: var(--r-md); }

/* events feed */
.feed { list-style: none; margin: 0; padding: 0; }
.ev { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr) auto; gap: var(--s3); align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.ev:last-child { border-bottom: 0; }
.ev[data-state="crit"] .ev-kind { color: var(--crit); }
.ev[data-state="warn"] .ev-kind { color: var(--warn); }
.ev[data-state="ok"] .ev-kind { color: var(--ok); }
.ev-detail { color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-time { color: var(--fg-faint); text-align: right; font-variant-numeric: tabular-nums; }

.backdrop { position: fixed; inset: 0; background: rgba(3, 5, 10, 0.62); backdrop-filter: blur(3px); z-index: calc(var(--z-nav) - 1); }
.backdrop[hidden] { display: none; }

/* ——— collapsed rail: manual at any width, automatic ≤1279 ——————— */
@media (min-width: 1024px) {
  .sidebar-rail .app { grid-template-columns: var(--side-rail) minmax(0, 1fr); }
  .sidebar-rail .brand-text, .sidebar-rail .nav-label, .sidebar-rail .nav-item span,
  .sidebar-rail .side-search span, .sidebar-rail .side-search kbd, .sidebar-rail .side-foot span { display: none; }
  .sidebar-rail .nav-item { justify-content: center; padding: 10px 0; }
  .sidebar-rail .side-head { justify-content: center; padding: var(--s4) 0 var(--s3); }
  .sidebar-rail .side-search { justify-content: center; width: 44px; margin: 0 auto var(--s3); padding: 8px 0; }
  .sidebar-rail .side-search::before { display: block; }
  .sidebar-rail .side-foot { justify-content: center; }
}

/* ——— responsive ————————————————————————————————— */
@media (min-width: 1024px) and (max-width: 1279px) {
  .app { grid-template-columns: var(--side-rail) minmax(0, 1fr); }
  .side .brand-text, .side .nav-label, .side .nav-item span,
  .side .side-search span, .side .side-search kbd, .side .side-foot span { display: none; }
  .side .nav-item { justify-content: center; padding: 10px 0; }
  .side .side-head { justify-content: center; padding: var(--s4) 0 var(--s3); }
  .side .side-search { justify-content: center; width: 44px; margin: 0 auto var(--s3); padding: 8px 0; }
  .side .side-search::before { display: block; }
  .side .side-foot { justify-content: center; }
  .side .side-collapse { display: none; }
}
@media (max-width: 1023px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); transform: translateX(-102%);
    transition: transform var(--t-layout) var(--ease);
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--line-strong);
    border-radius: 0 18px 18px 0;
  }
  body.side-open .side { transform: none; }
  body.side-open { overflow: hidden; }          /* lock the page behind the drawer */
  .hamburger { display: inline-flex; }
  .side .side-collapse { display: none; }
  .side .side-close { display: flex; }
  .side { padding-bottom: env(safe-area-inset-bottom); }
  .top { padding: 0 var(--s4); }
  main { padding: var(--s5) var(--s4) var(--s8); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 759px) {
  main { padding: var(--s4) var(--s3) var(--s6); }
  .page-title h1 { font-size: var(--fs-xl); }
  .top-meta { display: none; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .tun-table { display: none; }
  .tun-cards { display: grid; }
  .tc-grid { grid-template-columns: repeat(2, 1fr); }
  .ev { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; }
  .ev-kind { grid-column: 1; grid-row: 1; }
  .ev-time { grid-column: 2; grid-row: 1; text-align: right; }
  .ev-detail {
    grid-column: 1 / -1; grid-row: 2; white-space: normal; display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical; text-overflow: clip;
  }
}
/* feature wall — integrations, add-ons, products */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s3); }
.feature {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3) var(--s4);
  display: grid; gap: 6px; transition: border-color var(--t-micro) var(--ease), background var(--t-micro) var(--ease);
}
.feature:hover { border-color: var(--line-strong); background: var(--glass-2); }
.feature-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.feature-top b { font-size: var(--fs-sm); font-weight: 600; }
.feature-kind { font-size: var(--fs-2xs); color: var(--fg-faint); text-transform: uppercase; letter-spacing: 0.1em; }

/* ——— overlays: sign-in, keyboard help, palette card ———————————— */
.modal, #login {
  position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center;
  padding: var(--s4); overflow: auto; background: rgba(3, 5, 10, 0.74); backdrop-filter: blur(6px);
}
.modal[hidden], #login[hidden] { display: none; }
.pal-card {
  width: min(440px, 100%); background: var(--bg-elev); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3); padding: var(--s5); display: grid; gap: var(--s4);
}
.pal-card h3 { font-size: var(--fs-lg); }
.login { width: min(400px, 100%); background: var(--bg-elev); border: 1px solid var(--line-strong); border-radius: var(--r-xl); box-shadow: var(--shadow-3); padding: var(--s6); display: grid; gap: var(--s3); }
.login h2 { font-size: var(--fs-xl); }
.login label { display: grid; gap: 6px; }
.login input {
  background: var(--glass); border: 1px solid var(--line-strong); color: var(--fg);
  border-radius: var(--r-sm); padding: 11px var(--s3); min-height: 44px; font: inherit; font-size: var(--fs-md);
}
.login input:focus { border-color: var(--line-brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.login button[type="submit"] {
  border: 0; border-radius: var(--r-sm); padding: var(--s3); min-height: 44px; font: inherit; font-size: var(--fs-md);
  font-weight: 600; color: #fff; cursor: pointer; background: linear-gradient(140deg, var(--brand-400), var(--brand-600));
  box-shadow: var(--shadow-brand);
}
.login button[type="submit"]:hover { filter: brightness(1.08); }
.login-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s1); }
.login-head .brand-text b { font-size: var(--fs-md); }
.login-hint { margin: -6px 0 var(--s1); }

/* ——— page furniture that lives inside panels ————————————————— */
.rules { margin: 0; padding-left: var(--s5); font-size: var(--fs-sm); color: var(--fg-dim); }
.rules li + li { margin-top: 4px; }
.detail-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); flex-wrap: wrap; }
.detail-head h3 { margin: 0; font-size: var(--fs-lg); }
.panel-inset { background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s3) var(--s4); margin-top: var(--s3); }
.live-link { color: var(--info); text-decoration: underline; text-underline-offset: 2px; }

/* tunnel cards — the table's mobile twin (display is set by the breakpoint below) */
.tun-cards { list-style: none; margin: 0; padding: 0; gap: var(--s2); grid-template-columns: 1fr; }
.tc-head { display: flex; align-items: center; gap: var(--s2); justify-content: space-between; }
.tc-cc { color: var(--fg-dim); font-size: var(--fs-xs); }
.tc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); font-size: var(--fs-sm); color: var(--fg-dim); margin-top: var(--s2); }
.tc-ip { font-size: var(--fs-xs); color: var(--fg-dim); margin-top: var(--s1); }

/* time machine */
.tm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s2); }
.tm-item {
  background: var(--glass); border: 1px solid var(--line); color: var(--fg-2); border-radius: var(--r-sm);
  padding: 10px var(--s3); font: inherit; font-size: var(--fs-xs); cursor: pointer; text-align: left;
  transition: all var(--t-micro) var(--ease);
}
.tm-item:hover { border-color: var(--line-brand); color: #fff; background: var(--brand-soft); }

/* control page actions */
.action { border-top: 1px solid var(--line); padding: var(--s3) 0; }
.action:first-of-type { border-top: 0; }
.action-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.action-body { display: flex; gap: var(--s2); align-items: center; margin-top: var(--s2); flex-wrap: wrap; }
.action-body .search { flex: 1; min-width: 140px; }
.action[data-risk="high"] { background: color-mix(in srgb, var(--crit) 6%, transparent); }
.plan { margin-top: var(--s2); display: grid; gap: var(--s1); }
.plan code { background: var(--bg-0); border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s2); overflow-x: auto; font-size: var(--fs-xs); color: var(--fg-2); }
.out {
  background: var(--bg-0); border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s3);
  overflow: auto; max-height: 220px; font-size: var(--fs-xs); white-space: pre-wrap; color: var(--fg-2); margin: var(--s2) 0 0;
}
.out.err { border-color: color-mix(in srgb, var(--crit) 55%, transparent); color: #ffd9df; }

/* NOC wallboard */
.noc { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s3); margin: var(--s4) 0; }
.noc-item {
  background: linear-gradient(180deg, var(--glass-2), rgba(255, 255, 255, 0.012)), var(--bg-1);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s4) var(--s5);
  display: flex; flex-direction: column; gap: 6px;
}
.noc-item span { color: var(--fg-faint); text-transform: uppercase; letter-spacing: 0.1em; font-size: var(--fs-2xs); }
.noc-item b { font-size: var(--fs-4xl); line-height: 1; font-family: var(--font-mono); letter-spacing: -0.03em; }
.noc-item b.ok { color: var(--ok); }
.noc-item b.crit { color: var(--crit); }
.noc-item b.warn { color: var(--warn); }
.noc-item em { color: var(--fg-dim); font-style: normal; font-size: var(--fs-xs); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ico { display: block; }

/* command palette rows (the list holds buttons, not bare li) */
.pal-item {
  width: 100%; text-align: left; background: none; border: 0; color: var(--fg-2); font: inherit;
  font-size: var(--fs-sm); padding: 10px var(--s3); border-radius: var(--r-sm); cursor: pointer;
  display: flex; gap: var(--s3); align-items: center; min-height: 40px;
}
.pal-item:hover, .pal-item.is-active { background: var(--brand-soft); color: #fff; }
.pal-kind { font-size: var(--fs-2xs); color: var(--fg-faint); text-transform: uppercase; letter-spacing: 0.1em; min-width: 56px; }
.pal .search:focus { box-shadow: none; border-bottom-color: var(--line-brand); }

/* api key scope checkboxes */
.key-scope { accent-color: var(--brand); width: 20px; height: 20px; vertical-align: -4px; }
label:has(.key-scope) { min-height: 40px; padding-right: var(--s2); }

/* a long explanation is context, not content: closed by default */
.note { border-top: 1px solid var(--line); padding-top: var(--s3); margin-top: var(--s3); }
.note summary { cursor: pointer; font-size: var(--fs-sm); color: var(--fg-2); list-style: none; display: flex; align-items: center; gap: 8px; min-height: 40px; }
.note summary::-webkit-details-marker { display: none; }
.note summary::before { content: "+"; font-family: var(--font-mono); color: var(--brand-300); }
.note[open] summary::before { content: "−"; }
.note p { color: var(--fg-dim); font-size: var(--fs-xs); margin: var(--s2) 0 0; line-height: 1.6; }

/* ——— page composition: hero, split, meters, pricing ———————————————─
   The shell alone made every screen look the same. These are the pieces that
   let a page say what it is: a health hero, a 2-up split, meters, price cards. */
.hero {
  position: relative; overflow: hidden; border-radius: var(--r-xl); margin-bottom: var(--s5);
  border: 1px solid var(--line-strong); padding: var(--s6);
  background:
    radial-gradient(760px 260px at 8% -30%, var(--brand-glow), transparent 65%),
    linear-gradient(140deg, #16204a, #0b1020 55%);
  box-shadow: var(--shadow-3);
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--s6); align-items: center;
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.35;
  background-image: linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(70% 90% at 15% 10%, #000, transparent 75%);
}
.hero[data-state="crit"] { background: radial-gradient(760px 260px at 8% -30%, rgba(244, 63, 94, 0.35), transparent 65%), linear-gradient(140deg, #2a1220, #0b1020 55%); }
.hero[data-state="warn"] { background: radial-gradient(760px 260px at 8% -30%, rgba(245, 158, 11, 0.3), transparent 65%), linear-gradient(140deg, #241a12, #0b1020 55%); }
.hero-eyebrow { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.18em; color: var(--brand-300); }
.hero-value { font-size: clamp(34px, 4vw, 56px); font-weight: 680; letter-spacing: -0.04em; line-height: 1; margin: var(--s2) 0; }
.hero-value span { font-size: var(--fs-md); font-weight: 500; color: var(--fg-dim); letter-spacing: 0; margin-left: var(--s2); }
.hero-sub { color: var(--fg-2); font-size: var(--fs-sm); max-width: 60ch; }
.hero-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); position: relative; z-index: 1; }
.hero-stat { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: var(--s3) var(--s4); backdrop-filter: blur(8px); }
.hero-stat b { display: block; font-size: var(--fs-xl); font-weight: 650; letter-spacing: -0.02em; }
.hero-stat span { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.12em; color: var(--fg-dim); }
.hero-bar { height: 6px; border-radius: var(--r-pill); background: rgba(255, 255, 255, 0.12); margin-top: var(--s3); overflow: hidden; max-width: 460px; }
.hero-bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--ok), var(--brand-400)); }
.hero[data-state="warn"] .hero-bar > i { background: linear-gradient(90deg, var(--warn), #fbbf24); }

/* two-up composition — main column + context column */
.split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: var(--s4); align-items: start; align-content: start; }
.split > * { min-width: 0; }
.split > :first-child { grid-row: span 2; }
@media (max-width: 1199px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split > :first-child { grid-row: auto; }
  .split > :nth-child(2) { order: -1; }
}

/* meters — budget / quota with a number you can read at a glance */
.meters { display: grid; gap: var(--s3); }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); font-size: var(--fs-sm); margin-bottom: 6px; }
.meter-top b { font-variant-numeric: tabular-nums; }
.meter-track { height: 8px; border-radius: var(--r-pill); background: var(--glass-2); overflow: hidden; }
.meter-track > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--ok), #34d399); }
.meter[data-state="warn"] .meter-track > i { background: linear-gradient(90deg, var(--warn), #fbbf24); }
.meter[data-state="crit"] .meter-track > i { background: linear-gradient(90deg, var(--crit), #fb7185); }
.meter-note { font-size: var(--fs-2xs); color: var(--fg-faint); margin-top: 5px; }

/* pricing — the screen that has to sell */
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--s4); }
.price-card {
  position: relative; display: flex; flex-direction: column; gap: var(--s3);
  background: linear-gradient(180deg, var(--glass-2), rgba(255, 255, 255, 0.012)), var(--bg-1);
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow-1);
  transition: transform var(--t-layout) var(--ease), border-color var(--t-layout) var(--ease), box-shadow var(--t-layout) var(--ease);
}
.price-card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.price-card[data-current="true"] {
  border-color: var(--line-brand); box-shadow: var(--shadow-brand);
  background: linear-gradient(180deg, var(--brand-soft), rgba(255, 255, 255, 0.012)), var(--bg-1);
}
.price-card[data-highlight="true"]::before {
  content: "most popular"; position: absolute; top: -10px; left: var(--s5);
  background: linear-gradient(140deg, var(--brand-400), var(--brand-600)); color: #fff;
  font-size: var(--fs-2xs); letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600;
  padding: 3px 10px; border-radius: var(--r-pill); box-shadow: var(--shadow-brand);
}
.price-name { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.price-name h3 { font-size: var(--fs-md); font-weight: 600; letter-spacing: 0; }
.price-amount { font-size: var(--fs-3xl); font-weight: 680; letter-spacing: -0.03em; line-height: 1; }
.price-amount small { font-size: var(--fs-sm); font-weight: 500; color: var(--fg-dim); letter-spacing: 0; margin-left: 4px; }
.price-feats { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: var(--fs-sm); color: var(--fg-2); }
.price-feats li { display: flex; gap: 8px; align-items: flex-start; }
.price-feats li::before { content: "✓"; color: var(--ok); font-weight: 700; flex: 0 0 auto; }
.price-feats li.muted::before { content: "·"; color: var(--fg-faint); }
.price-actions { margin-top: auto; display: grid; gap: var(--s2); }
.price-actions .btn { width: 100%; }
@media (max-width: 1023px) {
  .hero { grid-template-columns: minmax(0, 1fr); padding: var(--s5); gap: var(--s4); }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 559px) {
  .hero-value { font-size: 34px; }
  .price-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi-value { font-size: 24px; }
  .kpi-unit { display: block; margin-left: 0; margin-top: 2px; }
}

/* checks — the host checklist in the overview's context column */
.checks { list-style: none; margin: 0; padding: 0; display: grid; }
.check {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: var(--s3);
  align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm);
}
.check:last-child { border-bottom: 0; }
.check-label { color: var(--fg-dim); }
.check-value { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }
.check-value small { color: var(--fg-faint); font-weight: 400; margin-left: 3px; }
.check[data-state="crit"] .check-value { color: var(--crit); }
.check[data-state="warn"] .check-value { color: var(--warn); }

/* ——— touch & small-screen ergonomics ————————————————————————
   Target size 44px wherever a finger lands, 16px inputs (iOS zooms below that). */
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
:root { --tap: 44px; }
button, .btn, .chip, .nav-item, a, summary, input, select, textarea { touch-action: manipulation; }
input.search, select, textarea, .login input { font-size: 16px; min-height: 44px; }
.sheet-close { min-width: var(--tap); min-height: var(--tap); }

@media (hover: none), (max-width: 1023px) {
  .btn { min-height: var(--tap); padding: 10px 16px; }
  .btn.sm { min-height: 38px; }
  .chip { min-height: 40px; padding: 9px 14px; }
  .nav-item { min-height: var(--tap); }
  .check { padding: 12px 0; }
  .ev { padding: 12px 0; }
  .dt td, .dt th { padding: 13px var(--s3); }
  .side-search { min-height: var(--tap); }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .table-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .dt { min-width: 620px; }
  .price-card:hover, .kpi:hover { transform: none; }
}

/* auto-composed panel grid (see composePanels in app.mjs) */
.panel-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));  /* 3-up squeezes .kv + long rows */
  gap: var(--s4); align-items: start; margin-bottom: var(--s4);
}
.panel-grid > .panel { margin-bottom: 0; height: 100%; min-width: 0; }
@media (max-width: 767px) { .panel-grid { grid-template-columns: minmax(0, 1fr); } }

/* checkboxes are small by nature: give the box itself a finger-sized hit */
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--brand); }
.dt input[type="checkbox"] { margin: 0; vertical-align: -4px; }

/* recovery links: text buttons, not chrome */
.linkbtn { background: none; border: 0; color: var(--brand-300); font: inherit; font-size: var(--fs-xs); cursor: pointer; padding: 4px 0; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
.linkbtn:hover { color: var(--brand-400); }
.forgot { display: grid; gap: var(--s2); margin-top: var(--s1); }
.forgot[hidden] { display: none; }
#reset { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center; padding: var(--s4); overflow: auto; background: rgba(3, 5, 10, 0.78); backdrop-filter: blur(6px); }
#reset[hidden] { display: none; }

/* inside the login card only the actual sign-in button is primary */
.login .forgot button[type="submit"] {
  background: none; color: var(--brand-300); box-shadow: none; min-height: 40px; justify-self: start;
  font-size: var(--fs-sm); font-weight: 500; padding: 6px 0; text-decoration: underline; text-underline-offset: 2px;
}
.login .forgot button[type="submit"]:hover { filter: none; color: var(--brand-400); }

/* C — account chip */
.acct { position: relative; }
.acct-btn { gap: 8px; padding-right: 10px; }
.acct-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.acct-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: var(--z-drop); min-width: 240px;
  background: var(--bg-elev); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-3); padding: var(--s2); display: grid; gap: 2px;
}
.acct-menu[hidden] { display: none; }
.acct-head { padding: var(--s2) var(--s3) var(--s3); border-bottom: 1px solid var(--line); margin-bottom: var(--s2); display: grid; gap: 2px; }
.acct-item {
  display: block; width: 100%; text-align: left; padding: 9px var(--s3); border-radius: var(--r-sm);
  color: var(--fg-2); font: inherit; font-size: var(--fs-sm); background: none; border: 0; cursor: pointer;
}
.acct-item:hover { background: var(--glass-2); color: var(--fg); }
.acct-out { color: var(--crit); }
@media (max-width: 759px) { .acct-btn #acct-name { display: none; } }

/* bulk selection on the tunnels table */
.bulk { gap: var(--s2); padding: var(--s2) var(--s3); border: 1px solid var(--line-brand); border-radius: var(--r-sm); background: var(--brand-soft); }
.bulk[hidden] { display: none; }
.bulk-pick { flex-direction: row; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--fg-2); }
.bulk b { font-size: var(--fs-sm); }
.dt td input[type="checkbox"] { width: 18px; height: 18px; margin: 0; }

.feedline { margin: 8px 0 0; font-size: var(--fs-2xs); color: var(--fg-faint); letter-spacing: 0.02em; }
.feedline b { color: var(--fg-dim); font-weight: 600; margin-left: 3px; }

/* ——— brand & header, premium pass ————————————————————————— */
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(150deg, rgba(196, 181, 253, 0.28), rgba(106, 69, 240, 0.16));
  border: 1px solid var(--line-brand); box-shadow: 0 8px 24px rgba(124, 92, 255, 0.28), 0 1px 0 rgba(255, 255, 255, 0.12) inset;
  position: relative;
}
.brand-mark::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; background: radial-gradient(60% 60% at 30% 10%, rgba(255,255,255,.18), transparent 70%); pointer-events: none; }
.logo { width: 24px; height: 24px; display: block; filter: drop-shadow(0 1px 3px rgba(106, 69, 240, 0.55)); }
.brand-mark-sm { width: 30px; height: 30px; flex-basis: 30px; border-radius: 9px; }
.brand-mark-sm .logo { width: 19px; height: 19px; }
.brand-text b { font-size: 15px; font-weight: 650; letter-spacing: -0.015em; }
.brand-sub { font-size: 10px !important; letter-spacing: 0.16em !important; text-transform: uppercase; color: var(--fg-faint) !important; margin-top: 1px; }

/* header: brand only when the sidebar is not visible */
.top-brand { display: none; align-items: center; gap: 10px; margin-right: var(--s2); }
.top-brand b { font-size: var(--fs-sm); font-weight: 650; letter-spacing: -0.01em; }
@media (max-width: 1023px) { .top-brand { display: inline-flex; } }

/* top bar: slightly deeper glass + hairline */
.top { background: rgba(5, 7, 13, 0.82); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 32px rgba(0, 0, 0, 0.35); }

/* account avatar */
.acct-avatar {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 24px;
  background: linear-gradient(140deg, var(--brand-400), var(--brand-600)); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: 0; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16) inset;
}
.acct-btn { padding-left: 6px; }
.acct-btn:hover .acct-avatar { filter: brightness(1.1); }

/* status pills: crisper at a glance, critical breathes */
.status, .pill { letter-spacing: 0.07em; }
.status[data-state="crit"]::before { animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .status[data-state="crit"]::before { animation: none; } }
.brand-text { min-width: 0; }
.brand-sub { white-space: nowrap; letter-spacing: 0.13em !important; }

/* phone header: one row, nothing overflows, brand stays as the mark */
@media (max-width: 759px) {
  .top { gap: var(--s2); padding: 0 var(--s3); }
  .top-brand b { display: none; }          /* the mark carries the brand; the drawer has the name */
  #auto-chip { display: none; }            /* it lives in the Overview panel on a phone */
  .top-actions { gap: 4px; }
  .top-actions .btn { min-width: 38px; padding: 0 8px; }
  .acct-btn { padding: 0 6px; }
  .brand-text b { white-space: nowrap; }
}

/* header cluster: workspace chip, hairline separators, tighter rhythm */
.ws-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px; margin-right: var(--s2);
  border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--glass); max-width: 320px;
}
.ws-chip[hidden] { display: none; }
.ws-chip b { font-size: var(--fs-sm); font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.ws-plan { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.12em; color: var(--brand-300); white-space: nowrap; }
@media (max-width: 1023px) { .ws-chip { display: none; } }

/* header vitals: the control plane's pulse, readable in one glance */
.vitals { display: inline-flex; align-items: center; gap: 2px; margin-right: var(--s2); }
.vitals[hidden] { display: none; }
.vital {
  display: inline-flex; align-items: baseline; gap: 5px; padding: 4px 10px; border-radius: var(--r-sm);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--fg-faint); white-space: nowrap;
}
.vital + .vital { box-shadow: -1px 0 0 var(--line) inset; }
.vital b { font-size: var(--fs-sm); letter-spacing: -0.01em; text-transform: none; color: var(--fg-2); font-weight: 650; }
.vital.is-bad b { color: var(--warn); }
@media (max-width: 1279px) { .vitals .vital:nth-child(n+3) { display: none; } }
@media (max-width: 1023px) { .vitals { display: none; } }



/* ——— Overview analytics strip ——————————————————————————————— */
.analytics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); margin: var(--s4) 0; }
@media (max-width: 1100px) { .analytics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .analytics { grid-template-columns: minmax(0, 1fr); } }

.chart-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: var(--s3); }
.chart-head b { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.chart-head .pill { margin-left: auto; }

.spark { width: 100%; height: 64px; display: block; border-bottom: 1px solid var(--line); padding-bottom: 1px; }
.spark rect { fill: var(--brand-400); opacity: .85; rx: 1.5; }
.spark:hover rect { opacity: 1; }

.donut-wrap { display: flex; align-items: center; gap: var(--s4); }
.donut { flex: 0 0 auto; filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.35)); }
.donut-legend { display: grid; gap: 6px; min-width: 0; }
.donut-legend span { display: flex; align-items: center; gap: 7px; font-size: var(--fs-sm); color: var(--fg-2); }
.donut-legend i { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }
.donut-legend b { margin-left: auto; color: var(--fg); }
.donut-legend em { font-style: normal; color: var(--fg-faint); font-size: var(--fs-2xs); min-width: 34px; text-align: right; }

.bars { display: grid; gap: 10px; }
.bars li { display: grid; grid-template-columns: 58px 1fr 32px; align-items: center; gap: 10px; }
.bar-label { font-size: var(--fs-xs); color: var(--fg-dim); }
.bar { height: 7px; border-radius: 999px; background: var(--glass-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--warn), var(--crit)); }
.bars b { text-align: right; font-size: var(--fs-sm); }

/* hero actions: same height, same gap, wraps instead of overflowing */
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.hero-actions .btn { height: 34px; }

/* phone: hero buttons form a tidy 2-up grid, the third spans the row */
@media (max-width: 560px) {
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
  .hero-actions .btn { justify-content: center; }
  .hero-actions .btn:nth-child(3) { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  /* a ghost button on a phone must still read as a button */
  .hero-actions .btn.ghost { border: 1px solid var(--line-strong); background: var(--glass); }
}


/* ════════════════════════════════════════════════════════════
   Overview — dashboard system
   ════════════════════════════════════════════════════════════ */
.dash { display: grid; gap: 20px; }

/* status bar */
.dash-top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 11px 18px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.015));
  border: 1px solid var(--line); box-shadow: 0 1px 0 rgba(255,255,255,.05) inset;
}
.dash-state { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dash-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(16,185,129,.13); }
.dash-top[data-state="warn"] .dash-dot { background: var(--warn); box-shadow: 0 0 0 4px rgba(245,158,11,.13); }
.dash-top[data-state="crit"] .dash-dot { background: var(--crit); box-shadow: 0 0 0 4px rgba(244,63,94,.15); animation: breathe 2.2s ease-in-out infinite; }
.dash-state b { display: block; font-size: 13.5px; font-weight: 620; letter-spacing: -0.01em; }
.dash-state span { display: block; margin-top: 1px; font-size: 11.5px; color: var(--fg-faint); }
.dash-top-right { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.dash-meta { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--fg-faint); }
.dash-meta b { color: var(--fg-2); font-variant-numeric: tabular-nums; letter-spacing: 0; text-transform: none; font-size: 12px; }

/* KPI row */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
  position: relative; overflow: hidden; padding: 18px 20px 16px; border-radius: 16px;
  background: linear-gradient(165deg, rgba(255,255,255,.055), rgba(255,255,255,.012));
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255,255,255,.05) inset, 0 12px 28px -22px rgba(0,0,0,.95);
  transition: transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.kpi::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 90% at 100% 0%, rgba(124,92,255,.12), transparent 62%);
}
.kpi:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.kpi-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .16em; color: var(--fg-faint); }
.kpi-value { display: block; margin-top: 9px; font-size: 34px; line-height: 1; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi-note { display: block; margin-top: 8px; font-size: 11.5px; color: var(--fg-dim); }
.kpi[data-tone="warn"] .kpi-value { color: var(--warn); }
.kpi[data-tone="warn"] { border-color: rgba(245, 158, 11, .22); }
.kpi-spark { position: absolute; right: 16px; top: 16px; width: 76px; height: 26px; opacity: .55; }

/* hero */
.dash .hero {
  all: unset; box-sizing: border-box;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 28px;
  padding: 26px 28px; border-radius: 20px; position: relative; overflow: hidden;
  background:
    radial-gradient(120% 150% at 0% 0%, rgba(124,92,255,.17), transparent 58%),
    linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.014));
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255,255,255,.07) inset, 0 26px 52px -34px rgba(0,0,0,.95);
}
.dash .hero[data-state="warn"] { background: radial-gradient(120% 150% at 0% 0%, rgba(245,158,11,.14), transparent 58%), linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.014)); }
.dash .hero[data-state="crit"] { background: radial-gradient(120% 150% at 0% 0%, rgba(244,63,94,.15), transparent 58%), linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.014)); }
.hero-ring { position: relative; display: grid; place-items: center; }
.ring { display: block; }
.hero-ring-pct { position: absolute; font-size: 28px; font-weight: 750; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.hero-ring-pct i { font-style: normal; font-size: 13px; color: var(--fg-faint); margin-left: 1px; }
.hero-body { min-width: 0; }
.hero-eyebrow { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .18em; color: var(--fg-faint); }
.hero-title { margin: 8px 0 0; font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.hero-title span { font-size: 16px; font-weight: 500; color: var(--fg-dim); letter-spacing: -.01em; margin-left: 6px; }
.hero-line { margin: 10px 0 0; font-size: 12.5px; color: var(--fg-dim); max-width: 62ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.hero-actions .btn { height: 32px; }
.hero-side { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-width: 240px; }
.hero-mini {
  padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.035);
  border: 1px solid var(--line);
}
.hero-mini b { display: block; font-size: 17px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hero-mini b small { font-size: 10px; color: var(--fg-faint); margin-left: 2px; }
.hero-mini span { display: block; margin-top: 2px; font-size: 9.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--fg-faint); }

/* rows + cards */
.dash-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.dash-row-2-1 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.card {
  padding: 18px 20px 20px; border-radius: 18px; background: var(--bg-panel, #0c1017);
  border: 1px solid var(--line); box-shadow: 0 1px 0 rgba(255,255,255,.045) inset;
  min-width: 0; transition: border-color var(--t-fast) var(--ease);
}
.card:hover { border-color: var(--line-strong); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 13px; font-weight: 620; letter-spacing: -.005em; }
.card-note { font-size: 10.5px; color: var(--fg-faint); white-space: nowrap; }
.card-figure { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.card-figure b { font-size: 24px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.card-figure span { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--fg-faint); }
.card-sep { width: 1px; height: 14px; background: var(--line); margin: 0 6px; align-self: center; }

/* events */
.feed .ev { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 10px; }
.ev-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-faint); }
.ev[data-state="ok"] .ev-dot { background: var(--ok); }
.ev[data-state="warn"] .ev-dot { background: var(--warn); }
.ev[data-state="crit"] .ev-dot { background: var(--crit); }

/* compact lists inside cards */
.checks.tight .check { padding: 7px 0; }
.card .check { border-bottom: 1px solid var(--line); }
.card .check:last-child { border-bottom: 0; }

/* responsive */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash .hero { grid-template-columns: auto minmax(0, 1fr); }
  .hero-side { display: none; }
  .dash-row, .dash-row-2-1 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .dash { gap: 14px; }
  .dash-top { flex-wrap: wrap; padding: 12px 14px; }
  .dash-top-right { width: 100%; justify-content: space-between; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px 16px; border-radius: 14px; }
  .kpi-value { font-size: 26px; }
  .kpi-spark { display: none; }
  .dash .hero { grid-template-columns: minmax(0, 1fr); padding: 20px 18px; gap: 16px; }
  .hero-ring { justify-self: start; }
  .hero-ring .ring { width: 96px; height: 96px; }
  .hero-ring-pct { font-size: 22px; }
  .hero-title { font-size: 24px; }
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .hero-actions .btn { justify-content: center; }
  .hero-actions .btn:nth-child(3) { grid-column: 1 / -1; }
  .card { padding: 16px 14px; border-radius: 16px; }
}

.dash-row-3 { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1180px) { .dash-row-3 { grid-template-columns: minmax(0, 1fr); } }

/* ════════════════════════════════════════════════════════════
   Widget system — KPI · hero · cards · timeline · meters
   ════════════════════════════════════════════════════════════ */
.ic { width: 15px; height: 15px; flex: 0 0 15px; stroke: currentColor; stroke-width: 1.7; fill: none;
      stroke-linecap: round; stroke-linejoin: round; opacity: .9; }

/* KPI */
.kpi { display: flex; flex-direction: column; gap: 0; }
.kpi-top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.kpi-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(150deg, rgba(124,92,255,.22), rgba(124,92,255,.06));
  border: 1px solid rgba(124,92,255,.22); color: var(--brand-300); }
.kpi-label { font-size: 10px; text-transform: uppercase; letter-spacing: .16em; color: var(--fg-faint); }
.kpi-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 12px; }
.kpi-tag { font-size: 9.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--fg-faint);
  padding: 3px 7px; border-radius: 6px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.kpi-spark { width: 84px; height: 28px; opacity: .8; }
.area { width: 100%; height: 62px; display: block; }
.kpi-spark .area { height: 28px; }

/* figures row inside chart cards */
.figures { display: flex; gap: 22px; margin-bottom: 6px; }
.figures div { display: grid; gap: 2px; }
.figures b { font-size: 22px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.figures span { font-size: 9.5px; text-transform: uppercase; letter-spacing: .13em; color: var(--fg-faint); }

/* donut centre label */
.donut-center { fill: var(--fg); font-size: 15px; font-weight: 700; letter-spacing: -.03em; }

/* hero tweaks for the new parts */
.hero-left { position: relative; display: grid; place-items: center; }
.hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-width: 250px; }
.hstat { padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.hstat b { display: block; font-size: 17px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hstat b small { font-size: 10px; color: var(--fg-faint); margin-left: 2px; }
.hstat span { display: block; margin-top: 2px; font-size: 9.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--fg-faint); }
.hstat[data-tone="warn"] b { color: var(--warn); }

/* grids */
.dgrid { display: grid; gap: 20px; }
.dgrid-3 { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr) minmax(0, 1fr); }
.dgrid-2-1 { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.dgrid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1180px) { .dgrid-3, .dgrid-2-1, .dgrid-2 { grid-template-columns: minmax(0, 1fr); } }

/* card heads with an icon */
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head .ic { color: var(--brand-300); opacity: .85; }

/* events as a timeline */
.tline { list-style: none; margin: 0; padding: 0; position: relative; }
.tline::before { content: ""; position: absolute; left: 3px; top: 8px; bottom: 8px; width: 1px; background: var(--line); }
.tline .ev { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
  padding: 9px 0 9px 18px; align-items: baseline; }
.tline .ev-dot { position: absolute; left: 0; top: 14px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--fg-faint); box-shadow: 0 0 0 3px var(--bg-panel, #0c1017); }
.tline .ev[data-state="ok"] .ev-dot { background: var(--ok); }
.tline .ev[data-state="warn"] .ev-dot { background: var(--warn); }
.tline .ev[data-state="crit"] .ev-dot { background: var(--crit); }
.tline .ev-kind { font-size: 11.5px; color: var(--fg-2); }
.tline .ev-time { font-size: 11px; color: var(--fg-faint); }
.tline .ev-detail { grid-column: 1 / -1; font-size: 10.5px; color: var(--fg-faint); }

/* checks: segmented summary bar */
.seg { display: flex; gap: 3px; margin-bottom: 12px; }
.seg i { flex: 1; height: 4px; border-radius: 3px; background: var(--glass-2); }
.seg i[data-state="ok"] { background: var(--ok); }
.seg i[data-state="warn"] { background: var(--warn); }
.seg i[data-state="crit"] { background: var(--crit); }

/* automation meter */
.check-meter { flex: 1; height: 4px; border-radius: 3px; background: var(--glass-2); overflow: hidden; min-width: 40px; }
.check-meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand-400), var(--brand-600)); }
.check[data-state="crit"] .check-meter i { background: linear-gradient(90deg, var(--warn), var(--crit)); }
.card .check { gap: 10px; }

/* diagnostics grid */
.diag { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-radius: 12px; overflow: hidden; }
.diag div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 10px 12px; background: var(--bg-panel, #0c1017); }
.diag span { font-size: 10.5px; color: var(--fg-faint); }
.diag b { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .diag { grid-template-columns: 1fr; } }

/* the KPI sparkline belongs in the card's footer row, not floating over the label */
.kpi .kpi-spark { position: static; top: auto; right: auto; }

/* automation rows: one line, meter in the middle, action on the right */
.card .check.wrow {
  display: grid; grid-template-columns: minmax(0, 1fr) 70px 46px auto;
  align-items: center; gap: 10px; padding: 9px 0;
}
.check.wrow .check-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check.wrow .check-meter { width: 100%; }
.check.wrow .check-value { text-align: right; white-space: nowrap; }
.check.wrow .btn { padding: 0 10px; height: 26px; line-height: 1; }

/* values never wrap mid-number */
.check-value { white-space: nowrap; }

/* cards size to their content instead of stretching to the tallest neighbour */
.dgrid-2-1, .dgrid-2, .dgrid-3 { align-items: start; }
/* the event stream scrolls inside its card instead of stretching the row */
.card .tline { max-height: 460px; overflow: auto; }
.card .tline::-webkit-scrollbar { width: 8px; }
.card .tline::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
.tline .ev { grid-template-columns: minmax(0, 1fr) auto; }
.tline .ev-kind { grid-column: 1; }

/* the header cluster was 2px too wide between 1280 and ~1360: the vitals are the first thing to go */
@media (max-width: 1599px) { .vitals { display: none; } }   /* only a 1920-class screen has room for them */
.top-actions { min-width: 0; }
.top-actions > * { flex: 0 0 auto; }

/* type scale: everything snaps to 10 · 11 · 12 · 13 · 15 · 17 · 22 · 26 · 34 */
.btn.sm, .pill, .kpi-tag { font-size: 10px; letter-spacing: .1em; }
.card-head h2 { font-size: 13px; }
.check-label, .ev-kind, .bar-label { font-size: 12px; }
.check-value, .diag b { font-size: 13px; }
.hero-line, .kpi-note, .card .check-label { font-size: 12px; }
.hero-title { font-size: 26px; }
.hero-title span { font-size: 15px; }
.dash-state b { font-size: 13px; }
.dash-state span, .dash-meta { font-size: 11px; }
/* tertiary labels were 3.4:1 — below AA for small text */
.hstat span, .kpi-tag, .hero-eyebrow, .kpi-label { color: var(--fg-dim); }

/* finish the scale: no 9.5 / 10.5 / 10.83 / 11.5 anywhere */
.hstat span, .hero-mini span, .diag span, .figures span, .kpi-tag, .donut-legend em { font-size: 10px; letter-spacing: .1em; }
.card-note { font-size: 11px; }
.tline .ev-kind { font-size: 12px; }
.tline .ev-detail { font-size: 11px; }
.check-value small { font-size: 10px; }
.hero-eyebrow { font-size: 10px; letter-spacing: .17em; }

/* the header must never push the page wider than the viewport */
.top { min-width: 0; }
.top-meta { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.top-actions { flex-wrap: nowrap; }
.ws-chip { min-width: 0; }
.ws-chip b { min-width: 0; }

/* event detail: truncate on purpose, with the full text in the title */
.tline .ev-detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* drawer layout: the header carries the mark only, the name lives in the drawer */
@media (max-width: 1023px) { .top-brand b { display: none; } }

/* signed out: the console must not paint behind the form */
body.is-locked #main, body.is-locked .side, body.is-locked .top { visibility: hidden; }

/* ════════════════════════════════════════════════════════════
   Pool · Fleet · Events · Automation · Diagnostics (refined)
   ════════════════════════════════════════════════════════════ */

/* pool: ring + centre + per-status bars */
.pool { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 18px; }
.pool-ring { position: relative; display: grid; place-items: center; }
.pool-center { position: absolute; text-align: center; }
.pool-center b { display: block; font-size: 24px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.pool-center span { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .14em; color: var(--fg-faint); }
.pool-legend { display: grid; gap: 10px; min-width: 0; }
.pleg { display: grid; grid-template-columns: 8px 46px minmax(0, 1fr) 34px 32px; align-items: center; gap: 8px; }
.pleg i { width: 8px; height: 8px; border-radius: 50%; }
.pleg-label { font-size: 11px; color: var(--fg-dim); text-transform: capitalize; }
.pleg-bar { height: 4px; border-radius: 3px; background: var(--glass-2); overflow: hidden; }
.pleg-bar b { display: block; height: 100%; border-radius: inherit; }
.pleg-value { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.pleg em { font-style: normal; font-size: 10px; color: var(--fg-faint); text-align: right; }
.pool-foot { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 11px; color: var(--fg-dim); }
.pool-foot b { color: var(--ok); font-size: 13px; }

/* fleet: ranked rows */
.fleet-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.fleet-head b { font-size: 26px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.fleet-head span { font-size: 10.5px; color: var(--fg-faint); }
.fleet { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.fleet li { display: grid; grid-template-columns: 16px minmax(0, 1fr) minmax(40px, 1.1fr) 28px; align-items: center;
  gap: 10px; padding: 7px 0; border-radius: 8px; transition: background var(--t-fast) ease; }
.fleet li:hover { background: rgba(255,255,255,.03); }
.fleet-rank { font-size: 10px; color: var(--fg-faint); font-variant-numeric: tabular-nums; text-align: right; }
.fleet-name { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.fleet-name b { font-size: 11.5px; color: var(--fg-2); }
.fleet-name em { font-style: normal; font-size: 9.5px; letter-spacing: .1em; color: var(--fg-faint); text-transform: uppercase; }
.fleet-bar { height: 6px; border-radius: 999px; background: var(--glass-2); overflow: hidden; }
.fleet-bar b { display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, rgba(245,158,11,.85), rgba(244,63,94,.9)); }
.fleet-value { text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* events: mark + pill + meta line */
.tline .ev { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 12px; padding: 10px 0; align-items: start; }
.tline .ev-mark { width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; background: var(--fg-faint);
  box-shadow: 0 0 0 3px rgba(255,255,255,.04); }
.tline .ev[data-state="ok"] .ev-mark { background: var(--ok); box-shadow: 0 0 0 3px rgba(16,185,129,.12); }
.tline .ev[data-state="warn"] .ev-mark { background: var(--warn); box-shadow: 0 0 0 3px rgba(245,158,11,.12); }
.tline .ev[data-state="crit"] .ev-mark { background: var(--crit); box-shadow: 0 0 0 3px rgba(244,63,94,.14); }
.ev-main { min-width: 0; display: grid; gap: 3px; }
.ev-row { display: flex; align-items: center; gap: 8px; }
.tline .ev-kind { font-size: 12px; color: var(--fg); font-weight: 550; }
.tline .ev-time { margin-left: auto; font-size: 10.5px; color: var(--fg-faint); }
.tline .ev-detail { font-size: 10.5px; color: var(--fg-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* automation rows */
.auto { list-style: none; margin: 0; padding: 0; }
.arow { display: grid; grid-template-columns: 8px minmax(0, 1fr) 64px 44px auto; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line); }
.arow:last-child { border-bottom: 0; }
.adot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(16,185,129,.1); }
.arow[data-tone="warn"] .adot { background: var(--warn); box-shadow: 0 0 0 3px rgba(245,158,11,.1); }
.arow[data-tone="crit"] .adot { background: var(--crit); box-shadow: 0 0 0 3px rgba(244,63,94,.12); }
.arow[data-tone="idle"] .adot { background: var(--fg-faint); box-shadow: none; }
.aname { display: grid; gap: 1px; min-width: 0; }
.aname b { font-size: 11.5px; color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aname em { font-style: normal; font-size: 9.5px; color: var(--fg-faint); letter-spacing: .04em; }
.ameter { height: 4px; border-radius: 3px; background: var(--glass-2); overflow: hidden; }
.ameter b { display: block; height: 100%; border-radius: inherit; background: var(--brand-400); }
.arow[data-tone="warn"] .ameter b { background: var(--warn); }
.arow[data-tone="crit"] .ameter b { background: var(--crit); }
.aval { text-align: right; font-size: 11.5px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.arow .btn { height: 24px; padding: 0 9px; font-size: 10px; }
.arow:hover { background: rgba(255,255,255,.02); }

/* diagnostics: grouped tiles */
.diag-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1500px) { .diag-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .diag-groups { grid-template-columns: minmax(0, 1fr); } }
.dgroup { min-width: 0; }
.dgroup-title { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .16em; color: var(--fg-faint); margin-bottom: 6px; }
.ditems { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-radius: 10px; overflow: hidden; }
.ditem { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 9px 10px; background: var(--bg-panel, #0c1017); }
.ditem span { font-size: 10px; color: var(--fg-faint); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.ditem b { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Run — a real secondary action: visible surface, brand tint, centred label */
.btn.run {
  display: inline-grid; grid-auto-flow: column; align-items: center; justify-content: center; gap: 5px;
  height: 26px; min-width: 58px; padding: 0 11px 0 9px; border-radius: 8px;
  font-size: 11px; font-weight: 600; letter-spacing: .03em; line-height: 1;
  color: var(--brand-300); background: rgba(124, 92, 255, .12);
  border: 1px solid rgba(124, 92, 255, .30);
  transition: background var(--t-fast) ease, border-color var(--t-fast) ease, color var(--t-fast) ease;
}
.btn.run:hover { background: rgba(124, 92, 255, .2); border-color: rgba(124, 92, 255, .55); color: #fff; }
.btn.run:active { transform: translateY(.5px); }
.btn.run:focus-visible { outline: 2px solid var(--brand-400); outline-offset: 2px; }
.btn.run .ic-play { width: 10px; height: 10px; opacity: .95; }
.arow .btn.run { height: 26px; padding: 0 11px 0 9px; font-size: 11px; align-self: center; }
@media (max-width: 700px) { .arow .btn.run { height: 30px; min-width: 62px; } }

/* the base .btn forces min-height:38px — a row action must be compact */
.btn.run, .arow .btn.run { min-height: 0; height: 26px; }
@media (max-width: 700px) { .btn.run, .arow .btn.run { min-height: 0; height: 30px; } }

/* ════════════════════════════════════════════════════════════
   Tunnels page
   ════════════════════════════════════════════════════════════ */
.tun-page { display: grid; gap: 18px; }
.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.tun-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tun-bar .muted { margin-left: auto; font-size: 11px; }

.tun-page .dash-top-right .search { width: 280px; }
@media (max-width: 700px) { .tun-page .dash-top-right .search { width: 100%; } }

.table-card { padding: 4px 6px; }
.tun-table .dt { width: 100%; }
.tun-table .dt thead th {
  position: sticky; top: 0; z-index: 2; background: rgba(9, 12, 18, .96); backdrop-filter: blur(6px);
  font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--fg-faint); font-weight: 500;
  padding: 10px 12px; border-bottom: 1px solid var(--line-strong);
}
.tun-table .dt tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 12px; }
.tun-table .dt tbody tr:hover td { background: rgba(255, 255, 255, .025); }
.tun-table .dt tbody tr[data-state="crit"] td:first-child { box-shadow: inset 3px 0 0 var(--crit); }
.tun-table .dt tbody tr[data-state="warn"] td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tun-table .dt tbody tr[data-state="ok"] td:first-child { box-shadow: inset 3px 0 0 rgba(16, 185, 129, .45); }
.tun-table .dt td:nth-child(1), .tun-table .dt th:nth-child(1) { width: 34px; padding-right: 0; }
.tun-table .dt td:nth-child(2) { font-family: var(--font-mono, ui-monospace); font-weight: 550; color: var(--fg); }
.tun-table .dt td.num, .tun-table .dt td:nth-child(n+7):nth-child(-n+9) { text-align: right; font-variant-numeric: tabular-nums; }
.tun-table .dt td:last-child { text-align: right; }
.tun-table .dt input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--brand-400); }

/* mobile cards */
.tun-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tun-card { padding: 14px; border-radius: 14px; background: var(--bg-panel, #0c1017);
  border: 1px solid var(--line); border-left: 3px solid rgba(16, 185, 129, .45); }
.tun-card[data-state="warn"] { border-left-color: var(--warn); }
.tun-card[data-state="crit"] { border-left-color: var(--crit); }
.tc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tc-head b { font-size: 13px; }
.tc-cc { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--fg-faint); }
.tc-head .pill { margin-left: auto; }
.tc-ip { font-size: 10.5px; color: var(--fg-faint); margin-bottom: 10px; }
.tc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tc-grid div { padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, .035); border: 1px solid var(--line); }
.tc-grid b { display: block; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tc-grid b small { font-size: 9px; color: var(--fg-faint); margin-left: 1px; }
.tc-grid span { display: block; margin-top: 1px; font-size: 9px; text-transform: uppercase; letter-spacing: .1em; color: var(--fg-faint); }

.tun-legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--fg-faint); }
.tun-legend i { width: 7px; height: 7px; border-radius: 50%; margin-left: 10px; }
.tun-legend i[data-state="crit"] { background: var(--crit); }
.tun-legend i[data-state="warn"] { background: var(--warn); }
.tun-legend i[data-state="ok"] { background: var(--ok); }
.tun-legend i:first-child { margin-left: 0; }

/* Tunnels — the mobile card list only exists on phones */
@media (min-width: 760px) { .tun-cards { display: none; } }
@media (max-width: 759px) { .tun-table { display: none; } .tun-cards { display: grid; } }

/* Tunnels — the header must wrap instead of pushing the page wider */
.tun-page .dash-top { flex-wrap: wrap; row-gap: 10px; }
.tun-page .dash-top-right { flex-wrap: wrap; row-gap: 8px; }
@media (max-width: 900px) {
  .tun-page .dash-top-right { width: 100%; }
  .tun-page .dash-top-right .search { width: 100%; flex: 1 1 auto; min-width: 0; }
}
@media (max-width: 759px) {
  .tun-page .dash-top { padding: 12px 14px; }
  .tun-page .dash-state span { font-size: 11px; }
  .tun-page .kpis { grid-template-columns: 1fr 1fr; }
}

/* a 12-column tunnel table has a wide min-content width — scroll it, never widen the page */
.table-card { overflow-x: auto; }
.table-card .dt { min-width: 720px; }
/* below 900 px the card list is the better read anyway */
@media (max-width: 900px) { .tun-table { display: none; } .tun-cards { display: grid; } }

/* filter chips must wrap on narrow screens — a single row of 8 chips forced the page to 841px */
.chips { flex-wrap: wrap; row-gap: 6px; }
.tun-bar { flex-wrap: wrap; }

/* Tunnels table — visual cells */
.tun-table .tun-id { font-weight: 600; letter-spacing: -.01em; }
.tun-table .ip { font-size: 11px; color: var(--fg-dim); }
.tun-table .cc { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg-faint); }
.mk { font-size: 11px; font-weight: 600; }
.mk[data-state="ok"] { color: var(--ok); }
.mk[data-state="crit"] { color: var(--crit); }
.mk[data-state="warn"] { color: var(--warn); }
.badge { display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: 600;
  text-align: center; background: rgba(245,158,11,.14); color: var(--warn); border: 1px solid rgba(245,158,11,.28); }
.tun-table .lat { display: inline-block; width: 46px; height: 4px; border-radius: 3px; background: var(--glass-2);
  overflow: hidden; margin-right: 8px; vertical-align: middle; }
.tun-table .lat i { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.tun-table .lat[data-state="warn"] i { background: var(--warn); }
.tun-table .dt tbody tr:hover .lat { filter: brightness(1.15); }

/* selected rows stay visible while you scroll a 170-row table */
.tun-table .dt tbody tr:has(input[type="checkbox"]:checked) td { background: rgba(124, 92, 255, .10); }
.tun-page .tc-head .btn.run { height: 24px; min-width: 0; padding: 0 8px; margin-left: 6px; }

/* transient confirmation for actions that re-render the page away */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90;
  padding: 9px 16px; border-radius: 999px; font-size: 12px; font-weight: 550;
  background: rgba(16, 185, 129, .14); color: #d9f7ec; border: 1px solid rgba(16, 185, 129, .35);
  box-shadow: 0 18px 40px -20px rgba(0, 0, 0, .9); backdrop-filter: blur(8px);
}
.toast[hidden] { display: none; }
.toast[data-tone="crit"] { background: rgba(244, 63, 94, .16); color: #ffe4e8; border-color: rgba(244, 63, 94, .38); }
@media (max-width: 560px) { .toast { left: 12px; right: 12px; transform: none; text-align: center; } }

/* ════════════════════════════════════════════════════════════
   Skeleton loading (Overview · Tunnels)
   ════════════════════════════════════════════════════════════ */
.sk {
  border-radius: 6px; background: linear-gradient(90deg, rgba(255,255,255,.055) 25%, rgba(255,255,255,.11) 37%, rgba(255,255,255,.055) 63%);
  background-size: 400% 100%; animation: sk-shimmer 1.4s ease-in-out infinite;
}
@keyframes sk-shimmer { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; background: rgba(255,255,255,.07) } }

.sk-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sk-col { display: grid; gap: 8px; flex: 1; min-width: 0; }
.sk-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-width: 240px; }
.sk-card { pointer-events: none; }
.dash-top.sk-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 18px; }
.sk-hero { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 28px; }
@media (max-width: 1180px) { .sk-hero { grid-template-columns: auto 1fr; } .sk-grid2 { display: none; } }
@media (max-width: 700px) { .sk-hero { grid-template-columns: 1fr; } .sk-grid2 { display: grid; } }
.sk-table .sk-tr { padding: 12px; border-bottom: 1px solid var(--line); margin: 0; }

/* ════════════════════════════════════════════════════════════
   Tunnel detail (bottom sheet)
   ════════════════════════════════════════════════════════════ */
.tdet { display: grid; gap: 16px; }
.tdet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tdet-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tdet-id h3 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.tdet-cc { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--fg-faint);
  padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); background: rgba(255,255,255,.035); }
.tdet-badge { font-size: 9.5px; font-weight: 700; letter-spacing: .12em; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--fg-dim); }
.tdet-badge[data-state="ok"] { color: var(--ok); border-color: rgba(16,185,129,.35); background: rgba(16,185,129,.10); }
.tdet-badge[data-state="warn"] { color: var(--warn); border-color: rgba(245,158,11,.35); background: rgba(245,158,11,.10); }
.tdet-badge[data-state="crit"] { color: var(--crit); border-color: rgba(244,63,94,.38); background: rgba(244,63,94,.12); }
.tdet-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.tdet-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .tdet-tiles { grid-template-columns: 1fr 1fr; } }
.tdet-tile { padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.tdet-tile span { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--fg-faint); }
.tdet-tile b { display: block; margin-top: 6px; font-size: 20px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tdet-tile b small { font-size: 10px; color: var(--fg-faint); margin-left: 2px; }
.tdet-tile em { display: block; margin-top: 4px; font-style: normal; font-size: 10px; color: var(--fg-faint); }
.tdet-tile[data-tone="warn"] b { color: var(--warn); }

.tdet-sec { border-top: 1px solid var(--line); padding-top: 12px; }
.tdet-sec h4 { margin: 0 0 8px; font-size: 9.5px; text-transform: uppercase; letter-spacing: .16em; color: var(--fg-faint); font-weight: 600; }
.tdet-rows { display: grid; gap: 1px; background: var(--line); border-radius: 10px; overflow: hidden; }
.tdet-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--bg-panel, #0c1017); flex-wrap: wrap; }
.tdet-row > span { font-size: 11.5px; color: var(--fg-faint); }
.tdet-row > b { font-size: 12px; font-weight: 600; display: inline-flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tdet-note { font-style: normal; font-size: 10px; color: var(--fg-faint); }

/* Details button in the table — quiet until you hover the row */
.tdet-open { gap: 4px; padding: 0 9px 0 6px; color: var(--fg-dim); border-color: var(--line); background: rgba(255,255,255,.03); }
.tdet-open .ic { width: 12px; height: 12px; opacity: .7; }
.tun-table .dt tbody tr:hover .tdet-open { color: var(--brand-300); border-color: rgba(124,92,255,.35); background: rgba(124,92,255,.10); }

/* ════════════════════════════════════════════════════════════
   Filter chips — segmented control
   ════════════════════════════════════════════════════════════ */
.chips {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px;
  background: rgba(255, 255, 255, .03); border: 1px solid var(--line);
}
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px;
  border: 1px solid transparent; border-radius: 9px; background: none; cursor: pointer;
  font: inherit; font-size: 11.5px; font-weight: 550; letter-spacing: .01em; color: var(--fg-dim);
  transition: background var(--t-fast) ease, color var(--t-fast) ease, border-color var(--t-fast) ease;
}
.chip:hover { background: rgba(255, 255, 255, .05); color: var(--fg); }
.chip b {
  min-width: 20px; padding: 1px 6px; border-radius: 6px; font-size: 10px; font-weight: 650;
  background: rgba(255, 255, 255, .07); color: var(--fg-dim); font-variant-numeric: tabular-nums;
}
.chip.is-active {
  background: linear-gradient(180deg, rgba(124, 92, 255, .22), rgba(124, 92, 255, .12));
  border-color: rgba(124, 92, 255, .38); color: #fff; box-shadow: 0 1px 0 rgba(255, 255, 255, .10) inset;
}
.chip.is-active b { background: rgba(255, 255, 255, .16); color: #fff; }
.chip[data-tone="crit"] b { background: rgba(244, 63, 94, .18); color: #ffb4c0; }
.chip[data-tone="warn"] b { background: rgba(245, 158, 11, .18); color: #ffd699; }
.chip[data-tone="ok"] b { background: rgba(16, 185, 129, .16); color: #a7f3d0; }
.chip[data-tone="crit"].is-active { background: rgba(244, 63, 94, .16); border-color: rgba(244, 63, 94, .4); }
.chip[data-tone="warn"].is-active { background: rgba(245, 158, 11, .16); border-color: rgba(245, 158, 11, .4); }
@media (max-width: 700px) {
  .chips { display: flex; width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; }
}

/* on phones the chip rail scrolls inside itself — it must never widen the page */
@media (max-width: 700px) {
  .tun-bar { min-width: 0; }
  .tun-bar > .chips { flex: 1 1 auto; min-width: 0; max-width: 100%; }
  .chips { width: auto; max-width: 100%; }
}

/* bulk bar: pinned to the viewport so it is discoverable while scrolling a long table */
#bulk-bar:not([hidden]) {
  position: sticky; bottom: 12px; z-index: 20;
  background: linear-gradient(180deg, rgba(28, 23, 56, .96), rgba(18, 15, 38, .98));
  border: 1px solid rgba(124, 92, 255, .38); border-radius: 14px;
  box-shadow: 0 20px 44px -22px rgba(0, 0, 0, .9), 0 1px 0 rgba(255, 255, 255, .06) inset;
  backdrop-filter: blur(10px);
}
#bulk-bar:not([hidden]) b { color: #fff; font-size: 12px; }
#bulk-bar .bulk-pick { color: var(--fg-2); }
#bulk-bar .btn.ghost { border: 1px solid var(--line-strong); background: rgba(255,255,255,.04); }
.tun-table .pick-col { width: 40px; padding-left: 12px; }
.tun-table .pick-col input { width: 15px; height: 15px; accent-color: var(--brand-400); }

/* selection controls on every screen */
.sel-all { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; font-size: 11px; color: var(--fg-dim);
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.03); cursor: pointer; }
.sel-all input { width: 14px; height: 14px; accent-color: var(--brand-400); }
.tun-card .tc-pick { width: 17px; height: 17px; accent-color: var(--brand-400); flex: 0 0 auto; }
.tun-card[data-picked="1"] { border-color: rgba(124,92,255,.45); background: rgba(124,92,255,.07); }
@media (min-width: 901px) { .sel-all { display: none; } }  /* the table header already has one */

/* ════════════════════════════════════════════════════════════
   Selection: custom checkbox, select-all chip, premium bulk bar
   ════════════════════════════════════════════════════════════ */
.tun-page input[type="checkbox"], .sel-all input[type="checkbox"], #bulk-bar input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 17px; height: 17px; border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .05);
  display: inline-grid; place-items: center; cursor: pointer; margin: 0;
  transition: background var(--t-fast) ease, border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
.tun-page input[type="checkbox"]:hover { border-color: rgba(124, 92, 255, .6); background: rgba(124, 92, 255, .12); }
.tun-page input[type="checkbox"]:checked {
  background: linear-gradient(180deg, var(--brand-400), var(--brand-600)); border-color: transparent;
  box-shadow: 0 0 0 3px rgba(124, 92, 255, .18);
}
.tun-page input[type="checkbox"]:checked::after {
  content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-.5px, -1px); border-radius: 1px;
}
.tun-page input[type="checkbox"]:indeterminate {
  background: rgba(124, 92, 255, .9); border-color: transparent;
}
.tun-page input[type="checkbox"]:indeterminate::after { content: ""; width: 9px; height: 2px; background: #fff; border-radius: 2px; }
.tun-page input[type="checkbox"]:focus-visible { outline: 2px solid var(--brand-400); outline-offset: 2px; }

/* select-all: a chip, not a bare label */
.sel-all {
  display: inline-flex; align-items: center; gap: 9px; padding: 7px 12px 7px 9px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .04); cursor: pointer;
  font-size: 11.5px; color: var(--fg-dim); transition: border-color var(--t-fast) ease, background var(--t-fast) ease;
}
.sel-all:hover { border-color: rgba(124, 92, 255, .45); background: rgba(124, 92, 255, .08); color: var(--fg); }
.sel-all b { color: var(--fg-faint); font-weight: 600; }
.sel-all:has(input:checked) { border-color: rgba(124, 92, 255, .5); background: rgba(124, 92, 255, .12); color: #fff; }

/* the bulk bar itself */
#bulk-bar:not([hidden]) {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(30, 25, 60, .92), rgba(16, 14, 33, .96));
  border: 1px solid rgba(124, 92, 255, .34);
  box-shadow: 0 24px 50px -26px rgba(0, 0, 0, .95), 0 1px 0 rgba(255, 255, 255, .07) inset;
  backdrop-filter: blur(14px);
}
.bulk-count { display: inline-flex; align-items: baseline; gap: 5px; padding: 4px 10px; border-radius: 9px;
  background: rgba(124, 92, 255, .18); border: 1px solid rgba(124, 92, 255, .32); }
.bulk-count b { font-size: 14px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.bulk-count span { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: #cbbdff; }
.bulk-sep { width: 1px; height: 22px; background: rgba(255, 255, 255, .12); }
.bulk-act { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line-strong); color: var(--fg); }
.bulk-act:hover { background: rgba(255, 255, 255, .1); }
.bulk-act.danger { color: #ffb4c0; border-color: rgba(244, 63, 94, .35); background: rgba(244, 63, 94, .10); }
.bulk-act.danger:hover { background: rgba(244, 63, 94, .18); }
.bulk-act .ic { width: 13px; height: 13px; }
.bulk-hint { font-size: 10.5px; color: var(--fg-faint); margin-left: auto; }
@media (max-width: 700px) {
  .bulk-hint { display: none; }
  #bulk-bar:not([hidden]) { gap: 8px; padding: 10px; }
  .bulk-act { flex: 1 1 auto; justify-content: center; }
}

/* detail sheet action row */
.tdet-actions { padding: 6px; border-radius: 12px; background: rgba(255, 255, 255, .035); border: 1px solid var(--line); }
.tdet-actions .btn { height: 30px; }
.tdet-actions .icon-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .04); }
.tdet-actions .icon-btn:hover { background: rgba(255, 255, 255, .08); }
.tdet-actions .ic { width: 13px; height: 13px; }

/* bulk bar as a bottom dock — floating over the table, never wedged mid-scroll */
#bulk-bar:not([hidden]) {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  width: min(1120px, calc(100vw - 40px)); z-index: 80;
  padding: 10px 14px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(34, 28, 68, .96), rgba(14, 12, 28, .98));
  border: 1px solid rgba(124, 92, 255, .38);
  box-shadow: 0 30px 60px -28px rgba(0, 0, 0, .95), 0 1px 0 rgba(255, 255, 255, .08) inset;
  animation: bulk-in .18s cubic-bezier(.2, .8, .2, 1);
}
@keyframes bulk-in { from { opacity: 0; transform: translate(-50%, 10px) } to { opacity: 1; transform: translate(-50%, 0) } }
@media (prefers-reduced-motion: reduce) { #bulk-bar:not([hidden]) { animation: none } }
#bulk-bar .bulk-hint kbd {
  font: inherit; font-size: 9.5px; padding: 1px 5px; border-radius: 4px; margin: 0 2px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .07); color: var(--fg-dim);
}
@media (max-width: 700px) {
  #bulk-bar:not([hidden]) { left: 12px; right: 12px; width: auto; transform: none; bottom: 12px; border-radius: 16px; }
  @keyframes bulk-in { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: none } }
}

/* the dock floats over content — make room so the last row is never hidden behind it */
body:has(#bulk-bar:not([hidden])) #main { padding-bottom: 96px; }
@media (max-width: 700px) { body:has(#bulk-bar:not([hidden])) #main { padding-bottom: 150px; } }

/* phone: two clean rows — count + clear on top, the two actions as a pair below */
@media (max-width: 700px) {
  #bulk-bar:not([hidden]) {
    display: grid; grid-template-columns: 1fr auto; grid-auto-rows: auto;
    gap: 8px 10px; padding: 10px 12px; border-radius: 16px;
  }
  #bulk-bar .bulk-count { grid-column: 1; grid-row: 1; justify-self: start; align-self: center; padding: 5px 10px; }
  #bulk-bar .bulk-count b { font-size: 15px; }
  #bulk-bar .bulk-sep,
  #bulk-bar .bulk-hint,
  #bulk-bar #bulk-msg { display: none; }
  #bulk-bar .btn[data-bulk-clear] {
    grid-column: 2; grid-row: 1; justify-self: end; align-self: center;
    height: 30px; padding: 0 12px; border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--fg-dim);
  }
  #bulk-bar .bulk-act { grid-row: 2; height: 42px; justify-content: center; font-size: 12px; border-radius: 11px; }
  #bulk-bar .bulk-act[data-bulk="restart"] { grid-column: 1; }
  #bulk-bar .bulk-act[data-bulk="mark_down"] { grid-column: 2; }
  #bulk-bar .bulk-act .ic { width: 15px; height: 15px; }
}

/* phone: one compact row — count chip, two square action buttons, a clear × */
@media (max-width: 700px) {
  #bulk-bar:not([hidden]) {
    display: flex; flex-wrap: nowrap; align-items: center; gap: 8px;
    padding: 9px 10px; height: 58px;
  }
  #bulk-bar .bulk-count { padding: 4px 9px; flex: 0 0 auto; }
  #bulk-bar .bulk-count span { display: none; }
  #bulk-bar .bulk-count b::after { content: " selected"; font-size: 10px; font-weight: 500; letter-spacing: .06em; color: #cbbdff; }
  #bulk-bar .bulk-sep, #bulk-bar .bulk-hint, #bulk-bar #bulk-msg { display: none; }
  #bulk-bar .bulk-act { width: 42px; height: 42px; padding: 0; flex: 0 0 42px; border-radius: 11px; }
  #bulk-bar .bulk-act span { display: none; }
  #bulk-bar .bulk-act .ic { width: 17px; height: 17px; }
  #bulk-bar .bulk-clear { margin-left: auto; width: 42px; height: 42px; padding: 0; flex: 0 0 42px;
    font-size: 0; border-radius: 11px; border: 1px solid var(--line); background: rgba(255,255,255,.04); }
  #bulk-bar .bulk-clear::after { content: "×"; font-size: 20px; line-height: 1; color: var(--fg-dim); }
}

/* phone: a full-width, obvious "select all" row and a bigger tap target per card */
@media (max-width: 900px) {
  .tun-bar { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .tun-bar .chips { order: 1; }
  .tun-bar .sel-all { order: 2; margin-left: 0; width: 100%; justify-content: flex-start; padding: 11px 13px; border-radius: 12px; font-size: 12px; }
  .tun-bar .sel-all span { display: inline-flex; align-items: baseline; gap: 5px; }
  .tun-bar .tun-count, .tun-bar > .muted { order: 3; margin-left: 0; }
}
@media (max-width: 700px) {
  .tun-card .tc-pick { width: 22px; height: 22px; }
  .tun-card .tc-head { gap: 10px; }
}

@media (max-width: 700px) {
  .tun-page .tun-card .tc-pick { width: 22px; height: 22px; border-radius: 6px; }
  .tun-bar .sel-all { min-height: 48px; height: 48px; white-space: nowrap; }
  .tun-bar .sel-all > span { white-space: nowrap; }
}

@media (max-width: 700px) {
  #bulk-bar .bulk-clear { height: 42px; min-height: 42px; }
  #bulk-bar:not([hidden]) { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
}
