/* ─────────────────────────────────────────────────────────────────────────────
   /admin — console layout.

   Two states live in one document: the gate (a centred sign-in) and the
   console (topbar + sidebar + one view at a time). Everything visual that is
   not layout comes from cuelight.css.
   ───────────────────────────────────────────────────────────────────────────── */

:root{ --topbar-h:58px; --side-w:232px; }
body{ position:relative; }

/* ── Gate ─────────────────────────────────────────────────────────────────── */
.gate{
  position:relative; z-index:1;
  min-height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:22px; padding:32px 20px;
}
.gate__box{ width:min(400px,100%); }
.gate__head{ position:relative; text-align:center; margin-bottom:24px; }
.gate__mark{ width:76px; height:76px; margin:0 auto 14px; display:block; }
.gate__home{ display:inline-block; border-radius:16px; }
.gate__home:focus-visible{ outline:2px solid var(--accent); outline-offset:4px; }
.gate__title{ font-size:22px; font-weight:700; letter-spacing:-.025em; }
.gate__sub{ margin-top:8px; color:var(--fg-2); font-size:12.5px; }
/* The second way in, under Connect: the route to /register for someone with no
   account to sign in with yet. Separated by a rule, so it reads as a different
   errand rather than a second step of this one. */
.gate__alt{ margin-top:18px; padding-top:16px; border-top:1px solid var(--line); text-align:center; }
.gate__alt .hint{ display:block; margin-bottom:10px; }

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar{
  position:sticky; top:0; z-index:20;
  display:flex; align-items:center; gap:10px; height:var(--topbar-h); padding:0 18px;
  border-bottom:1px solid var(--line);
  background:rgba(var(--panel-rgb),.82); backdrop-filter:blur(24px); -webkit-backdrop-filter:blur(24px);
}
.topbar__brand{ display:flex; align-items:center; gap:9px; min-width:0; }
.topbar__home{ display:flex; align-items:center; gap:9px; min-width:0; text-decoration:none; color:inherit; border-radius:10px; }
.topbar__home:focus-visible{ outline:2px solid var(--accent); outline-offset:3px; }
.topbar__mark{ width:26px; height:26px; }
.topbar__name{ font-size:14.5px; }
.topbar__right{ margin-left:auto; display:flex; align-items:center; gap:8px; }
.topbar__link{
  display:inline-flex; align-items:center; gap:6px; padding:7px 12px; border-radius:var(--r-pill);
  color:var(--fg-2); font-size:11.5px; font-weight:500; border:1px solid transparent; transition:.15s;
}
.topbar__link:hover{ color:var(--fg); background:var(--stage-750); border-color:var(--line-mid); }
/* ── Identity menu ────────────────────────────────────────────────────────
   The corner used to hold three things at once: a link out, a two-line
   identity block, and a power button. One trigger now, with the rest behind
   it — the role and the way out are things you look at rarely and act on
   once. */
.usermenu{ position:relative; }
.whoami{
  display:flex; align-items:center; gap:9px; padding:5px 10px 5px 6px;
  border-radius:var(--r-pill); border:1px solid var(--line); background:rgba(var(--ground-rgb),.5);
  color:inherit; font-family:inherit; cursor:pointer; transition:border-color .15s, background .15s;
}
.whoami:hover{ border-color:var(--line-mid); background:var(--stage-750); }
.whoami__name{ font-size:12px; font-weight:600; max-width:150px; }
.whoami__caret{ width:13px; height:13px; color:var(--fg-3); transition:transform .18s; }
.whoami[aria-expanded="true"] .whoami__caret{ transform:rotate(180deg); }

.usermenu__pop{
  position:absolute; top:calc(100% + 8px); right:0; z-index:30; min-width:212px;
  padding:6px; border:1px solid var(--line-mid); border-radius:var(--r-lg);
  background:var(--popover-bg); backdrop-filter:blur(20px); -webkit-backdrop-filter:blur(20px);
  box-shadow:var(--shadow-pop);
}
.usermenu__head{
  display:flex; align-items:center; gap:8px; justify-content:space-between;
  padding:9px 10px 11px; margin-bottom:4px; border-bottom:1px solid var(--line);
}
.usermenu__name{ font-size:12px; font-weight:600; min-width:0; }
.usermenu__item{
  display:flex; align-items:center; gap:9px; width:100%; padding:9px 10px;
  border:none; border-radius:var(--r-md); background:transparent;
  color:var(--fg-2); font-family:inherit; font-size:12px; text-align:left; cursor:pointer;
  transition:background .13s, color .13s;
}
.usermenu__item svg{ width:15px; height:15px; flex-shrink:0; }
.usermenu__item:hover{ background:var(--stage-750); color:var(--fg); }
.usermenu__item--danger:hover{ background:rgba(var(--danger-rgb),.12); color:var(--danger); }

/* ── Shell ────────────────────────────────────────────────────────────────── */
/* An author `display` outranks the UA sheet's [hidden] rule, so any gated
   element that declares its own display stays on screen while logged out —
   which is how the whole console, and the admin-only nav items, rendered
   before Connect. One rule closes the class of bug; the per-selector
   .view[hidden] / .modal[hidden] / .pane[hidden] below are what it replaces. */
[hidden]{ display:none !important; }
/* A switch reads as a state you can flip; a checkbox reads as a form field to
   be submitted. Registration being on or off is the former. */
.switch{ display:flex; align-items:center; gap:11px; cursor:pointer; font-size:12.5px; }
.switch input{ position:absolute; opacity:0; width:0; height:0; }
.switch__track{
  position:relative; flex-shrink:0; width:38px; height:22px; border-radius:var(--r-pill);
  background:var(--stage-700); border:1px solid var(--line); transition:background .16s, border-color .16s;
}
.switch__thumb{
  position:absolute; top:2px; left:2px; width:16px; height:16px; border-radius:50%;
  background:var(--fg-3); transition:transform .16s, background .16s;
}
.switch input:checked + .switch__track{ background:rgba(var(--ok-rgb),.22); border-color:rgba(var(--ok-rgb),.44); }
.switch input:checked + .switch__track .switch__thumb{ transform:translateX(16px); background:var(--accent); }
.switch input:focus-visible + .switch__track{ box-shadow:0 0 0 3px rgba(var(--accent-rgb),.28); }

.pm-preview{ white-space:nowrap; font-variant-numeric:tabular-nums; }
.pm-preview--warn{ color:var(--warn); }
.unpriced{ display:flex; flex-direction:column; gap:8px; }
.unpriced__row{
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  padding:9px 11px; border:1px solid var(--line); border-radius:var(--r-md);
  background:rgba(var(--ground-rgb),.4);
}
.unpriced__id{ font-family:var(--mono); font-size:11.5px; color:var(--warn); }
.unpriced__meta{ font-size:11px; color:var(--fg-3); margin-left:auto; }




.console{ position:relative; z-index:1; min-height:100vh; display:flex; flex-direction:column; }
.console__body{ flex:1; display:grid; grid-template-columns:var(--side-w) minmax(0,1fr); align-items:start; }

.sidenav{
  position:sticky; top:var(--topbar-h); align-self:start;
  height:calc(100vh - var(--topbar-h)); overflow-y:auto;
  display:flex; flex-direction:column; gap:4px; padding:18px 12px;
  border-right:1px solid var(--line); background:rgba(var(--panel-rgb),.5);
}
.sidenav__label{
  padding:0 10px; margin:4px 0 8px;
  font-size:9.5px; font-weight:600; letter-spacing:.13em; text-transform:uppercase; color:var(--fg-4);
}
.navitem{
  display:flex; align-items:center; gap:10px; padding:9px 11px; border-radius:var(--r-md);
  color:var(--fg-2); font-size:12.5px; font-weight:500; text-align:left; cursor:pointer;
  background:transparent; border:1px solid transparent; font-family:inherit;
  transition:background .14s, color .14s, border-color .14s;
}
.navitem svg{ width:16px; height:16px; flex-shrink:0; color:var(--fg-3); transition:color .14s; }
/* Hover is a tint only: next to the active item it must not read as a second
   selection. */
.navitem:hover{ background:rgba(var(--line-rgb),.045); color:var(--fg); }
.navitem:hover svg{ color:var(--fg-2); }
/* Keyboard focus as a hairline inside the item. The global 2px outline, offset
   outside it, drew a second ring around an item that is already outlined. */
.navitem:focus-visible{ outline:none; box-shadow:inset 0 0 0 1px rgba(var(--accent-rgb),.55); }
.navitem.is-active{
  background:rgba(var(--accent-rgb),.1);
  border-color:rgba(var(--accent-rgb),.26); color:var(--accent-bright); font-weight:600;
}
.navitem.is-active svg{ color:var(--accent); }
.navitem__badge{ margin-left:auto; font-size:10px; color:var(--fg-3); font-variant-numeric:tabular-nums; }
.navitem.is-active .navitem__badge{ color:var(--accent); }
/* The sidebar in named groups, so a setting is found by what it belongs to.
   Each group is its own column of items; a divider label sits above all but the
   first. */
.navgroup{ display:flex; flex-direction:column; gap:3px; }
.navgroup + .navgroup{ margin-top:16px; }
.navgroup__label{
  padding:0 10px; margin:0 0 5px;
  font-size:9.5px; font-weight:600; letter-spacing:.13em; text-transform:uppercase; color:var(--fg-4);
}
.sidenav__foot{ margin-top:auto; padding:12px 11px 4px; border-top:1px solid var(--line); }
.sidenav__stat{ display:flex; align-items:center; gap:8px; font-size:11px; color:var(--fg-3); }
.sidenav__stat + .sidenav__stat{ margin-top:7px; }

/* Read-only key/value rows, for the account summary. A label on the left, its
   value right-aligned; the value may wrap (an email is long) without pushing
   the label. */
.kv{ margin:0; display:grid; gap:0; }
.kv > div{ display:flex; justify-content:space-between; align-items:baseline; gap:16px;
  padding:11px 0; border-top:1px solid var(--line); }
.kv > div:first-child{ border-top:0; padding-top:0; }
.kv dt{ color:var(--fg-3); font-size:12.5px; flex:none; }
.kv dd{ margin:0; color:var(--fg); font-size:13px; font-weight:500; text-align:right; min-width:0; overflow-wrap:anywhere; }
.kv dd.mono{ font-family:var(--mono); font-size:12px; }

/* ── Views ────────────────────────────────────────────────────────────────── */
/* Centred in the column, not pinned to its left edge: on a wide screen the
   960px of content used to sit against the sidebar with the rest of the
   display empty beside it.
   `width:100%` matters — an auto inline margin on a grid item cancels the
   default stretch, so without it the host shrank to fit whatever the current
   view happened to contain and every section came out a different width. */
.viewhost{ width:100%; max-width:960px; margin-inline:auto; padding:26px 26px 44px; }
.view[hidden]{ display:none; }
.view{ animation:view-in .28s var(--ease); }
@keyframes view-in{ from{ opacity:0; transform:translateY(6px); } }
.view__head{ display:flex; align-items:flex-start; gap:14px; flex-wrap:wrap; margin-bottom:20px; }
.view__title{ font-size:19px; font-weight:700; letter-spacing:-.025em; }
.view__sub{ margin-top:5px; color:var(--fg-2); font-size:12.5px; max-width:60ch; }
.view__actions{ margin-left:auto; display:flex; align-items:center; gap:9px; }
.stack{ display:flex; flex-direction:column; gap:16px; }

/* Users table gets a name cell with an avatar; on narrow screens the whole
   table reflows into cards so nothing has to be scrolled sideways. */
.who{ display:flex; align-items:center; gap:10px; min-width:0; }
.who__name{ font-size:12.5px; font-weight:600; }
.who__id{ font-family:var(--mono); font-size:10.5px; color:var(--fg-3); }
.usecell{ min-width:120px; }
.usecell__t{ display:flex; justify-content:space-between; gap:10px; font-size:11px; color:var(--fg-2); margin-bottom:5px; font-variant-numeric:tabular-nums; }

.tokencard{
  margin-top:16px; padding:16px; border-radius:var(--r-lg);
  background:rgba(var(--accent-rgb),.07); border:1px solid rgba(var(--accent-rgb),.28);
}
.tokencard__head{ display:flex; align-items:center; gap:8px; margin-bottom:10px; font-size:12px; font-weight:600; color:var(--accent-bright); }
.tokencard__head svg{ width:15px; height:15px; }

/* ── Burger, mobile only ──────────────────────────────────────────────────
   The tab strip this replaces scrolled sideways, so on a phone half the
   sections sat off-screen with nothing to say they were there. A drawer shows
   the whole list, keeps the section labels and the user footer, and gets out
   of the way when you pick one. */
.burger{
  display:none; flex-direction:column; justify-content:center; gap:4px;
  width:34px; height:34px; padding:0 8px; margin-right:2px;
  border:1px solid var(--line); border-radius:var(--r-md);
  background:transparent; cursor:pointer;
}
.burger span{ display:block; height:1.5px; background:var(--fg-2); border-radius:2px; transition:transform .18s, opacity .18s; }
.burger[aria-expanded="true"] span:nth-child(1){ transform:translateY(5.5px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2){ opacity:0; }
.burger[aria-expanded="true"] span:nth-child(3){ transform:translateY(-5.5px) rotate(-45deg); }
.scrim{
  position:fixed; inset:var(--topbar-h) 0 0; z-index:14;
  background:rgba(6,7,10,.62); backdrop-filter:blur(2px);
}

@media (max-width:900px){
  .console__body{ grid-template-columns:minmax(0,1fr); }
  .burger{ display:flex; }

  .sidenav{
    position:fixed; top:var(--topbar-h); left:0; z-index:15;
    width:min(278px, 82vw); height:calc(100vh - var(--topbar-h));
    border-right:1px solid var(--line);
    background:rgba(var(--panel-rgb),.98); backdrop-filter:blur(20px); -webkit-backdrop-filter:blur(20px);
    transform:translateX(-102%); transition:transform .22s var(--ease);
  }
  .sidenav.is-open{ transform:translateX(0); }
  .viewhost{ padding:20px 16px 40px; }
}

@media (min-width:901px){
  /* The drawer only exists below the breakpoint; above it the scrim must never
     appear even if a resize left it open. */
  .scrim{ display:none; }
}
@media (max-width:640px){
  .topbar{ padding:0 12px; }
  /* The bar is down to icons and identity: the scope is already obvious from
     which sections the tab strip offers. */
  #scope-chip{ display:none; }
  .whoami__name{ max-width:92px; }
  .view__title{ font-size:17px; }
  .card__body,.card__head,.card__foot{ padding-left:15px; padding-right:15px; }

  /* Card-per-row tables. Each cell carries its header in data-label. */
  .table--stack thead{ display:none; }
  .table--stack tbody tr{
    display:block; margin-bottom:10px; padding:12px;
    border:1px solid var(--line); border-radius:var(--r-lg); background:rgba(var(--ground-rgb),.35);
  }
  .table--stack tbody td{
    display:flex; align-items:center; justify-content:space-between; gap:14px;
    padding:6px 0; border:none; text-align:left;
  }
  .table--stack tbody td::before{
    content:attr(data-label);
    font-size:9.5px; font-weight:600; letter-spacing:.11em; text-transform:uppercase; color:var(--fg-3);
    flex-shrink:0;
  }
  .table--stack tbody td.act{ justify-content:flex-end; padding-top:10px; margin-top:4px; border-top:1px solid var(--line); }
  .table--stack tbody td.act::before{ content:''; }
  .table--stack tbody tr:hover td{ background:transparent; }
}

/* A block of settings that belongs to the card around it rather than standing
   on its own — prices inside a provider, which are meaningless apart from it. */
.subcard{
  margin-top:16px; padding:13px 14px; border:1px solid var(--line);
  border-radius:var(--r-md); background:rgba(var(--ground-rgb),.34);
}
.subcard__head{
  display:flex; align-items:baseline; justify-content:space-between;
  gap:10px; margin-bottom:11px;
}
.subcard__head .card__title{ font-size:12.5px; }

/* A disabled provider stays legible: it is still configured, still holding its
   key, and the operator has to be able to read it in order to turn it back on. */
.prov--off{ opacity:.62; }
.prov--off .card__head{ opacity:1; }
.prov__rank{
  display:inline-flex; align-items:center; justify-content:center;
  width:20px; height:20px; margin-right:9px; border-radius:var(--r-sm);
  background:var(--stage-700); border:1px solid var(--line);
  font-size:11px; font-variant-numeric:tabular-nums; color:var(--fg-3);
}

/* A select sitting in a card header, sized to the buttons beside it. */
.select--sm{
  height:28px; padding:0 26px 0 9px; font-size:12px;
  background-position:right 8px center;
}

/* The chooser sits with the buttons it belongs to, on one row. A max-width was
   not enough: the base .select is width:100%, and a percentage width in a
   content-sized, wrapping row still pushed Add model onto a second line. */
#pr-provider{ width:210px; flex:0 0 auto; }

/* ── Model capability badges ─────────────────────────────────────────────────
   "Load models" fills this grid so an admin sees what each model supports
   (vision/audio/STT/reasoning) without leaving the console — same badges the
   desktop app's model picker shows (src/renderer/shared/capabilities.js),
   restyled onto this page's own tokens. Clicking a card fills the model
   field above it, same as picking one in the app. */
.model-grid{
  display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr));
  gap:6px; margin-top:8px;
}
.model-card{
  display:flex; flex-direction:column; gap:4px; align-items:flex-start;
  padding:8px 10px; text-align:left; font-family:inherit; cursor:pointer;
  background:var(--stage-800); border:1px solid var(--line); border-radius:var(--r-sm);
  transition:border-color .15s, background .15s;
}
.model-card:hover{ border-color:var(--line-strong); background:var(--stage-750); }
.model-card--active{ border-color:rgba(var(--accent-rgb),.5); background:var(--accent-tint); }
.model-card__name{ font-size:11px; font-weight:600; color:var(--fg); line-height:1.3; word-break:break-all; }
.model-card__caps{ display:flex; gap:3px; }

.cap-badge{
  display:inline-flex; align-items:center; padding:3px;
  border-radius:var(--r-pill); border:1px solid var(--line);
}
.cap-badge--on{ color:var(--ok); border-color:rgba(var(--ok-rgb),.35); background:rgba(var(--ok-rgb),.1); }
.cap-badge--off{ color:var(--fg-4); }
.cap-badge__icon{
  width:13px; height:13px; stroke:currentColor; fill:none;
  stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round;
}


/* ── Models catalog ────────────────────────────────────────────────────────── */

/* Sticky "you have unsaved changes" bar. Reads as an action, not a warning. */
.modelbar{
  position:sticky; top:12px; z-index:6; display:flex; align-items:center; gap:12px;
  padding:10px 12px 10px 15px; border:1px solid rgba(var(--accent-rgb),.4);
  background:linear-gradient(180deg, rgba(var(--accent-rgb),.14), rgba(var(--accent-rgb),.09));
  border-radius:var(--r-md); box-shadow:var(--shadow-card);
}
.modelbar__note{ display:flex; align-items:center; gap:8px; font-size:12.5px; color:var(--fg); font-weight:600; margin-right:auto; }
.modelbar__note::before{ content:''; width:7px; height:7px; border-radius:50%; background:var(--accent); box-shadow:0 0 0 4px rgba(var(--accent-rgb),.16); }

/* ── A model, collapsed: one clean list row ─────────────────────────────────── */
.mdl{
  border:1px solid var(--line); border-radius:var(--r-md); background:var(--stage-800);
  transition:border-color .15s, background .15s, box-shadow .15s;
}
.mdl + .mdl{ margin-top:9px; }
.mdl:hover{ border-color:var(--line-mid); }
.mdl--open{ border-color:var(--line-strong); background:var(--stage-850); box-shadow:var(--shadow-card); }
.mdl--off{ opacity:.72; }
.mdl--warn{ border-color:rgba(var(--warn-rgb),.4); }

.mdl__row{ display:flex; align-items:center; gap:12px; padding:11px 14px; }
.mdl__toggle{ flex:0 0 auto; }
.mdl__main{
  display:flex; flex-direction:column; align-items:flex-start; gap:2px;
  background:none; border:0; padding:0; cursor:pointer; min-width:0; flex:1 1 auto;
}
.mdl__title{ display:flex; align-items:center; gap:7px; min-width:0; max-width:100%; }
.mdl__name{ font-size:13.5px; font-weight:600; color:var(--fg); line-height:1.2; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.mdl__star{ flex:0 0 auto; color:var(--accent); font-size:12px; line-height:1; }
.mdl__id{ font-family:var(--mono); font-size:10.5px; color:var(--fg-3); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:100%; }
.mdl__caps{ display:flex; gap:3px; flex:0 0 auto; }

/* Route summary pill: a status dot + count. */
.mdl__routes{
  display:inline-flex; align-items:center; gap:7px; flex:0 0 auto;
  padding:4px 10px; border-radius:var(--r-pill); border:1px solid var(--line-mid);
  background:var(--stage-750); font-size:11px; color:var(--fg-2); white-space:nowrap;
}
.mdl__routes .route-dot{ width:7px; height:7px; }
.mdl__routes--warn{ border-color:rgba(var(--warn-rgb),.4); color:var(--warn); }

.mdl__chevbtn{ flex:0 0 auto; display:inline-flex; align-items:center; padding:4px; margin:-4px -2px -4px 0; background:none; border:0; cursor:pointer; color:var(--fg-3); }
.mdl__chevbtn:hover{ color:var(--fg); }
.mdl__chev{ width:16px; height:16px; transition:transform .18s; }
.mdl--open .mdl__chev{ transform:rotate(180deg); }

/* ── A model, expanded: the editor ──────────────────────────────────────────── */
.mdl__body{ padding:2px 14px 15px; }
.mdl__section{ padding-top:14px; margin-top:14px; border-top:1px solid var(--line); }
.mdl__section:first-child{ padding-top:6px; margin-top:0; border-top:0; }
.mdl__section-label{
  display:block; font-size:10.5px; font-weight:700; letter-spacing:.06em; text-transform:uppercase;
  color:var(--fg-3); margin-bottom:9px;
}
.mdl__section-label .field__hint{ font-weight:500; letter-spacing:0; text-transform:none; }
.mdl__foot{ display:flex; justify-content:flex-end; padding-top:12px; margin-top:14px; border-top:1px solid var(--line); }

.field-grid{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
/* The grid gap spaces these. The stacked-field rule (.field + .field) otherwise
   pushed the second column 16px below the first -- Public id under Name. */
.field-grid > .field + .field{ margin-top:0; }
.field__hint{ font-weight:400; color:var(--fg-3); }
.checkline{ display:inline-flex; align-items:center; gap:8px; font-size:12.5px; color:var(--fg-2); cursor:pointer; }
.checkline input{ accent-color:var(--accent); width:15px; height:15px; }
.checkrow{ display:flex; flex-wrap:wrap; gap:9px 16px; }
.checkrow .checkline{ padding:6px 11px; border:1px solid var(--line); border-radius:var(--r-pill); background:var(--stage-800); }

/* A model that is on but cannot answer — say so where it is edited. */
.mdl__alert{
  display:flex; align-items:center; gap:8px; margin-top:10px; padding:8px 11px;
  border:1px solid rgba(var(--warn-rgb),.35); background:rgba(var(--warn-rgb),.08);
  border-radius:var(--r-sm); font-size:11.5px; color:var(--warn);
}
.mdl__alert svg{ width:14px; height:14px; flex:0 0 auto; }

/* ── Routes ─────────────────────────────────────────────────────────────────── */
.routes{ display:flex; flex-direction:column; gap:8px; margin-bottom:10px; }
.route{
  display:flex; align-items:center; gap:9px;
  padding:8px 10px; border:1px solid var(--line); border-radius:var(--r-sm); background:var(--stage-800);
}
.route--off{ opacity:.6; }
.route__ord{ display:flex; flex-direction:column; flex:0 0 auto; }
.route__num{ flex:0 0 auto; width:19px; height:19px; display:grid; place-items:center; border-radius:50%; background:var(--stage-700); color:var(--fg-3); font-size:10.5px; font-weight:700; }
.route .route-provider{ flex:0 0 auto; width:130px; }
.route .route-model{ flex:1 1 auto; min-width:0; font-family:var(--mono); font-size:11.5px; }
.route__health{ flex:0 0 auto; display:inline-flex; }
.route .route-test{ flex:0 0 auto; }

/* Move up / down: a stacked pair of chevrons, together the height of the row's
   other controls. They were 7px text triangles in 13px boxes. */
.iconbtn{
  display:grid; place-items:center; width:22px; height:14px; padding:0;
  color:var(--fg-3); background:var(--stage-700); border:1px solid var(--line); cursor:pointer;
}
.iconbtn svg{ width:12px; height:12px; }
.iconbtn--up svg{ transform:rotate(180deg); }
.iconbtn:first-child{ border-radius:6px 6px 0 0; border-bottom:0; }
.iconbtn:last-child{ border-radius:0 0 6px 6px; }
.iconbtn:hover:not(:disabled){ color:var(--fg); border-color:var(--line-strong); background:var(--stage-600); }
.iconbtn:disabled{ opacity:.35; cursor:default; }

/* Remove route: an icon button the height of Test beside it, quiet until
   pointed at. (It shared .iconbtn's reorder-arrow box and came out a sliver.) */
.route .route-del{ flex:0 0 auto; color:var(--fg-3); }
.route .route-del:hover:not(:disabled){ color:var(--danger); background:rgba(var(--danger-rgb),.12); }

.route-add{ align-self:flex-start; }

/* Compact toggle used inside a route row. */
.switch--sm{ flex:0 0 auto; }
.switch--sm .switch__track{ width:30px; height:17px; }
.switch--sm .switch__thumb{ width:11px; height:11px; }
.switch--sm input:checked + .switch__track .switch__thumb{ transform:translateX(13px); }

/* Live route health, as a dot with a clear three-state colour. */
.route-dot{ display:inline-block; width:9px; height:9px; border-radius:50%; background:var(--fg-4); box-shadow:0 0 0 3px rgba(var(--line-rgb),.05); }
.route-dot--ok{ background:var(--ok); box-shadow:0 0 0 3px rgba(var(--ok-rgb),.16); }
.route-dot--bad{ background:var(--warn); box-shadow:0 0 0 3px rgba(var(--warn-rgb),.18); }

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty{
  display:flex; flex-direction:column; align-items:center; text-align:center; gap:6px;
  padding:40px 24px; border:1px dashed var(--line-strong); border-radius:var(--r-lg); background:var(--stage-850);
}
.empty__icon{ width:34px; height:34px; color:var(--fg-4); margin-bottom:4px; }
.empty__title{ font-size:14px; font-weight:600; color:var(--fg); }
.empty__sub{ font-size:12.5px; color:var(--fg-3); max-width:340px; }
.empty__acts{ display:flex; gap:9px; margin-top:12px; flex-wrap:wrap; justify-content:center; }

/* ── New models inbox ───────────────────────────────────────────────────────── */
.inbox-item{
  display:flex; align-items:center; gap:11px;
  padding:9px 12px; border:1px solid var(--line); border-radius:var(--r-md); background:var(--stage-800);
}
.inbox-item + .inbox-item{ margin-top:8px; }
.inbox-item__id{ font-family:var(--mono); font-size:11.5px; color:var(--fg); word-break:break-all; min-width:0; }
.inbox-item__acts{ margin-left:auto; display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }

@media (max-width:640px){
  .field-grid{ grid-template-columns:1fr; }
  .mdl__routes-txt{ display:none; }
  .route{ flex-wrap:wrap; }
  .route .route-provider{ width:auto; flex:1 1 40%; }
  .route .route-model{ flex:1 1 100%; order:5; }
  .inbox-item{ flex-wrap:wrap; }
  .inbox-item__acts{ width:100%; justify-content:flex-start; }
}

/* ── Selling prices (Pricing) and a model's price (Models) ─────────────────── */
.sheet__name{ font-weight:600; }
.sheet__off td{ opacity:.55; }
/* Under 30% the margin is flagged: little room for gateway fees and the rate. */
.sheet__warn{ color:var(--warn); font-weight:600; }
.sheet__foot{ display:flex; flex-direction:column; gap:6px; padding-top:14px; border-top:1px solid var(--line); }
.mdl__price-note{ margin-top:8px; }
/* Two price boxes in one cell, and the cost → price → profit line beside them. */
/* One figure a column: the boxes are the width of the number they hold. */
td .sheet-in, td .sheet-out{ width:84px; }
td .sheet-markup, td .sheet-min{ width:70px; }
/* The name column keeps its width so a model id does not break over four
   lines while the price boxes sit in acres of space. */
#sheet-body td:first-child{ min-width:200px; }
#sheet-body td{ vertical-align:middle; }
.sheet__q{ text-align:right; font-variant-numeric:tabular-nums; }
/* The breakdown may wrap; the column it sits in must not push Min balance off
   the card, which is what a nowrap line did. */
#sheet-body td:nth-child(5){ width:176px; }
#sheet-body td:first-child{ min-width:230px; }
.sheet__cost{ margin-top:3px; font-variant-numeric:tabular-nums; }
.sheet__per{ color:var(--fg-4); }
.sheet__breakdown{ white-space:nowrap; }
.sheet__margin{ font-size:11.5px; font-weight:600; color:var(--ok); }
.sheet__margin.sheet__warn{ color:var(--warn); }
.sheet__price-big{ font-size:14px; font-weight:600; color:var(--fg); }
.sheet__breakdown{ margin-top:2px; }
.sheet__profit{ color:var(--ok); font-weight:600; }
.sheet__profit.sheet__warn{ color:var(--warn); }

/* Five rates, one even row: the fifth was wrapping its label while the other
   four sat on one line. */
#pricing-form .grid--4 { grid-template-columns:repeat(3,minmax(0,1fr)); }
@media (max-width:900px){ #pricing-form .grid--4 { grid-template-columns:repeat(auto-fit,minmax(158px,1fr)); } }
.sheet__intro { padding-bottom:0; }
.sheet__stt { margin-left:12px; }
.sheet__note { margin-top:4px; text-align:right; white-space:nowrap; }
/* A truncated model id cannot be told from the next one; the column that names
   the row gets the width, and the example column gives it up. */
#pricing-body td:first-child { width:34%; }
#pricing-body .pm-id { width:100%; }
#pricing-body .pm-preview { white-space:nowrap; }
/* "default" was being cut to "def": the markup column keeps its own width. */
#pricing-body td:nth-child(4) { width:13%; }
#pricing-body .pm-mult { width:100%; min-width:76px; }

/* A hint inside a table heading is a unit, not part of the title: the heading
   is uppercased, and "MODEL AND WHAT IT COSTS US" read as one shout. */
.table th .hint{ text-transform:none; letter-spacing:0; font-weight:400; }

/* ── Top-up page (topup.html) ──────────────────────────────────────────────── */
/* Credits are rupiah, so a package tile shows one number twice: the price and
   the credit it buys. Keeping both on the tile stops anyone doing the sum. */
.balance{ margin:0; font-size:26px; font-weight:600; color:var(--accent); font-variant-numeric:tabular-nums; }

.pkg-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(132px,1fr)); gap:10px; margin-top:14px; }
.pkg{
  display:flex; flex-direction:column; gap:3px; padding:12px 14px; cursor:pointer; text-align:left;
  border:1px solid var(--line); border-radius:var(--r-md); background:var(--stage-800); color:inherit;
  font:inherit; transition:border-color .14s, background .14s;
}
.pkg:hover{ border-color:rgba(var(--accent-rgb),.4); background:rgba(var(--accent-rgb),.06); }
.pkg.is-picked{ border-color:rgba(var(--accent-rgb),.55); background:rgba(var(--accent-rgb),.12); }
.pkg__amount{ font-size:15px; font-weight:600; color:var(--accent); font-variant-numeric:tabular-nums; }
.pkg__credits{ font-size:11.5px; color:var(--fg-3); font-variant-numeric:tabular-nums; }
/* The discount, said on the tile rather than left to be worked out. Sits under
   the credits so the eye reads price, then what it buys, then why it is a
   better deal than the one above it. */
.pkg__badge{
  align-self:flex-start; margin-top:4px; font-size:10.5px; font-weight:600; letter-spacing:.02em;
  padding:2px 7px; border-radius:var(--r-pill);
  background:rgba(var(--ok-rgb),.12); color:var(--ok); border:1px solid rgba(var(--ok-rgb),.28);
}

.buy-actions{ display:flex; flex-direction:column; gap:10px; margin-top:18px; }

.reqlist{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; }
.req{
  display:flex; align-items:center; gap:12px; flex-wrap:wrap;
  padding:10px 12px; border:1px solid var(--line); border-radius:var(--r-md); background:var(--stage-800);
}
.req__amount{ font-weight:600; font-variant-numeric:tabular-nums; }
.req__when{ color:var(--fg-3); font-size:12px; margin-right:auto; display:flex; flex-direction:column; gap:2px; }
/* What the money bought, under when it was paid. */
.req__sub{ color:var(--fg-3); font-size:11px; font-variant-numeric:tabular-nums; }
.req__status{ font-size:11.5px; padding:3px 9px; border-radius:var(--r-pill); border:1px solid var(--line); color:var(--fg-3); }
.req--pending .req__status{ color:var(--info); border-color:rgba(var(--them-rgb),.3); }
.req--approved .req__status{ color:var(--ok); border-color:rgba(var(--ok-rgb),.3); }
.req--rejected .req__status{ color:var(--danger); border-color:rgba(var(--danger-rgb),.3); }
.req--paid .req__status{ color:var(--ok); border-color:rgba(var(--ok-rgb),.3); }
.req--expired .req__status,
.req--failed .req__status{ color:var(--fg-3); }
.req--refunded .req__status{ color:var(--danger); border-color:rgba(var(--danger-rgb),.3); }
/* Actions for a payment still waiting — reopen its DOKU page, or ask whether it
   went through. On their own row under the amount, so they never crowd the
   status pill on a narrow screen. */
.req__actions{ width:100%; display:flex; flex-wrap:wrap; gap:8px; margin-top:2px; }

/* A row of plain checkboxes, for picking payment channels. */
.checks{ display:flex; flex-wrap:wrap; gap:9px 16px; margin-top:8px; }
.check{ display:inline-flex; align-items:center; gap:7px; font-size:13px; color:var(--fg-2); cursor:pointer; }
.check input{ accent-color:var(--accent); }

/* ── Top-up requests, in the console ──────────────────────────────────────── */
.topup-actions{ display:flex; gap:8px; }

/* .grid--2 is auto-fit, so four payment fields collapsed into four narrow
   columns and their labels ran into their hints. Two, or one when narrow. */
#view-topups .grid--2{ grid-template-columns:repeat(2,minmax(0,1fr)); }
@media (max-width:720px){ #view-topups .grid--2{ grid-template-columns:1fr; } }

/* The requests table: let Who and Note take the room, keep the rest tight so
   the action buttons are not pushed off the end. */
#topups-body td:last-child{ text-align:right; white-space:nowrap; }
#view-topups .table th:last-child{ width:1%; }

/* The foot of a paged list: one button and a count of what is showing. A list
   that stops at fifty rows with nothing under it reads as a list that ends. */
.more{ display:flex; align-items:center; gap:12px; padding:14px 2px 2px; }
.more .hint{ margin:0; }

/* ── The arithmetic behind one charge ─────────────────────────────────────── */
/* A history row that only states a figure asks to be believed; opening it
   shows the multiplication, in rupiah, so it can be checked instead. */
.row--open{ cursor:pointer; }
.row--open:hover{ background:var(--stage-800); }
.row--open.is-open{ background:var(--stage-800); }
.working__row > td{ padding:0 12px 14px !important; background:var(--stage-800); }
.working{ width:100%; max-width:460px; border-collapse:collapse; font-size:12px; }
.working td{ padding:5px 0; border:0; color:var(--fg-3); }
.working td:last-child{ text-align:right; color:var(--fg-2); }
.working__total td{ padding-top:8px; border-top:1px solid var(--line); color:var(--fg); font-weight:600; }

/* A note under a field can carry a warning of its own — a rate nobody has
   revisited in months, a number that is not one. `.status` colours are for the
   status strip; these are for the hint line. */
.field__note.is-warn{ color:var(--warn); }
.field__note.is-err{ color:var(--danger); }

/* A URL to paste, not a command to run: wrapping it is fine, and on a phone
   scrolling it slid the text under the SELECT button. */
.copy__code--url{ white-space:pre-wrap; overflow-wrap:anywhere; overflow-x:visible; }

/* A small select in a card header keeps its own width, so a count chip beside
   it stays on the same line instead of dropping underneath. */
.card__actions .select--sm{ width:auto; }

/* Users: one line of actions per row — Save for the budget beside it, and a
   menu for everything else that acts on the account. */
.u-actions{ display:flex; align-items:center; justify-content:flex-end; gap:6px; white-space:nowrap; }
.rowmenu{ position:relative; }
.rowmenu .u-more svg{ width:13px; height:13px; margin-left:2px; margin-right:0; }
.rowmenu__pop{ top:calc(100% + 6px); min-width:200px; text-align:left; }

/* Users: budget and use, laid out alike — a figure on top, a quiet line under. */
.budgetcell{ display:flex; flex-direction:column; gap:6px; width:150px; }
.budgetcell__in{ position:relative; }
.budgetcell__in .u-budget{ width:100%; padding-right:58px; }
.budgetcell__unit{ position:absolute; right:12px; top:50%; transform:translateY(-50%); font-size:11px; color:var(--fg-4); pointer-events:none; }
.budgetcell__sub{ font-size:11.5px; margin:0; }
.usecell{ min-width:150px; }
.meter--flat{ opacity:.45; }

/* Models autosave line: quiet when saved, accent while saving, red on error. */
.modelbar[data-state="ok"] .modelbar__note::before{ background:var(--ok); box-shadow:0 0 0 4px rgba(var(--ok-rgb),.16); }
.modelbar[data-state="err"]{ border-color:rgba(var(--danger-rgb),.45); }
.modelbar[data-state="err"] .modelbar__note{ color:var(--danger); }
.modelbar[data-state="err"] .modelbar__note::before{ background:var(--danger); box-shadow:0 0 0 4px rgba(var(--danger-rgb),.16); }
.budgetcell{ gap:3px; width:auto; min-width:120px; }
.budgetcell__v{ font-size:13px; font-weight:600; color:var(--fg); font-variant-numeric:tabular-nums; }

/* Autosave: the save button gives way to a small state in the card head. */
.autosave-btn, .prov-save{ display:none !important; }
.autosave-state{ margin-left:auto; font-size:11.5px; color:var(--fg-3); white-space:nowrap; }
.card__head .card__actions ~ .autosave-state{ margin-left:10px; }
.autosave-state[data-state="pending"], .autosave-state[data-state="dirty"]{ color:var(--accent-bright, var(--fg-2)); }
.autosave-state[data-state="ok"]{ color:var(--ok); }
.autosave-state[data-state="err"]{ color:var(--danger); font-weight:600; }
/* A foot that held only the save button disappears with it. */
.card__foot:not(:has(> :not(.autosave-btn):not(.prov-save):not([hidden]))){ display:none; }

/* Signing in from a held session: a loading screen, never the form first. */
.boot{ display:none; }
html.is-restoring #gate{ display:none; }
html.is-restoring .boot{
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px;
  min-height:100vh; color:var(--fg-3); font-size:13px;
}
.boot__mark{ width:56px; height:56px; animation:boot-glow 1.4s ease-in-out infinite; }
@keyframes boot-glow{ 0%,100%{ opacity:.55; transform:scale(.97); } 50%{ opacity:1; transform:scale(1); } }
@media (prefers-reduced-motion: reduce){ .boot__mark{ animation:none; } }

/* A secret's state beside its label: quiet when saved, amber when missing. */
.secret-state--missing{ color:var(--warn); }
/* A saved secret's ends, shown in its box: readable, not faded like a hint. */
.input--saved-secret::placeholder{ color:var(--fg-2); opacity:1; letter-spacing:.02em; }

/* A model's price, set on its card: four boxes in a row, two on a phone. */
.mdl__price-grid{ display:grid; grid-template-columns:repeat(4, minmax(0, 1fr)); gap:10px; margin:6px 0 8px; align-items:end; }
.mdl__price-grid .field{ display:flex; flex-direction:column; justify-content:flex-end; margin:0; }
@media (max-width:720px){ .mdl__price-grid{ grid-template-columns:repeat(2, minmax(0, 1fr)); } }

/* ── Sections inside one view (Providers: chat, speech, purchase prices) ───── */
.view__section{ padding-top:14px; scroll-margin-top:calc(var(--topbar-h) + 12px); }
.view__section:first-child{ padding-top:0; }
.view__section-title{ font-size:15px; font-weight:650; letter-spacing:-.015em; color:var(--fg); }
.jumps{ display:flex; flex-wrap:wrap; gap:6px; margin-top:10px; }
.jump{
  padding:3px 10px; border-radius:var(--r-pill); border:1px solid var(--line-mid);
  font-size:11.5px; color:var(--fg-2); text-decoration:none; background:var(--stage-750);
}
.jump:hover{ color:var(--fg); border-color:var(--line-strong); }

/* ── A route row: the controls, then a line with its cost and any problem ─── */
.route-wrap{ display:flex; flex-direction:column; gap:5px; }
.route-wrap--dead .route{ border-style:dashed; }
.route__cost{ display:flex; flex-wrap:wrap; align-items:center; gap:6px 8px; padding-left:31px; font-size:11.5px; color:var(--fg-3); }
.route__cost--none{ color:var(--warn); }
.route__why{ text-transform:none; letter-spacing:0; }
.linkbtn{
  background:none; border:0; padding:0; font:inherit; font-size:11.5px; font-weight:600;
  color:var(--accent); cursor:pointer; text-decoration:underline; text-underline-offset:2px;
}
.linkbtn:hover{ color:var(--accent-bright); }
.model-grid--readonly .model-card{ cursor:default; }
.model-grid--readonly .model-card:hover{ border-color:var(--line); background:var(--stage-800); }

/* ── Status checks ─────────────────────────────────────────────────────────── */
.check{ display:flex; align-items:center; gap:12px; padding:11px 20px; border-top:1px solid var(--line); font-size:12.5px; }
.check:first-child{ border-top:0; }
.check__sev{
  flex:0 0 52px; text-align:center; padding:2px 0; border-radius:var(--r-pill);
  font-size:10px; font-weight:700; letter-spacing:.08em; text-transform:uppercase;
}
.check--bad .check__sev{ color:var(--danger); background:rgba(var(--danger-rgb),.12); }
.check--warn .check__sev{ color:var(--warn); background:rgba(var(--warn-rgb),.12); }
.check--info .check__sev{ color:var(--fg-3); background:var(--stage-700); }
.check__text{ flex:1 1 auto; min-width:0; color:var(--fg-2); }
.check .btn{ flex:0 0 auto; }

/* ── Add-a-provider wizard ─────────────────────────────────────────────────── */
.modal__box--wide{ width:min(640px,100%); max-height:calc(100vh - 40px); overflow-y:auto; }
.wiz__steps{ display:flex; gap:6px; list-style:none; margin:0 0 14px; padding:0; counter-reset:wiz; }
.wiz__step{
  counter-increment:wiz; flex:1 1 0; padding-top:7px; border-top:2px solid var(--line-mid);
  font-size:11px; color:var(--fg-4);
}
.wiz__step::before{ content:counter(wiz) ". "; }
.wiz__step.is-done{ border-top-color:rgba(var(--accent-rgb),.5); color:var(--fg-3); }
.wiz__step.is-current{ border-top-color:var(--accent); color:var(--fg); font-weight:600; }
.wiz__presets{ display:grid; grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:8px; margin-bottom:18px; }
.wiz__preset{
  display:flex; flex-direction:column; gap:3px; align-items:flex-start; text-align:left;
  padding:10px 12px; font-family:inherit; cursor:pointer;
  background:var(--stage-750); border:1px solid var(--line); border-radius:var(--r-md);
}
.wiz__preset:hover,.wiz__preset:focus-visible{ border-color:var(--accent); }
.wiz__preset-name{ font-size:12.5px; font-weight:600; color:var(--fg); }
.wiz__preset-url{ font-family:var(--mono); font-size:10px; color:var(--fg-3); word-break:break-all; }
.wiz__models{
  display:flex; flex-direction:column; gap:4px; margin:10px 0 14px;
  max-height:min(320px, 40vh); overflow-y:auto; padding-right:4px;
}
.wiz__model{
  display:flex; align-items:center; gap:9px; padding:7px 10px; cursor:pointer;
  border:1px solid var(--line); border-radius:var(--r-md); background:var(--stage-750);
}
.wiz__model input{ accent-color:var(--accent); width:15px; height:15px; flex:0 0 auto; }
.wiz__model-id{ flex:1 1 auto; min-width:0; font-family:var(--mono); font-size:11.5px; color:var(--fg); word-break:break-all; }
.wiz__opts{ display:flex; flex-direction:column; gap:8px; margin-bottom:12px; }
#wiz .status:not(:empty){ margin:10px 0; }
#wiz form .modal__actions, #wiz [data-pane] > .modal__actions{ margin-top:16px; }

@media (max-width:640px){
  /* Three header buttons (Models) do not fit one line on a phone. */
  .view__actions{ flex-wrap:wrap; }
  /* A model's name gets its own line; its badges and route count wrap below it. */
  .mdl__row{ flex-wrap:wrap; row-gap:8px; }
  .mdl__main{ flex:1 1 calc(100% - 110px); }
  .mdl__chevbtn{ order:1; }
  .mdl__caps,.mdl__used,.mdl__routes{ order:2; }
  .mdl__caps{ margin-left:62px; }
  .mdl__routes-txt{ display:inline; }
  .route__cost{ padding-left:0; }
  .check{ flex-wrap:wrap; padding:11px 15px; }
  .check__text{ flex-basis:calc(100% - 64px); }
}

/* A search box in a card header, the height of .select--sm beside it. */
.input--sm{ height:28px; padding:0 9px; font-size:12px; width:220px; flex:0 1 auto; min-width:0; }
@media (max-width:560px){ .card__actions .input--sm{ width:100%; flex:1 1 140px; } }

/* A typed amount read back as money under its box (rpHint in admin.js). */
.rp-hint{ margin-top:6px; min-height:1em; }
.rp-hint--warn{ color:var(--warn); }
