/* deployd console — design tokens. Light + dark, no remote assets. */
:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --bg-grid: rgba(15, 23, 42, 0.035);
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #e9ecf1;
  --elevated: #ffffff;
  --line: rgba(15, 23, 42, 0.09);
  --line-2: rgba(15, 23, 42, 0.16);

  --text: #0f172a;
  --text-2: #55607a;
  --text-3: #8b94a9;

  --brand: #4f46e5;
  --brand-text: #ffffff;
  --brand-soft: rgba(79, 70, 229, 0.1);
  --brand-ring: rgba(79, 70, 229, 0.35);

  --ok: #047857;
  --ok-soft: rgba(4, 120, 87, 0.1);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.12);
  --bad: #be123c;
  --bad-soft: rgba(190, 18, 60, 0.1);
  --info: #0369a1;
  --info-soft: rgba(3, 105, 161, 0.1);

  --rail: #0f172a;
  --rail-text: #e6e9f0;
  --rail-muted: #8b94a9;
  --rail-hover: rgba(255, 255, 255, 0.07);
  --rail-active: rgba(255, 255, 255, 0.14);
  --rail-line: rgba(255, 255, 255, 0.1);

  --code-bg: #0f172a;
  --code-text: #dfe4ee;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --sh-1: 0 1px 2px rgba(15, 23, 42, 0.06);
  --sh-2: 0 4px 14px -4px rgba(15, 23, 42, 0.14), 0 1px 3px rgba(15, 23, 42, 0.06);
  --sh-3: 0 24px 60px -18px rgba(15, 23, 42, 0.35);

  --rail-w: 232px;
  --step: 150ms cubic-bezier(0.2, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0d16;
    --bg-grid: rgba(255, 255, 255, 0.03);
    --surface: #121723;
    --surface-2: #171d2b;
    --surface-3: #1e2534;
    --elevated: #161c28;
    --line: rgba(255, 255, 255, 0.09);
    --line-2: rgba(255, 255, 255, 0.16);

    --text: #e9ecf2;
    --text-2: #a2abbd;
    --text-3: #717c92;

    --brand: #7c74f5;
    --brand-text: #0a0d16;
    --brand-soft: rgba(124, 116, 245, 0.16);
    --brand-ring: rgba(124, 116, 245, 0.45);

    --ok: #34d399;
    --ok-soft: rgba(52, 211, 153, 0.14);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.14);
    --bad: #fb7185;
    --bad-soft: rgba(251, 113, 133, 0.14);
    --info: #38bdf8;
    --info-soft: rgba(56, 189, 248, 0.14);

    --rail: #0d1119;
    --rail-text: #e9ecf2;
    --rail-muted: #717c92;
    --rail-hover: rgba(255, 255, 255, 0.06);
    --rail-active: rgba(255, 255, 255, 0.12);
    --rail-line: rgba(255, 255, 255, 0.08);

    --code-bg: #080b12;
    --code-text: #cfd6e4;

    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --sh-2: 0 4px 16px -4px rgba(0, 0, 0, 0.6);
    --sh-3: 0 28px 70px -20px rgba(0, 0, 0, 0.8);
  }
}

:root[data-theme="dark"] {
  --bg: #0a0d16;
  --bg-grid: rgba(255, 255, 255, 0.03);
  --surface: #121723;
  --surface-2: #171d2b;
  --surface-3: #1e2534;
  --elevated: #161c28;
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);

  --text: #e9ecf2;
  --text-2: #a2abbd;
  --text-3: #717c92;

  --brand: #7c74f5;
  --brand-text: #0a0d16;
  --brand-soft: rgba(124, 116, 245, 0.16);
  --brand-ring: rgba(124, 116, 245, 0.45);

  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --bad: #fb7185;
  --bad-soft: rgba(251, 113, 133, 0.14);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.14);

  --rail: #0d1119;
  --rail-text: #e9ecf2;
  --rail-muted: #717c92;
  --rail-hover: rgba(255, 255, 255, 0.06);
  --rail-active: rgba(255, 255, 255, 0.12);
  --rail-line: rgba(255, 255, 255, 0.08);

  --code-bg: #080b12;
  --code-text: #cfd6e4;

  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --sh-2: 0 4px 16px -4px rgba(0, 0, 0, 0.6);
  --sh-3: 0 28px 70px -20px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; }
::selection { background: var(--brand-soft); }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { letter-spacing: -0.02em; font-weight: 600; margin: 0; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { flex: none; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 0.86em; letter-spacing: 0; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: var(--brand); color: var(--brand-text);
  font-size: 13px; font-weight: 550; white-space: nowrap;
  cursor: pointer; transition: background var(--step), border-color var(--step), color var(--step), transform var(--step);
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(0.5px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.quiet {
  background: var(--surface); color: var(--text); border-color: var(--line-2);
  filter: none;
}
.btn.quiet:hover { background: var(--surface-2); filter: none; }
.btn.bare { background: transparent; color: var(--text-2); }
.btn.bare:hover { background: var(--surface-2); color: var(--text); filter: none; }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--line-2); }
.btn.danger:hover { background: var(--bad-soft); border-color: transparent; filter: none; }
.btn.icon { width: 34px; padding: 0; }
.btn.icon.sm { width: 28px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100vh; align-content: start; }

.rail {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px;
  background: var(--rail); color: var(--rail-text);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand), #22d3ee);
  color: #fff; font-weight: 700; font-size: 15px; letter-spacing: -0.05em;
}
.brand b { display: block; font-size: 14px; font-weight: 600; letter-spacing: -0.02em; }
.brand small { display: block; color: var(--rail-muted); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }

.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail .navlink {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 36px; padding: 0 10px;
  background: transparent; border: 0; border-radius: var(--r-sm);
  color: var(--rail-muted); font-size: 13px; font-weight: 500; text-align: left;
  cursor: pointer; transition: background var(--step), color var(--step);
}
.rail .navlink:hover { background: var(--rail-hover); color: var(--rail-text); }
.rail .navlink[aria-current="page"] { background: var(--rail-active); color: #fff; font-weight: 550; }
.rail .navlink .count {
  margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--rail-muted); background: var(--rail-hover);
  padding: 1px 6px; border-radius: 999px;
}
.rail .spacer { flex: 1; }
.rail .foot { border-top: 1px solid var(--rail-line); padding-top: 12px; display: grid; gap: 8px; }
.rail .whoami { display: flex; align-items: center; gap: 9px; padding: 0 4px; }
.rail .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--rail-active); color: #fff; font-size: 11px; font-weight: 600;
}
.rail .whoami span { font-size: 12px; color: var(--rail-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail .foot .btn.bare { color: var(--rail-muted); justify-content: flex-start; height: 30px; }
.rail .foot .btn.bare:hover { background: var(--rail-hover); color: var(--rail-text); }

.main { min-width: 0; max-width: 100%; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .crumbs { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.topbar h1 { font-size: 17px; }
.topbar .crumbs p { color: var(--text-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.tick { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 12px; }
.tick .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.tick.stale .dot { background: var(--warn); }
.tick.err .dot { background: var(--bad); }
.tick.busy .dot { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

.search[hidden] { display: none; }
.search {
  display: flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  color: var(--text-3);
}
.search input { width: 190px; border: 0; background: transparent; outline: 0; font-size: 13px; }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.search kbd {
  font: 500 10px/1 var(--mono); color: var(--text-3);
  border: 1px solid var(--line-2); border-radius: 4px; padding: 3px 4px;
}

.content { padding: 22px 24px 64px; display: grid; gap: 18px; align-content: start; }
.content > *, .stack > *, .card { min-width: 0; }

/* ---------- banners ---------- */
.banners { display: grid; gap: 8px; }
.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px; border-radius: var(--r);
  background: var(--bad-soft); color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 25%, transparent);
  font-size: 13px;
}
.banner.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.banner.info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.banner svg { margin-top: 1px; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; }
.tile {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px 15px 13px; box-shadow: var(--sh-1);
}
.tile .k { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 11px; font-weight: 550; letter-spacing: 0.05em; text-transform: uppercase; }
.tile .v { margin-top: 9px; display: flex; align-items: baseline; gap: 5px; font-size: 24px; font-weight: 600; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.tile .v u { font-size: 12px; font-weight: 500; color: var(--text-3); text-decoration: none; letter-spacing: 0; }
.tile .note { margin-top: 6px; color: var(--text-3); font-size: 12px; }
.tile.ok .v { color: var(--ok); }
.tile.bad .v { color: var(--bad); }
.tile.warn .v { color: var(--warn); }
.tile .spark { position: absolute; right: 0; bottom: 0; left: 0; height: 30px; opacity: 0.5; pointer-events: none; }

/* ---------- section / card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
  overflow: hidden;
}
.card > header {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.card > header h2 { font-size: 13px; font-weight: 600; }
.card > header p { color: var(--text-3); font-size: 12px; }
.card > header .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card .body { padding: 16px; }
.card .body.tight { padding: 0; }
.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.split > * { min-width: 0; }
@media (max-width: 1180px) { .split { grid-template-columns: 1fr; } }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--text-3);
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  white-space: nowrap;
}
tbody tr { transition: background var(--step); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.name { font-weight: 550; white-space: nowrap; }
td .sub { color: var(--text-3); font-size: 12px; font-weight: 400; white-space: nowrap; }
td.actions, th.actions {
  position: sticky; right: 0; z-index: 2;
  text-align: right; white-space: nowrap;
  background: var(--surface);
  box-shadow: -8px 0 8px -8px rgba(15, 23, 42, 0.25);
}
th.actions { background: var(--surface-2); }
tbody tr:hover td.actions { background: var(--surface-2); }
td.actions .row { justify-content: flex-end; gap: 6px; }
.rowmenu { display: inline-flex; gap: 6px; opacity: 0.55; transition: opacity var(--step); }
tr:hover .rowmenu, .rowmenu:focus-within { opacity: 1; }

/* ---------- pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2);
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  white-space: nowrap;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.pill.bare::before { display: none; }
.pill.ok, .pill.running, .pill.healthy, .pill.enabled, .pill.issued { background: var(--ok-soft); color: var(--ok); }
.pill.bad, .pill.down, .pill.exited, .pill.dead, .pill.failed, .pill.unhealthy { background: var(--bad-soft); color: var(--bad); }
.pill.warn, .pill.created, .pill.restarting, .pill.paused, .pill.degraded, .pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.info, .pill.building { background: var(--info-soft); color: var(--info); }

/* ---------- meters ---------- */
.meter { display: grid; gap: 5px; min-width: 116px; }
.meter .line { display: flex; align-items: baseline; gap: 4px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.meter .line b { font-weight: 550; }
.meter .line span { color: var(--text-3); }
.meter .track { height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter .track i { display: block; height: 100%; border-radius: 99px; background: var(--brand); transition: width var(--step); }
.meter.warm .track i { background: var(--warn); }
.meter.hot .track i { background: var(--bad); }

/* ---------- empty / skeleton ---------- */
.empty { display: grid; justify-items: center; gap: 4px; padding: 44px 24px; text-align: center; }
.empty .glyph {
  width: 38px; height: 38px; border-radius: var(--r); margin-bottom: 6px;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text-3);
}
.empty strong { font-size: 14px; font-weight: 600; }
.empty p { color: var(--text-3); font-size: 13px; max-width: 46ch; }
.empty .btn { margin-top: 10px; }
.skel { display: grid; gap: 10px; padding: 16px; }
.skel i {
  display: block; height: 13px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
.skel i:nth-child(2n) { width: 72%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label { font-size: 12px; font-weight: 550; color: var(--text-2); }
.field .help { font-size: 11.5px; color: var(--text-3); }
.field.wide { grid-column: 1 / -1; }
input[type="text"], input[type="password"], input[type="number"], input:not([type]), select, textarea {
  width: 100%; height: 36px; padding: 0 11px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  outline: 0; transition: border-color var(--step), box-shadow var(--step);
}
textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
input[aria-invalid="true"] { border-color: var(--bad); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.err { color: var(--bad); font-size: 12.5px; min-height: 1em; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 14px; }
fieldset legend {
  padding: 0 0 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-3);
}
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-2); border-radius: var(--r-sm); border: 1px solid var(--line); }
.seg button {
  height: 26px; padding: 0 11px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-2); font-size: 12px; font-weight: 550; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 11px;
  background: var(--surface); border: 1px dashed var(--line-2); border-radius: 999px;
  font-family: var(--mono); font-size: 12px; cursor: pointer;
  transition: border-color var(--step), background var(--step), color var(--step);
}
.chip:hover { border-style: solid; border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.chip em { font-family: var(--sans); font-style: normal; font-size: 11.5px; color: var(--text-3); }

/* ---------- code ---------- */
pre.code {
  margin: 0; padding: 14px 16px; overflow: auto;
  max-height: 60vh;
  background: var(--code-bg); color: var(--code-text);
  border-radius: var(--r); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  -webkit-overflow-scrolling: touch;
}
pre.code.flush { border-radius: 0; border: 0; max-height: none; height: 100%; }

/* ---------- site cards ---------- */
.sitelist { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; }
.site {
  display: grid; gap: 9px;
  padding: 14px 15px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.site .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.site .top strong { font-size: 13.5px; }
.site dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 12.5px; }
.site dt { color: var(--text-3); }
.site dd { margin: 0; overflow: hidden; text-overflow: ellipsis; }
.site .flag { display: flex; gap: 7px; align-items: flex-start; color: var(--warn); font-size: 12px; }

/* ---------- dialogs: slide-over + drawer + confirm ---------- */
dialog { border: 0; padding: 0; color: var(--text); background: transparent; max-width: none; max-height: none; }
dialog::backdrop { background: rgba(6, 9, 16, 0.55); backdrop-filter: blur(2px); }

.sheet {
  position: fixed; inset: 0 0 0 auto;
  width: min(560px, 100%); height: 100%;
  display: flex; flex-direction: column;
  background: var(--elevated); box-shadow: var(--sh-3);
  border-left: 1px solid var(--line);
  animation: slidein 220ms cubic-bezier(0.2, 0, 0.2, 1);
}
.sheet.wide { width: min(880px, 100%); }
@keyframes slidein { from { transform: translateX(18px); opacity: 0.4; } }
.sheet > header {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.sheet > header h2 { font-size: 15px; }
.sheet > header p { color: var(--text-3); font-size: 12.5px; }
.sheet > header .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.sheet .scroll { flex: 1; overflow: auto; padding: 18px; display: grid; gap: 16px; align-content: start; }
.sheet .scroll.tight { padding: 0; display: block; }
.sheet .scroll.tight > pre.code { min-height: 100%; }
.sheet > footer {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; border-top: 1px solid var(--line); background: var(--surface);
}
.sheet > footer .right { margin-left: auto; display: flex; gap: 8px; }
.sheet > footer .status { color: var(--text-3); font-size: 12.5px; }

.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(430px, calc(100vw - 32px));
  background: var(--elevated); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--sh-3);
  padding: 22px; display: grid; gap: 12px;
  animation: pop 160ms cubic-bezier(0.2, 0, 0.2, 1);
}
@keyframes pop { from { transform: translate(-50%, -48%) scale(0.97); opacity: 0; } }
.modal h2 { font-size: 16px; }
.modal p { color: var(--text-2); font-size: 13px; }
.modal .row { justify-content: flex-end; margin-top: 4px; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; z-index: 90; right: 18px; bottom: 18px;
  display: grid; gap: 9px; justify-items: end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  max-width: 400px; padding: 11px 13px;
  background: var(--elevated); color: var(--text);
  border: 1px solid var(--line); border-left: 3px solid var(--text-3);
  border-radius: var(--r); box-shadow: var(--sh-2);
  font-size: 13px; pointer-events: auto;
  animation: rise 180ms cubic-bezier(0.2, 0, 0.2, 1);
}
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.toast.ok { border-left-color: var(--ok); }
.toast.ok svg { color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
.toast.bad svg { color: var(--bad); }
.toast.info { border-left-color: var(--info); }
.toast.info svg { color: var(--info); }
.toast b { font-weight: 600; }
.toast .msg { display: grid; gap: 2px; min-width: 0; }
.toast .msg span { color: var(--text-2); font-size: 12.5px; overflow-wrap: anywhere; }
.toast.leaving { animation: fade 160ms forwards; }
@keyframes fade { to { opacity: 0; transform: translateY(-4px); } }

/* ---------- auth pages ---------- */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 28px 16px;
  background:
    radial-gradient(1000px 520px at 50% -12%, var(--brand-soft), transparent 70%),
    linear-gradient(transparent 0 0) , var(--bg);
}
.authcard {
  width: min(400px, 100%);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--sh-2);
  padding: 30px 28px 26px;
}
.authcard .mark {
  width: 34px; height: 34px; border-radius: 10px; margin-bottom: 16px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand), #22d3ee);
  color: #fff; font-weight: 700; letter-spacing: -0.05em;
}
.authcard h1 { font-size: 21px; }
.authcard .lede { margin-top: 6px; color: var(--text-2); font-size: 13.5px; }
.authcard form { display: grid; gap: 14px; margin-top: 20px; }
.authcard .foot { margin-top: 18px; color: var(--text-3); font-size: 12px; text-align: center; }
.otp {
  font-family: var(--mono); font-size: 19px; letter-spacing: 0.32em;
  text-align: center; height: 46px;
}
.qr {
  display: block; margin: 4px auto 0; background: #fff;
  padding: 10px; border-radius: var(--r); border: 1px solid var(--line);
}
.secret {
  display: block; margin-top: 10px; padding: 9px 11px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--mono); font-size: 11.5px; color: var(--text-2);
  word-break: break-all; text-align: center;
}
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps i { height: 3px; flex: 1; border-radius: 99px; background: var(--surface-3); }
.steps i.on { background: var(--brand); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: static; height: auto; flex-direction: row; align-items: center;
    gap: 8px; padding: 10px 16px; overflow-x: auto;
  }
  .brand { padding: 0 8px 0 0; }
  .brand div { display: none; }
  .rail nav { flex-direction: row; gap: 4px; }
  .rail .navlink { height: 32px; white-space: nowrap; }
  .rail .navlink .count { display: none; }
  .rail .spacer { flex: 0 0 auto; }
  .rail .foot { border: 0; padding: 0; display: flex; align-items: center; gap: 6px; margin-left: auto; }
  .rail .whoami span, .rail .foot .btn.bare span { display: none; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .topbar .tools { width: 100%; }
  .tick span { display: none; }
  /* A pinned action column on a narrow screen just covers the data behind it. */
  td.actions, th.actions { position: static; box-shadow: none; }
  .search { flex: 1 1 140px; min-width: 0; }
  .search input { width: 100%; min-width: 0; }
  .search kbd { display: none; }
  .rail { min-width: 0; }
  .content { padding: 16px 16px 56px; }
  th, td { padding: 10px 12px; }
  .sheet { inset: auto 0 0 0; width: 100%; height: min(92vh, 100%); border-left: 0; border-top-left-radius: var(--r-xl); border-top-right-radius: var(--r-xl); }
  .toasts { right: 12px; left: 12px; bottom: 12px; justify-items: stretch; }
  .toast { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- layout helpers used by the JS views ---------- */
.stack { display: grid; gap: 18px; }
.metric-label {
  color: var(--text-3); font-size: 11px; font-weight: 550;
  letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 8px;
}
.cardnote { padding: 12px 16px; border-top: 1px solid var(--line); }
.sub.bad { color: var(--bad); }
select.narrow { width: auto; min-width: 120px; }

input[readonly] {
  background: var(--surface-2); color: var(--text-2); cursor: default;
  border-style: dashed;
}
input[readonly]:focus { border-color: var(--line-2); box-shadow: none; }

/* A pill that opens something — the deploy badge on an app row. */
button.pill {
  border: 0; cursor: pointer; font-family: inherit;
  transition: filter var(--step);
}
button.pill:hover { filter: brightness(1.08); }

/* Key/value facts in the settings panels. */
.field > b { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }

/* Inside a sheet there is no sideways scroll, so the pinned action column only
   showed up as a mismatched block against the sheet's own background. */
.sheet td.actions, .sheet th.actions {
  position: static; background: transparent; box-shadow: none;
}
.sheet table th { background: var(--surface-2); }
