/* Veld console + admin plane: tokens and components. Layout uses Tailwind utilities (app.css).
   ponytail: identical copy in console/public/ui.css; extract a shared package if they start to diverge. */

/* Style: "framed sheet" (dealt from a study of real product screens, docs in the workspace CLAUDE.md).
   One tinted L-shaped frame holds the sidebar; the work sits on a sheet with a hairline edge and 16px
   corners, inset 8px from the window. Depth comes from one tone step, never a shadow. Colour stays
   under 3% of the screen: a near-black primary, status in pale tints, the org swatch, nothing else.
   Themes: light tokens on :root; dark on [data-theme="dark"] and, without a choice, on the OS setting.
   The picker in the sidebar (public/theme.js) stores light | dark | system; the admin plane starts dark. */

@font-face { font-family: "Geist"; font-weight: 100 900; font-display: swap; src: url("/public/assets/geist-latin-wght-normal-BgDaEnEv.woff2") format("woff2"); }
@font-face { font-family: "Geist Mono"; font-weight: 100 900; font-display: swap; src: url("/public/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --ground: #f4f4f5;          /* the frame: sidebar and window */
  --surface: #ffffff;         /* the sheet, cards, inputs */
  --raised: #f4f4f5;          /* a filled inner well, hover rows, the tab track */
  --active: #e8e8ea;          /* the active nav pill */
  --border: #e6e6e8;          /* sheet and card edges: a whisper */
  --rule: #efeff1;            /* row rules inside tables */
  --control: #d4d4d8;         /* inputs and outlined buttons: one step stronger */
  --text: #111113;
  --muted: #5f6368;           /* labels, secondary text: 4.5:1 on white */
  --faint: #6b6b70;           /* meta, placeholders */
  --primary: #18181b;
  --on-primary: #ffffff;
  --ring: #a1a1aa;
  --ring-soft: rgba(161, 161, 170, 0.45);
  --ok: #247b50;        --ok-bg: #dcfae5;    --ok-ink: #04250e;
  --warn: #92400e;      --warn-bg: #fffbeb;  --warn-ink: #92400e;  --warn-line: #fde68a;
  --err: #c4242a;       --err-bg: #ffedea;   --err-ink: #831c1e;   --on-err: #ffffff;
  --term: #0f0f10;      --term-text: #e4e4e7;
  --radius-card: 8px;   --radius-control: 6px;   --radius-chip: 4px;   --radius-sheet: 16px;
  --focus: var(--ring);
  /* aliases kept for older rules */
  --bg: var(--ground); --side: var(--ground); --card: var(--surface); --sunken: var(--raised);
  --line: var(--border); --line-strong: var(--control); --hover: var(--raised);
}
/* dark: one true-neutral ground, elevation by lightness; two greys that read apart */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0a0a0a; --surface: #141414; --raised: #1f1f1f; --active: #262626;
  --border: #262626; --rule: #1e1e1e; --control: #3a3a3a;
  --text: #fafafa; --muted: #b4b4b4; --faint: #949494;
  --primary: #fafafa; --on-primary: #0a0a0a;
  --ring: #737373; --ring-soft: rgba(115, 115, 115, 0.5);
  --ok: #3fc07a;   --ok-bg: #172a1d;   --ok-ink: #3fc07a;
  --warn: #e5a93b; --warn-bg: #2b2414; --warn-ink: #e5a93b; --warn-line: #4a3b14;
  --err: #e5566f;  --err-bg: #2c1a20;  --err-ink: #e5566f;  --on-err: #ffffff;
  --term: #000000; --term-text: #e4e4e7;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0a0a0a; --surface: #141414; --raised: #1f1f1f; --active: #262626;
    --border: #262626; --rule: #1e1e1e; --control: #3a3a3a;
    --text: #fafafa; --muted: #b4b4b4; --faint: #949494;
    --primary: #fafafa; --on-primary: #0a0a0a;
    --ring: #737373; --ring-soft: rgba(115, 115, 115, 0.5);
    --ok: #3fc07a;   --ok-bg: #172a1d;   --ok-ink: #3fc07a;
    --warn: #e5a93b; --warn-bg: #2b2414; --warn-ink: #e5a93b; --warn-line: #4a3b14;
    --err: #e5566f;  --err-bg: #2c1a20;  --err-ink: #e5566f;  --on-err: #ffffff;
    --term: #000000; --term-text: #e4e4e7;
  }
}

html, body { background: var(--ground); color: var(--text); }
body { font-family: "Geist", ui-sans-serif, system-ui, sans-serif; font-size: 14px; line-height: 20px; -webkit-font-smoothing: antialiased; }
code, pre, .mono { font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring-soft); border-radius: var(--radius-control); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; }
.link { color: var(--text); text-decoration: underline; text-decoration-color: var(--control); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -100px; z-index: 100; padding: 8px 12px; border-radius: var(--radius-control); background: var(--primary); color: var(--on-primary); font-weight: 500; }
.skip-link:focus { top: 8px; }
main:focus { outline: none; }
.table-wrap:focus-visible, .logs:focus-visible { outline-offset: -2px; }
.items-start { align-items: flex-start; }

/* ---- shell: the frame and the sheet
   sidebar 232 on the frame ground; the sheet butts against it and is inset 8px from the window's
   top, right and bottom edges. Canvas padding 24; content capped at 1320 and centred on the sheet. */
.shell { display: flex; min-height: 100vh; }
.side { width: 232px; flex-shrink: 0; background: var(--ground); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.main { flex: 1; min-width: 0; margin: 8px 8px 8px 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sheet); }
.content { max-width: 1320px; margin: 0 auto; padding: 24px 24px 48px; display: flex; flex-direction: column; gap: 24px; }

.brand { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 16px; font-weight: 600; letter-spacing: -0.01em; }
.brand-mark { width: 24px; height: 24px; border-radius: var(--radius-control); background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.plane { margin-left: auto; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; line-height: 16px; padding: 1px 6px; border-radius: var(--radius-chip); background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; }
.nav-label { font-size: 12px; color: var(--faint); padding: 16px 8px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 8px; border-radius: var(--radius-card); color: var(--muted); font-size: 14px; transition: background-color 150ms, color 150ms; }
.nav a:hover { background: var(--raised); color: var(--text); }
.nav a[aria-current="page"] { background: var(--active); color: var(--text); }
.nav svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav .count { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; }

/* theme picker: a segmented track of three buttons; the chosen one sits on the surface */
.theme-pick { display: flex; gap: 2px; padding: 2px; border-radius: var(--radius-control); background: var(--active); }
.theme-pick button { flex: 1; height: 26px; padding: 0 8px; border: 0; border-radius: 4px; background: none; color: var(--muted); font-size: 12px; font-weight: 500; cursor: pointer; }
.theme-pick button:hover { color: var(--text); }
:root[data-theme-choice="light"] .theme-pick [data-theme-pick="light"],
:root[data-theme-choice="dark"] .theme-pick [data-theme-pick="dark"],
:root:not([data-theme-choice="light"]):not([data-theme-choice="dark"]) .theme-pick [data-theme-pick="system"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }

/* a 16px grey chevron drawn from a mask, used by the two switchers */
.chev { width: 16px; height: 16px; flex-shrink: 0; margin-left: auto; background: var(--muted); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / 16px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / 16px no-repeat; }

/* menus shared by the org switcher and the account row: a floating panel (so it may carry the
   shadow), 6px inset, 36px items with 10px side padding, one rule before a secondary action */
.menu { position: absolute; left: 0; right: 0; z-index: 20; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); display: flex; flex-direction: column; gap: 2px; }
.menu a, .menu button.menu-item { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 10px; border-radius: var(--radius-control); font-size: 14px; color: var(--text); width: 100%; border: 0; background: none; text-align: left; cursor: pointer; }
.menu a:hover, .menu button.menu-item:hover { background: var(--raised); }
.menu .menu-label { font-size: 12px; color: var(--faint); padding: 8px 10px 4px; }
.menu .menu-rule { height: 1px; background: var(--rule); margin: 4px 0; }
.menu .menu-head { padding: 6px 10px 8px; }
.menu .theme-pick { margin: 0 6px 4px; }

/* org switcher (native <details>): a 44px row, 24px swatch, name over role, chevron at the end */
.switcher { position: relative; margin: 0 12px 4px; }
.switcher > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; border-radius: var(--radius-card); border: 1px solid var(--border); background: var(--surface); }
.switcher > summary::-webkit-details-marker { display: none; }
.switcher > summary:hover, .switcher[open] > summary { border-color: var(--control); }
.switcher-menu { top: calc(100% + 4px); }
.switcher-menu a[aria-current="true"] { background: var(--active); }
.swatch { width: 24px; height: 24px; border-radius: var(--radius-control); flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }

/* account row (native <details>) at the sidebar's foot: avatar, name, chevron; the menu opens upward
   with the email, the theme choice, the plane link and Log out */
.account { position: relative; margin: 0 12px 12px; }
.account > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px 0 8px; border-radius: var(--radius-card); color: var(--text); }
.account > summary::-webkit-details-marker { display: none; }
.account > summary:hover, .account[open] > summary { background: var(--active); }
.avatar { width: 24px; height: 24px; border-radius: 999px; flex-shrink: 0; background: var(--active); color: var(--muted); display: grid; place-items: center; }
.avatar svg { width: 14px; height: 14px; }
.account-menu { bottom: calc(100% + 4px); }

/* ---- page title row: a noun at 24/600, one grey sentence, real actions on the right */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; line-height: 28px; font-weight: 600; letter-spacing: -0.01em; }
.page-head p { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumbs a:hover { color: var(--text); }

/* ---- cards: surface + 1px edge, 8px corners, 20px inset, no shadow, no header rule.
   A table or an empty state inside a card runs edge to edge under a rule. */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
.card-head { padding: 20px 20px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-head h2 { font-size: 16px; line-height: 20px; font-weight: 600; }
.card-head p { color: var(--muted); margin-top: 2px; }
.card-head:last-child { padding-bottom: 20px; }
.card-body { padding: 20px; }
.card-head + .table-wrap, .card-head + .empty, .card-head + .logs, .card-head + .term { margin-top: 16px; }
.card > .table-wrap, .card > div > .table-wrap { border-top: 1px solid var(--border); }
.card > .table-wrap:last-child, .card > div > .table-wrap:last-child { border-radius: 0 0 var(--radius-card) var(--radius-card); overflow: hidden; }
.card-danger { border-color: var(--err); }
.grid:not(.items-end):not(.items-center) { align-items: flex-start; }

/* ---- KPIs: one container split by 1px dividers, label over value, value 24 at 500, no tiles.
   Three cells per row, so three or six figures fill their rows; the phone shows two. */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.stat { background: var(--surface); padding: 16px 20px; min-width: 0; }
.stat-label { color: var(--muted); }
.stat-value { font-size: 24px; line-height: 28px; font-weight: 500; letter-spacing: -0.01em; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-hint { font-size: 12px; line-height: 16px; color: var(--faint); margin-top: 4px; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.fact dt { font-size: 12px; line-height: 16px; color: var(--muted); }
.fact dd { margin: 2px 0 0; overflow-wrap: anywhere; }

/* ---- tables: 12px grey sentence-case header with no band, 44px rows, 1px rules, numbers right in
   tabular figures. The identity column gets the ink; the rest stays quiet. */
.table-wrap { overflow-x: auto; position: relative; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { height: 36px; text-align: left; font-weight: 400; font-size: 12px; color: var(--muted); padding: 0 16px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.table td { height: 44px; padding: 8px 16px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--raised); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table td .muted, .table td .text-xs { color: var(--muted); }

/* empty state: the block keeps its frame; one sentence in a dashed box */
.empty { margin: 0 20px 20px; padding: 9px 12px; min-height: 38px; border: 1px dashed var(--control); border-radius: var(--radius-card); display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; color: var(--muted); }
.empty strong { color: var(--text); font-weight: 500; }
.empty > .btn, .empty > form { margin-left: auto; }
.card-head + .empty { margin-top: 16px; }
/* an empty block with no header: the dashed box is the block, not a box inside a card */
.card:has(> .empty:only-child) { border: 0; background: none; border-radius: 0; }
.card > .empty:only-child { margin: 0; }

/* ---- controls: 32px, 6px corners, flat. Outline = surface + control border; .btn-primary near-black
   (inverted on dark); .btn-danger the negative colour. One primary per screen. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius-control); font-size: 14px; font-weight: 500; line-height: 1; border: 1px solid var(--control); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; transition: background-color 120ms, border-color 120ms; }
.btn:hover { background: var(--raised); }
.btn:disabled { pointer-events: none; opacity: 0.5; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary); opacity: 0.9; }
.btn-danger { background: var(--surface); border-color: var(--err); color: var(--err); }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-link { border: 0; background: none; padding: 0; height: auto; color: var(--muted); }
.btn-link:hover { background: none; color: var(--text); }
.btn:focus-visible, .input:focus-visible, .checkbox:focus-visible, .switcher > summary:focus-visible, .theme-pick button:focus-visible { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px var(--ring-soft); }
form.inline { display: inline; margin: 0; }

/* fields: 14/500 label above, 8px gap, 36px input with 12px inset, 14px grey help */
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span, .field > legend { font-size: 14px; font-weight: 500; line-height: 16px; }
.field > small { font-size: 13px; line-height: 18px; color: var(--muted); }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field > legend { padding: 0; margin-bottom: 10px; }
.input { width: 100%; height: 36px; min-width: 0; padding: 4px 12px; border-radius: var(--radius-control); border: 1px solid var(--control); background: var(--surface); color: var(--text); font-size: 14px; line-height: 20px; transition: border-color 120ms, box-shadow 120ms; }
.input::placeholder { color: var(--faint); }
.input:disabled { cursor: not-allowed; opacity: 0.5; }
.input[aria-invalid="true"] { border-color: var(--err); }
.input:focus { outline: none; }
select.input { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6b70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; cursor: pointer; }
textarea.input { height: auto; min-height: 64px; padding: 8px 12px; font-family: "Geist Mono", ui-monospace, monospace; font-size: 13px; line-height: 1.6; }
.affix { display: flex; align-items: center; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); padding-right: 12px; }
.affix .input { border: 0; }
.affix:focus-within { border-color: var(--ring); box-shadow: 0 0 0 3px var(--ring-soft); }
.affix span { color: var(--muted); white-space: nowrap; }

/* checkbox: 16px, 4px corners, filled with the primary when checked */
.checkbox { appearance: none; width: 16px; height: 16px; flex-shrink: 0; margin: 0; border: 1px solid var(--control); border-radius: var(--radius-chip); background: var(--surface); cursor: pointer; display: grid; place-content: center; transition: background-color 120ms, border-color 120ms; }
.checkbox:checked { background: var(--primary); border-color: var(--primary); }
.checkbox:checked::after { content: ""; width: 10px; height: 10px; background: var(--on-primary); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; line-height: 16px; cursor: pointer; user-select: none; min-height: 20px; }

/* ---- status: pale tint with dark text of the same hue, 20px tall, one mark per row */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; line-height: 16px; padding: 2px 8px; border-radius: var(--radius-chip); background: var(--raised); color: var(--text); white-space: nowrap; flex: none; }
.badge-ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge-warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge-err { background: var(--err-bg); color: var(--err-ink); }
.rollout-fail { display: flex; flex-direction: column; gap: 4px; min-height: 44px; padding: 12px 16px; border: 1px solid var(--err); border-radius: var(--radius-card); background: var(--surface); color: var(--text); font-size: 14px; }
.rollout-fail strong { color: var(--err); }
.rollout-fail code { overflow-wrap: anywhere; font-size: 13px; }
.dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; display: inline-block; }

.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: var(--radius-card); border: 1px solid var(--border); background: var(--surface); font-size: 14px; }
.flash-ok { color: var(--ok); }
.flash-err { color: var(--err); border-color: var(--err); }
.flash pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }

/* ---- code & logs */
.term { background: var(--term); color: var(--term-text); border-radius: var(--radius-card); padding: 12px 14px; margin: 0; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.term .c { color: #8f8f99; }
.copy { user-select: all; }
.logs { background: var(--term); color: var(--term-text); border-radius: var(--radius-card); padding: 10px 0; overflow-y: auto; font-family: "Geist Mono", ui-monospace, monospace; font-size: 12.5px; line-height: 1.7; }
.logs > div { display: flex; gap: 14px; padding: 0 14px; }
.logs > div:hover { background: rgba(255, 255, 255, 0.04); }
.logs .t { color: #8f8f99; width: 72px; flex-shrink: 0; }
.logs .s { color: #7dd3fc; width: 140px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logs .l { white-space: pre-wrap; overflow-wrap: anywhere; }
.logs .none { color: #8f8f99; padding: 24px 14px; }

/* ---- tabs: the style's move. Underline tabs on a full-width 1px rule, a 2px indicator as wide as
   the label, grey labels, ink for the active one. */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; height: 36px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 14px; font-weight: 500; white-space: nowrap; transition: color 120ms; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--text); }

/* ---- popover dialog (native [popover]): one of the few things that floats, so it has the shadow */
[popover] { border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); color: var(--text); padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2); }
[popover]::backdrop { background: rgba(0, 0, 0, 0.5); }

/* ---- editor (Monaco via veld-monarch.js) */
.editor { border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; background: #09090b; }
.editor-bar { height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px 0 0; background: #09090b; border-bottom: 1px solid #27272a; }
.editor-tab { height: 40px; padding: 0 14px; display: inline-flex; align-items: center; border-right: 1px solid #27272a; border-top: 2px solid transparent; color: #a1a1aa; font-family: "Geist Mono", ui-monospace, monospace; font-size: 12.5px; cursor: pointer; }
.editor-tab:hover { color: #f4f4f5; }
.editor-tab[aria-current="true"] { color: #f4f4f5; border-top-color: #34d399; background: #111113; }
#veld-compiler-status-badge { font-size: 12px; color: #a1a1aa; }
#veld-compiler-status-badge[data-state="ok"] { color: #34d399; }
#veld-compiler-status-badge[data-state="err"] { color: #fb7185; }
.editor-status { height: 30px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; background: #09090b; border-top: 1px solid #27272a; color: #a1a1aa; font-size: 12px; }

/* ---- auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: 100%; max-width: 400px; }
.auth .card-body, .auth form { padding: 24px; }
.auth h1 { font-size: 20px; line-height: 24px; font-weight: 600; letter-spacing: -0.01em; }

/* ---- admin plane: same chrome as the console; the ADMIN chip in the brand row names the plane and
   theme.js starts it dark (data-theme-default on <html>). */
.plane-admin .brand { gap: 8px; }

/* ---- phone (<768px): the frame disappears and the sheet becomes the screen. Brand + org on one row,
   the nav wraps into chip rows under it (sticky), footer under the content. .side uses display: contents
   so .nav can stick for the whole page. Keep this block last. */
@media (max-width: 767px) {
  body { font-size: 15px; }
  .shell { display: flex; flex-wrap: wrap; align-content: flex-start; min-height: 100dvh; }
  .side { display: contents; }
  .main { margin: 0; border: 0; border-radius: 0; }
  .brand { background: var(--ground); padding: 0 8px 0 16px; align-self: stretch; }
  .plane-admin .brand { flex: 1 1 auto; padding-right: 8px; }
  .switcher { flex: 1 1 0; min-width: 0; margin: 0; padding: 4px 8px 4px 0; background: var(--ground); }
  .switcher > summary { min-height: 40px; padding: 4px 8px; }
  .switcher-menu { max-height: 60vh; overflow-y: auto; }
  .switcher-menu a { min-height: 44px; }
  .nav { flex: 0 0 100%; position: sticky; top: 0; z-index: 10; flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 6px 16px 8px; background: var(--ground); border-bottom: 1px solid var(--border); }
  .nav a { flex: 0 0 auto; min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
  .nav a[aria-current="page"] { background: var(--surface); border-color: var(--control); }
  .nav .count { margin-left: 6px; }
  .main { flex: 1 1 100%; }
  .content { padding: 20px 16px 32px; gap: 20px; }
  /* first row: brand, org switcher, account; then the nav; then the sheet */
  .side-foot { flex: 0 0 auto; margin-left: auto; background: var(--ground); padding-right: 8px; }
  .nav { order: 1; }
  .main { order: 2; }
  .account { margin: 0; }
  .account > summary { height: 44px; }
  .account > summary > .min-w-0, .account > summary > .chev { display: none; }
  .account-menu { top: calc(100% + 4px); bottom: auto; left: auto; right: 0; width: 260px; }
  .switcher-menu { left: 0; right: 16px; }
  .theme-pick button { height: 32px; }

  .page-head { align-items: flex-start; }
  .page-head > .btn, .page-head > div + div { flex: 1 1 100%; }
  .page-head > div + div { flex-wrap: wrap; }
  .page-head > div + div > .btn, .page-head > div + div > form { flex: 1 1 auto; }
  .card-head { flex-wrap: wrap; padding: 16px 16px 0; }
  .card-body { padding: 16px; }
  .empty { margin: 0 16px 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat-value { font-size: 22px; }

  .btn, .btn-sm { min-height: 44px; height: auto; padding: 0 16px; }
  .input { height: 44px; font-size: 16px; }
  textarea.input { font-size: 14px; }
  .check { min-height: 44px; }
  .tabs { gap: 20px; }
  .tabs a { min-height: 44px; }
  .table th, .table td { padding: 4px 12px; }
  .table th:first-child, .table td:first-child { padding-left: 16px; }
  .table th:last-child, .table td:last-child { padding-right: 16px; }
  .table td a { display: inline-flex; align-items: center; min-height: 44px; }
  .table th:first-child, .table td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
  .table tbody tr:hover td:first-child { background: var(--surface); }
  .table-wrap { border-right: 1px solid var(--border); } /* flat hint that the table continues sideways */
  /* stacked rows (.table-stack): one compact card per row instead of a wrapped, very tall table.
     Cells keep their order in the DOM: when, actor, action, target. */
  .table-wrap:has(.table-stack) { background: none; }
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .table-stack, .table-stack tbody { display: block; }
  .table-stack tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 10px 16px; border-bottom: 1px solid var(--rule); }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack td, .table-stack td:first-child { display: block; position: static; height: auto; padding: 0; border: 0; background: none; }
  .table-stack td:nth-child(1) { order: 3; margin-left: auto; font-size: 12px; }
  .table-stack td:nth-child(2) { order: 1; }
  .table-stack td:nth-child(3) { order: 2; }
  .table-stack td:nth-child(4) { order: 4; flex: 1 0 100%; font-size: 12.5px; overflow-wrap: anywhere; }
  .logs > div { flex-wrap: wrap; gap: 2px 10px; padding: 6px 14px; }
  .logs .t { width: auto; }
  .logs .s { width: auto; max-width: 60%; }
  .logs .l { flex-basis: 100%; }
  .editor-status span:last-child { display: none; }
  .editor-bar { height: auto; min-height: 40px; flex-wrap: wrap; }
  [popover] { max-height: 90dvh; overflow-y: auto; }
  .auth { padding: 16px; align-items: start; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
