/* ============================================================
   reMaestro cloud console
   The same design system as the hub (src/Remaestro.Hub/wwwroot/app.css) — same tokens, same type scale,
   same card/chip/button treatment — written out again rather than imported.

   Why a copy: these are two applications, deployed separately, that must be able to change at different
   speeds. Importing the hub's sheet would make a rail tweak for a living-room tablet a deploy of the paid
   service, and it would drag in three thousand lines of device cards, remote walls and IR designers that
   nothing here renders. What is shared is the *language* — the variable names below are deliberately
   identical, so anything copied between the two projects lands looking right.
   ============================================================ */

/* ---- Tokens: shared ---- */
:root {
  /* Hanken Grotesk if the reader has it (the hub ships the webfont; this service doesn't carry a
     binary just for a headline), otherwise the platform's own UI face — which is what the fallback
     stack is for, and it is a better answer than a flash of nothing while a font downloads. */
  --font-sans: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  --r-xs: 8px; --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 24px; --r-2xl: 32px; --r-pill: 999px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-1: 0.14s; --dur-2: 0.22s; --dur-3: 0.4s;

  --z-dropdown: 100; --z-sticky: 200; --z-rail: 300; --z-backdrop: 400; --z-modal: 500; --z-toast: 600;
}

/* ---- Tokens: dark (default — "cinema") ---- */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: oklch(0.155 0.012 264);
  --bg-deep: oklch(0.12 0.012 264);
  --surface: oklch(0.198 0.013 264);
  --surface-2: oklch(0.238 0.014 264);
  --surface-3: oklch(0.29 0.015 264);
  --border: oklch(0.99 0.01 264 / 0.10);
  --border-strong: oklch(0.99 0.01 264 / 0.20);
  --ink: oklch(0.96 0.006 264);
  --ink-muted: oklch(0.735 0.014 264);
  --ink-faint: oklch(0.57 0.016 264);

  --accent: oklch(0.77 0.155 60);
  --accent-hi: oklch(0.84 0.14 66);
  --accent-text: oklch(0.84 0.13 66);
  --on-accent: oklch(0.2 0.045 58);
  --accent-soft: oklch(0.77 0.155 60 / 0.16);
  --accent-line: oklch(0.77 0.155 60 / 0.32);
  --accent-glow: oklch(0.77 0.155 60 / 0.42);

  --signal: oklch(0.82 0.1 205);
  --signal-text: oklch(0.85 0.09 205);
  --signal-soft: oklch(0.82 0.1 205 / 0.16);

  --ok: oklch(0.79 0.15 155);
  --warn: oklch(0.83 0.14 88);
  --warn-text: oklch(0.86 0.12 88);
  --danger: oklch(0.72 0.16 22);
  --danger-text: oklch(0.8 0.12 22);
  --danger-soft: oklch(0.72 0.16 22 / 0.16);

  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.4), 0 3px 10px oklch(0 0 0 / 0.28);
  --shadow-2: 0 12px 40px oklch(0 0 0 / 0.5);
  --shadow-pop: 0 30px 80px oklch(0 0 0 / 0.6);
  --scrim: oklch(0.08 0.01 264 / 0.66);

  --body-glow: radial-gradient(1200px 720px at 88% -8%, oklch(0.77 0.155 60 / 0.09), transparent 60%),
               radial-gradient(900px 600px at 8% 108%, oklch(0.82 0.1 205 / 0.05), transparent 55%);
}

/* ---- Tokens: light ("daylight") ---- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: oklch(0.981 0.004 264);
  --bg-deep: oklch(0.955 0.005 264);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.976 0.004 264);
  --surface-3: oklch(0.95 0.006 264);
  --border: oklch(0.22 0.02 264 / 0.10);
  --border-strong: oklch(0.22 0.02 264 / 0.18);
  --ink: oklch(0.26 0.02 264);
  --ink-muted: oklch(0.45 0.02 264);
  --ink-faint: oklch(0.56 0.02 264);

  --accent: oklch(0.7 0.17 54);
  --accent-hi: oklch(0.66 0.18 50);
  --accent-text: oklch(0.5 0.16 46);
  --on-accent: oklch(0.99 0.02 80);
  --accent-soft: oklch(0.7 0.17 54 / 0.12);
  --accent-line: oklch(0.7 0.17 54 / 0.34);
  --accent-glow: oklch(0.7 0.17 54 / 0.3);

  --signal: oklch(0.62 0.12 220);
  --signal-text: oklch(0.52 0.13 222);
  --signal-soft: oklch(0.62 0.12 220 / 0.12);

  --ok: oklch(0.62 0.15 155);
  --warn: oklch(0.68 0.14 70);
  --warn-text: oklch(0.5 0.13 62);
  --danger: oklch(0.58 0.19 24);
  --danger-text: oklch(0.52 0.19 24);
  --danger-soft: oklch(0.58 0.19 24 / 0.1);

  --shadow-1: 0 1px 2px oklch(0.4 0.02 264 / 0.08), 0 4px 14px oklch(0.4 0.02 264 / 0.08);
  --shadow-2: 0 14px 40px oklch(0.3 0.02 264 / 0.14);
  --shadow-pop: 0 30px 80px oklch(0.3 0.02 264 / 0.24);
  --scrim: oklch(0.4 0.02 264 / 0.28);

  --body-glow: radial-gradient(1200px 720px at 88% -8%, oklch(0.7 0.17 54 / 0.06), transparent 60%),
               radial-gradient(900px 600px at 8% 108%, oklch(0.62 0.12 220 / 0.05), transparent 55%);
}

/* The theme is stamped on <html> before first paint by a script in App.razor. This is the fallback for the
   half-second before that runs and for anyone with script off: follow the operating system rather than
   assuming dark, because a white page arriving in a dark room is the failure people actually notice. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: oklch(0.981 0.004 264); --bg-deep: oklch(0.955 0.005 264);
    --surface: oklch(1 0 0); --surface-2: oklch(0.976 0.004 264); --surface-3: oklch(0.95 0.006 264);
    --border: oklch(0.22 0.02 264 / 0.10); --border-strong: oklch(0.22 0.02 264 / 0.18);
    --ink: oklch(0.26 0.02 264); --ink-muted: oklch(0.45 0.02 264); --ink-faint: oklch(0.56 0.02 264);
    --accent: oklch(0.7 0.17 54); --accent-hi: oklch(0.66 0.18 50); --accent-text: oklch(0.5 0.16 46);
    --on-accent: oklch(0.99 0.02 80); --accent-soft: oklch(0.7 0.17 54 / 0.12);
    --accent-line: oklch(0.7 0.17 54 / 0.34); --accent-glow: oklch(0.7 0.17 54 / 0.3);
    --signal: oklch(0.62 0.12 220); --signal-text: oklch(0.52 0.13 222); --signal-soft: oklch(0.62 0.12 220 / 0.12);
    --ok: oklch(0.62 0.15 155); --warn: oklch(0.68 0.14 70); --warn-text: oklch(0.5 0.13 62);
    --danger: oklch(0.58 0.19 24); --danger-text: oklch(0.52 0.19 24); --danger-soft: oklch(0.58 0.19 24 / 0.1);
    --shadow-1: 0 1px 2px oklch(0.4 0.02 264 / 0.08), 0 4px 14px oklch(0.4 0.02 264 / 0.08);
    --shadow-2: 0 14px 40px oklch(0.3 0.02 264 / 0.14);
    --shadow-pop: 0 30px 80px oklch(0.3 0.02 264 / 0.24);
    --scrim: oklch(0.4 0.02 264 / 0.28);
    --body-glow: radial-gradient(1200px 720px at 88% -8%, oklch(0.7 0.17 54 / 0.06), transparent 60%),
                 radial-gradient(900px 600px at 8% 108%, oklch(0.62 0.12 220 / 0.05), transparent 55%);
  }
}

:root[data-theme="light"] .btn-primary { color: var(--on-accent); }

/* ---- Reset / base ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
/* 16px is the threshold below which iOS zooms into a focused field and drags the page sideways with it. */
input, select, textarea { font-size: max(16px, 1em); }
body {
  font-family: var(--font-sans);
  font-weight: 450;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--body-glow);
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
::selection { background: var(--accent-soft); color: var(--ink); }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }

h1, h2, h3, h4 { font-weight: 750; letter-spacing: -0.02em; line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: 1.6rem; letter-spacing: -0.03em; }
h2 { font-size: 1.2rem; margin: 0 0 14px; }
h3 { font-size: 1rem; }
p { margin: 0; }
code, .mono { font-family: var(--font-mono); }
small { font-size: 0.82em; }

/* ============================================================
   Console shell — left rail + content
   ============================================================ */
.app { min-height: 100dvh; display: grid; grid-template-columns: 248px 1fr; }

.rail {
  position: sticky; top: 0; align-self: start; height: 100dvh; z-index: var(--z-rail);
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 14px; background: var(--bg-deep);
  border-right: 1px solid var(--border);
}
.rail-brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 14px; }
.rail-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center; color: var(--on-accent);
  background: linear-gradient(150deg, var(--accent-hi), var(--accent));
  box-shadow: 0 6px 18px var(--accent-glow), inset 0 1px 0 oklch(1 0 0 / 0.35);
}
.rail-mark svg { width: 19px; height: 19px; }
.rail-word { display: flex; flex-direction: column; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; font-size: 1.06rem; }
.rail-word small { color: var(--ink-faint); font-weight: 600; font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; }

.rail-label { font-size: 0.64rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); padding: 14px 10px 6px; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--ink-muted); font-weight: 600; font-size: 0.92rem;
  transition: background var(--dur-1), color var(--dur-1);
}
.rail-link svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.rail-link:hover { background: var(--surface); color: var(--ink); }
.rail-link.active { background: var(--accent-soft); color: var(--accent-text); }
.rail-link.active svg { opacity: 1; }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 12px; }
.rail-who {
  display: flex; align-items: center; gap: 10px; padding: 10px 11px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border); min-width: 0;
}
.rail-who-mark {
  width: 28px; height: 28px; flex: none; border-radius: var(--r-pill); display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text); font-weight: 800; font-size: 0.78rem;
}
.rail-who-txt { min-width: 0; line-height: 1.25; }
.rail-who-email { font-size: 0.8rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-who-role { font-size: 0.66rem; color: var(--ink-faint); font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.rail-out { width: 100%; }

.main { min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 30px 32px 90px; }
/* The model browser is genuinely a wide table and says so by putting .wide-page on the page. Selecting on
   what the page contains rather than on a class the layout would have to be told to add — the layout renders
   statically and has no idea which route is inside it. */
.content:has(.wide-page) { max-width: 1420px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.7rem; }
.page-head p { margin: 6px 0 0; color: var(--ink-muted); font-size: 0.95rem; max-width: 62ch; line-height: 1.55; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Mobile: the rail folds into a bar whose menu is a <details>, because this layout renders
        statically and must work with no circuit and no script at all. ---- */
.topbar { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .topbar {
    display: block; position: sticky; top: 0; z-index: var(--z-sticky);
    background: var(--bg-deep); border-bottom: 1px solid var(--border);
  }
  .topbar-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
  .topbar-row .rail-word { flex: 1; min-width: 0; }
  .topbar-menu { list-style: none; position: relative; flex: none; }
  .topbar-menu > summary {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
    padding: 8px 13px; border-radius: var(--r-sm);
    background: var(--surface); border: 1px solid var(--border-strong);
    font-weight: 700; font-size: 0.9rem;
  }
  .topbar-menu > summary::-webkit-details-marker { display: none; }
  .topbar-menu[open] > summary { border-color: var(--accent-line); color: var(--accent-text); }
  /* Dropped out of flow so the row keeps its height whether the menu is open or shut. */
  .topbar-panel {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: var(--z-dropdown);
    width: min(300px, calc(100vw - 32px));
    padding: 2px 12px 14px; border-radius: var(--r-md);
    background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-2);
  }
  .topbar-panel .rail-label:first-child { padding-top: 10px; }
  .content { padding: 20px 16px 70px; }
  .page-head { margin-bottom: 16px; gap: 10px; }
  .page-head h1 { font-size: 1.32rem; }
  .page-head p { font-size: 0.88rem; }
}

/* ============================================================
   Primitives — same names as the hub, so markup travels
   ============================================================ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-1); }
.card + .card { margin-top: 14px; }
.card h2 { font-size: 1.05rem; margin: 0 0 4px; }
.card > p.muted { margin-bottom: 14px; line-height: 1.55; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); align-items: start; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--ink);
  border-radius: var(--r-sm); padding: 9px 15px; font-size: 0.9rem; font-weight: 650; cursor: pointer;
  transition: background var(--dur-1), border-color var(--dur-1), transform var(--dur-1) var(--ease), box-shadow var(--dur-1);
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: linear-gradient(150deg, var(--accent-hi), var(--accent)); border: none; color: var(--on-accent);
  box-shadow: 0 6px 18px var(--accent-glow), inset 0 1px 0 oklch(1 0 0 / 0.3);
}
.btn-primary:hover {
  border: none;
  background: linear-gradient(150deg, color-mix(in oklab, var(--accent-hi) 86%, white), color-mix(in oklab, var(--accent) 90%, white));
  box-shadow: 0 8px 24px var(--accent-glow), inset 0 1px 0 oklch(1 0 0 / 0.35);
}
.btn-danger { background: var(--danger-soft); border-color: color-mix(in oklab, var(--danger) 40%, transparent); color: var(--danger-text); }
.btn-danger:hover { background: color-mix(in oklab, var(--danger) 22%, transparent); }
.btn-sm { padding: 6px 11px; font-size: 0.82rem; border-radius: var(--r-xs); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-block { width: 100%; }

/* ---- Forms ---- */
.field { margin-bottom: 14px; }
.field label, .field > .lbl { display: block; font-size: 0.78rem; font-weight: 650; color: var(--ink-muted); margin-bottom: 6px; }
.input, .select, textarea.input {
  width: 100%; padding: 10px 13px; border-radius: var(--r-sm); background: var(--bg-deep);
  border: 1px solid var(--border); color: var(--ink); font-size: 0.92rem; font-family: inherit; outline: none;
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.input::placeholder { color: var(--ink-faint); }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); outline: none; }
.input-sm { padding: 6px 9px; font-size: 0.84rem; }
.input-num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.row-tight { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'><path d='M7 10l5 5 5-5'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center; padding-right: 34px; cursor: pointer;
}
.select option { background: var(--surface); color: var(--ink); }
.select-sm { padding: 6px 28px 6px 9px; font-size: 0.84rem; width: auto; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.86rem; font-weight: 600; color: var(--ink-muted); cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---- Chips / tags / status ---- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--border); font-size: 0.74rem; font-weight: 650; white-space: nowrap; }
.chip.ok { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 34%, transparent); background: color-mix(in oklab, var(--ok) 13%, transparent); }
.chip.warn { color: var(--warn-text); border-color: color-mix(in oklab, var(--warn) 34%, transparent); background: color-mix(in oklab, var(--warn) 13%, transparent); }
.chip.bad { color: var(--danger-text); border-color: color-mix(in oklab, var(--danger) 32%, transparent); background: var(--danger-soft); }
.chip.accent { color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-family: var(--font-mono); font-size: 0.72rem; padding: 2px 8px; border-radius: var(--r-xs); background: var(--surface-2); color: var(--ink-muted); border: 1px solid var(--border); white-space: nowrap; }
.tag.type { color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok) 20%, transparent); }
.pill { display: inline-block; min-width: 62px; text-align: center; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 9px; border-radius: var(--r-pill); }
.pill-admin { background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent-line); }
.pill-user { background: var(--surface-3); color: var(--ink-muted); border: 1px solid var(--border-strong); }

/* ---- Page furniture ---- */
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.hint { font-size: 0.8rem; color: var(--ink-faint); margin-top: 5px; line-height: 1.5; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.num { font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 46px 20px; color: var(--ink-muted); }
.empty h3 { color: var(--ink); font-size: 1.1rem; margin: 0 0 8px; }
.empty p { max-width: 50ch; margin: 0 auto; line-height: 1.6; font-size: 0.92rem; }

/* A sentence the reader is meant to act on. Three tones and no icons — the colour and the words carry it. */
.note { border-radius: var(--r-md); padding: 11px 14px; font-size: 0.86rem; line-height: 1.55; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-muted); }
.note strong { color: var(--ink); font-weight: 700; }
.note.ok { border-color: color-mix(in oklab, var(--ok) 34%, transparent); background: color-mix(in oklab, var(--ok) 10%, transparent); color: var(--ink); }
.note.warn { border-color: color-mix(in oklab, var(--warn) 36%, transparent); background: color-mix(in oklab, var(--warn) 10%, transparent); color: var(--ink); }
.note.bad { border-color: color-mix(in oklab, var(--danger) 38%, transparent); background: var(--danger-soft); color: var(--ink); }
.note + .note, .note + .card, .card + .note, .note + .stack { margin-top: 14px; }

/* ---- Segmented control ---- */
.seg { display: inline-flex; background: var(--bg-deep); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg-btn { border: none; background: none; color: var(--ink-muted); font-size: 0.82rem; font-weight: 650; padding: 6px 11px; border-radius: var(--r-xs); cursor: pointer; white-space: nowrap; transition: background var(--dur-1), color var(--dur-1); }
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--surface-3); color: var(--accent-text); box-shadow: var(--shadow-1); }

/* ---- Definition rows (account facts, backup facts) ---- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; font-size: 0.9rem; align-items: baseline; }
.facts dt { color: var(--ink-faint); font-size: 0.78rem; font-weight: 650; letter-spacing: 0.03em; text-transform: uppercase; }
.facts dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .facts { grid-template-columns: 1fr; gap: 2px 0; } .facts dd { margin-bottom: 10px; } }

/* ---- Tables ---- */
.tbl-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.tbl th {
  text-align: left; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-faint); font-weight: 700; padding: 10px 10px; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.tbl td { padding: 11px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.tbl tr.off { opacity: 0.55; }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-sort { background: none; border: none; color: inherit; font: inherit; cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 4px; }
.tbl-sort:hover { color: var(--ink); }
.tbl-sort.on { color: var(--accent-text); }

/* ============================================================
   Public pages — sign in, sign up, sign out
   ============================================================ */
.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(120% 80% at 50% -10%, var(--accent-glow), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-2xl); box-shadow: var(--shadow-pop); padding: 34px 30px 30px; }
@media (max-width: 460px) { .auth-shell { padding: 16px; align-content: safe center; } .auth-card { padding: 26px 22px 24px; } }
.auth-brand { display: flex; align-items: center; gap: 11px; justify-content: center; margin-bottom: 24px; }
.auth-word { font-weight: 800; letter-spacing: -0.02em; font-size: 1.15rem; text-align: left; }
.auth-word small { display: block; color: var(--ink-faint); font-weight: 600; font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase; }
.auth-h { font-size: 1.4rem; margin: 0 0 4px; text-align: center; }
.auth-sub { margin: 0 0 20px; text-align: center; color: var(--ink-muted); font-size: 0.9rem; line-height: 1.55; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > span { font-size: 0.78rem; font-weight: 650; color: var(--ink-muted); }
.auth-submit { margin-top: 4px; padding-top: 11px; padding-bottom: 11px; }
.auth-err { background: var(--danger-soft); color: var(--danger-text); border-radius: var(--r-sm); padding: 10px 13px; font-size: 0.84rem; margin-bottom: 16px; line-height: 1.5; }
.auth-alt { margin: 18px 0 0; text-align: center; font-size: 0.86rem; color: var(--ink-muted); }
.auth-alt a { color: var(--accent-text); font-weight: 650; }
.auth-alt a:hover { text-decoration: underline; }

/* The first-account-is-the-administrator notice. Deliberately loud on the sign-up page: it is the one fact
   about this form whose consequences are permanent, and burying it in small grey text would be a way of
   technically having said it. */
.auth-first {
  border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--ink);
  border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 18px; font-size: 0.85rem; line-height: 1.55;
}
.auth-first strong { color: var(--accent-text); }

/* ============================================================
   Feature list (what an account may use)
   ============================================================ */
.feat { display: flex; gap: 14px; align-items: flex-start; padding: 15px 0; border-top: 1px solid var(--border); }
.feat:first-child { border-top: none; padding-top: 4px; }
.feat-mark { width: 32px; height: 32px; flex: none; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-faint); }
.feat-mark svg { width: 17px; height: 17px; }
.feat.on .feat-mark { background: color-mix(in oklab, var(--ok) 14%, transparent); border-color: color-mix(in oklab, var(--ok) 34%, transparent); color: var(--ok); }
.feat-body { min-width: 0; flex: 1; }
.feat-name { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-weight: 700; font-size: 0.96rem; }
.feat-desc { color: var(--ink-muted); font-size: 0.87rem; margin-top: 3px; line-height: 1.55; }
.feat-meta { color: var(--ink-faint); font-size: 0.78rem; margin-top: 5px; }

/* ============================================================
   Hubs
   ============================================================ */
.hub { display: flex; gap: 14px; align-items: flex-start; }
.hub-mark { width: 38px; height: 38px; flex: none; border-radius: var(--r-md); display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-muted); }
.hub-mark svg { width: 20px; height: 20px; }
.hub.live .hub-mark { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.hub-body { flex: 1; min-width: 0; }
.hub-name { font-weight: 750; font-size: 1rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hub-meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.8rem; color: var(--ink-faint); }
.hub-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   Model browser — the admin centrepiece
   ============================================================ */
.mdl-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.mdl-search { flex: 1 1 260px; min-width: 200px; }
.mdl-count { font-size: 0.82rem; color: var(--ink-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mdl-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.mdl-id { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink); overflow-wrap: anywhere; }
.mdl-name { font-size: 0.78rem; color: var(--ink-faint); margin-top: 2px; }
.mdl-prov { font-size: 0.78rem; font-weight: 650; color: var(--ink-muted); }
.mdl-price { font-family: var(--font-mono); font-size: 0.82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mdl-price .was { color: var(--ink-faint); text-decoration: line-through; margin-right: 6px; }
.mdl-unpriced { color: var(--ink-faint); font-style: italic; font-size: 0.8rem; }

/* Drift is the one thing on this screen that must not be findable only by squinting: it means we are
   quoting a price that upstream has already moved away from, and every request in between costs real
   money. So it gets a colour, a border and its own row under the model rather than a subtle asterisk. */
.mdl-drift {
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
  margin-top: 7px; padding: 7px 11px; border-radius: var(--r-sm);
  font-size: 0.79rem; line-height: 1.4;
  border: 1px solid color-mix(in oklab, var(--warn) 40%, transparent);
  background: color-mix(in oklab, var(--warn) 12%, transparent);
  color: var(--ink);
}
.mdl-drift.rose { border-color: color-mix(in oklab, var(--danger) 42%, transparent); background: var(--danger-soft); }
.mdl-drift b { font-weight: 750; }
.mdl-drift .mdl-price { font-size: 0.79rem; }

.mdl-editor { border: 1px solid var(--accent-line); background: var(--surface-2); border-radius: var(--r-md); padding: 16px; margin-top: 10px; }
.mdl-editor h3 { font-size: 0.95rem; margin: 0 0 3px; }
.mdl-editor .row { margin-bottom: 12px; }
.mdl-editor-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

@media (max-width: 900px) {
  .tbl-wrap { margin: 0 -16px; padding: 0 16px; }
  .tbl th, .tbl td { padding-left: 7px; padding-right: 7px; }
}

/* ============================================================
   Pager
   ============================================================ */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.pager-where { font-size: 0.82rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.pager-btns { display: flex; gap: 8px; }

/* ============================================================
   Toast — a saved/failed acknowledgement
   ============================================================ */
.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: var(--z-toast);
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--ink);
  padding: 12px 16px; border-radius: var(--r-md); box-shadow: var(--shadow-2);
  font-size: 0.88rem; max-width: 380px; line-height: 1.5;
}
.toast.bad { border-color: color-mix(in oklab, var(--danger) 45%, transparent); color: var(--danger-text); }
.toast.ok { border-color: color-mix(in oklab, var(--ok) 45%, transparent); color: var(--ok); }
@media (max-width: 560px) { .toast { right: 12px; left: 12px; bottom: 12px; max-width: none; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
