/* ==========================================================================
   kamal·ui — Component layer
   A small, deliberate set of reusable classes. Naming is loosely BEM:
   .block, .block__element, .block--modifier. Status is expressed through a
   single data attribute (data-status / data-tone) so partials stay clean.
   ========================================================================== */

/* ==========================================================================
   1. App shell / layout
   ========================================================================== */
.app { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}
.wordmark__dot { color: var(--accent); margin: 0 1px; }
.wordmark__sub { color: var(--text-faint); font-weight: var(--weight-normal); }
.wordmark__logo {
  height: 32px; width: auto; margin-right: 10px; flex: none;
  filter: drop-shadow(0 1px 2px color-mix(in srgb, var(--accent) 22%, transparent));
}

.topbar__nav { display: flex; align-items: center; gap: 3px; margin-left: var(--space-3); }
.topbar__spacer { flex: 1 1 auto; }
.topbar__right { display: flex; align-items: center; gap: var(--space-3); }

.app__main {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-10) var(--space-6) var(--space-20);
}

.page-head { margin-bottom: var(--space-6); }
.page-head__title { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.page-head__title h1 { font-size: var(--text-3xl); }
.page-head__desc {
  color: var(--text-muted); margin-top: var(--space-2);
  font-size: var(--text-md); line-height: var(--leading-normal);
}
/* A small teal eyebrow above the H1 — gives each page a confident "label". */
.page-head__eyebrow {
  font-size: var(--text-xs); font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  color: var(--accent-hover); margin-bottom: var(--space-1);
}
/* Breadcrumb line above the app-detail H1. */
.page-head__crumb {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-xs); color: var(--text-faint); margin-bottom: var(--space-2);
}
.section { margin-top: var(--space-10); }
/* The dashboard's live state lives in an inline <turbo-frame>; make it a block
   and give it the same breathing room a .section gets so the hero (and the fleet
   chart under it) don't butt right up against the stat grid. */
#dashboard { display: block; margin-top: var(--space-10); }
.section__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-4);
}
.section__title {
  font-size: var(--text-sm); font-weight: var(--weight-bold);
  letter-spacing: 0.01em;
  color: var(--text);
}
/* A quiet sub-label that can sit beside a section title (its own line). */
.section__sub {
  display: block; font-size: var(--text-xs); color: var(--text-subtle);
  font-weight: var(--weight-normal); letter-spacing: 0; margin-top: 2px;
}

/* ==========================================================================
   2. Nav items (top nav + sidebar share the look)
   ========================================================================== */
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 34px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item[aria-current="page"], .nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: var(--weight-semibold);
}
.nav-item__icon { width: 15px; height: 15px; opacity: 0.8; }
.nav-item__count {
  font-size: var(--text-2xs); color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   3. Buttons
   ========================================================================== */
.btn {
  --_bg: var(--surface);
  --_fg: var(--text);
  --_bd: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  color: var(--_fg);
  background: var(--_bg);
  border: 1px solid var(--_bd);
  border-radius: var(--radius-pill);
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); box-shadow: var(--shadow-xs); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn__icon { width: 15px; height: 15px; }

.btn--primary {
  --_bg: var(--accent); --_fg: var(--accent-fg); --_bd: var(--accent);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 30%, transparent),
              0 2px 8px color-mix(in srgb, var(--accent) 22%, transparent);
}
.btn--primary:hover {
  background: var(--accent-hover); border-color: var(--accent-hover);
  box-shadow: 0 2px 4px color-mix(in srgb, var(--accent) 32%, transparent),
              0 4px 14px color-mix(in srgb, var(--accent) 26%, transparent);
}

.btn--danger {
  --_bg: var(--surface); --_fg: var(--bad-fg); --_bd: var(--bad-bd);
}
.btn--danger:hover { background: var(--bad-bg); border-color: var(--bad-fg); color: var(--bad-fg); }

.btn--ghost {
  --_bg: transparent; --_bd: transparent; --_fg: var(--text-muted);
  box-shadow: none;
}
.btn--ghost:hover { background: var(--surface-hover); border-color: transparent; color: var(--text); box-shadow: none; }

.btn--sm { height: 30px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn--icon { width: 36px; padding: 0; }
.btn--block { width: 100%; }

/* ==========================================================================
   4. Status pill + bare status dot
   data-status: running|healthy | starting|warning | unhealthy|stopped|exited | neutral
   ========================================================================== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px 0 9px;
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: var(--_fg, var(--neutral-fg));
  background: var(--_bg, var(--neutral-bg));
  border: 1px solid var(--_bd, var(--neutral-bd));
}
.pill__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
}

.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--_fg, var(--neutral-fg)); flex: none;
}
.dot--pulse { position: relative; }
.dot--pulse::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 1px solid var(--_fg); opacity: 0.5;
  animation: pulse 1.8s var(--ease) infinite;
}
@keyframes pulse {
  0%   { transform: scale(0.8); opacity: 0.6; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* Status tones, shared by .pill and .dot via data-status */
[data-status="running"], [data-status="healthy"], [data-status="active"],
[data-status="ok"], [data-status="up"] {
  --_fg: var(--ok-fg); --_bg: var(--ok-bg); --_bd: var(--ok-bd);
}
[data-status="starting"], [data-status="warning"], [data-status="restarting"],
[data-status="deploying"], [data-status="pending"] {
  --_fg: var(--warn-fg); --_bg: var(--warn-bg); --_bd: var(--warn-bd);
}
[data-status="unhealthy"], [data-status="stopped"], [data-status="failed"],
[data-status="error"], [data-status="down"] {
  --_fg: var(--bad-fg); --_bg: var(--bad-bg); --_bd: var(--bad-bd);
}
[data-status="exited"], [data-status="none"], [data-status="neutral"],
[data-status="off"], [data-status="paused"] {
  --_fg: var(--neutral-fg); --_bg: var(--neutral-bg); --_bd: var(--neutral-bd);
}

/* ==========================================================================
   5. Cards
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
}
.card__head svg { color: var(--accent); }
.card__title { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.card__body { padding: var(--space-6); }
.card__body--flush { padding: 0; }
.card__foot {
  padding: var(--space-3) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==========================================================================
   6. Stat (metric) blocks
   ========================================================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-4);
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-5) var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat__label {
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
  color: var(--text-muted);
  display: flex; align-items: center; gap: var(--space-2);
}
.stat__value {
  margin-top: var(--space-3);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  line-height: 1.05;
}
.stat__unit { font-size: var(--text-lg); color: var(--text-subtle); font-weight: var(--weight-medium); }
.stat__meta { margin-top: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); line-height: var(--leading-normal); }

/* ==========================================================================
   7. Table
   ========================================================================== */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table thead th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
  color: var(--text-muted);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-faint);
  color: var(--text);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-hover); }
.table--rows tbody tr { cursor: pointer; }
.cell--num { text-align: right; font-variant-numeric: tabular-nums; }
.cell--mono { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }
.cell--tight { width: 1%; white-space: nowrap; }

/* kamal-proxy request log: method bolded, long paths truncate within a cap so
   the row stays scannable (full path in a title= tooltip). */
.requests .req__method { font-weight: var(--weight-semibold); color: var(--text); }
.requests .req__path { display: inline-block; max-width: 32ch; vertical-align: bottom; }

/* Domains: keep host + long cells to a single line (full value in title=) so
   rows stay an even height — a long host like "pixelglass-web" no longer wraps
   to two lines and makes its row taller than its neighbors on mobile. */
.dom__host { min-width: 0; flex: 1 1 auto; max-width: 100%; }
.dom__host-cell .row { min-width: 0; flex-wrap: nowrap; }
.dom__cell { display: inline-block; max-width: 28ch; vertical-align: bottom; }

/* ==========================================================================
   8. Container group (service > role > containers) — the dashboard centerpiece
   ========================================================================== */
.service {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.service + .service { margin-top: var(--space-5); }
.service__head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 4%, var(--surface)), var(--surface));
}
.service__title { display: flex; align-items: center; gap: var(--space-2); }
.service__title svg { color: var(--accent); }
.service__name { font-size: var(--text-lg); font-weight: var(--weight-bold); }
.service__dest {
  font-family: var(--font-mono); font-size: var(--text-2xs);
  color: var(--accent-hover); font-weight: var(--weight-medium);
  padding: 3px 9px; border-radius: var(--radius-pill);
  background: var(--accent-soft);
}
.service__summary { display: flex; align-items: center; gap: var(--space-4); margin-left: auto; }
.summary-stat { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--weight-medium); }

.role {
  padding: var(--space-3) var(--space-5) var(--space-4);
}
.role + .role { border-top: 1px solid var(--border-faint); }
.role__head {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) 0 var(--space-3);
}
.role__head svg { color: var(--text-faint); }
.role__name {
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
  color: var(--text-muted);
}
.role__badge {
  font-size: var(--text-2xs); color: var(--text-subtle);
  font-variant-numeric: tabular-nums; font-weight: var(--weight-medium);
}

/* container row — scannable, status-first */
.crow {
  display: grid;
  grid-template-columns: 110px minmax(140px, 1.4fr) 80px 90px minmax(0, 0.9fr) 96px 110px 84px;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  transition: background var(--dur-fast) var(--ease);
}
.crow:hover { background: var(--surface-hover); }
.crow + .crow { margin-top: 2px; }
.crow__name { font-weight: var(--weight-medium); display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.crow__name .truncate { display: inline-block; max-width: 100%; }
.crow__cell--image .truncate { display: block; max-width: 100%; }
.crow__label {
  font-size: var(--text-2xs); text-transform: uppercase;
  letter-spacing: var(--tracking-wide); color: var(--text-faint);
}
.crow__value { font-size: var(--text-xs); color: var(--text-muted); }
.crow__sha {
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-inset); padding: 2px 7px; border-radius: var(--radius-xs);
}
.crow__head { color: var(--text-subtle); padding-top: 0; padding-bottom: var(--space-2); }
.crow__head .crow__cell { font-size: var(--text-2xs); font-weight: var(--weight-semibold); letter-spacing: 0.01em; color: var(--text-subtle); }
.crow__cell { min-width: 0; }
.usage {
  display: inline-flex; align-items: baseline; gap: 4px;
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--text); white-space: nowrap;
}
.usage__cpu { font-weight: var(--weight-semibold); }
.usage__mem { color: var(--text-faint); }
.usage--empty { color: var(--text-faint); }
.ports { display: flex; flex-wrap: wrap; gap: 4px; }
.port {
  font-family: var(--font-mono); font-size: var(--text-2xs);
  color: var(--accent-hover); background: var(--accent-soft);
  padding: 2px 7px; border-radius: var(--radius-xs);
}

@container (max-width: 760px) {
  .crow { grid-template-columns: 96px 1fr auto; }
  .crow__cell--role, .crow__cell--sha, .crow__cell--image, .crow__cell--ports, .crow__cell--usage { display: none; }
}

/* ==========================================================================
   9. Definition list (inspect / env)
   ========================================================================== */
.dl {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
}
.dl > div {
  display: contents;
}
.dl dt, .dl dd {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-faint);
}
.dl dt {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.dl dd {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text);
  word-break: break-word;
}
.dl > div:last-child dt, .dl > div:last-child dd { border-bottom: none; }
.secret { color: var(--text-faint); letter-spacing: 0.12em; user-select: none; }
.tag-secret {
  font-family: var(--font-sans); font-size: var(--text-2xs);
  color: var(--warn-fg); background: var(--warn-bg);
  border: 1px solid var(--warn-bd);
  padding: 0 5px; border-radius: var(--radius-xs); margin-left: var(--space-2);
}

/* ==========================================================================
   10. Badges (small, for TLS / kind labels)
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px;
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  border-radius: var(--radius-pill);
  color: var(--_fg, var(--neutral-fg));
  background: var(--_bg, var(--neutral-bg));
  border: 1px solid var(--_bd, var(--neutral-bd));
}
.badge--accent { --_fg: var(--accent-hover); --_bg: var(--accent-soft); --_bd: transparent; }
.badge--plain  { --_fg: var(--text-muted); --_bg: transparent; --_bd: var(--border-strong); }

/* ==========================================================================
   11. Empty state
   ========================================================================== */
.empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: var(--space-2);
  padding: var(--space-16) var(--space-6);
  color: var(--text-muted);
}
.empty__icon {
  width: 56px; height: 56px; border-radius: var(--radius-lg);
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  margin-bottom: var(--space-3);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 14%, transparent);
}
.empty__title { font-size: var(--text-lg); font-weight: var(--weight-bold); color: var(--text); }
.empty__desc { font-size: var(--text-sm); max-width: 42ch; line-height: var(--leading-normal); }

/* ==========================================================================
   12. Log viewer (terminal panel)
   ========================================================================== */
.logs {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--term-bg);
  box-shadow: var(--shadow-sm);
}
.logs__bar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  background: color-mix(in srgb, var(--term-text) 5%, var(--term-bg));
  border-bottom: 1px solid var(--term-line);
}
.logs__title {
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--term-text); display: flex; align-items: center; gap: var(--space-2);
}
.logs__spacer { flex: 1 1 auto; }
.logs__follow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-2xs); color: var(--term-dim);
  font-family: var(--font-mono);
}
/* Segmented tail (line-count) selector. */
.logs__tail { display: inline-flex; }
.logs__tail-btn {
  appearance: none; cursor: pointer;
  height: 24px; padding: 0 8px;
  font-family: var(--font-mono); font-size: var(--text-2xs); line-height: 1;
  color: var(--term-dim);
  background: transparent;
  border: 1px solid var(--term-line);
}
.logs__tail-btn:first-child { border-radius: var(--radius-xs) 0 0 var(--radius-xs); }
.logs__tail-btn:last-child  { border-radius: 0 var(--radius-xs) var(--radius-xs) 0; }
.logs__tail-btn + .logs__tail-btn { border-left: 0; }
.logs__tail-btn:hover { color: var(--term-text); }
.logs__tail-btn.is-active {
  color: var(--ok-fg);
  background: color-mix(in srgb, var(--ok-fg) 14%, transparent);
  border-color: color-mix(in srgb, var(--ok-fg) 40%, var(--term-line));
}

/* Client-side filter input. */
.logs__filter {
  height: 24px; width: 140px; padding: 0 8px;
  font-family: var(--font-mono); font-size: var(--text-2xs);
  color: var(--term-text);
  background: var(--term-bg);
  border: 1px solid var(--term-line);
  border-radius: var(--radius-xs);
}
.logs__filter::placeholder { color: var(--term-dim); }
.logs__filter:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent-300) 50%, var(--term-line));
}
.switch {
  position: relative; width: 28px; height: 16px; border-radius: var(--radius-pill);
  background: var(--term-line); transition: background var(--dur) var(--ease); flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%; background: var(--term-dim);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.switch.is-on { background: color-mix(in srgb, var(--ok-fg) 35%, var(--term-line)); }
.switch.is-on::after { transform: translateX(12px); background: var(--ok-fg); }

.logs__body {
  font-family: var(--font-mono); font-size: var(--text-xs);
  line-height: var(--leading-loose);
  color: var(--term-text);
  padding: var(--space-3) 0;
  max-height: 440px; overflow: auto;
}
.logline {
  display: grid; grid-template-columns: 92px 52px 1fr;
  gap: var(--space-3); padding: 1px var(--space-4);
  align-items: baseline;
  white-space: pre-wrap; word-break: break-word;
}
/* The filter toggles [hidden]; .logline's display:grid would otherwise win
   over the UA [hidden]{display:none} (class beats attribute), so re-assert it. */
.logline[hidden] { display: none; }
.logline__time { white-space: nowrap; }
.logline:hover { background: rgba(255,255,255,0.025); }
.logline__time { color: var(--term-dim); }
.logline__lvl { text-transform: uppercase; font-size: var(--text-2xs); align-self: center; }
.logline__lvl[data-lvl="info"]  { color: var(--accent-300); }
.logline__lvl[data-lvl="warn"]  { color: var(--warn-fg); }
.logline__lvl[data-lvl="error"] { color: var(--bad-fg); }
.logline__lvl[data-lvl="debug"] { color: var(--term-dim); }
.logline__msg { color: var(--term-text); }

/* ==========================================================================
   13. Toast / flash
   ========================================================================== */
.toasts {
  position: fixed; right: var(--space-5); bottom: var(--space-5);
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--space-2);
  width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--_fg, var(--neutral-fg));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
}
.toast__icon { color: var(--_fg, var(--neutral-fg)); flex: none; margin-top: 1px; }
.toast__body { flex: 1 1 auto; min-width: 0; }
.toast__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.toast__msg { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.toast__close { color: var(--text-faint); flex: none; }
.toast__close:hover { color: var(--text); }
.toast[data-tone="success"] { --_fg: var(--ok-fg); }
.toast[data-tone="warning"] { --_fg: var(--warn-fg); }
.toast[data-tone="error"]   { --_fg: var(--bad-fg); }
.toast[data-tone="info"]    { --_fg: var(--accent); }

/* Inline flash banner variant */
.flash {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--_bd, var(--border));
  background: var(--_bg, var(--surface));
  color: var(--_fg, var(--text));
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.flash[data-tone="success"] { --_fg: var(--ok-fg); --_bg: var(--ok-bg); --_bd: var(--ok-bd); }
.flash[data-tone="warning"] { --_fg: var(--warn-fg); --_bg: var(--warn-bg); --_bd: var(--warn-bd); }
.flash[data-tone="error"]   { --_fg: var(--bad-fg); --_bg: var(--bad-bg); --_bd: var(--bad-bd); }

/* ==========================================================================
   14. Auth / login
   ========================================================================== */
.auth {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: var(--space-6);
  background:
    radial-gradient(1100px 520px at 50% -12%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 62%),
    radial-gradient(620px 420px at 14% 108%, color-mix(in srgb, var(--teal-300) 12%, transparent), transparent 60%),
    var(--bg);
}
.auth__card {
  width: 100%; max-width: 392px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-pop);
  padding: var(--space-10) var(--space-8) var(--space-8);
}
.auth__brand {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-3); margin-bottom: var(--space-6);
}
.auth__logo {
  height: 76px; width: auto;
  filter: drop-shadow(0 6px 16px color-mix(in srgb, var(--accent) 28%, transparent));
}
.auth__title { text-align: center; font-size: var(--text-2xl); }
.auth__desc { text-align: center; color: var(--text-muted); font-size: var(--text-md); margin: var(--space-2) 0 var(--space-8); }

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field + .field { margin-top: var(--space-5); }
.field__label { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text); }
.input {
  height: 46px; padding: 0 var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  width: 100%;
}
.input::placeholder { color: var(--text-faint); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.auth__card .btn--block { height: 46px; font-size: var(--text-md); }
.auth__foot { text-align: center; margin-top: var(--space-6); font-size: var(--text-xs); color: var(--text-faint); }

/* ==========================================================================
   15. Connection-status dot in topbar + small helpers
   ========================================================================== */
.conn {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-muted);
  padding: 5px 11px 5px 9px; border-radius: var(--radius-pill);
  background: var(--bg-sunken); border: 1px solid var(--border);
}

.avatar {
  width: 32px; height: 32px; border-radius: var(--radius-pill);
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--teal-300), var(--teal-600));
  color: #fff;
  font-size: var(--text-xs); font-weight: var(--weight-bold);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  box-shadow: var(--shadow-xs);
}

.kbd {
  font-family: var(--font-mono); font-size: var(--text-2xs);
  padding: 1px 5px; border-radius: var(--radius-xs);
  background: var(--bg-inset); border: 1px solid var(--border);
  color: var(--text-subtle);
}

/* ==========================================================================
   16. Activity feed
   ========================================================================== */
.feed { list-style: none; }
.feed__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
}
.feed__item + .feed__item { border-top: 1px solid var(--border-faint); }
.feed__icon {
  width: 34px; height: 34px; border-radius: var(--radius-pill);
  display: grid; place-items: center;
  color: var(--_fg, var(--neutral-fg));
  background: var(--_bg, var(--neutral-bg));
  border: 1px solid var(--_bd, var(--neutral-bd));
}
.feed__body { min-width: 0; }
.feed__line { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.feed__actor { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.feed__action { color: var(--text-muted); font-size: var(--text-sm); }
.feed__target { font-size: var(--text-xs); color: var(--text); }
.feed__detail { margin-top: 3px; font-size: var(--text-xs); color: var(--text-muted); }
.feed__time { font-size: var(--text-xs); color: var(--text-faint); white-space: nowrap; padding-top: 4px; }

.divider { height: 18px; width: 1px; background: var(--border); }
.meta-row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.meta { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-muted); }
.meta__k { color: var(--text-faint); }

/* ==========================================================================
   17. Type-to-confirm popover (destructive removals)
   A <details> disclosure: summary is the trigger button, the panel holds the
   type-to-confirm form. No JS needed to open; Stimulus gates the submit.
   ========================================================================== */
.confirm-pop { position: relative; display: inline-block; }
.confirm-pop > summary { list-style: none; cursor: pointer; }
.confirm-pop > summary::-webkit-details-marker { display: none; }
/* Explicitly collapse the closed panel. It's position:fixed with a transform,
   so a transformed/fixed child of a closed <details> can still get laid out
   (and, off-screen-centered, push horizontal scroll) when it isn't clipped by a
   scroll-container ancestor — assert display:none rather than rely on the UA. */
.confirm-pop:not([open]) > .confirm-pop__panel { display: none; }
/* A fixed bottom-centered sheet at every width: position:fixed escapes the
   table-wrap's overflow (absolute positioning got clipped by it on desktop). */
.confirm-pop__panel {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%);
  z-index: var(--z-toast);
  width: min(400px, calc(100vw - 24px));
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--bad-bd);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  text-align: left;
  white-space: normal;
}
.confirm-pop__warn {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  line-height: var(--leading-normal);
}
.confirm-pop__warn strong { color: var(--bad-fg); }
.confirm-pop__label {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-subtle);
  margin-bottom: var(--space-2);
}
.confirm-pop__panel .input { margin-bottom: 0; }

/* Retained (old/dead) container rows on the app-detail Lifecycle table. */
.row--retained td { color: var(--text-muted); }
.row--retained .mono { color: var(--text-muted); }

/* --- Resources charts (app detail) ------------------------------------- */
/* Segmented time-range selector. */
.range-select {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.range-select__btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-subtle);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.range-select__btn:hover { color: var(--text); }
.range-select__btn.is-active {
  color: var(--accent-fg);
  background: var(--accent);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--accent) 36%, transparent);
}

/* Two side-by-side chart cards (CPU + Memory). */
.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
.chart-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4) var(--space-4) var(--space-3);
}
.chart-card__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}
.chart-card__canvas { position: relative; height: 190px; }
.chart-card__canvas canvas { width: 100% !important; }
.chart-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: var(--space-6);
  text-align: center;
  color: var(--text-faint);
  font-size: var(--text-sm);
}
/* The controller toggles [hidden]; display:grid would otherwise win over the UA
   [hidden]{display:none} (class beats attribute), so re-assert it. */
.chart-empty[hidden] { display: none; }

/* ==========================================================================
   18a. Hero status banner — the dashboard's "arrival" moment
   Reassurance first: a big friendly status word tinted by overall state, a warm
   one-liner, and key counts as quiet chips. Its tint comes from data-status.
   ========================================================================== */
.hero {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-5); flex-wrap: wrap;
  padding: var(--space-6) var(--space-6);
  border-radius: var(--radius-xl);
  border: 1px solid var(--_bd, var(--border));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--_fg, var(--accent)) 7%, var(--surface)), var(--surface));
  box-shadow: var(--shadow-sm);
  /* default (running) tone — overridden per data-status below */
  --_fg: var(--ok-fg); --_bd: var(--ok-bd);
}
.hero[data-status="starting"] { --_fg: var(--warn-fg); --_bd: var(--warn-bd); }
.hero[data-status="stopped"],
.hero[data-status="down"]     { --_fg: var(--bad-fg); --_bd: var(--bad-bd); }
.hero__main { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.hero__beacon {
  flex: none; display: grid; place-items: center;
  width: 16px; height: 16px; margin: 0 6px;
}
/* A solid status light with two soft halo rings — reads as "live", not an empty
   disc. The halo is box-shadow so it bleeds into the gap without taking layout. */
.hero__beacon-dot {
  width: 14px; height: 14px; border-radius: 50%; background: var(--_fg);
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--_fg) 16%, transparent),
    0 0 0 9px color-mix(in srgb, var(--_fg) 7%, transparent);
  position: relative;
}
.hero[data-status="running"] .hero__beacon-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid var(--_fg); opacity: 0.5;
  animation: pulse 2.4s var(--ease) infinite;
}
.hero__text { min-width: 0; }
.hero__label {
  font-size: var(--text-xl); font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight); color: var(--_fg); line-height: 1.1;
}
.hero__headline {
  font-size: var(--text-md); color: var(--text-muted);
  line-height: var(--leading-normal); margin-top: 2px;
}
.hero__chips { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-end; gap: var(--space-3) var(--space-5); }
.hero__chip { display: inline-flex; align-items: baseline; gap: 6px; }
.hero__chip-v {
  font-size: var(--text-md); font-weight: var(--weight-bold);
  color: var(--text); font-variant-numeric: tabular-nums lining-nums;
}
.hero__chip-k { font-size: var(--text-xs); color: var(--text-subtle); }
.hero__action { flex: none; }

/* ==========================================================================
   18b. Summary strip — a calm band of "the numbers that matter"
   Shared by the Requests / Domains pages and the App-detail vitals. Lighter than
   the 4-up stat grid: one card, divided into equal cells.
   ========================================================================== */
.summary {
  display: grid;
  grid-auto-flow: column;
  /* Each column is at least its content width, then shares the slack — so a wide
     compound value (e.g. "216 ms · 1.48 s") never clips beside narrow count cells. */
  grid-auto-columns: minmax(max-content, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.summary__cell {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--space-4) var(--space-5);
  min-width: 0;
  color: inherit;
}
.summary__cell + .summary__cell { border-left: 1px solid var(--border-faint); }
.summary__cell--link { transition: background var(--dur-fast) var(--ease); }
.summary__cell--link:hover { background: var(--surface-hover); }
.summary__label {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--text-subtle); white-space: nowrap;
}
.summary__value {
  font-size: var(--text-xl); font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight); line-height: 1.15;
  color: var(--text); font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.summary__cell[data-status] .summary__value { color: var(--_sfg, inherit); }
.summary__cell[data-status="running"] { --_sfg: var(--ok-fg); }
.summary__cell[data-status="warning"] { --_sfg: var(--warn-fg); }
.summary__cell[data-status="error"]   { --_sfg: var(--bad-fg); }
.summary__cell[data-status="off"] .summary__value { color: var(--text); }
.summary__unit { font-size: var(--text-md); color: var(--text-subtle); font-weight: var(--weight-medium); margin-left: 2px; }
.summary__note { font-size: var(--text-2xs); color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ==========================================================================
   18c. Requests log — de-monotonized
   Method gets a color-weighted chip; slow durations are tinted; the row reads
   with anchors instead of a uniform grey wall.
   ========================================================================== */
.requests tbody td { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.requests .req__method {
  display: inline-block; min-width: 4ch; text-align: center;
  font-size: var(--text-2xs); font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
  padding: 2px 6px; border-radius: var(--radius-xs);
  color: var(--text-muted); background: var(--bg-inset);
}
.requests .req__method[data-method="GET"]    { color: var(--ok-fg);   background: var(--ok-bg); }
.requests .req__method[data-method="POST"]   { color: var(--accent-hover); background: var(--accent-soft); }
.requests .req__method[data-method="PUT"]    { color: var(--warn-fg); background: var(--warn-bg); }
.requests .req__method[data-method="PATCH"]  { color: var(--warn-fg); background: var(--warn-bg); }
.requests .req__method[data-method="DELETE"] { color: var(--bad-fg);  background: var(--bad-bg); }
.requests .req__path { display: inline-block; max-width: 32ch; vertical-align: bottom; color: var(--text); }
.requests .req__dur { color: var(--text-muted); }
/* Slow requests stand out so the eye lands on them. */
.requests .req__dur.is-slow {
  color: var(--bad-fg); font-weight: var(--weight-semibold);
}

/* ==========================================================================
   18d. Domains — calmer, friendlier rows
   Host is the anchor (icon + mono host), service drops to a quiet sub-line so
   the table reads as "places", not a grid of equal cells.
   ========================================================================== */
.dom__host-cell { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.dom__host-icon {
  flex: none; width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: var(--accent); background: var(--accent-soft);
}
.dom__host-stack { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.dom__host { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text); }
.dom__host-sub { font-size: var(--text-2xs); color: var(--text-subtle); }
.dom__backed {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--text-xs); color: var(--text-faint);
}
.dom__backed svg { color: var(--ok-fg); opacity: 0.8; }

/* ==========================================================================
   18e. Activity — day-grouped feed
   A quiet day header above each day's card gives the feed rhythm and a sense of
   "when". The feed itself is unchanged; this just frames it.
   ========================================================================== */
.day-group__head {
  display: flex; align-items: baseline; gap: var(--space-3);
  padding: 0 var(--space-2) var(--space-3);
}
.day-group__label {
  font-size: var(--text-sm); font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight); color: var(--text);
}
.day-group__count { font-size: var(--text-xs); color: var(--text-faint); }
.feed__detail { font-family: var(--font-mono); }

/* ==========================================================================
   18. Responsive — phones / small tablets (≤ 640px)
   Desktop is dense: a single-row multi-item topbar (which otherwise pins the
   page to ~690px and scrolls sideways) and wide tables. Below 640px we collapse
   the topbar to two rows, shed non-essential chrome, let wide tables scroll
   inside their card, and turn destructive popovers into bottom sheets so the
   table's overflow can never clip them.
   ========================================================================== */
@media (max-width: 640px) {
  .app__main { padding: var(--space-6) var(--space-4) var(--space-12); }

  /* Topbar → two rows: brand + account on row 1, nav as a full-width tab row. */
  .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--topbar-h);
    column-gap: var(--space-2);
    row-gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
  }
  /* Drop low-value chrome to make room. */
  .topbar .divider,
  .topbar .conn { display: none; }
  .topbar__nav {
    order: 4;            /* wrap below the brand/account row */
    flex: 1 0 100%;
    min-width: 0;        /* allow the row to fit the viewport, not its content */
    margin-left: 0;
    gap: 2px;            /* 3 gaps share the row; keep them tiny so 4 tabs fit 390 */
  }
  /* Four tabs share the row equally. min-width:0 + clipped overflow lets the
     flex basis (0) actually win over each label's min-content width, so the row
     can never exceed the viewport (no 2px "Activity" poke past the edge). */
  .topbar__nav .nav-item {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    padding: 0 var(--space-2);
    overflow: hidden;
  }

  /* Wide tables scroll horizontally inside their card instead of clipping.
     A right-edge fade hints there's more to swipe to — and, via the
     local/scroll background trick, it only shows while content overflows and
     melts away once you reach the end. The two scroll-attached "cover" layers
     (a solid patch pinned to each edge) hide the fade when nothing is hidden
     there, so a table that already fits shows no fade at all. */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background:
      /* right-edge fade (fixed to the viewport of the scroller) */
      linear-gradient(to left, color-mix(in srgb, var(--text) 12%, transparent), transparent 26px) right center / 26px 100% no-repeat,
      /* cover patch pinned to the scroll content's right edge */
      linear-gradient(to left, var(--surface), var(--surface)) right center / 14px 100% no-repeat,
      var(--surface);
    background-attachment: scroll, local, scroll;
  }

  /* Service header wraps: title on top, summary + Open on their own line. */
  .service__head { flex-wrap: wrap; }
  .service__summary { margin-left: 0; width: 100%; }

  /* Lifecycle tables live in a card (not a .table-wrap), so give the flush body
     the same horizontal scroll affordance for the wide Actions column. */
  .card__body--flush { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Charts stack to one column; range selector can wrap below the title. */
  .charts { grid-template-columns: 1fr; }
  .chart-card__canvas { height: 160px; }

  /* Log bar controls wrap instead of overflowing on narrow screens. */
  .logs__bar { flex-wrap: wrap; row-gap: var(--space-2); }
  .logs__filter { flex: 1 1 120px; width: auto; }

  /* Hero: stack the action below, let the headline breathe. */
  .hero { padding: var(--space-5); gap: var(--space-4); }
  .hero__label { font-size: var(--text-lg); }
  .hero__action { width: 100%; }
  /* Chips wrap under the headline now, so read them left-to-right, not right-aligned. */
  .hero__chips { justify-content: flex-start; }

  /* Summary strip: a column grid would cram 6 cells off-screen. Wrap to a tidy
     grid (auto-fit) where each cell keeps a comfortable min width; borders flip
     to a hairline grid so cells still read as one panel. */
  .summary {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-columns: auto;
  }
  .summary__cell { padding: var(--space-3) var(--space-4); }
  /* Replace the single left-border rule with a full hairline grid (every cell
     gets a top + left rule; the first row/column rules are trimmed). */
  .summary__cell + .summary__cell { border-left: none; }
  .summary__cell { border-top: 1px solid var(--border-faint); border-left: 1px solid var(--border-faint); }
  .summary__cell:nth-child(-n+2) { border-top: none; }
  .summary__cell:nth-child(odd)  { border-left: none; }
  .summary__value { font-size: var(--text-lg); }
}
