/* Colours follow design/tokens.json. This crate builds from its own Docker context, so the values are copied.
   The console CSP allows no inline styles, fonts or images: everything here is self-contained CSS. */
:root {
  --canvas: #1a1e23; --rail: #14171b; --pane: #22272e; --raised: #2c3139; --well: rgba(0, 0, 0, .22);
  --field: rgba(255, 255, 255, .07); --rule: rgba(255, 255, 255, .08); --rule-strong: rgba(255, 255, 255, .14);
  --ink: #f5f7fa; --body: #d0d6dd; --hint: #909aa4; --faint: #6c757f;
  --accent: #6aa6ff; --accent-wash: rgba(106, 166, 255, .16); --halo: rgba(106, 166, 255, .25);
  --run: #62c98a; --run-wash: rgba(98, 201, 138, .16);
  --warn: #e2bb6e; --warn-wash: rgba(226, 187, 110, .16);
  --bad: #f27a7a; --bad-wash: rgba(224, 92, 92, .18);
  --idle: #b4bcc6; --idle-wash: rgba(255, 255, 255, .1);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--body); background: var(--canvas); color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.015em; color: var(--ink); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 13px; font-weight: 650; letter-spacing: .02em; color: var(--ink); }
h3 { font-size: 13px; font-weight: 600; color: var(--ink); }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--well); padding: 1px 5px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--hint); }
.hint { color: var(--hint); font-size: 12.5px; max-width: 78ch; }
.pre-line { white-space: pre-line; }

/* Brand: a ring and its satellite. */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--ink); letter-spacing: -.01em; font-size: 15px; }
.brand-mark { position: relative; width: 18px; height: 18px; border: 2px solid var(--accent); border-radius: 50%; flex: none; }
.brand-mark::after { content: ""; position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); top: -3px; right: -2px; box-shadow: 0 0 0 2px var(--rail); }

/* Controls */
label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--hint); min-width: 0; }
input, select, textarea, button { font: inherit; color: var(--ink); }
input, select, textarea { background: var(--field); border: 1px solid var(--rule-strong); border-radius: 7px; padding: 8px 10px; min-width: 0; width: 100%; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:not([type=checkbox], [type=file]), select { height: 36px; }
input[type=checkbox] { width: 15px; height: 15px; padding: 0; accent-color: var(--accent); flex: none; }
input[type=file] { padding: 6px; }
textarea { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; resize: vertical; }
:is(input, select, textarea, button, summary, [role=tab]):focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; box-shadow: 0 0 0 4px var(--halo); }
input:user-invalid, select:user-invalid { border-color: var(--bad); }
button { cursor: pointer; background: var(--field); border: 1px solid var(--rule-strong); border-radius: 7px; padding: 7px 13px; font-weight: 550; white-space: nowrap; transition: background .12s, border-color .12s; }
button:hover { background: rgba(255, 255, 255, .12); }
button.primary { background: var(--accent); border-color: transparent; color: #0b1526; }
button.primary:hover { background: #86b7ff; }
button.danger { color: var(--bad); }
button.danger:hover { background: var(--bad-wash); border-color: var(--bad); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.busy { cursor: progress; }
fieldset { border: 1px solid var(--rule); border-radius: 9px; padding: 14px; margin: 0; min-width: 0; }
fieldset:disabled { opacity: .55; }
legend { font-size: 12px; color: var(--hint); padding: 0 6px; }
.check { flex-direction: row; align-items: center; gap: 9px; color: var(--body); font-size: 13px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.field-error { color: var(--bad); font-size: 12.5px; }
details > summary { cursor: pointer; font-weight: 600; color: var(--ink); font-size: 13px; border-radius: 5px; }
details[open] > summary { margin-bottom: 12px; }

/* Connect */
.connect { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(900px 480px at 50% -10%, rgba(106, 166, 255, .1), transparent 70%); }
.connect-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; background: var(--pane); border: 1px solid var(--rule-strong); border-radius: 14px; padding: 30px; box-shadow: 0 24px 60px rgba(0, 0, 0, .4); }
.connect-card h1 { margin-top: 8px; }
.connect-card .brand-mark::after { box-shadow: 0 0 0 2px var(--pane); }

/* Shell */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--rail); border-right: 1px solid var(--rule); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.rail .brand { padding: 0 8px; }
.account { padding: 2px 8px 14px 36px; color: var(--hint); font-size: 12.5px; overflow-wrap: anywhere; }
.rail-heading { padding: 10px 8px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.rail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.rail-list ul { list-style: none; margin: 1px 0 6px 13px; padding: 0 0 0 9px; border-left: 1px solid var(--rule-strong); display: flex; flex-direction: column; gap: 1px; }
.rail-item, .rail-link { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; border-radius: 7px; padding: 6px 8px; color: var(--body); font-weight: 500; overflow: hidden; }
.rail-item span:first-child { overflow: hidden; text-overflow: ellipsis; }
.rail-item:hover, .rail-link:hover { background: var(--field); }
.rail-item[aria-current=true], .rail-link[aria-current=true] { background: var(--accent-wash); color: var(--ink); }
.rail-item .dot { margin-left: auto; }
.rail-empty { padding: 4px 8px; color: var(--faint); font-size: 12.5px; }
.rail-form { display: flex; gap: 6px; padding: 8px 0 0; }
.rail-form button { padding: 7px 10px; }
.rail-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 1px; }

.stage { padding: 30px clamp(18px, 4vw, 48px) 80px; min-width: 0; }
.view { max-width: 1060px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; animation: rise .18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .view, .toast { animation: none !important; } }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: 2px; }
.crumb { background: none; border: 0; padding: 0; font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--hint); }
.crumb:hover { background: none; color: var(--accent); }
.crumb::before { content: "← "; }

.panel { background: var(--pane); border: 1px solid var(--rule); border-radius: 12px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; align-items: end; }
.grid > .wide, .grid > fieldset, .grid > .actions { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack:empty { display: none; }
.actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.actions.start { justify-content: flex-start; }
.actions.start:not(:has(> :not([hidden]))) { display: none; }
.actions.sticky { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--canvas) 35%); }
.actions.sticky p { margin-right: auto; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule-strong); overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; padding: 9px 12px; color: var(--hint); margin-bottom: -1px; }
.tabs button:hover { color: var(--ink); background: var(--field); }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); }
.tab-panel, #deploy { display: flex; flex-direction: column; gap: 18px; }

/* State */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; padding: 2px 9px; border-radius: 999px; background: var(--idle-wash); color: var(--idle); white-space: nowrap; }
.badge::before, .dot { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.dot { display: inline-block; color: var(--idle); }
.good { color: var(--run); } .badge.good { background: var(--run-wash); }
.active { color: var(--accent); } .badge.active { background: var(--accent-wash); }
.badge.active::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.warn { color: var(--warn); } .badge.warn { background: var(--warn-wash); }
.bad { color: var(--bad); } .badge.bad { background: var(--bad-wash); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--pane); border: 1px solid var(--rule); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat dt, .stat .k { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.stat .v { font-size: 17px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.stat .s { font-size: 12px; color: var(--hint); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.cards:empty { display: none; }
.card { text-align: left; white-space: normal; background: var(--pane); border: 1px solid var(--rule); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.card:hover { border-color: var(--accent); background: var(--raised); }
.card strong { color: var(--ink); font-size: 15px; }
.card .s { font-size: 12.5px; color: var(--hint); font-weight: 400; }

.notice { border-radius: 9px; padding: 10px 13px; font-size: 13px; background: var(--idle-wash); color: var(--body); max-width: none; }
.notice.warn { background: var(--warn-wash); color: var(--warn); }
.empty { color: var(--hint); padding: 8px 0; }
.empty.big { text-align: center; padding: 18vh 20px; display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* Records */
dl.kv { display: grid; grid-template-columns: minmax(130px, max-content) minmax(0, 1fr); gap: 7px 18px; margin: 0; }
dl.kv dt { color: var(--hint); font-size: 12.5px; }
dl.kv dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
dl.kv dd.mono { color: var(--body); }
.rows { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; align-items: center; padding: 11px 0; border-top: 1px solid var(--rule); }
.row:first-child { border-top: 0; padding-top: 2px; }
.row-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.row-main strong { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.row-sub { grid-column: 1 / -1; font-size: 12.5px; color: var(--hint); overflow-wrap: anywhere; }
.row > details { grid-column: 1 / -1; }
.row > details > summary { font-weight: 500; font-size: 12.5px; color: var(--hint); }
pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--well); border: 1px solid var(--rule); border-radius: 9px; padding: 13px 15px; max-height: 460px; overflow: auto; color: var(--body); line-height: 1.55; }

.service { border: 1px solid var(--rule-strong); border-radius: 10px; padding: 14px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 12px; background: var(--well); }
.service-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.secret { border: 1px solid var(--warn); background: var(--warn-wash); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.secret p { color: var(--warn); font-size: 13px; }
.secret pre { user-select: all; color: var(--ink); }

/* Toasts */
#toasts { position: fixed; z-index: 10; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 36px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; background: var(--raised); border: 1px solid var(--rule-strong); border-left: 3px solid var(--run); border-radius: 9px; padding: 11px 13px; box-shadow: 0 12px 34px rgba(0, 0, 0, .45); animation: rise .16s ease-out; color: var(--ink); font-size: 13px; }
.toast.error { border-left-color: var(--bad); }
.toast p { flex: 1; overflow-wrap: anywhere; }
.toast button { background: none; border: 0; padding: 0 2px; color: var(--hint); font-size: 16px; line-height: 1.2; }

@media (max-width: 820px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--rule); }
  .rail-foot { margin-top: 10px; flex-direction: row; flex-wrap: wrap; }
  .rail-link { width: auto; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
}
