/* FUJI VPN panel — charcoal glass cards over a black sheet.
   White ink and neutral reflections, with small colored count indicators. */

:root {
  color-scheme: dark;

  --sheet: linear-gradient(#000000, #000000);
  --bg: #000000;
  --ink-inverse: #111111;

  /* Keep the existing grid spacing with subtle white lines. */
  --grid:
    linear-gradient(to right, rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.055) 1px, transparent 1px);
  --grid-size: 32px 32px, 32px 32px;

  --glass: rgba(22, 22, 22, 0.88);
  --glass-strong: rgba(22, 22, 22, 0.94);
  --glass-blur: blur(20px);
  --glass-blur-heavy: blur(28px);
  --glass-line: rgba(255, 255, 255, 0.22);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);

  --smoke: rgba(16, 16, 16, 0.96);
  --smoke-solid: #101010;
  --raise: rgba(255, 255, 255, 0.055);
  --well: rgba(0, 0, 0, 0.24);
  --field-fill: rgba(0, 0, 0, 0.24);
  --field-hover: rgba(0, 0, 0, 0.30);
  --field-focus: rgba(0, 0, 0, 0.34);

  --line-soft: rgba(255, 255, 255, 0.28); /* a control's border */
  --rule: rgba(255, 255, 255, 0.22);      /* a column's rule */
  --hairline: rgba(255, 255, 255, 0.14);  /* the rule between rows */

  --radius: 20px;
  --radius-sm: 12px;

  --ink: #ffffff;
  --muted: #d4d4d4;
  --muted-2: #bdbdbd;
  --faint: #a3a3a3;
  --link: #e5e5e5;

  /* Status labels stay readable in neutral tones on the dark panes. */
  --ok: #d4d4d4;
  --warn: #e5e5e5;
  --bad: #ffffff;

  /* White primary controls carry dark ink. */
  --accent: #ffffff;
  --accent-end: #dedede;

  /* Count indicators: totals, active/in use, expiring, blocked, recent activity. */
  --lamp-total: #60a5fa;
  --lamp-live: #4ade80;
  --lamp-amber: #fbbf24;
  --lamp-rose: #fb7185;
  --lamp-violet: #a78bfa;

  --ring: rgba(255, 255, 255, 0.85);
  --track: rgba(255, 255, 255, 0.16);

  --display: "Space Grotesk", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* The ground. Fixed rather than scrolled, so the ruling stays where the panes
   were composed against it and the blur has a constant to work from. It is a
   pseudo-element rather than a background on `body` because `background:
   fixed` is unreliable on iOS and because a negative z-index layer paints above
   the canvas but below every pane. The grid has to paint *over* the wash, so
   both live here in one background-image stack. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--grid), var(--sheet);
  background-size: var(--grid-size), 100% 100%;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font: 13.5px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); }
code { font-family: var(--mono); font-size: 0.92em; }

.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;
}

/* Every small label on the page — column headers, field names, the captions
   under the summary figures — at one size and one distance apart. They are
   letterspaced and set in the display face, which is what keeps a 9.5px word
   legible against a busy sheet. */
.acc th,
.stat,
.cred-label,
.facts dt,
.database-facts dt,
.brand-sub,
.signin-sub {
  font-family: var(--display);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.muted { color: var(--muted-2); }
.inline { display: inline; }
.right { text-align: right; }

/* ------------------------------------------------------------------ glass */

/* Neutral glass keeps the grid faintly visible through the dark cards. */
.card,
.signin-card {
  --glass:
    radial-gradient(ellipse at 0% 0%, rgba(255, 255, 255, 0.08), transparent 55%),
    linear-gradient(125deg, transparent 15%, rgba(255, 255, 255, 0.035) 24%, rgba(255, 255, 255, 0.12) 27%, rgba(255, 255, 255, 0.035) 30%, transparent 38%),
    linear-gradient(135deg, rgba(26, 26, 26, 0.90), rgba(20, 20, 20, 0.94) 48%, rgba(12, 12, 12, 0.98));
  --smoke:
    radial-gradient(ellipse at 0% 0%, rgba(255, 255, 255, 0.08), transparent 55%),
    linear-gradient(125deg, transparent 15%, rgba(255, 255, 255, 0.05) 27%, transparent 38%),
    linear-gradient(135deg, rgba(20, 20, 20, 0.94), rgba(12, 12, 12, 0.98));
  --card-solid: #181818;
  --smoke-solid: #101010;
  --glass-line: rgba(255, 255, 255, 0.25);
  --glass-shadow:
    0 18px 46px -14px rgba(0, 0, 0, 0.60),
    0 4px 12px -4px rgba(0, 0, 0, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    inset 0 -1px 0 rgba(255, 255, 255, 0.07);
  --glass-blur: blur(8px);
  --glass-blur-heavy: blur(10px);
  color: var(--ink);
}

/* The one recipe every pane on the page is built from. */
.card {
  position: relative;
  overflow: hidden;
  padding: 22px;
  margin-bottom: 18px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-top-color: rgba(255, 255, 255, 0.50);
  border-left-color: rgba(255, 255, 255, 0.34);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.card-narrow { max-width: 620px; margin: 36px auto 0; }

/* A card holding nothing but a short form, so it is sized to the form rather
   than to the forms it might have held.
 *
 * `card-narrow` is 620px because it also carries the client page, whose
 * credential rows and Java snippet want the room. Three fields do not. At 620px
 * the fields kept their own 320px cap and everything sat against the left edge
 * with a quarter of the card empty beside it — a card that is centred while its
 * contents are not reads as a mistake, not as a choice. Sized to the fields, the
 * card and its contents are the same width and the same centre. */
.card-form { max-width: 420px; }

/* The button under the generated credentials, which is not inside an edit form. */
.card > .edit-actions { margin-top: 24px; }

/* A deeper charcoal fill keeps the table's small text clear above the grid. */
.card-table {
  padding: 18px 22px 22px;
  background: var(--smoke);
  box-shadow: var(--glass-shadow);
}

/* --------------------------------------------------------------- masthead */

/* Floating rather than full-bleed: a glass bar that spans the viewport edge to
   edge is a coloured band again, just a blurred one. The gap above it is the
   point — the sheet scrolls through that gap and under the bar, ruled above the
   edge and milky below it, which is the one place the effect explains itself. */
.topbar {
  position: sticky;
  top: 14px;
  z-index: 20;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0;
  min-height: 72px;
  padding: 0;
  overflow: hidden;
  margin-bottom: 20px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 16px 18px;
  text-decoration: none;
}

/* The artwork is already cut to a circle with a transparent surround, so the
   tile is the picture and nothing else — a background fill would show through
   the corners. The rim is a ring rather than a border for the same reason. */
.brand-mark {
  display: block;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--glass-line), 0 10px 22px -12px rgba(0, 0, 0, 0.6);
  object-fit: cover;
  filter: grayscale(1);
}

.brand-text { display: grid; min-width: 0; line-height: 1.25; }
.brand-name {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Connected navigation buttons sit flush against the header's outer edges. */
.topnav {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  align-self: stretch;
  gap: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.topnav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 64px;
  margin: 0;
  padding: 16px 18px;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.topnav a + a { border-inline-start: 1px solid var(--hairline); }
.topnav a svg { flex: none; }
.topnav a:hover {
  background: var(--raise);
  border-color: var(--hairline);
  color: var(--ink);
}
.topnav a:focus-visible,
.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}
.topnav .nav-signout { color: var(--muted-2); }

/* A charcoal fill and slim white underline mark the current page. */
.topnav a[aria-current="page"],
.topnav a[aria-current="page"]:hover {
  background: #262626;
  border-color: var(--hairline);
  color: var(--ink);
  box-shadow: inset 0 -3px 0 var(--ink);
}

/* ----------------------------------------------------------------- layout */

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding-block: 16px 60px;
  padding-inline: 30px;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

h2 {
  margin: 0 0 16px;
  font-family: var(--display);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}

/* ---------------------------------------------------------- the figures */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.stat { min-width: 0; }

/* <b>n</b> label, with the number as a block so the name falls onto the line
   under it. The lamp sits inside the number's line rather than above the tile,
   where it would read as a bullet for the label instead of a light on the
   figure. Account figures use neutral ink; Devices summaries use their status
   colors to make each count easy to distinguish. */
.stat b {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
  font-family: var(--display);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat b::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c, var(--lamp-total));
  box-shadow: none;
}

.stats .stat:nth-child(1) { --c: var(--lamp-total); }
.stats .stat:nth-child(2) { --c: var(--lamp-live); }
.stats .stat:nth-child(3) { --c: var(--lamp-amber); }
.stats .stat:nth-child(4) { --c: var(--lamp-violet); }

/* Named lamps, for a shelf that is not the whole four. The positions above are
   the accounts page's reading order; the devices page wants its three figures to
   keep their status colors — total devices, in use, blocked — wherever they
   sit. Naming the lamp keeps the colour meaning the figure rather than the
   column it happens to sit in. */
.stats .stat.lamp-total { --c: var(--lamp-total); }
.stats .stat.lamp-rose { --c: var(--lamp-rose); }
.stats .stat.lamp-live { --c: var(--lamp-live); }
.stats .stat.lamp-amber { --c: var(--lamp-amber); }
.stats .stat.lamp-violet { --c: var(--lamp-violet); }

/* A shelf of three rather than four — the devices page, without the figure for
   the account it no longer shows. Spreading them over the card beats leaving a
   column empty, and the narrow breakpoint already draws two to a row anyway. */
.stats.is-trio { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* The one figure allowed to shout, and only while there is something to shout
   about — renderer's call, not the stylesheet's. */
.stat.is-attn b { color: var(--warn); }

/* Devices counts share the indicator color, including nonzero blocked counts. */
.stats.is-trio .stat b { color: var(--c, var(--ink)); }

/* ----------------------------------------------------------- section head */

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* The right end of a head, kept as one item so that adding a control does not
   push the label it belongs with into the middle of the row — `space-between`
   on three children centres the middle one. */
.head-acts { display: flex; align-items: center; gap: 12px; }

/* -------------------------------------------------------------- toolbar */

/* The search box and the filter chips are the only controls on the page that
   need script. With none, they would sit there doing nothing — so they are
   hidden until the `js` class says the handlers are attached. */
.tools { display: none; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.js .tools { display: flex; }

/* A well, not a pane. The search box was a frosted pill floating on the table
   card, which made it the one control on the page drawn the opposite way from
   every other field in the panel: those are pressed into the surface they sit
   on, and this one laid on top of it. It is a field you type into, so it is
   drawn as one — the same 12px corner and hairline rim as the inputs, with the
   fill going the other way. Deeper, not lighter, because the card underneath is
   already a pane: a lighter fill here is the pill again, one shade down. */
.search {
  flex: 1 1 240px;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 9px 14px;
  background: var(--well);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s;
}

/* The rim is the whole answer to a click, so it goes to the focus colour
   on the page. The inset shadow stays: it is what says the field is below the
   card, and lifting it on focus would undo that at the moment it matters. */
.search:focus-within { border-color: var(--ring); }
.search input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  /* The generic `input, select` rule above hands every field an 11px corner,
     and `border: 0` does not take a radius away. On a field this short that
     radius is very nearly a pill, and the browser draws the text selection to
     match the box it is in — so selecting what you had typed wrapped the run
     in a rounded cap that belonged to nothing on screen. The well's own 12px
     corner is the only curve this field is allowed. */
  border-radius: 0;
  /* WebKit gives input[type=search] a field of its own — a rounded box with an
     inset shadow and a magnifier of its own, drawn whether or not the page has
     one. Inside this well that is a second box, so it is turned off here for the
     same reason the select's arrow is drawn by hand. */
  appearance: none;
  -webkit-appearance: none;
  /* Set rather than inherited. `.search` is a <label>, and the label rule above
     puts every label on the page at 10.5px — right for the name of a field,
     wrong for the text typed into one, and visibly two sizes smaller than the
     filter chips beside it. */
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  line-height: 20px; /* so the field and the chips beside it are the same height */
  color: var(--ink);
  outline: none;
}

/* The well is the field. The general `input:hover` / `input:focus` rules further
   down know nothing about that, and they land harder than the rule above — same
   specificity, later in the sheet — so clicking into this box used to paint a
   second field inside it: a fill brighter than the glass around it and a 3px
   glow, running from the rim to the rim with no margin on any edge. It read as
   a box that did not fit. A field that is already drawn has nothing of its own
   to draw, and the well's own focus state is the one that answers. */
.search input:hover,
.search input:focus,
.search input:focus-visible {
  background: none;
  box-shadow: none;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 20px; /* matched to the search field */
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.chip:hover { background: rgba(255, 255, 255, 0.22); color: var(--ink); }

/* The selected chip is the one solid fill in the row, so the filter in force is
   legible at a glance rather than by comparing four shades of glass. */
.chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink-inverse);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12);
}

/* ---------------------------------------------------------------- tables */

.tbl-scroll { overflow-x: auto; }

.acc {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.acc th {
  text-align: left;
  padding: 0 14px 10px 0;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

/* Rows are divided and columns are not: a vertical line through six columns on
   a translucent pane turns the table into a grid of glass, and the leading
   name column is enough to follow an account across. */
.acc td {
  padding: 12px 14px 12px 0;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}
.acc th:first-child, .acc td:first-child { padding-left: 0; }
.acc th:last-child, .acc td:last-child { padding-right: 0; }
.acc tr:last-child td { border-bottom: 0; }

/* The figure column is set right, as a column of figures is. */
.acc .num { text-align: right; }

@media (min-width: 721px) {
  .acc tbody tr[data-account]:hover > td { background: var(--raise); }
}

.acct-name { font-weight: 600; }
.acct-note { font-size: 12px; color: var(--muted-2); margin-top: 2px; }
.empty { margin: 0; padding: 26px 0; color: var(--muted-2); text-align: center; }

.acts { display: flex; gap: 6px; justify-content: flex-end; }

/* Status reads as a dot and a word. On a pane where every row is already a
   tinted fill, a filled pill on every row would leave nothing to notice, and
   the exceptions — expired, suspended — are what should stand out. The dot
   stays flat and small, and the word stays legible. */
.st {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}
.st .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: none;
}
.st-ok { color: var(--ok); }
.st-warn { color: var(--warn); }
.st-bad { color: var(--bad); }

/* Shapes keep warning and blocked states distinct without coloured ink. */
.st-warn .dot { border-radius: 1px; transform: rotate(45deg); }
.st-bad .dot { border-radius: 1px; box-shadow: none; }

/* A device that has checked in, but not lately, uses a quieter status label. */
.st-idle { color: var(--muted-2); }
.st-idle .dot { box-shadow: none; }

/* Expiry: the countdown, and under it how much of the granted window is left.
   The bar is a glance, the number is the answer. */
.exp { min-width: 100px; }
.exp-t { font-weight: 600; }
.bar {
  height: 4px;
  background: var(--track);
  border-radius: 999px;
  margin-top: 7px;
  overflow: hidden;
}
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--ok); box-shadow: 0 0 8px rgba(212, 212, 212, 0.35); }
.bar.is-warn i { background: var(--warn); box-shadow: 0 0 8px rgba(229, 229, 229, 0.35); }
.bar.is-bad i { background: var(--bad); box-shadow: 0 0 8px rgba(255, 255, 255, 0.35); }

/* ------------------------------------------------------------ icon buttons */

/* Inline SVG rather than an icon font or a sprite: it needs no new file and no
   build step, and currentColor means the icon takes the button's colour with no
   rule per button. The label lives in title and aria-label, because the glyph
   alone is not a name.

   Unfilled at rest, so a table of thirty rows does not look like a tray of
   buttons; hovered, the fill comes up behind the icon. */
.ico {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ico:hover { background: rgba(255, 255, 255, 0.26); border-color: var(--glass-line); }
.ico svg { display: block; }

/* Delete is the one control that should look like a warning before it is
   pressed, not only after. */
.ico-danger { color: var(--bad); border-color: rgba(255, 255, 255, 0.4); }
.ico-danger:hover { background: var(--accent); border-color: var(--accent); color: var(--ink-inverse); }
.time-grant { color: var(--ok); }
.time-grant:hover { color: var(--ink-inverse); background: var(--ok); border-color: var(--ok); }
.time-grant-reduce { color: var(--warn); }
.time-grant-reduce:hover { color: var(--ink-inverse); background: var(--warn); border-color: var(--warn); }
/* ---------------------------------------------------------------- buttons */

/* White primary buttons stand out against the charcoal cards. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font: inherit;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-inverse);
  background: linear-gradient(135deg, var(--accent), var(--accent-end));
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  box-shadow: 0 12px 26px -16px rgba(255, 255, 255, 0.20);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, filter 0.15s;
}
.btn:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12), 0 18px 32px -18px rgba(255, 255, 255, 0.20);
}

.btn-ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--line-soft);
  box-shadow: none;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.92); border-color: rgba(255, 255, 255, 0.92); color: var(--ink-inverse); filter: none; }

.btn-tiny { padding: 6px 12px; font-size: 11.5px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Only rendered with script: without it the form it opens is already on the
   page, below the table, and a button that does nothing is worse than none. */
.sheet-open { display: none; }
.js .sheet-open { display: inline-flex; }

/* ---------------------------------------------------------------- forms */

label {
  display: block;
  font-family: var(--display);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-2);
}

/* Fields are the most opaque thing on a pane: they are where the eye goes to
   type, and a frosted field with the ruling showing through it is a field you
   cannot read what you wrote in. */
input, select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
  background: var(--field-fill, rgba(255, 255, 255, 0.14));
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

/* The chevron is drawn rather than left to the browser: `appearance: none` is
   what lets the popup be themed at all, and once the native arrow is gone this
   is the replacement, drawn in white against the dark fill. */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23ffffff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 11px 7px;
}
select option { background: var(--bg); color: var(--ink); }

input:hover, select:hover { border-color: var(--ring); background-color: var(--field-hover, rgba(255, 255, 255, 0.9)); }
input:focus, select:focus {
  border-color: var(--ring);
  background-color: var(--field-focus, rgba(255, 255, 255, 0.95));
  box-shadow: 0 0 0 3px var(--hairline);
}

input::placeholder { color: var(--faint); }

.stack { display: grid; gap: 15px; }

/* A field and the button that fills it in. The same shape as `.expiry-row`
   below and for the same reason: the input takes the width that is left and the
   button takes what it needs, so the pair reads as one answer rather than as two
   questions. The button is small because it is a convenience — a password can
   still be typed straight into the field it sits beside. */
.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  margin-top: 5px;
}
.field-row input, .field-row button { margin-top: 0; }
.field-row button { width: auto; white-space: nowrap; }

/* The expiry number and its unit are one answer — "30 days" — so they sit on
   one line. Stacked, they read as two separate questions, and the number alone
   means nothing without the unit beside it. */
.expiry-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  margin-top: 5px;
}
.expiry-row input, .expiry-row select { margin-top: 0; }
.expiry-row select { width: auto; }

/* ------------------------------------------------------------- edit row */

/* The child combinator is load-bearing: the device list is a table inside this
   cell, and a plain descendant selector put the edit row's fill on every one of
   its cells as well. */
.edit-row > td {
  padding: 18px 16px;
  background: var(--raise);
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}
.edit-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 15px;
  align-items: end;
}
.edit-actions { grid-column: 1 / -1; display: flex; gap: 8px; }

.edit-sub {
  margin: 24px 0 10px;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}

/* The device list nested inside an account's edit row — the same table at the
   smaller scale it already had. */
.dev-table {
  width: 100%;
  border-collapse: collapse;
}
.dev-table th, .dev-table td {
  text-align: left;
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid var(--hairline);
}
.dev-table th:last-child, .dev-table td:last-child { padding-right: 0; }
.dev-table tr:last-child td { border-bottom: 0; }
.dev-table th {
  padding-bottom: 7px;
  border-bottom: 1px solid var(--rule);
}

/* The model name under its own presence line: the dot and the word answer "is
   this phone in use", and the name is what tells the admin which phone it is.
   The name never truncates and the id never overflows — a device id is the one
   value on this page that has to survive a copy. */
.dev-name { margin-top: 5px; font-weight: 600; }
.dev-table .acts { flex-wrap: wrap; }

/* The second line a device cell carries: the Android release and the app build
   under the name, the time a balance arrived under the balance. Quieter than the
   value above it, because it qualifies that value rather than competing. */
.dev-meta { margin-top: 4px; font-size: 11.5px; line-height: 1.35; color: var(--muted-2); }
.install-source { margin-top: 5px; font-size: 11px; line-height: 1.3; color: var(--muted-2); }
.install-source strong { color: var(--ink); font-weight: 600; }
.app-integrity { margin-top: 5px; font-size: 11px; line-height: 1.3; }
.app-integrity .st { font-size: inherit; }

/* The app's own countdown. Tabular figures so a column of them lines up, and a
   weight that says "this is a number to compare", which the account time beside
   it is not — that one is a date the panel owns and this one is a report. */
.bal { font-variant-numeric: tabular-nums; font-weight: 600; }
.bal-when { margin-top: 3px; font-size: 11px; color: var(--muted-2); }

/* The account a device is bound to. A jump inside the panel, not a destination,
   so it reads as part of the row rather than as an exit from it. */
.acct-link { color: inherit; text-decoration: none; border-bottom: 1px solid var(--line-soft); }
.acct-link:hover { border-bottom-color: var(--ring); }

/* The directory: the device table at page scale, so its cells hold more than the
   nested list's do. The two time columns are held on one line — "3d 4h" broken
   across a wrap reads as two values — and the rows are centred because the first
   cell is two lines tall and the rest are one. */
.dir-table td { vertical-align: middle; }
.dir-table td:last-child { white-space: nowrap; }
.connection-value { display: inline-block; min-width: 100px; overflow-wrap: anywhere; }

@media (min-width: 721px) {
  .dir-table th:nth-child(4),
  .dir-table td[data-label="Setup"] { text-align: center; }
}

/* Device row status labels and their dots share a clear status color. */
.dir-table .st-ok { color: var(--lamp-live); }
.dir-table .st-idle { color: var(--lamp-amber); }
.dir-table .st-bad { color: var(--lamp-rose); }
.dir-table .st .dot { flex: none; border-radius: 50%; }

/* The hardware id is shown in full. This column is the widest thing in the
   table, so it is the one that gives when the row runs out of room: the id
   breaks anywhere rather than pushing the actions off the edge. */
.hwid {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.hwid code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted-2);
  overflow-wrap: anywhere;
  min-width: 0;
}

/* Time the owner has granted that the phone has not collected yet. It sits
   under the balance rather than being added to it — the sum would be a number
   the user cannot see yet, and the two facts it is made of are worth seeing
   apart. Coloured, because unlike the line above it this one is waiting on
   something rather than reporting it. */
.bal-pending {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ok);
  white-space: nowrap;
}
.bal-pending-subtract { color: var(--warn); }

.dev-table td[data-label="Balance"] {
  white-space: nowrap;
}

/* The footnote under the device list. It carries a limit rather than a hint, so
   it is set as prose and not as a label — it is the panel saying out loud what
   it cannot see. */
.dev-note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted-2);
}

/* ---------------------------------------------------------------- alerts */

/* A note in the margin: tinted, with the colour carried down the left edge. A
   border in the alert's own colour all the way round reads as a shout, and the
   message is usually not the loudest thing on the page. */
.alert {
  padding: 12px 16px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--line-soft);
  border-left: 3px solid currentColor;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}
.alert-error { color: var(--bad); }
.alert-ok    { color: var(--ok); }

/* ------------------------------------------------------- Database status */

.database-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 20px 0 0;
}
.database-facts > div {
  min-width: 0;
  padding: 13px 14px;
  background: var(--well);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}
.database-facts dt { margin: 0 0 5px; }
.database-facts dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

/* ------------------------------------------------------------- login gate */

.gate { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
/* The title and its one-line explanation travel together, so the form beside
   them stays centred against the pair rather than against the heading alone. */
.gate-copy { flex: 1; min-width: 0; }
.gate-copy p { margin: 4px 0 0; font-size: 12.5px; }
.gate-title { margin: 0; flex: 1; min-width: 0; }
.gate-form { display: flex; align-items: center; gap: 12px; }

.switch { position: relative; display: inline-block; width: 46px; height: 24px; flex: none; cursor: pointer; }
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--track);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  transition: background 0.18s, border-color 0.18s;
  pointer-events: none;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(22px); background: var(--ink-inverse); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--hairline); }

/* ------------------------------------------------------------ new account */

/* Without script this is an ordinary pane at the end of the page and the tabs
   are radios the browser switches on its own, so the whole form still works.
   With script it becomes the slide-over, and the radios keep doing the tabs. */
.sheet {
  padding: 22px;
  margin-bottom: 18px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  backdrop-filter: var(--glass-blur-heavy);
  -webkit-backdrop-filter: var(--glass-blur-heavy);
}

/* The slide-over is the one pane that has to sit over the page rather than in
   it, so it keeps the blur and the shadow but drops the rounded corners on its
   outer edge — a floating pane with four rounded corners and one of them off
   screen reads as a mistake. It also takes the heaviest fill of the lot: it
   covers content rather than sitting beside it, and a light frost over the
   table would let thirty rows read straight through it. */
.js .sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: min(420px, 100%);
  margin: 0;
  padding: 24px 26px;
  background: var(--glass-strong);
  border-radius: 0;
  border-width: 0 0 0 1px;
  border-left-color: var(--glass-line);
  overflow-y: auto;
  overscroll-behavior: contain;
  visibility: hidden;
  transform: translateX(100%);
  transition: transform 0.24s ease, visibility 0.24s;
}
/* Visibility follows the sheet that was actually asked for, not the body: the
   accounts page now carries two — the new-account form and the grant form — and
   a body class that only says "a sheet is open" would slide both in at once.
   The body class is still the one that holds the scrim and stops the scroll, so
   a page that somehow opened none of them still cannot be scrolled behind one
   that is not there. Without script, `.js .sheet` never applies and this is
   moot: every sheet is an ordinary pane down the page. */
.js .sheet.is-open { visibility: visible; transform: none; }
body.sheet-open { overflow: hidden; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s, visibility 0.24s;
}
body.sheet-open .scrim { opacity: 1; visibility: visible; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.sheet-head h2 { margin: 0; }

/* Tabs, as a segmented pill rather than two loose buttons. */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
}
.tabs label {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--muted-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tabinput { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
#tab-manual:checked ~ .tabs label[for="tab-manual"],
#tab-trial:checked ~ .tabs label[for="tab-trial"] {
  background: linear-gradient(135deg, var(--accent), var(--accent-end));
  color: var(--ink-inverse);
}
#tab-manual:focus-visible ~ .tabs label[for="tab-manual"],
#tab-trial:focus-visible ~ .tabs label[for="tab-trial"] {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.pane { display: none; }
#tab-manual:checked ~ .pane[data-pane="manual"],
#tab-trial:checked ~ .pane[data-pane="trial"] { display: grid; }

/* ----------------------------------------------------- generated credentials */

/* Monospace and selectable because these get read off the screen and typed into
   a phone by hand. */
.cred { margin: 14px 0 4px; display: grid; gap: 12px; }

/* The label over the box, like every other field on the panel: the name above,
   the value under it. The rows used to be a label, a value and a button on one
   line, which worked until the value was a 64-character key — then the line
   wrapped, the box grew to two storeys and the Copy button floated beside the
   middle of it, belonging to neither line. */
.cred-label { display: block; margin-bottom: 6px; }

/* The value in a box made of the same parts as every `input` on the page — the
   same fill, border, radius and padding — because it is the same thing to read:
   a labelled value in a box.
 *
 * A box rather than an `input` because a form control scrolls its overflow
 * sideways, and a key with its last twenty characters hidden is a key that gets
 * pasted wrong. Left to wrap, the whole of it stays on the page. */
.cred-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--field-fill, rgba(255, 255, 255, 0.14));
  border: 1px solid var(--line-soft);
  border-radius: 11px;
}

/* The Copy button is sized to the box, not to the text in it, so a key that runs
   onto a second line does not drag the button down the middle of the field. */
.cred-box .btn { flex: none; }

/* The key keeps its own class rather than sharing the page container's.
 *
 * `wrap` is that container: max-width 1100px, margin auto, and 16px/60px of block
 * padding. A `<code>` carrying it silently inherited every one of those, which is
 * what drew the tall half-empty box the key used to sit in — the padding alone
 * was 76px of a row that needed one line. Nothing about a container belongs on a
 * string, so it does not share the name. */
.cred-box code {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.6;
  word-break: break-all;
  user-select: all;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin: 22px 0 0;
}
.facts dt { margin-bottom: 4px; }
.facts dd { margin: 0; font-weight: 700; }

/* -------------------------------------------------------------------- apps */

.app-detail {
  padding: 18px;
  background: var(--well);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}
.app-page-link {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.app-page-link:hover { color: var(--accent); border-bottom-color: currentColor; }

/* ------------------------------------------------------------ client list */

/* A client's name is the way into their page. Underlined, because on a table of
   names the one link in a row should not have to be guessed at from its colour
   alone — but only on hover, so the column still reads as a column of names
   rather than as a column of links. */
.client-name { color: var(--ink); text-decoration: none; }
.client-name:hover { color: var(--accent); text-decoration: underline; }

.card .app-page-link:hover,
.card .client-name:hover,
.card .cred-drawer > summary:hover,
.card .new-app summary:hover { color: var(--link); }

/* Select arrows share the white ink used by the native dark options. */
.card select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23ffffff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* The app whose accounts these are, at the head of the accounts card. Muted like
   the label it replaces — the heading is the page's title and this is a note
   beside it — but a link, because it is the way to the page holding that app's
   URL, key and controls, and for the panel's own app it is the only way there. */
.app-crumb { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
.app-crumb:hover { color: var(--ink); border-bottom-color: currentColor; }

/* The two things a client is, side by side at the end of their row: the accounts
   those credentials create, and the credentials themselves. Right-aligned so the
   buttons stack into a column the eye can run down, and nowrap so a narrow
   column breaks the row instead of the labels. */
.client-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  white-space: nowrap;
}

/* The controls one code needs: copy it, stop it, throw it away. Right-aligned
   and nowrap for the same reasons as the client list's — a column of buttons
   the eye runs down, and a narrow column that breaks the row rather than the
   labels. */
.code-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  white-space: nowrap;
}

/* The code itself is this table's identity column, so it takes the monospace
   face and a size up from body text. That is what makes a string of groups read
   as one object to copy rather than as a sentence to read — the page's whole
   use for it is the clipboard. */
.code-text {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

.app-detail > .muted { margin: 0 0 4px; font-size: 12.5px; }

.snippet { margin: 14px 0 4px; }
.snippet summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 0;
}
.snippet summary:hover { color: var(--ink); }

/* The drawer the URL and key live in.
 *
 * Shut by default. Unfolded they are the tallest thing on the card, and they are
 * wanted on the day a build is cut rather than every day the panel is opened —
 * see the note in connectionBlock().
 *
 * The summary is drawn as a full-width bar with the arrow at its far end, the
 * shape a dropdown has everywhere else, rather than as a pill the width of its
 * own words. Sized to its text it read as one more button among the buttons
 * around it, and the one control that opens the two fields below was the one
 * that looked least like it belonged to them.
 *
 * The arrow and the Show/Hide label both come from CSS, so the closed-to-open
 * change needs nothing to run and works with scripts off.
 */
.cred-drawer { margin: 14px 0 4px; }
.cred-drawer > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
  user-select: none;
}
.cred-drawer > summary::-webkit-details-marker { display: none; }
.cred-drawer > summary::after {
  content: '▾';
  margin-left: auto;
  font-size: 10px;
}
.cred-drawer[open] > summary::after { content: '▴'; }
.cred-drawer > summary:hover { color: var(--ink); border-color: var(--accent); }
.cred-drawer > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* One label or the other, never both. */
.cred-drawer > summary .when-open { display: none; }
.cred-drawer[open] > summary .when-closed { display: none; }
.cred-drawer[open] > summary .when-open { display: inline; }

.cred-drawer[open] > .cred { margin-top: 12px; }
.snippet pre {
  margin: 10px 0 12px;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--well);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}
.snippet code {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre;
  user-select: all;
}

/* Its own line, aligned with the fields above rather than floating under the
   snippet at whatever width its words happened to be. */
.snippet-actions { display: flex; justify-content: flex-end; }

/* The rename form's own line of fields, which wrap rather than crush. */
/* Name, Login and New password share one row.
 *
 * They are three answers to one question — who this client is — and the card is
 * wide enough for them (620px, see `.card-narrow`) as long as each takes a third
 * rather than claiming a width of its own. At a fixed 220px the third wrapped to
 * a line of its own with two thirds of the card empty beside it.
 *
 * Below 720px they stack, where a third of the width is too little to read. */
.app-rename { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.app-rename label { flex: 1 1 0; min-width: 0; margin: 0; }

/* Save and the way to the accounts, on a line of their own and centred.
 *
 * Left in the flow they land wherever the third field happens to end, which put
 * Save in the middle of the row with a field to its left and nothing at all to
 * its right — a button that belongs to the whole form, positioned as though it
 * belonged to the field before it. Given the full width and centred, they read
 * as the form's ending rather than as the password field's two neighbours.
 *
 * Save is the card's one commit, so it is set a size above the ghost beside it,
 * which is a way out rather than a change. Both keep the same block padding, so
 * the two sit on one line instead of the taller one hanging below the other, and
 * the ghost gives up the width floor the primary takes. */
.app-rename .edit-actions { flex: 1 1 100%; justify-content: center; }
.app-rename .edit-actions .btn { min-width: 150px; padding: 14px 30px; font-size: 15px; }
.app-rename .edit-actions .btn-ghost { min-width: 0; padding: 14px 20px; font-size: 13px; }

/* The email, and the sentence about it, on lines of their own.
 *
 * A fourth field in the same row would take the three above it down to a quarter
 * of the card each, which is narrower than an email address can be read in — and
 * the address is the one field here whose whole value is being checked for
 * typos. Full width also gives it the room to be the longest thing on the card,
 * which it usually is.
 *
 * Two classes to one, so this beats `.app-rename label` on specificity and not on
 * where it happens to sit in the file. */
.app-rename .app-wide { flex: 1 1 100%; }

/* A client's id and how many accounts they hold. Two short values on the same
   grid the trial page's facts use, so "here is the client" reads the same way as
   "here is the account". */
.client-facts { margin-top: 16px; gap: 14px; }
.client-facts dt { font-size: 12px; }
.client-facts dd { font-size: 14px; }
.client-facts dd code { font-family: var(--mono); font-size: 13px; }

/* One sentence under a field, explaining what the field does rather than what it
   is. Not `.muted`: that is a word or two beside a label, at the label's size,
   and this is a sentence that has to survive being read at 12.5px on a phone. */
.field-hint { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--muted-2); }

/* Mixing the two button modifiers rather than introducing a third fill: the
   white gradient is the page's strongest shape and a destructive action is not
   the thing that should be holding it. */
.btn-ghost.danger { color: var(--bad); border-color: rgba(255, 255, 255, 0.5); }
.btn-ghost.danger:hover { background: var(--bad); border-color: var(--bad); color: var(--ink-inverse); }

.card .btn-ghost.danger:hover { color: var(--ink-inverse); }

.new-app { margin-top: 18px; }
.new-app summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 0;
}
.new-app summary:hover { color: var(--accent); }
.app-new-form { margin-top: 12px; }
.app-new-form .muted { font-size: 12.5px; margin: 8px 0 0; }

.sheet-app { margin: 0; padding: 0 0 14px; font-size: 12.5px; color: var(--muted); }

/* What the app says the balance is, under the device the sheet is about.
   Written by script from the row that opened it, so it does not exist on a page
   read without script — and it is hidden until it has been filled, because an
   empty line under a heading is a rendering fault. */
.grant-now {
  margin: 0 0 18px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-line);
  border-radius: 10px;
}

/* The amounts that come up again and again, as presses rather than typing. */
.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 16px;
}

/* ------------------------------------------------------------- public site */

.is-home-page:not(.js) {
  scroll-behavior: smooth;
}

.is-home {
  color-scheme: light;
  --public-accent: #7b1534;
  --public-accent-dark: #590b25;
  --public-blue: #b33c5e;
  --public-panel: rgba(255, 255, 255, 0.88);
  --sheet: linear-gradient(#ffffff, #ffffff);
  --bg: #ffffff;
  --ink: #481022;
  --ink-inverse: #ffffff;
  --muted: #70404d;
  --muted-2: #875b67;
  --faint: #a17882;
  --link: #7b1534;
  --accent: #7b1534;
  --accent-end: #590b25;
  --track: rgba(123, 21, 52, 0.14);
  --grid:
    linear-gradient(to right, rgba(123, 21, 52, 0.09) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(123, 21, 52, 0.09) 1px, transparent 1px);
  background: #ffffff;
  overflow-x: hidden;
}

.is-home::before {
  background-image:
    radial-gradient(circle at 78% 14%, rgba(123, 21, 52, 0.10), transparent 28%),
    radial-gradient(circle at 18% 38%, rgba(179, 60, 94, 0.07), transparent 25%),
    linear-gradient(to right, rgba(123, 21, 52, 0.09) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(123, 21, 52, 0.09) 1px, transparent 1px),
    linear-gradient(#ffffff, #ffffff);
  background-size: auto, auto, 48px 48px, 48px 48px, 100% 100%;
}

.is-home .wrap { max-width: none; padding: 0; }
.site-shell { max-width: 1240px; margin: 0 auto; padding: 0 36px; }

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  gap: 28px;
  border-bottom: 1px solid rgba(123, 21, 52, 0.16);
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}
.site-brand img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(123, 21, 52, 0.22), 0 12px 30px -18px rgba(89, 11, 37, 0.34);
}
.site-brand span { display: grid; line-height: 1.1; }
.site-brand strong {
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 0.08em;
}
.site-brand small {
  margin-top: 5px;
  font-family: var(--display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.site-nav nav { display: flex; align-items: center; gap: 30px; }
.site-nav nav a {
  font-family: var(--display);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.site-nav nav a:hover { color: var(--ink); }
.site-nav nav .site-nav-download {
  padding: 10px 17px;
  color: #ffffff;
  background: var(--public-accent);
  border: 1px solid var(--public-accent);
  border-radius: 999px;
}
.site-nav nav .site-nav-download:hover { color: #ffffff; background: var(--public-accent-dark); }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(390px, 0.95fr);
  align-items: center;
  gap: clamp(36px, 7vw, 96px);
  min-height: min(790px, calc(100vh - 92px));
  padding: 74px 0 92px;
}
.hero-copy { min-width: 0; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--public-accent);
}
.eyebrow > span { width: 32px; height: 1px; background: currentColor; }

.hero h1 {
  max-width: 720px;
  font-size: clamp(50px, 7.2vw, 92px);
  line-height: 0.94;
  letter-spacing: -0.065em;
}
.hero h1 em,
.modes-copy h2 em {
  color: transparent;
  background: linear-gradient(100deg, var(--public-accent), #9b2c4c 48%, var(--public-blue));
  background-clip: text;
  -webkit-background-clip: text;
  font-style: normal;
}
.hero-lead {
  max-width: 630px;
  margin: 30px 0 0;
  font-size: clamp(16px, 1.7vw, 19px);
  line-height: 1.7;
  color: var(--muted);
}
.hero-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 24px; margin-top: 34px; }
.is-home .btn {
  min-height: 52px;
  color: #ffffff;
  background: var(--public-accent);
  border-color: var(--public-accent);
  box-shadow: 0 16px 34px -20px rgba(123, 21, 52, 0.60);
}
.is-home .btn:hover {
  color: #ffffff;
  background: var(--public-accent-dark);
  border-color: var(--public-accent-dark);
  box-shadow: 0 0 0 4px rgba(123, 21, 52, 0.10), 0 20px 40px -22px rgba(123, 21, 52, 0.62);
}
.is-home .btn svg { width: 22px; height: 22px; flex: none; }
.hero-download { padding: 11px 20px; }
.hero-download > span { display: grid; text-align: left; line-height: 1.15; }
.hero-download small {
  margin-top: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  opacity: 0.65;
}
.hero-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.hero-link:hover { color: var(--ink); }
.hero-link span { color: var(--public-accent); font-size: 16px; }

.hero-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 670px;
  margin-top: 54px;
  padding-top: 24px;
  border-top: 1px solid rgba(123, 21, 52, 0.16);
}
.hero-facts > span {
  display: grid;
  gap: 5px;
  padding-right: 18px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.hero-facts strong { font-family: var(--display); font-size: 12px; letter-spacing: 0; text-transform: none; color: var(--ink); }

.hero-art { position: relative; display: grid; place-items: center; min-height: 580px; isolation: isolate; }
.hero-art::before {
  content: "";
  position: absolute;
  width: 390px;
  height: 390px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(123, 21, 52, 0.16), rgba(179, 60, 94, 0.07) 45%, transparent 70%);
  filter: blur(8px);
}
.orbit { position: absolute; border: 1px solid rgba(123, 21, 52, 0.18); border-radius: 50%; }
.orbit-one { width: 490px; height: 490px; }
.orbit-two { width: 370px; height: 370px; border-style: dashed; border-color: rgba(123, 21, 52, 0.28); transform: rotate(24deg); }
.orbit-one::before,
.orbit-two::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--public-accent);
  box-shadow: 0 0 18px rgba(123, 21, 52, 0.50);
}
.orbit-one::before { top: 74px; right: 55px; }
.orbit-two::after { bottom: 50px; left: 44px; background: var(--public-blue); }

.device-preview {
  position: relative;
  z-index: 2;
  width: 272px;
  height: auto;
  display: block;
  border: 1px solid rgba(123, 21, 52, 0.28);
  border-radius: 36px;
  box-shadow: 0 45px 90px -30px rgba(89, 11, 37, 0.38), 0 0 60px -20px rgba(123, 21, 52, 0.30);
  transform: rotate(3deg);
}

.float-chip {
  position: absolute;
  z-index: 3;
  display: grid;
  min-width: 112px;
  padding: 12px 15px;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(123, 21, 52, 0.22);
  border-radius: 14px;
  box-shadow: 0 20px 40px -20px rgba(89, 11, 37, 0.32);
  backdrop-filter: blur(12px);
}
.float-chip small { margin-top: 3px; font-size: 8px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.chip-fast { left: 5px; top: 145px; }
.chip-live { right: -2px; bottom: 118px; color: var(--public-accent); }

.public-section { padding: 120px 0; border-top: 1px solid rgba(123, 21, 52, 0.16); scroll-margin-top: 24px; }
.section-heading { display: grid; grid-template-columns: 1.15fr 0.85fr; align-items: end; gap: 50px; margin-bottom: 48px; }
.section-heading .eyebrow { grid-column: 1 / -1; margin-bottom: -24px; }
.section-heading h2,
.modes-copy h2,
.download-banner h2 {
  font-size: clamp(36px, 5vw, 62px);
  line-height: 1.02;
  letter-spacing: -0.045em;
}
.section-heading > p:last-child,
.modes-copy > p,
.download-banner > div > p:last-child { margin: 0; font-size: 16px; line-height: 1.7; color: var(--muted); }

.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.feature-grid article {
  position: relative;
  min-height: 290px;
  padding: 28px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(123,21,52,0.07), rgba(255,255,255,0.92));
  border: 1px solid rgba(123, 21, 52, 0.18);
  border-radius: 22px;
}
.feature-grid article::after { content: ""; position: absolute; width: 160px; height: 160px; right: -80px; bottom: -95px; border-radius: 50%; background: var(--public-accent); filter: blur(70px); opacity: 0.12; }
.feature-no { position: absolute; top: 25px; right: 26px; font-family: var(--mono); font-size: 10px; color: var(--faint); }
.feature-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 52px; color: #ffffff; background: var(--public-accent); border-radius: 14px; font-size: 20px; }
.feature-grid h3 { margin: 0 0 12px; font-family: var(--display); font-size: 20px; }
.feature-grid p { margin: 0; font-size: 13px; line-height: 1.7; color: var(--muted-2); }

.modes-section {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(50px, 9vw, 120px);
  align-items: center;
  padding: 118px clamp(28px, 5vw, 64px);
  background: linear-gradient(135deg, rgba(179, 60, 94, 0.08), rgba(123, 21, 52, 0.05));
  border: 1px solid rgba(123,21,52,0.18);
  border-radius: 30px;
  scroll-margin-top: 24px;
}
.modes-copy > p { margin: 26px 0 30px; }
.mode-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 24px;
  border-top: 1px solid rgba(123,21,52,0.18);
}
.mode-list > div {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 4px 12px;
  min-height: 92px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(123,21,52,0.18);
}
.mode-list span { font-family: var(--mono); font-size: 10px; color: var(--public-accent); }
.mode-list strong { min-width: 0; font-family: var(--display); font-size: 15px; overflow-wrap: anywhere; }
.mode-list small { grid-column: 2; color: var(--muted-2); }

.download-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 36px;
  margin: 110px 0;
  padding: 54px 58px;
  background: linear-gradient(120deg, rgba(123,21,52,0.11), rgba(179,60,94,0.08));
  border: 1px solid rgba(123,21,52,0.28);
  border-radius: 28px;
}
.download-banner .eyebrow { margin-bottom: 17px; }
.download-banner h2 { font-size: clamp(32px, 4vw, 52px); }
.download-banner > div > p:last-child { margin-top: 15px; }
.download-banner .hero-download { flex: none; }

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  min-height: 120px;
  border-top: 1px solid rgba(123,21,52,0.16);
}
.site-footer .site-brand img { width: 34px; height: 34px; }
.site-footer p { margin: 0; font-size: 11px; color: var(--faint); }

@media (max-width: 980px) {
  .hero { grid-template-columns: minmax(0, 1fr); padding-top: 64px; }
  .hero-copy { max-width: 760px; }
  .hero-art { min-height: 630px; }
  .chip-fast { left: calc(50% - 220px); }
  .chip-live { right: calc(50% - 225px); }
  .section-heading { grid-template-columns: 1fr; gap: 22px; }
  .section-heading .eyebrow { margin-bottom: 0; }
  .modes-section { grid-template-columns: 1fr; }
  .download-banner { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 720px) {
  .site-shell { padding-inline: max(18px, env(safe-area-inset-left)) max(18px, env(safe-area-inset-right)); }
  .site-nav { min-height: 76px; }
  .site-nav nav { gap: 8px; }
  .site-nav nav a:not(.site-nav-download) { display: none; }
  .site-nav nav .site-nav-download { min-height: 44px; display: inline-flex; align-items: center; padding-inline: 16px; }
  .hero { min-height: 0; padding: 62px 0 76px; gap: 24px; }
  .hero h1 { font-size: clamp(47px, 15vw, 70px); }
  .hero-lead { font-size: 16px; }
  .hero-facts { grid-template-columns: 1fr; gap: 15px; margin-top: 42px; }
  .hero-facts > span { padding-bottom: 14px; border-bottom: 1px solid rgba(123,21,52,0.11); }
  .hero-art { min-height: 550px; transform: scale(0.88); margin-inline: -30px; }
  .orbit-one { width: 450px; height: 450px; }
  .chip-fast { left: calc(50% - 190px); }
  .chip-live { right: calc(50% - 190px); }
  .public-section { padding: 84px 0; }
  .section-heading h2, .modes-copy h2 { font-size: 42px; }
  .feature-grid { grid-template-columns: 1fr; }
  .feature-grid article { min-height: 250px; }
  .modes-section { margin-inline: -6px; padding: 68px 24px; border-radius: 24px; }
  .mode-list { grid-template-columns: 1fr; }
  .mode-list > div { grid-template-columns: 36px 1fr; gap: 10px; padding: 14px 0; }
  .mode-list small { grid-column: 2; }
  .download-banner { margin: 76px 0; padding: 38px 24px; border-radius: 22px; }
  .download-banner .hero-download { width: 100%; }
  .site-footer { align-items: flex-start; flex-direction: column; justify-content: center; padding: 30px 0; }
}

@media (max-width: 440px) {
  .site-brand small { display: none; }
  .hero-actions { align-items: stretch; flex-direction: column; }
  .hero-actions .btn { width: 100%; }
  .hero-link { justify-content: center; min-height: 44px; }
  .hero-art { transform: scale(0.76); min-height: 470px; margin: -20px -60px 0; }
  .float-chip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .is-home *, .is-home *::before, .is-home *::after { scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------- sign in */

/* The page with no masthead: the brand is the pane. The sheet still carries the
   ruling behind it here too — a sign-in card over a flat fill would be the one
   place the effect stops. */
.is-signin .wrap {
  display: grid;
  place-items: center;
  max-width: none;
  min-height: 100vh;
  padding: 40px 24px;
}

.signin-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 400px;
  padding: 32px 30px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-top-color: rgba(255, 255, 255, 0.50);
  border-left-color: rgba(255, 255, 255, 0.34);
  border-radius: 24px;
  box-shadow: var(--glass-shadow);
  backdrop-filter: var(--glass-blur-heavy);
  -webkit-backdrop-filter: var(--glass-blur-heavy);
}

.signin-brand { margin-bottom: 26px; text-align: center; }

.signin-logo {
  display: block;
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--glass-line), 0 16px 30px -16px rgba(0, 0, 0, 0.7);
  object-fit: cover;
  filter: grayscale(1);
}

/* The h1 is the brand here, not the word "Sign in": on a screen whose only
   action is signing in, the name is the heading and the form says the rest. */
.signin-title {
  font-family: var(--display);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.signin-sub { margin: 6px 0 0; }

.signin { display: grid; gap: 14px; }
.signin .btn { width: 100%; }

/* The sentence above the form on the four pages that ask for one thing: where a
   code went, or what this page is about to do. Centred, because the card is. */
.signin-note {
  margin: 0 0 18px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
  text-align: center;
}
.signin-note strong { color: var(--ink); font-weight: 600; }

/* A way out or a way back, under the form rather than beside it. The card has one
   action and these are not it — they are what to do when that action is the
   wrong one, and putting them in the same row as the button would make the page
   ask a second question before the first is answered. */
.signin-alt {
  margin: 18px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted-2);
  text-align: center;
}
.signin-alt a { color: var(--ink); font-weight: 600; }
.signin-alt a:hover { text-decoration: underline; }

/* "Send a new code", which is a second action and is drawn as the lesser one. */
.signin-alt-form { margin: 12px 0 0; }
.signin-alt-form .btn { width: 100%; }

/* A rule the reader is about to run into, set under the control it applies to
   rather than in a banner. It is the same sentence on every visit — nothing here
   is about this person — so it is drawn at the size of a footnote, and it is why
   a press that sends nothing is not a surprise. */
.signin-fine {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted-2);
  text-align: center;
}

/* The same footnote when it is about this person: a code is on its way to them,
   and the wait is theirs. The countdown is the one thing on it worth reading at a
   glance, so it is the one thing in ink — and in tabular figures, because a
   number that changes every second should not shuffle the words beside it. */
.signin-fine .timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
}

/* ---------------------------------------------------------------- footer */

.foot {
  padding: 0 30px 40px;
  text-align: center;
  font-family: var(--display);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---------------------------------------------------------------- loader */

/* Hidden unless script is running. The overlay covers the whole viewport and
   only script can take it away, so a browser without it must never be shown the
   loader at all — the same `js` class the toolbar and the slide-over gate on.
   It also holds the panel back by less than a second: this is opened from a
   phone when an account has stopped working, and a splash that makes the admin
   wait is a splash that has stopped being decoration. */
.loader { display: none; }
.js .loader {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  /* the very same sheet as the page, so the crossfade into it is invisible */
  background-color: var(--bg);
  background-image: var(--grid), var(--sheet);
  background-size: var(--grid-size), 100% 100%;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.js .loader.done { opacity: 0; visibility: hidden; }

.loader-core { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 24px; }
.ring { position: relative; width: 116px; height: 116px; display: grid; place-items: center; margin-bottom: 26px; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ring-track { fill: none; stroke: var(--track); stroke-width: 3; }
.ring-sweep {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 74 253;
  transform-box: view-box;
  transform-origin: 60px 60px;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.35));
  animation: spin 1.15s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* The same artwork as the masthead brand, just bigger. It is already cut to a
   circle with a transparent surround, so the box is the picture and nothing
   else — a radius here would clip it and a fill would show through the corners. */
.ring-mark {
  width: 70px;
  height: 70px;
  background-image: url("/aika.png");
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  filter: grayscale(1) drop-shadow(0 10px 22px rgba(0, 0, 0, 0.45));
  animation: breathe 2.6s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.55; } }

.loader-title { margin: 0; font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -0.015em; }
.loader-status {
  margin: 9px 0 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--muted-2);
  min-height: 15px;
}
.loader-bar {
  position: relative;
  width: 196px;
  height: 2px;
  margin-top: 24px;
  border-radius: 2px;
  background: var(--track);
  overflow: hidden;
}
.loader-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, #a3a3a3, var(--accent) 55%, #d4d4d4);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
  animation: fill 0.65s cubic-bezier(0.3, 0.55, 0.35, 1) forwards;
}
@keyframes fill { to { width: 100%; } }

/* ---------------------------------------------------------------- fallback */

/* Solid fills preserve the cards' contrast when backdrop blur is unavailable. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card,
  .signin-card { background: var(--card-solid); }
  .card-table { background: var(--smoke-solid); }
  .topbar,
  .sheet { background: var(--bg); }
  .scrim { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(0, 0, 0, 0.7); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ----------------------------------------------------------------- mobile */

/* The panel gets opened from a phone at least as often as from a desk — it is
   where you go when someone messages you that their account stopped working —
   so below this width the table stops being a table. Six columns on a phone is
   either a sideways scroll or six unreadable slivers. Each account becomes a
   small pane of glass of its own instead: the name and its status on the top
   line, the rest as labelled rows, the actions along the bottom where a thumb
   can reach them.

   The header row goes, because every value now carries its own label. Those
   labels are generated content, which assistive technology does read — and they
   have to carry it here, since display:block on a table drops the header
   association whether or not the header is on screen. */
@media (max-width: 860px) {
  .wrap { padding-inline: 20px; }
  .topnav { width: 100%; }
  .topnav a { flex: 1 1 auto; }
  /* The named shelf has to be listed here too: `.stats.is-trio` is two classes
     to this one's one, so it would otherwise outrank the narrow layout and set
     three figures to a row on a phone. */
  .stats,
  .stats.is-trio { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .stat b { font-size: 28px; }
}

@media (max-width: 720px) {
  .wrap {
    padding-block: 12px 36px;
    padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
  }
  .topbar { top: max(8px, env(safe-area-inset-top)); border-radius: 16px; }
  .brand { padding: 12px 14px; }
  .topnav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
  }
  .topnav a {
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    min-height: 62px;
    padding: 10px 3px;
    font-size: 11.5px;
  }
  .topnav a svg { display: block; width: 18px; height: 18px; }

  .stats.is-trio { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stats.is-trio .stat b { font-size: clamp(20px, 5.5vw, 28px); gap: 7px; }
  .stat { overflow-wrap: anywhere; }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea { min-width: 0; min-height: 44px; font-size: 16px; }
  .field-row,
  .expiry-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .field-row input,
  .expiry-row input { min-width: 0; }
  .search { min-height: 46px; padding: 0 12px; }
  .search input { min-height: 44px; font-size: 16px; padding-block: 10px; }

  .btn,
  .chip { min-height: 44px; }
  .btn-tiny { padding: 10px 12px; font-size: 12px; }
  .btn,
  .ico,
  .chip,
  .topnav a,
  .tabs label,
  .switch { touch-action: manipulation; }
  .tabs label { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 44px; }
  .switch { height: 44px; }
  .switch-track { top: 10px; bottom: 10px; }

  .card-head { gap: 10px; }
  .card-head h1,
  .card-head h2,
  .card-head > .muted { min-width: 0; overflow-wrap: anywhere; }
  .head-acts { flex: 1 1 100%; flex-wrap: wrap; min-width: 0; gap: 8px; }
  .head-acts > .muted { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  .head-acts > form { flex: none; }
  .acts { flex-wrap: wrap; gap: 8px; }
  .edit-actions { flex-wrap: wrap; gap: 8px; }
  .edit-actions .btn { min-width: 0; flex: 1 1 140px; }
  .app-rename .edit-actions .btn { min-width: 0; flex-basis: 100%; padding-inline: 16px; }
  .client-actions,
  .code-actions { flex-wrap: wrap; white-space: normal; }
  .client-actions > *,
  .code-actions > * { flex: 1 1 100px; }
  .client-actions form .btn,
  .code-actions form .btn { width: 100%; }

  .acct-note,
  .app-crumb,
  .sheet-app,
  .facts dd,
  .cred-row code { overflow-wrap: anywhere; }
  .cred-row { flex-wrap: wrap; }
  .cred-row code,
  .hwid,
  .cred-box,
  .snippet { min-width: 0; }
  .client-name,
  .app-crumb { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; }
  .app-page-link { display: inline-flex; align-items: center; min-height: 44px; }
  .snippet summary,
  .cred-drawer > summary { min-height: 44px; }

  .tbl-scroll { overflow-x: visible; }

  .acc { min-width: 0; border-collapse: separate; }
  .acc thead { display: none; }
  .acc tbody,
  .acc tr,
  .acc td { display: block; }
  .acc .num { text-align: left; }

  /* Each account is a lightly raised pane inside the charcoal table card. */
  .acc tr[data-account] {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 12px;
    padding: 14px;
    margin-bottom: 12px;
    background: var(--raise);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
  }
  .acc tr[data-account] td { padding: 0; border: 0; }

  /* Name and status share the top line — the first thing you check when an
     account is reported broken. */
  .acc tr[data-account] td:nth-child(1) { grid-column: 1; align-self: center; min-width: 0; }
  .acc tr[data-account] td:nth-child(2) { grid-column: 2; justify-self: end; align-self: center; }
  .acct-name { overflow-wrap: anywhere; }

  /* The rest are label-over-value rows, divided from each other so the block
     reads as a small table laid on its side: the labels are the column, and the
     line down their right edge is the column line. The label is stretched to
     the height of whatever sits beside it, which is what makes that line reach
     the full row rather than stopping at the word. */
  .acc tr[data-account] td:nth-child(3),
  .acc tr[data-account] td:nth-child(4),
  .acc tr[data-account] td:nth-child(5) {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    column-gap: 12px;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid var(--hairline);
  }
  .acc tr[data-account] td:nth-child(3) { margin-top: 14px; padding-top: 14px; }
  .acc tr[data-account] td:nth-child(3)::before,
  .acc tr[data-account] td:nth-child(4)::before,
  .acc tr[data-account] td:nth-child(5)::before {
    content: attr(data-label);
    display: flex;
    align-items: center;
    align-self: stretch;
    padding-right: 12px;
    border-right: 1px solid var(--hairline);
    font-family: var(--display);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted-2);
  }
  .acc tr[data-account] .exp { min-width: 0; }

  .acc tr[data-account] td:nth-child(6) {
    grid-column: 1 / -1;
    margin-top: 15px;
    padding-top: 14px;
    border-top: 1px solid var(--hairline);
  }

  /* A client row holds four columns of a different shape from an account's, so
     it is its own block rather than a borrowed grid — but it is the same pane,
     and the same label-over-value rows underneath, because a table laid on its
     side is what this page does at every other width. */
  .acc tr[data-client] {
    padding: 14px;
    margin-bottom: 12px;
    background: var(--raise);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
  }
  .acc tr[data-client] td { padding: 0; border: 0; }
  .acc tr[data-client] code { overflow-wrap: anywhere; }

  /* The name leads and the id sits under it, the way a subtitle does. */
  .acc tr[data-client] td:nth-child(1) { margin-bottom: 12px; }

  .acc tr[data-client] td:nth-child(2),
  .acc tr[data-client] td:nth-child(3) {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    column-gap: 12px;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid var(--hairline);
  }
  .acc tr[data-client] td:nth-child(2)::before,
  .acc tr[data-client] td:nth-child(3)::before {
    content: attr(data-label);
    display: flex;
    align-items: center;
    align-self: stretch;
    padding-right: 12px;
    border-right: 1px solid var(--hairline);
    font-family: var(--display);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted-2);
  }

  /* The two ways out, side by side under everything they are ways out of. */
  .acc tr[data-client] td:nth-child(4) {
    margin-top: 15px;
    padding-top: 14px;
    border-top: 1px solid var(--hairline);
  }
  .acc tr[data-client] .client-actions { display: flex; justify-content: flex-start; }

  /* A code row is a pane of the same kind again, with the code itself as the
     thing that leads. It gets the monospace face here too, at the size the rest
     of the pane's values are set at, because on a phone the code is not read so
     much as checked character by character against what somebody was sent. */
  .acc tr[data-code] {
    padding: 14px;
    margin-bottom: 12px;
    background: var(--raise);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
  }
  .acc tr[data-code] td { padding: 0; border: 0; }

  .acc tr[data-code] td:nth-child(1) { margin-bottom: 12px; }
  .acc tr[data-code] .code-text { font-size: 15px; }

  .acc tr[data-code] td:nth-child(2),
  .acc tr[data-code] td:nth-child(3),
  .acc tr[data-code] td:nth-child(4),
  .acc tr[data-code] td:nth-child(5) {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    column-gap: 12px;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid var(--hairline);
  }
  .acc tr[data-code] td:nth-child(2)::before,
  .acc tr[data-code] td:nth-child(3)::before,
  .acc tr[data-code] td:nth-child(4)::before,
  .acc tr[data-code] td:nth-child(5)::before {
    content: attr(data-label);
    display: flex;
    align-items: center;
    align-self: stretch;
    padding-right: 12px;
    border-right: 1px solid var(--hairline);
    font-family: var(--display);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted-2);
  }

  /* The three controls a code has, under everything they act on. Copy leads,
     because it is the one the admin actually wants. */
  .acc tr[data-code] td:nth-child(6) {
    margin-top: 15px;
    padding-top: 14px;
    border-top: 1px solid var(--hairline);
  }
  .acc tr[data-code] .code-actions {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    white-space: normal;
  }

  /* The edit form follows its account as a pane of its own. Child combinator
     for the same reason as above — the device table is inside this cell. */
  .acc tr.edit-row > td {
    padding: 18px 14px;
    margin-bottom: 12px;
    background: var(--raise);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
  }
  .edit-form { grid-template-columns: 1fr; }
  .edit-actions .btn { flex: 1; }

  /* Setting display on the rows above would otherwise beat the user agent's
     [hidden] rule — which would leave filtered-out accounts on screen and the
     edit forms open under the wrong row. */
  .acc tr[data-account][hidden],
  .acc tr.edit-row[hidden] { display: none; }

  /* The device list under an edit form becomes labelled rows too, with the same
     treatment as the account above it at the smaller scale it already had. */
  .dev-table thead { display: none; }
  .dev-table,
  .dev-table tbody,
  .dev-table tr,
  .dev-table td { display: block; }
  .dev-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px 10px;
    padding: 12px 0;
  }
  .dev-table tr + tr { border-top: 1px solid var(--hairline); }
  .dev-table td { padding: 0; border: 0; }

  /* The same trap as the accounts rows above, and the one that made the devices
     page look broken on a phone: a row given a display of its own here keeps it
     whatever the [hidden] property says, so the chips and the search box — which
     do nothing but set that property — appeared to work and changed nothing.
     Drawn on the directory rows alone: the device list under an account is not
     filtered, and its rows carry no data-row to be caught by this. */
  .dev-table tr[data-row][hidden] { display: none; }
  .dev-table td:nth-child(1) { grid-column: 1; overflow-wrap: anywhere; }
  .dev-table td:nth-child(2),
  .dev-table td:nth-child(3),
  .dev-table td:nth-child(4) {
    grid-column: 1;
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    column-gap: 10px;
    align-items: center;
    font-size: 12px;
  }
  .dev-table td:nth-child(2)::before,
  .dev-table td:nth-child(3)::before,
  .dev-table td:nth-child(4)::before {
    content: attr(data-label);
    display: flex;
    align-items: center;
    align-self: stretch;
    padding-right: 10px;
    border-right: 1px solid var(--hairline);
    font-family: var(--display);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted-2);
  }
  /* Nested device actions sit below their values so long IDs retain room. */
  .dev-table td:nth-child(5) { grid-column: 1; grid-row: auto; align-self: auto; }
  .dev-table:not(.dir-table) td:nth-child(5) { margin-top: 12px; }
  .dev-table .acts { flex-direction: row; justify-content: flex-start; gap: 8px; }

  /* Blocked-device actions sit below their details without an extra label. */
  .blocked-table td:nth-child(4) {
    grid-column: 1;
    grid-row: auto;
    align-self: auto;
    margin-top: 12px;
    display: block;
    font-size: inherit;
  }
  .blocked-table td:nth-child(4)::before { content: none; }
  .blocked-table .acts { align-items: center; }

  /* The directory is the same table with more columns than the rules above were
     written for, so the labelled-row treatment — which is handed out by position
     — puts the wrong cell in the action column. It is undone here and re-issued
     by attribute: a cell with a label is a labelled row wherever it sits. */
  .dev-table.dir-table td {
    grid-column: 1;
    grid-row: auto;
    align-self: auto;
  }
  .dev-table.dir-table td[data-label] {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    column-gap: 10px;
    align-items: center;
    font-size: 12px;
    white-space: normal;
  }
  /* Everything a cell holds belongs in the value's column. A balance is the one
     cell with a second line — "as of 43 minutes ago" — and left to the grid's
     own placement that line lands under the label instead, wrapping itself
     inside the narrow column it was never meant to be in. It qualifies the
     number, so it sits under the number. */
  .dev-table.dir-table td[data-label] > * { grid-column: 2; min-width: 0; overflow-wrap: anywhere; }
  /* The labels are the ones above, spelled again because the selector that
     carries them is a positional one that cannot be shared with these. The
     label names the whole cell rather than its first line, so the box is
     stretched down the cell — and it is one word on one line by construction: a
     label that wrapped inside this column would take the value down with it.
     The word itself sits on the value's line rather than in the middle of the
     cell: a balance carries a second line, and a label centred across both
     lines reads as a caption for the note instead of for the number. */
  .dev-table.dir-table td[data-label]::before {
    content: attr(data-label);
    display: flex;
    align-items: flex-start;
    align-self: stretch;
    grid-column: 1;
    grid-row: 1 / span 4;
    line-height: 18px;
    white-space: nowrap;
    padding-right: 10px;
    border-right: 1px solid var(--hairline);
    font-family: var(--display);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted-2);
  }
  /* The directory's actions run under the whole card rather than down its right
     edge: the row is seven labelled lines tall here, and a column of icons
     spanning that is a lot of empty space to aim across. Full width, so the
     target is the thing under the thumb rather than the thing beside it. */
  .dev-table.dir-table td:last-child { grid-column: 1 / -1; margin-top: 10px; }
  .dev-table.dir-table .acts { flex-direction: row; justify-content: flex-start; }
  .dev-table.dir-table .acts > .btn { width: auto; flex: 1 1 calc(50% - 4px); }
  .dev-table.dir-table tr[data-row] {
    padding: 14px;
    margin-bottom: 12px;
    background: var(--raise);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-sm);
    gap: 8px;
  }
  .bal-pending { white-space: normal; }

  /* Targets sized for a thumb rather than a pointer. The icons were 30px, which
     a mouse hits comfortably and a thumb does not. */
  .ico { width: 44px; height: 44px; min-width: 44px; }

  /* Full-width controls: a pill at half width on a 360px screen is a target the
     thumb has to aim at. */
  .card-head { align-items: stretch; }
  .card-head .btn { width: 100%; }

  .tools { flex-direction: column; align-items: stretch; }
  .search { flex: none; }
  /* Flex with a grow, not four fixed columns: "Expiring" at 12px does not fit a
     quarter of a 320px screen, and a grid would either clip it or push it out
     of the card. This way the row wraps when it has to and fills the width when
     it does not. */
  .chip { flex: 1 1 auto; padding: 8px 10px; text-align: center; }

  .gate { flex-direction: column; align-items: stretch; gap: 14px; }
  .gate-form { justify-content: space-between; }

  /* The connection block puts the label above the value at every width now, so
     there is nothing to restack here. The key still breaks anywhere rather than
     running out of the box — see `.cred-box code`. */
  .cred-box code { font-size: 11.5px; }
  .app-rename { flex-direction: column; align-items: stretch; }
  .app-rename label { flex: 1 1 auto; }

  .js .sheet {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    bottom: auto;
    border-left: 0;
    padding: max(20px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    scroll-padding-block: 20px;
    -webkit-overflow-scrolling: touch;
  }
  .sheet-head { position: sticky; top: 0; z-index: 1; padding-block: 8px; background: var(--glass-strong); }
  .sheet-head h2 { min-width: 0; overflow-wrap: anywhere; }
  .sheet-head .ico { flex: none; }
  .signin-alt a { display: inline-flex; align-items: center; min-height: 44px; padding: 8px; }
}

@media (max-width: 560px) {
  .wrap { padding-block: 12px 36px; }

  /* Keep all navigation labels visible in their original order on phones. */
  .topbar {
    top: max(8px, env(safe-area-inset-top));
    padding: 0;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 0;
  }
  .brand { padding: 12px 14px; }
  .topnav { gap: 0; }
  .topnav a { min-height: 62px; padding: 10px 3px; }
  .topnav a svg { display: block; }
  .brand { display: none; }
  .brand-sub { display: none; }

  .card { padding: 16px; margin-bottom: 14px; }
  .card-table { padding: 16px; }

  .stats { gap: 14px; }
  .stat b { font-size: 25px; }
  .dev-table td[data-label="Balance"] {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    column-gap: 10px;
    row-gap: 0;
  }
  .dev-table td[data-label="Balance"]::before {
    flex: none;
  }
  .dev-table td[data-label="Balance"] .bal {
    font-size: 14px;
  }
  .dev-table td[data-label="Balance"] .bal-when,
  .dev-table td[data-label="Balance"] .bal-pending {
    margin-top: 0;
    margin-left: auto;
    text-align: right;
  }

  .is-signin .wrap { min-height: 100svh; padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
  .signin-card { padding: 24px 20px; border-radius: 18px; }
  .signin-logo { width: 64px; height: 64px; }
  .signin-title { font-size: 22px; }
}

@media (max-width: 860px) and (max-height: 500px) {
  .topbar { position: relative; top: 0; }
}
