/* KyrosNext panel — design system
   Tokens first, then base, shell, components, pages. Add new screens by composing
   existing components (table, form.stack, .badge, .tabs, .chip, .fold, .stats).
   Radius roles: --r-ctl controls, --r-box containers, --r-pill tags/avatars. */

/* Fonts are self-hosted (Latin + Greek subsets, SIL OFL — see static/fonts/OFL-*.txt). */
@font-face {
  font-family: Commissioner;
  src: url("/static/fonts/commissioner.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* colour */
  --ink: #0e1420;
  --ink-2: #374151;
  --muted: #667085;
  --line: #e3e6ec;
  --line-strong: #cdd2dc;
  --paper: #f4f5f8;
  --card: #ffffff;
  --sunk: #eceff4;
  --ping: #c8f03c;
  --ping-deep: #b6e022;
  --ping-soft: #f3fbd2;
  --info: #2447d6;
  --ok: #0f7a4f;
  --ok-bg: #e4f6ec;
  --warn: #9a5b07;
  --warn-bg: #fff3d9;
  --bad: #b42318;
  --bad-bg: #fdeceb;
  --ink-3: #8a92a3;
  --faint: #98a2b3;
  --field: #ffffff;
  --head: #fafbfc;
  --hover: #fafbfd;
  --info-bg: #e9eefe;
  --warn-line: #efd9a0;
  --warn-ink: #5b4108;
  --bad-line: #f4c7c3;
  --solid: #0e1420;
  --solid-line: #3a4456;
  --on-solid: #ffffff;
  --on-solid-2: #aab2c0;
  --on-ping: #0e1420;
  --focus: rgba(200, 240, 60, 0.55);
  /* shape */
  --r-ctl: 8px;
  --r-box: 12px;
  --r-pill: 999px;
  /* type */
  --font: Commissioner, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --rail: 248px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--font);
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--info); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }

/* ---------- type scale: 12.5 / 14 / 15 / 18 / 22 / 28 ---------- */
h1 { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 6px; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 650; letter-spacing: -0.015em; margin: 30px 0 10px; }
h3 { font-size: 15px; font-weight: 650; margin: 22px 0 8px; }
main > h1 + p.muted { margin-top: 0; margin-bottom: 20px; }

/* ---------- shell ---------- */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 12px 12px;
  background: var(--card);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; text-decoration: none; color: var(--ink); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; font-weight: 750; letter-spacing: -0.02em; }
.brand-text span { font-size: 12.5px; color: var(--muted); }
.mark rect { fill: var(--solid); }
.mark path { fill: var(--ping); }
.mark, .mark-img { display: block; height: 30px; width: auto; border-radius: 9px; }
.nav-group { margin-bottom: 6px; }
.nav-title { margin: 14px 10px 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-ctl);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
}
.nav-link .ico { flex: none; color: var(--muted); }
.nav-link:hover { background: var(--paper); color: var(--ink); }
.nav-link.on { background: var(--solid); color: var(--on-solid); }
.nav-link.on .ico { color: var(--ping); }
.rail-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.who { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--ping);
  color: var(--on-ping);
  font-weight: 750;
}
.who-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.who-text strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.who-text span { font-size: 12.5px; color: var(--muted); }
.rail-foot form { margin: 0; }
button.ghost {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  color: var(--ink-2);
  border: 0;
  font-weight: 500;
  padding: 8px 10px;
}
button.ghost:hover { background: var(--paper); color: var(--ink); }
button.ghost .ico { color: var(--muted); }

.stage { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  padding: 0 32px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.spacer { flex: 1; }
.menu-btn, .topbar-brand, .scrim { display: none; }
@media (min-width: 901px) { .topbar.quiet { display: none; } }
.balance {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
}
.balance span { font-size: 12.5px; color: var(--muted); }
.balance strong { font-weight: 700; }
.balance:hover { border-color: var(--ink); }
.cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-ctl);
  background: var(--ping);
  color: var(--on-ping);
  font-weight: 650;
  text-decoration: none;
}
.cta:hover { background: var(--ping-deep); color: var(--on-ping); }
.viewing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 32px;
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-line);
  color: var(--warn-ink);
}
.viewing form { margin: 0; }
.viewing button { background: var(--card); border-color: var(--warn-line); padding: 6px 12px; }

main { width: 100%; max-width: 1240px; margin: 0 auto; padding: 30px 32px 56px; flex: 1; }

/* A long form keeps its Save button in view: the bar sticks to the bottom of the window while the form is on screen. */
.savebar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 20px; padding: 12px 0; background: var(--card); border-top: 1px solid var(--line-strong); }
.savebar .muted { margin: 0; font-size: 14px; }
footer { padding: 8px 32px 28px; font-size: 13px; text-align: center; }

/* ---------- boxes: one border, no shadow ---------- */
main table,
main form.stack,
main section,
main ul,
.fold,
.sender-card,
.stats div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-box);
}
.error {
  margin: 12px 0;
  padding: 10px 14px;
  border: 1px solid var(--bad-line);
  border-left: 4px solid var(--bad);
  border-radius: var(--r-ctl);
  background: var(--bad-bg);
  color: var(--bad);
  font-weight: 600;
}

/* ---------- tables ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden; margin: 14px 0 22px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
th { font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--head); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }
td a { font-weight: 550; }
table input, table select { width: 130px; max-width: none; padding: 8px 10px; }
table form, td form, th form { display: inline-flex; gap: 8px; align-items: center; margin: 0 6px 0 0; }
.nowrap { white-space: nowrap; }
/* the start of a message text in a list; the whole text is in the title (mouse) and on the report page */
td.preview { max-width: 16em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted, inherit); }
td form.close-as { flex-wrap: wrap; max-width: 250px; }
.close-failed { display: inline-flex; gap: 8px; align-items: center; }
table button { background: var(--ping-soft); color: var(--ink); border-color: color-mix(in srgb, var(--ping) 55%, var(--card)); border-width: 1px; border-style: solid; padding: 7px 12px; font-weight: 600; }
table button:hover { background: color-mix(in srgb, var(--ping) 20%, var(--card)); border-color: var(--ping); }
/* a link that does what a row button does (Edit): the same look as the buttons of the table, so a row does not mix text and buttons */
a.row-action { display: inline-block; margin: 0 6px 0 0; padding: 7px 12px; border: 1px solid color-mix(in srgb, var(--ping) 55%, var(--card)); border-radius: var(--r-ctl); background: var(--ping-soft); color: var(--ink); font-weight: 600; text-decoration: none; }
a.row-action:hover { background: color-mix(in srgb, var(--ping) 20%, var(--card)); border-color: var(--ping); color: var(--ink); }

/* ---------- forms ---------- */
input, textarea, select {
  width: 100%;
  max-width: 480px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--focus);
}
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; max-width: none; padding: 0; accent-color: var(--ink); box-shadow: none; }
input[type="file"] { padding: 8px; background: var(--paper); border-style: dashed; }
input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 6px 12px;
  border: 1px solid color-mix(in srgb, var(--ping) 55%, var(--card));
  border-radius: var(--r-ctl);
  background: var(--ping-soft);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
form.stack { padding: 24px; max-width: 700px; margin: 12px 0 20px; }
form.stack label { display: block; margin: 16px 0 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
form.stack > label:first-child { margin-top: 0; }
form.stack label:has(input[type="checkbox"]),
form.stack label:has(input[type="radio"]) { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
main > form:not(.stack) {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-box);
}
main > form:not(.stack) input:not([type="checkbox"]):not([type="radio"]),
main > form:not(.stack) select,
main > form:not(.stack) textarea { width: auto; flex: 1 1 160px; min-width: 140px; max-width: none; }
main > form:not(.stack) label { display: inline-flex; align-items: center; gap: 8px; margin-right: 10px; }
.field-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.field-row input { flex: 1; max-width: 420px; }

/* ---------- buttons: ping is the primary action; everything else is quiet ---------- */
button {
  padding: 9px 16px;
  border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
  border-radius: var(--r-ctl);
  background: var(--ping);
  color: var(--on-ping);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .06s;
}
button:hover { background: var(--ping-deep); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
button[type="button"],
button.remove-field,
form[action$="/delete"] button {
  background: var(--ping-soft); color: var(--ink); border-color: color-mix(in srgb, var(--ping) 55%, var(--card));
}
button[type="button"]:hover,
button.remove-field:hover { background: color-mix(in srgb, var(--ping) 20%, var(--card)); border-color: var(--ping); }
form[action$="/delete"] button,
button.quiet { background: var(--card); color: var(--bad); border-color: var(--bad-line); }
form[action$="/delete"] button:hover,
button.quiet:hover { background: var(--bad-bg); border-color: var(--bad); }

/* ---------- panels, tabs, chips ---------- */
#live, .quote {
  margin: 14px 0;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ping-deep);
  border-radius: var(--r-ctl);
  font-weight: 600;
}
.tabs { display: inline-flex; gap: 2px; margin: 8px 0 18px; padding: 3px; background: var(--sunk); border-radius: 10px; flex-wrap: wrap; }
.tabs a { padding: 6px 14px; border-radius: 7px; color: var(--ink-2); font-weight: 600; text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { background: var(--card); color: var(--ink); border: 0; box-shadow: 0 0 0 1px var(--line-strong); }
#fields[hidden], #groups[hidden] { display: none !important; }
.group-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.group-list a, .group-list span, .group-list button {
  width: auto;
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
}
.group-list a.on { background: var(--solid); border-color: var(--solid); color: var(--on-solid); }
.field-list { display: flex; flex-wrap: wrap; gap: 6px; }
.field-list button, button.token {
  width: auto;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--card);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
}
.placeholders { display: flex; flex-wrap: wrap; gap: 6px; }
.member-list { max-height: 320px; overflow: auto; padding: 8px; background: var(--field); border: 1px solid var(--line); border-radius: var(--r-ctl); }
table.controls td:last-child { min-width: 250px; }
table.controls input, table.controls select { width: 190px; }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin: 14px 0 26px; }
a.pcard { display: block; padding: 14px 16px; border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--r-box); background: var(--card); color: var(--ink); text-decoration: none; }
a.pcard:hover { border-color: var(--ink-2); }
a.pcard.problem { border-left-color: var(--bad); background: var(--bad-bg); }
a.pcard.working { border-left-color: var(--ok); }
a.pcard.paused, a.pcard.changing { border-left-color: var(--warn); }
a.pcard.disabled, a.pcard.unknown { border-left-color: var(--line-strong); }
a.pcard h3 { margin: 0 0 6px; font-size: 15px; }
a.pcard .reason { margin: 8px 0 0; font-size: 13.5px; color: var(--ink-2); }
a.pcard .warn { margin: 6px 0 0; font-size: 13.5px; font-weight: 650; color: var(--warn); }
a.pcard.problem .warn { color: var(--bad); }
a.pcard .meta { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 6px; background: var(--sunk); color: var(--ink-2); font-size: 13.5px; font-weight: 550; }
.chosen button, button.chip { width: auto; padding: 3px 10px; border: 0; border-radius: 6px; background: var(--ping-soft); color: var(--ink); font-size: 13.5px; font-weight: 600; }
.hits { margin-top: 8px; padding: 4px 12px; background: var(--field); border: 1px solid var(--line); border-radius: var(--r-ctl); }
.hits label { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
#hits { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#hits:empty { display: none; }
#country-hits { margin-top: 8px; }
#country-hits form { display: inline; }
code { padding: 2px 6px; border-radius: 5px; background: var(--sunk); color: var(--ink-2); font-family: var(--mono); font-size: 12.5px; }
pre.log { max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
pre { margin: 10px 0 18px; padding: 12px 14px; overflow-x: auto; border-radius: var(--r-box); background: var(--sunk); color: var(--ink-2); font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }

/* status badges: dot + sentence case */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 600; background: var(--sunk); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.pending { background: var(--info-bg); color: var(--info); }
.badge.blocked { background: var(--bad-bg); color: var(--bad); }
.badge.expired { background: var(--warn-bg); color: var(--warn); }
.badge.payment { background: var(--sunk); color: var(--ink-2); }

/* ---------- sections, folds, lists ---------- */
main section { padding: 8px 20px 18px; margin: 12px 0; }
main ul { padding: 14px 20px 14px 38px; }
.fold { margin: 8px 0; }
button.fold-toggle {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: var(--r-box);
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 650;
}
button.fold-toggle:hover { background: var(--head); }
.fold-body { padding: 0 16px 16px; }
.fold-meta { color: var(--muted); font-weight: 500; font-size: 13.5px; }
.sender-card { padding: 16px 18px; margin: 10px 0; }
.sender-line { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.sender-line h2 { margin: 0 0 4px; }
.sender-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sender-actions form { margin: 0; }
.panel { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.edit-grid label { display: block; margin: 0 0 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.edit-grid input, .edit-grid select, .edit-grid textarea { width: 100%; max-width: none; }
.edit-grid .wide { grid-column: 1 / -1; }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 16px 0 8px; padding: 0; border: 0; background: transparent; }
.stats div { padding: 16px 18px; }
.stats span { display: block; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.stats strong { display: block; margin-top: 4px; font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.balance-card { padding: 22px 24px; background: var(--solid); color: var(--on-solid); border-radius: var(--r-box); }
.balance-card .label { color: var(--on-solid-2); font-size: 13.5px; }
.balance-card .amount { display: block; margin: 4px 0 18px; font-size: 40px; line-height: 1.1; font-weight: 750; letter-spacing: -0.035em; }
.balance-card .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.balance-card a.btn-ping { background: var(--ping); color: var(--on-ping); }
.balance-card a.btn-line { background: transparent; color: var(--on-solid); border: 1px solid var(--solid-line); }
.btn-ping, .btn-line { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--r-ctl); font-weight: 650; text-decoration: none; }
.btn-ping:hover { background: var(--ping-deep); color: var(--on-ping); }
.btn-line:hover { border-color: var(--on-solid); color: var(--on-solid); }
.quick { display: grid; gap: 8px; }
.quick a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-box);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.quick a:hover { border-color: var(--ink); }
.quick .ico { color: var(--muted); }
.quick small { display: block; color: var(--muted); font-size: 13px; font-weight: 450; }

/* ---------- composer (Send) ---------- */
.send-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; max-width: 1060px; }
.send-layout form.stack { max-width: none; }
.send-layout form.stack input:not([type="checkbox"]), .send-layout form.stack select, .send-layout form.stack textarea { max-width: none; }
#body { min-height: 168px; max-width: none; font-family: var(--mono); font-size: 14px; line-height: 1.65; resize: vertical; }
.meter { height: 6px; margin: 8px 0 2px; border-radius: var(--r-pill); background: var(--sunk); overflow: hidden; }
.meter i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--ink); transition: width .12s; }
.meter.multi i { background: var(--info); }
.meter-text { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
/* phone preview: an iPhone-style Messages screen. Device colours are literal on purpose, they imitate the OS. */
.handset-wrap { position: sticky; top: 84px; align-self: start; }   /* the phone and the line under it stay together while the page scrolls */
.handset { position: relative; width: 292px; padding: 10px; background: #14161b; border-radius: 46px; box-shadow: inset 0 0 0 2px #2a2e37; }
.handset-island { position: absolute; z-index: 2; top: 20px; left: 50%; width: 86px; height: 24px; margin-left: -43px; border-radius: 14px; background: #000; }
.handset-screen { position: relative; display: flex; flex-direction: column; min-height: 540px; overflow: hidden; background: #fff; border-radius: 37px; color: #000; }
.ios-status { display: flex; align-items: center; justify-content: space-between; padding: 17px 28px 0 30px; font-size: 14.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.ios-icons { display: inline-flex; align-items: center; gap: 5px; }
.ios-icons svg { fill: #000; }
.ios-head { position: relative; display: flex; flex-direction: column; align-items: center; padding: 14px 14px 9px; background: rgba(247, 247, 248, .96); border-bottom: 1px solid #d9d9dd; }
.ios-back { position: absolute; left: 16px; top: 24px; color: #0a84ff; }
.ios-contact { display: flex; flex-direction: column; align-items: center; gap: 3px; max-width: 170px; }
.ios-avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(#a6abb6, #7e8390); color: #fff; font-size: 18px; font-weight: 600; }
.ios-name { display: flex; align-items: baseline; gap: 4px; max-width: 100%; font-size: 11.5px; font-weight: 500; color: #1c1c1e; }
.ios-name > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ios-name i { font-style: normal; font-size: 13px; color: #8e8e93; }
.ios-thread { flex: 1; padding: 14px 12px 20px; }
.ios-stamp { margin-bottom: 12px; text-align: center; font-size: 10.5px; line-height: 1.35; color: #8e8e93; }
.ios-stamp b { font-weight: 600; }
.handset-bubble {
  position: relative;
  max-width: 82%;
  padding: 8px 13px 9px;
  background: #e9e9eb;
  border-radius: 18px;
  color: #000;
  font-size: 15px;
  line-height: 1.3;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.handset-bubble::before { content: ""; position: absolute; left: -5px; bottom: 0; width: 16px; height: 16px; background: #e9e9eb; border-bottom-right-radius: 14px; }
.handset-bubble::after { content: ""; position: absolute; left: -9px; bottom: 0; width: 9px; height: 16px; background: #fff; border-bottom-right-radius: 10px; }
.handset-meta { margin: 12px 4px 0; color: var(--muted); font-size: 13px; font-weight: 550; }

/* ---------- login & public pages ---------- */
.bare-wrap { max-width: 560px; margin: 0 auto; padding: 8vh 20px 24px; }
.bare-brand { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 28px; color: var(--ink); text-decoration: none; font-size: 18px; letter-spacing: -0.02em; }
.bare-main { padding: 0; max-width: none; }
.docs-wrap { max-width: 860px; }
.docs-wrap table th, .docs-wrap table td { vertical-align: top; }
.login-wrap { max-width: 420px; }
.login-wrap h1 { margin-bottom: 4px; }
.login-wrap form.stack { max-width: none; margin-top: 18px; }
.login-wrap button { width: 100%; padding: 11px 16px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .home-grid { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .send-layout { grid-template-columns: 1fr; }
  .handset-wrap { position: static; }
  .handset { margin: 0 auto; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 280px; transform: translateX(-102%); transition: transform .2s ease; }
  .nav-toggle:checked ~ .shell .rail { transform: none; }
  .nav-toggle:checked ~ .shell .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(14, 20, 32, 0.45); }
  .menu-btn { display: inline-flex; align-items: center; padding: 8px; border-radius: var(--r-ctl); cursor: pointer; }
  .topbar-brand { display: inline-flex; align-items: center; gap: 8px; }
  .topbar-brand .mark, .topbar-brand .mark-img { height: 26px; }
  .topbar { padding: 0 14px; }
  .balance span { display: none; }
  main { padding: 22px 14px 44px; }
  .viewing { padding: 10px 14px; }
  h1 { font-size: 24px; }
  main table { display: block; overflow-x: auto; }
  .edit-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .cta span { display: none; }
  .topbar-brand strong { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* pager: row count on the left, Newer / Older on the right */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3, 16px); margin: 12px 0; font-size: 13.5px; color: var(--ink-2); }
.pager-links { display: inline-flex; align-items: center; gap: 14px; }
.pager-links a { font-weight: 600; }
.pager-links .off { color: var(--ink-3); }
.pager-pos { font-variant-numeric: tabular-nums; }

/* search/filter forms (GET) stay quiet so the lime button is reserved for the page's main action */
main > form[method="get"] button { background: var(--ping-soft); color: var(--ink); border-color: color-mix(in srgb, var(--ping) 55%, var(--card)); border-width: 1px; border-style: solid; font-weight: 600; }
main > form[method="get"] button:hover { background: color-mix(in srgb, var(--ping) 20%, var(--card)); border-color: var(--ping); }

/* one-time message after a save: green when saved, red (and kept) when refused */
.flash { margin: 0 0 16px; padding: 11px 16px; border-radius: var(--r-md, 12px); font-weight: 600; font-size: 14.5px; background: var(--ok-bg); color: var(--ok); animation: flash-in .18s ease-out; }
.flash.error { background: var(--bad-bg); color: var(--bad); }
/* on a long page the message stays in view, and the page keeps the place where the person was */
.flash.toast { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 20; max-width: min(92vw, 640px); margin: 0; box-shadow: 0 6px 24px rgba(0,0,0,.25); cursor: pointer; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; } }

/* a labelled multi-field form placed directly in <main> keeps its grid (beats the inline-row rule) */
main > form.edit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-items: end; }
main > form.edit-grid .wide { grid-column: 1 / -1; }
main > form.edit-grid > div { display: block; }
main > form.edit-grid label { display: block; margin-bottom: 6px; }

/* inline rename in a table row: a quiet summary link that opens a one-field form */
details.rename { display: inline-block; vertical-align: middle; margin-right: 6px; }
details.rename summary { cursor: pointer; font-weight: 600; color: var(--info); list-style: none; padding: 7px 4px; }
details.rename summary::-webkit-details-marker { display: none; }
details.rename[open] form { display: flex; gap: 6px; margin-top: 6px; }
details.rename input { width: 150px; }

/* Sender field lock (static/sender-lock.js): a short note when a character is refused. */
.sender-hint { display: block; margin-top: 4px; color: var(--warn); font-size: 13px; }
.sender-hint[hidden] { display: none; }

/* A file box with its own button and texts (file-pick.js): the native box stays in the form but is not shown. */
.file-pick { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-pick .file-native { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }

/* one-line add form: fields side by side, the button at the end */
main > form.edit-grid.row-form.row-form { grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) minmax(220px, 2fr) auto; }
@media (max-width: 860px) { main > form.edit-grid.row-form { grid-template-columns: 1fr; } }
button.secondary { background: var(--ping-soft); color: var(--ink); border-color: color-mix(in srgb, var(--ping) 55%, var(--card)); }
button.secondary:hover { background: color-mix(in srgb, var(--ping) 20%, var(--card)); border-color: var(--ping); }
main > form.edit-grid.row-form { align-items: end; }
main > form.edit-grid.row-form.row-form input,
main > form.edit-grid.row-form.row-form select { width: 100%; min-width: 0; flex: none; }
main > form.edit-grid.row-form label { margin: 0 0 6px; }
main > form.edit-grid.row-form.row-form label { display: block; margin-right: 0; }

/* a long explanation that is read once: closed by default, one line */
details.help { margin: 8px 0 18px; padding: 10px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-box); }
details.help > summary { cursor: pointer; font-weight: 600; list-style-position: inside; }
details.help > summary .muted { font-weight: 400; }
details.help[open] > summary { margin-bottom: 8px; }

/* discount tiers: one row per tier, the header shares the same columns */
.tiers { margin: 12px 0; padding: 6px 16px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-box); }
.tier-row { display: grid; grid-template-columns: 110px 110px 110px auto; gap: 10px; align-items: center; margin: 8px 0; padding: 0; border: 0; background: none; }
.tier-row input { width: 100%; max-width: none; }
.tier-head { margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.with-unit { display: flex; align-items: center; gap: 6px; }
.tier-row button { justify-self: start; }
.bare-wrap:has(.login-wrap) { max-width: 460px; }

/* Admin -> Appearance */
.theme-row { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.theme-row:last-child { border-bottom: 0; }
.swatches { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.swatches i { display: block; width: 18px; height: 26px; }
.theme-actions { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.theme-actions form { display: inline; margin: 0; padding: 0; border: 0; background: none; }
.btn-line-quiet { padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); color: var(--ink); text-decoration: none; font-weight: 600; background: var(--ping-soft); border-color: color-mix(in srgb, var(--ping) 55%, var(--card)); }
.btn-line-quiet:hover { background: color-mix(in srgb, var(--ping) 20%, var(--card)); border-color: var(--ping); }
.theme-editor { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.2fr); gap: 20px; align-items: start; }
.theme-editor form.stack { margin: 0; max-width: none; }
.colour-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-top: 12px; }
.colour-grid label.colour { display: flex !important; align-items: center; justify-content: space-between; gap: 10px; margin: 0 !important; font-weight: 500; }
.colour-grid input[type="color"] { width: 46px; height: 32px; padding: 2px; border-radius: 6px; cursor: pointer; }
@media (max-width: 900px) { .theme-editor { grid-template-columns: 1fr; } .theme-row { grid-template-columns: auto 1fr; } .theme-actions { grid-column: 1 / -1; justify-content: flex-start; } }

/* a button that cannot be pressed yet (the sign-in button waits for the robot check): one neutral look in every theme.
   Fading the accent with opacity left muddy colour with unreadable text on dark themes. */
button:disabled:not([hidden]) { background: var(--sunk); color: var(--muted); border-color: var(--line); opacity: 1; cursor: not-allowed; transform: none; }
button:disabled:not([hidden]):hover { background: var(--sunk); border-color: var(--line); }
