/* Deploy Manager — app shell, components, light/dark themes.
   Dark values appear twice on purpose: once for the system preference and once
   for an explicit [data-theme="dark"], so the sidebar switch wins either way. */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e9ecf1;
  --border: #e4e7ec;
  --border-strong: #cdd3dc;
  --text: #14171d;
  --muted: #59616f;
  --faint: #878e9b;
  /* Only --accent and --accent-contrast are set per theme; the hover and soft
     tints are derived, so adding an accent means picking two colours, not six.
     --accent-ink is what hover darkens towards: black on light, white on dark. */
  --accent: #6d4df6;
  --accent-contrast: #ffffff;
  --accent-ink: #000;
  --accent-hover: color-mix(in srgb, var(--accent) 84%, var(--accent-ink));
  --accent-soft: color-mix(in srgb, var(--accent) 11%, var(--surface));
  --ok: #17794a;
  --ok-soft: #e2f4ea;
  --warn: #92600a;
  --warn-soft: #fcf2dc;
  --err: #c0362e;
  --err-soft: #fbe8e6;
  --run: #ac7000;
  --run-soft: #fdf1da;
  --code-bg: #f4f5f8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 2px 4px rgba(16, 24, 40, .04), 0 6px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 248px;

  /* One spacing scale, so gaps between things are chosen rather than guessed.
     Everything vertical steps through these rather than inventing 13px. */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 22px;
  --s6: 30px;
  --s7: 44px;

  /* Type scale. The jump from a page title to body text was doing all the work
     of hierarchy on its own; these give the middle of a page somewhere to sit. */
  --t-display: 26px;
  --t-title: 19px;
  --t-body: 14px;
  --t-small: 12.5px;
  --t-micro: 11.5px;

  /* One focus ring, defined once, so every control agrees on what focus is. */
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1015;
    --surface: #161920;
    --surface-2: #1d212a;
    --surface-3: #262b35;
    --border: #282d37;
    --border-strong: #3a414d;
    --text: #e9ebef;
    --muted: #a2a9b5;
    --faint: #757d8a;
    --accent: #a48cff;
    --accent-contrast: #16072e;
    --accent-ink: #fff;
    --ok: #4cc488;
    --ok-soft: #142a20;
    --warn: #e0a642;
    --warn-soft: #2d2413;
    --err: #f07167;
    --err-soft: #321a19;
    --run: #e0a642;
    --run-soft: #2d2413;
    --code-bg: #11141a;
    /* Dark surfaces are separated by their own lightness, not by shadow — a
       shadow on a near-black background is invisible, so borders do the work. */
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1015;
  --surface: #161920;
  --surface-2: #1d212a;
  --surface-3: #262b35;
  --border: #282d37;
  --border-strong: #3a414d;
  --text: #e9ebef;
  --muted: #a2a9b5;
  --faint: #757d8a;
  --accent: #a48cff;
  --accent-contrast: #16072e;
  --accent-ink: #fff;
  --ok: #4cc488;
  --ok-soft: #142a20;
  --warn: #e0a642;
  --warn-soft: #2d2413;
  --err: #f07167;
  --err-soft: #321a19;
  --run: #e0a642;
  --run-soft: #2d2413;
  --code-bg: #11141a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- accents ----------
   Chosen so none of them can be mistaken for a status: green, amber and red
   mean healthy, deploying and failed, so an accent never borrows those hues.
   Each needs only the colour and something legible on top of it; hover and the
   soft tint derive from there. Declared last so they win in either theme. */
:root[data-accent="violet"] { --accent: #6d4df6; --accent-contrast: #fff; }
:root[data-accent="indigo"] { --accent: #4f46e5; --accent-contrast: #fff; }
:root[data-accent="cyan"] { --accent: #0e7490; --accent-contrast: #fff; }
:root[data-accent="graphite"] { --accent: #262b36; --accent-contrast: #fff; }
:root[data-accent="blue"] { --accent: #2f6fed; --accent-contrast: #fff; }
/* Deep enough to stay legible as link text on white, and red-leaning so it
   reads as orange rather than as the amber that means "deploying". */
:root[data-accent="orange"] { --accent: #c2410c; --accent-contrast: #fff; }
/* The one accent that shares a hue with a status. Pushed to a forest green —
   purer and darker than the sea-green that means healthy — and relied on
   appearing as filled buttons and links, where the status green only ever
   appears as a small pill. The closest pairing in the app; see the note in
   the accent picker. */
:root[data-accent="green"] { --accent: #15803d; --accent-contrast: #fff; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-accent="violet"] { --accent: #a48cff; --accent-contrast: #16072e; }
  :root:not([data-theme="light"])[data-accent="indigo"] { --accent: #8b9cff; --accent-contrast: #0d1033; }
  :root:not([data-theme="light"])[data-accent="cyan"] { --accent: #4dd0e8; --accent-contrast: #032b33; }
  /* On a near-black page graphite has to invert, or the accent disappears. */
  :root:not([data-theme="light"])[data-accent="graphite"] { --accent: #dfe3ea; --accent-contrast: #14171d; }
  :root:not([data-theme="light"])[data-accent="blue"] { --accent: #5b8cff; --accent-contrast: #0a0f1c; }
  :root:not([data-theme="light"])[data-accent="orange"] { --accent: #ff8a4c; --accent-contrast: #2b1003; }
  :root:not([data-theme="light"])[data-accent="green"] { --accent: #4ade80; --accent-contrast: #052e16; }
}
:root[data-theme="dark"][data-accent="violet"] { --accent: #a48cff; --accent-contrast: #16072e; }
:root[data-theme="dark"][data-accent="indigo"] { --accent: #8b9cff; --accent-contrast: #0d1033; }
:root[data-theme="dark"][data-accent="cyan"] { --accent: #4dd0e8; --accent-contrast: #032b33; }
:root[data-theme="dark"][data-accent="graphite"] { --accent: #dfe3ea; --accent-contrast: #14171d; }
:root[data-theme="dark"][data-accent="blue"] { --accent: #5b8cff; --accent-contrast: #0a0f1c; }
:root[data-theme="dark"][data-accent="orange"] { --accent: #ff8a4c; --accent-contrast: #2b1003; }
:root[data-theme="dark"][data-accent="green"] { --accent: #4ade80; --accent-contrast: #052e16; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: var(--t-small); }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: var(--t-display); font-weight: 660; letter-spacing: -.022em; }
h2 { font-size: var(--t-title); font-weight: 630; letter-spacing: -.015em; }
h3 { font-size: 15px; font-weight: 600; letter-spacing: -.008em; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--t-small); }
.hidden { display: none !important; }
/* Any author rule setting display beats the browser's own [hidden] rule, and
   .btn sets display: inline-flex — so hiding a button needs saying outright. */
[hidden] { display: none !important; }

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

.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 12px 14px;
}
.sidebar-brand { margin: 0 8px 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--text); white-space: nowrap; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  /* Depth from the accent itself rather than a second hue, so the mark follows
     whichever accent is chosen instead of always leaning purple. */
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 72%, var(--accent-ink)));
  color: var(--accent-contrast); display: grid; place-items: center; box-shadow: var(--shadow);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 530; transition: background .12s, color .12s;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.active svg { opacity: 1; }
.nav-count {
  margin-left: auto; font-size: 11.5px; font-weight: 600; color: var(--faint);
  background: var(--surface-2); border-radius: 999px; padding: 1px 7px; min-width: 22px; text-align: center;
}
.nav a.active .nav-count { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.nav-count:empty { display: none; }

.sidebar-foot { margin-top: auto; display: grid; gap: 10px; padding-top: 14px; }
.theme-switch {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px;
}
.theme-switch button {
  appearance: none; border: 0; background: none; color: var(--faint);
  padding: 6px 0; border-radius: 6px; cursor: pointer; display: grid; place-items: center;
  transition: background .12s, color .12s;
}
.theme-switch button svg { width: 16px; height: 16px; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

/* Accent picker. Each swatch paints itself with the colour it selects, so the
   choice is the preview — no labels needed. */
.accent-switch { display: flex; gap: 6px; justify-content: center; padding: 2px 0; }
.accent-switch button {
  appearance: none; width: 20px; height: 20px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; background-clip: padding-box;
  box-shadow: 0 0 0 1px var(--border) inset;
  transition: transform .12s, box-shadow .12s;
}
.accent-switch button:hover { transform: scale(1.12); }
.accent-switch button.on { box-shadow: 0 0 0 2px var(--surface) inset, 0 0 0 2px currentColor; }
.accent-switch button:focus-visible { outline: none; box-shadow: var(--focus); }

.user-chip {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 13px; transition: border-color .12s;
}
.user-chip:hover { text-decoration: none; border-color: var(--border-strong); }
.user-chip img { width: 28px; height: 28px; border-radius: 50%; flex: none; }
.user-chip .who { min-width: 0; display: grid; }
.user-chip .who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who span { color: var(--faint); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-fallback {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: 12px;
}

.mobile-bar { display: none; }
.icon-btn {
  appearance: none; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  width: 36px; height: 36px; border-radius: var(--radius-sm); display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); z-index: 29; animation: fade .12s ease-out; }

.content { padding: var(--s6) var(--s6) 90px; max-width: 1140px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head p { margin-top: var(--s1); max-width: 68ch; }
.actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }

/* ---------- buttons & inputs ---------- */
.btn {
  appearance: none; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; padding: 7px 14px; border-radius: var(--radius-sm); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.3; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--err); }
.danger-text { color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn svg { width: 15px; height: 15px; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

label.field { display: block; }
.field-label { display: block; font-weight: 560; margin-bottom: 5px; font-size: 13px; }
.field-hint { display: block; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 10px;
  transition: border-color .12s, box-shadow .12s;
}
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 120px; resize: vertical; }
/* A ring rather than an outline: it follows the border radius, and sitting
   outside the control means it never nudges the layout. */
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--focus);
}
.btn:focus-visible, summary:focus-visible, .nav a:focus-visible, .user-chip:focus-visible,
.icon-btn:focus-visible, .theme-switch button:focus-visible, .chip-btn:focus-visible,
.choice-card:focus-visible, .repo-item:focus-visible, .menu-pop button:focus-visible,
.subtabs a:focus-visible, .stepper li:focus-visible {
  outline: none; box-shadow: var(--focus); border-color: var(--accent);
}
/* Keyboard users get a ring on rows that are only clickable, too. */
.proj:focus-within { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip-btn {
  font: inherit; font-size: 12px; padding: 2px 8px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); transition: color .12s, border-color .12s;
}
.chip-btn:hover { color: var(--text); border-color: var(--border-strong); }

.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button {
  font: inherit; font-weight: 550; border: 0; background: var(--surface); color: var(--muted);
  padding: 7px 16px; cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--border-strong); }
.segmented button.on { background: var(--accent-soft); color: var(--accent); }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: var(--s5); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s5); border-bottom: 1px solid var(--border); }
.card + .card { margin-top: var(--s4); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: var(--s4); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .k { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.stat .v { font-size: 26px; font-weight: 660; letter-spacing: -.02em; margin-top: 6px; display: flex; align-items: center; gap: 8px; }
.stat .v .dot { width: 9px; height: 9px; }
.stat .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- profile ---------- */
.profile-head { display: flex; align-items: center; gap: 18px; padding: 22px; flex-wrap: wrap; }
.profile-head img, .profile-head .avatar-fallback { width: 72px; height: 72px; border-radius: 50%; font-size: 26px; }
.profile-head .who { display: grid; gap: 2px; min-width: 0; }
.profile-head .who h2 { font-size: 20px; }
.scope-list { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- onboarding ---------- */
.onboard { padding: 22px 24px; margin-bottom: 24px; }
.onboard h2 { margin-bottom: 4px; }
.steps { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 12px; }
.steps .num {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none;
  border: 1.5px solid var(--border-strong); font-size: 12px; font-weight: 600; color: var(--muted);
}
.steps li.done .num { background: var(--ok); border-color: var(--ok); color: #fff; }
.steps li.done .txt { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.steps .txt { flex: 1; }

/* ---------- server groups & project rows ---------- */
.group { margin-bottom: 24px; }
.group-head { display: flex; align-items: baseline; gap: 10px; margin: 0 4px 9px; }
.group-head h2 { font-size: 14px; }
.group-head .mono { color: var(--muted); }
.list { overflow: visible; }
.proj {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto; gap: 16px; align-items: center;
  padding: 14px 18px; transition: background .12s;
}
.proj:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.proj + .proj { border-top: 1px solid var(--border); }
.proj-name { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.proj-name .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.proj-name a.n:hover { color: var(--accent); }
.proj-meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-width: 0; }
.proj-meta a { color: var(--muted); }
.proj-meta a:hover { color: var(--accent); }
.sep { color: var(--faint); }
/* Type is a fact about a project, not a warning about it. Kept deliberately
   colourless so that on a page of projects the only colour is status — the red
   row is the one thing that should catch the eye. */
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 5px;
  letter-spacing: .04em; text-transform: uppercase; flex: none;
  background: var(--surface-2); color: var(--faint); border: 1px solid var(--border);
}

/* ---------- status ---------- */
/* One chip, one vocabulary, everywhere a state is shown. */
.chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: none;
  padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: .005em;
  background: var(--surface-2); color: var(--muted);
}
.chip .dot { width: 6px; height: 6px; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.err { background: var(--err-soft); color: var(--err); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.run { background: var(--run-soft); color: var(--run); }

.status { display: flex; align-items: center; gap: var(--s2); font-size: 13px; min-width: 0; }
.status a { color: inherit; }
.status .sub { color: var(--faint); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: currentColor; opacity: .9; }
.dot.ok { background: var(--ok); }
.dot.err { background: var(--err); }
.dot.run { background: var(--run); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.status .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-err { color: var(--err); font-size: var(--t-small); }

/* A failed project should be findable without reading every row. */
.proj.is-failed { box-shadow: inset 3px 0 0 var(--err); }
.proj.is-running { box-shadow: inset 3px 0 0 var(--run); }

/* overflow menu */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 5px;
}
.menu-pop button {
  display: block; width: 100%; text-align: left; font: inherit; background: none; border: 0; color: var(--text);
  padding: 7px 10px; border-radius: 6px; cursor: pointer;
}
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop button.danger { color: var(--err); }

/* ---------- servers ---------- */
.server-card { display: flex; flex-direction: column; }
.server-card .card-pad { flex: 1; }
.server-card .top { display: flex; justify-content: space-between; gap: var(--s3); align-items: flex-start; }
.server-card .top h2 { font-size: 16px; }
.server-card .top h2 a { color: var(--text); }
.server-card .top h2 a:hover { color: var(--accent); text-decoration: none; }

.srv-status { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s3); }
.srv-meters { display: grid; gap: var(--s3); margin-top: var(--s4); }
.srv-facts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: var(--s3); color: var(--muted); font-size: var(--t-small); }

/* A proportion worth watching. The fill changes colour rather than the label,
   so a full disk is visible from across the page. */
.meter { display: grid; gap: 5px; }
.meter-top { display: flex; justify-content: space-between; gap: var(--s2); font-size: var(--t-small); }
.meter-track { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
/* Neutral until it means something. A bar at 39% is a quantity, not a brand
   moment, and painting it in the accent makes a warm accent read as a warning. */
.meter-fill {
  display: block; height: 100%; border-radius: 999px;
  background: color-mix(in srgb, var(--text) 42%, transparent);
  transition: width .3s ease-out, background .2s;
}
.meter-fill.warn { background: var(--warn); }
.meter-fill.err { background: var(--err); }

.tone-ok { color: var(--ok); }
.tone-warn { color: var(--warn); }
.tone-err { color: var(--err); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin-top: 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.keybox {
  margin-top: var(--s3); background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--s2) var(--s3); font-family: var(--mono); font-size: var(--t-micro); overflow-wrap: anywhere; color: var(--muted);
  max-height: 64px; overflow: auto;
}
/* Actions sit on the card's floor, so cards in a row line up however tall their
   contents are. Two named buttons and a menu, not six wrapping onto four lines. */
.server-card .foot {
  display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center;
  padding: var(--s3) var(--s5); border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius); margin-top: auto;
}
.server-card .foot .menu { margin-left: auto; }
.subpanel { margin-top: var(--s3); padding: var(--s3); border-radius: var(--radius-sm); background: var(--surface-2); }

/* ---------- checklists ---------- */
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checks li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: start; font-size: 13px; }
.checks .ic { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; margin-top: 1px; }
.checks .ic.ok { background: var(--ok-soft); color: var(--ok); }
.checks .ic.err { background: var(--err-soft); color: var(--err); }
.checks .ic.warn { background: var(--warn-soft); color: var(--warn); }
.checks .ic.idle { background: var(--surface-2); color: var(--faint); }
.checks .d { display: block; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }

.callout { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; }
.callout.info { background: var(--accent-soft); }
.callout.warn { background: var(--warn-soft); color: var(--text); }
.callout.err { background: var(--err-soft); }

.pill-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); }
.pill.yes { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: var(--ok-soft); }
.pill.no { color: var(--faint); text-decoration: line-through; }

/* ---------- repo picker ---------- */
.repo-list {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); max-height: 260px; overflow: auto; margin-top: 8px;
}
.repo-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; background: none; border: 0; border-bottom: 1px solid var(--border);
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
}
.repo-item:last-child { border-bottom: 0; }
.repo-item:hover, .repo-item:focus-visible { background: var(--surface-2); outline: none; }
.repo-item .rn { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repo-item .rn .o { color: var(--muted); font-weight: 400; }
.repo-item .rt { color: var(--faint); font-size: 12px; white-space: nowrap; }
.repo-picked {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2);
}
.lock { font-size: 11px; color: var(--faint); margin-left: 6px; }
.in-use { font-size: 11px; color: var(--ok); margin-left: 6px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 14, 20, .45); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow: auto;
  animation: fade .12s ease-out;
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
/* The dialog never grows past the screen: the title and the buttons stay put
   and only the body scrolls, so Save is always reachable. */
.modal {
  width: min(640px, 100%); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); animation: rise .16s ease-out;
  /* 100% of the backdrop, which already reserves its own padding. Sizing
     against the parent rather than vh keeps this correct under page zoom. */
  display: flex; flex-direction: column; max-height: 100%;
}
.modal-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 20px; display: grid; gap: 16px; overflow-y: auto; min-height: 0; }
.modal-foot { flex: none; display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
/* Grid and flex items take a content-based minimum by default, so one wide
   child — the workflow preview, whose lines are long — widens the whole column
   and pushes every field past the dialog's edge. Letting them shrink to zero is
   what allows the preview's own overflow:auto to scroll instead. */
.modal-body > *, .stack > *, .grid-2 > *, .grid-3 > * { min-width: 0; }
.modal-body .row > input, .modal-body .row > select { min-width: 0; }
.modal-foot .left { margin-right: auto; }
.x { font-size: 20px; line-height: 1; padding: 2px 8px; }
details.yaml summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.yaml pre {
  margin: 8px 0 0; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; overflow: auto; max-height: 280px; font-size: 12px; line-height: 1.55;
}
table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini td { padding: 6px 10px 6px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.mini tr:last-child td { border-bottom: 0; }
table.mini td:first-child { width: 1%; white-space: nowrap; }

.logbox {
  margin: 0; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; overflow: auto; max-height: 52vh; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--text);
}
.section-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin-bottom: -6px; }

/* ---------- add-project wizard ---------- */
/* One step at a time when adding; everything at once when editing. */
.wiz .wstep { display: none; }
/* minmax(0,1fr), not auto: a long repository name in the picker would otherwise
   size the column and push the whole step past the modal's edge. */
.wstep.on, .pf-all .wstep { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; }
.wstep > * { min-width: 0; }
.wstep-head h3 { font-size: 17px; margin-bottom: 3px; }
.wstep-head p { font-size: 13px; }

.stepper { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-bottom: 4px; list-style: none; }
.stepper li {
  display: flex; align-items: center; gap: 6px; padding: 5px 9px 5px 5px; border-radius: 999px;
  font-size: 12.5px; color: var(--faint); cursor: pointer; transition: color .12s, background .12s;
}
.stepper li:hover { color: var(--muted); background: var(--surface-2); }
.stepper .sdot {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--border-strong); font-size: 11px; font-weight: 600;
}
.stepper li.done { color: var(--muted); }
.stepper li.done .sdot { background: var(--ok); border-color: var(--ok); color: #fff; font-size: 0; }
/* The number is replaced by a tick once the step is behind you. */
.stepper li.done .sdot::after { content: "✓"; font-size: 11px; }
.stepper li.now { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.stepper li.now .sdot { border-color: var(--accent); color: var(--accent); }

/* Two ways to deploy, each explained, rather than a segmented control that
   makes you guess what the words mean. */
.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-card {
  display: grid; gap: 4px; text-align: left; padding: 13px 15px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.choice-card:hover { border-color: var(--accent); }
.choice-card.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.cc-title { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
.cc-desc { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.cc-tick { margin-left: auto; color: var(--accent); opacity: 0; transition: opacity .12s; }
.choice-card.on .cc-tick { opacity: 1; }

table.mini.review td.r { width: 1%; text-align: right; white-space: nowrap; }
table.mini.review td { vertical-align: top; padding-top: 9px; padding-bottom: 9px; }

@media (max-width: 560px) {
  .choice-cards { grid-template-columns: 1fr; }
  .stepper .slabel { display: none; }
  .stepper li { padding: 5px; }
}

/* ---------- one project ---------- */
.backlink { display: inline-block; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.backlink:hover { color: var(--text); }

/* The state anyone opening this screen came to read: what is running, where,
   and whether it is answering. */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px 20px; }
.fact { display: grid; gap: 3px; align-content: start; min-width: 0; }
.fact-k { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.fact-v { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13.5px; min-width: 0; }
.fact-s { font-size: 12px; color: var(--muted); }
.fact-s .btn { padding: 2px 6px; }
/* Each fact's value is a wrapper holding several spans. It has to be a flex row
   itself: otherwise they run together, and .dot — which has no display of its
   own — collapses to nothing instead of drawing a circle. */
/* Wrap between the parts, never inside one: a narrow column should push "1d ago"
   onto its own line, not break it into "1d" and "ago". */
.fact-v [data-status], .fact-v [data-fact] {
  display: flex; align-items: center; gap: var(--s1) var(--s2); flex-wrap: wrap; min-width: 0;
}
.fact-v [data-status] > *, .fact-v [data-fact] > * { white-space: nowrap; }

.subtabs { display: flex; gap: 2px; margin: 18px 0 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.subtabs a {
  padding: 8px 13px; font-size: 13.5px; font-weight: 530; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subtabs a:hover { color: var(--text); }
.subtabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* domain → project → where it actually goes, read left to right */
.mapping { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.mapping .arrow { color: var(--faint); }

/* ---------- deployment history ---------- */
.dep-list { display: grid; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.dep {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 11px 13px; border-bottom: 1px solid var(--border);
}
.dep:last-child { border-bottom: 0; }
.dep-main { min-width: 0; display: grid; gap: 5px; }
.dep-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 13.5px; }
.dep-msg { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep-side { display: grid; justify-items: end; gap: 2px; text-align: right; white-space: nowrap; }

/* Real stages, one pip each. A deploy is somewhere in a known sequence, which is
   information; a percentage crawling to 90% and stopping is not. */
.stages { display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.stage { width: 18px; height: 4px; border-radius: 2px; background: var(--border-strong); flex: none; }
.stage.done { background: var(--ok); }
.stage.now { background: var(--run); animation: pulse 1.2s ease-in-out infinite; }
.stage.err { background: var(--err); animation: none; }
.stage-txt { margin-left: 5px; font-size: 12px; color: var(--muted); }

@media (max-width: 560px) {
  .dep { grid-template-columns: minmax(0, 1fr); }
  .dep-side { justify-items: start; text-align: left; }
}

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg);
  font-size: 13px; animation: rise .15s ease-out;
}
.toast.err { background: var(--err); color: #fff; }

/* ---------- empty & loading ---------- */
.empty { text-align: center; padding: var(--s7) var(--s5); }
.empty h2 { margin-bottom: var(--s1); }
.empty p { max-width: 44ch; margin: 0 auto; color: var(--muted); }
.empty .btn { margin-top: var(--s4); }
.empty .empty-mark {
  width: 44px; height: 44px; margin: 0 auto var(--s3); border-radius: var(--radius-sm);
  display: grid; place-items: center; background: var(--surface-2); color: var(--faint);
}
.empty .empty-mark svg { width: 22px; height: 22px; }

/* Shaped placeholders while something loads: a bar the width of the thing that
   is coming reads as "nearly there", where the word "Loading…" reads as a stall. */
.skel { display: block; height: 11px; border-radius: 5px; background: var(--surface-2); position: relative; overflow: hidden; }
.skel + .skel { margin-top: var(--s2); }
.skel.w40 { width: 40%; }
.skel.w60 { width: 60%; }
.skel.w80 { width: 80%; }
.skel.tall { height: 17px; }
.skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface-3) 80%, transparent), transparent);
  animation: sweep 1.3s ease-in-out infinite;
}
@keyframes sweep { to { transform: translateX(100%); } }
.skel-rows { display: grid; gap: var(--s4); padding: var(--s1) 0; }

.settings-grid { display: grid; gap: 16px; max-width: 760px; }
.gh-user { display: flex; align-items: center; gap: 12px; }
.gh-user img { width: 40px; height: 40px; border-radius: 50%; }
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.radio-card {
  display: block; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { margin: 0 6px 0 0; accent-color: var(--accent); }
.radio-card .d { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .mobile-bar {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px;
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border);
  }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 30; width: var(--sidebar-w);
    transform: translateX(-100%); transition: transform .18s ease-out; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 22px 16px 80px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (max-width: 720px) {
  .proj { grid-template-columns: 1fr; gap: 10px; }
  .grid-2, .grid-3, .radio-cards { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
}

/* Sign-in screen: the shell is replaced entirely, so it centres itself. */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.gate .card { width: min(380px, 100%); }
.gate .brand { font-size: 16px; }
