/* SMS allocation — a small internal tool, so: dense tables, obvious actions,
   no decoration that does not carry information. */

:root {
  color-scheme: light dark;

  --ink: #111827;
  --ink-2: #374151;
  --ink-3: #6b7280;
  --line: #e5e7eb;
  --line-2: #d1d5db;
  --bg: #f9fafb;
  --card: #ffffff;
  --accent: #1d4ed8;
  --accent-soft: #eff6ff;
  --good: #047857;
  --good-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #b91c1c;
  --bad-soft: #fef2f2;
  --radius: 8px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 10%);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f3f4f6;
    --ink-2: #d1d5db;
    --ink-3: #9ca3af;
    --line: #1f2937;
    --line-2: #374151;
    --bg: #0b1220;
    --card: #111827;
    --accent: #93b4fd;
    --accent-soft: #172554;
    --good: #6ee7b7;
    --good-soft: #052e26;
    --warn: #fcd34d;
    --warn-soft: #3b2c06;
    --bad: #fca5a5;
    --bad-soft: #3f1414;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  }
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute has to actually hide things.
   Any author rule that sets `display` beats the user-agent's
   `[hidden] { display: none }`, and this sheet sets it on `button`
   (inline-flex) and `.badge` (inline-block) — so `el.hidden = true` on a
   button or a badge did nothing at all. That is why the review-queue and
   registry count badges used to sit in the tab bar as empty pills, and why
   `.brand .env[hidden]` needed a rule of its own. One declaration here
   instead of one per component. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* --- shell --------------------------------------------------------------- */

header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 10px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-right: auto;
}

.brand strong {
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand span {
  color: var(--ink-3);
  font-size: 12px;
}

nav.tabs {
  display: flex;
  gap: 2px;
  padding: 4px 20px 0;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

nav.tabs button {
  position: relative;
  padding: 8px 14px 10px;
  border: 0;
  border-radius: 6px 6px 0 0;
  background: none;
  color: var(--ink-3);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

nav.tabs button:hover {
  color: var(--ink);
  background: var(--bg);
}

nav.tabs button[aria-selected="true"] {
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

nav.tabs .badge {
  margin-left: 6px;
}

main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 20px;
}

section.panel[hidden] {
  display: none !important;
}

/* --- primitives ---------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.card > h2,
.card > h3 {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.card .body {
  padding: 16px;
}

.card .body.tight {
  padding: 0;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.row.end {
  justify-content: flex-end;
}

.grow {
  flex: 1 1 auto;
}

.muted {
  color: var(--ink-3);
}

.small {
  font-size: 12px;
}

.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

button,
.btn {
  padding: 7px 13px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

button:hover:not(:disabled),
.btn:hover {
  border-color: var(--ink-3);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary,
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  button.primary,
  .btn.primary {
    color: #0b1220;
  }
}

button.danger {
  color: var(--bad);
  border-color: var(--line-2);
}

button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

button.tiny {
  padding: 3px 8px;
  font-size: 12px;
}

input,
select,
textarea {
  padding: 7px 9px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  max-width: 100%;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
}

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

.scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 7px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--card);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
  z-index: 1;
}

tbody tr:hover {
  background: var(--bg);
}

tfoot td {
  font-weight: 600;
  border-top: 2px solid var(--line-2);
  border-bottom: 0;
  background: var(--bg);
}

tr.flag {
  background: var(--warn-soft);
}

tr.flag:hover {
  background: var(--warn-soft);
}

td.wrap {
  white-space: normal;
  max-width: 520px;
}

/* --- bars ---------------------------------------------------------------- */

.bar {
  height: 6px;
  min-width: 2px;
  border-radius: 3px;
  background: var(--accent);
}

.bar.warn {
  background: var(--warn);
}

.barcell {
  width: 130px;
  padding-top: 12px;
}

/* --- stats --------------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
}

.stat {
  padding: 14px 16px;
  background: var(--card);
}

.stat .k {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.stat .v {
  margin-top: 3px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat .n {
  font-size: 12px;
  color: var(--ink-3);
}

.stat.good .v {
  color: var(--good);
}

.stat.warn .v {
  color: var(--warn);
}

/* --- badges and notices -------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--line);
  color: var(--ink-2);
}

.badge.good {
  background: var(--good-soft);
  color: var(--good);
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.badge.info {
  background: var(--accent-soft);
  color: var(--accent);
}

.notice {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-3);
  border-radius: 6px;
  background: var(--card);
  margin-bottom: 12px;
  font-size: 13px;
}

.notice.good {
  border-left-color: var(--good);
  background: var(--good-soft);
}

.notice.warn {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.notice.bad {
  border-left-color: var(--bad);
  background: var(--bad-soft);
}

.notice strong {
  display: block;
  margin-bottom: 2px;
}

.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--ink-3);
}

/* --- review queue -------------------------------------------------------- */

.queue-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.queue-item:last-child {
  border-bottom: 0;
}

.queue-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.queue-key {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}

.queue-samples {
  margin: 8px 0 10px;
  padding-left: 12px;
  border-left: 2px solid var(--line-2);
  color: var(--ink-3);
  font-size: 12.5px;
}

.queue-samples div {
  margin: 2px 0;
  overflow-wrap: anywhere;
}

.queue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

/* --- upload dropzone ----------------------------------------------------- */

.drop {
  padding: 28px 20px;
  border: 2px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--bg);
  text-align: center;
  cursor: pointer;
}

.drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop strong {
  display: block;
  margin-bottom: 4px;
}

/* --- toasts -------------------------------------------------------------- */

#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(460px, calc(100vw - 32px));
}

.toast {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: rise 0.16s ease-out;
}

.toast.good {
  border-left-color: var(--good);
}

.toast.bad {
  border-left-color: var(--bad);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }
}

/* --- misc ---------------------------------------------------------------- */

details.help {
  margin-bottom: 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 13px;
}

details.help summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-2);
}

details.help p {
  margin: 8px 0;
  color: var(--ink-2);
  max-width: 78ch;
}

details.help code {
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--bg);
}

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Environment label in the header. Absent in production, loud everywhere else,
   because dev and production are the same UI over different client data. */
.brand .env,
.auth-brand .env {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--ink-3, #6b7280);
  color: #fff;
}

.brand .env.env-dev,
.auth-brand .env.env-dev {
  background: #b45309;
}

/* The [hidden] special case that used to live here is now a single global
   rule near the top of this file, which covers every component. */

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

/* The login page has no header, tabs or tables — it is one card on the page
   background, centred, at a width that keeps the explanatory copy readable
   rather than stretching it across a monitor. */

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-shell {
  width: 100%;
  max-width: 420px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-left: 2px;
}

.auth-brand strong {
  font-size: 16px;
  letter-spacing: -0.01em;
}

.auth-mark {
  display: flex;
  flex: 0 0 auto;
}

.auth-card {
  margin: 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form[hidden] {
  display: none;
}

.auth-form h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-form .auth-sub {
  margin: -8px 0 2px;
}

.auth-form label.field {
  gap: 5px;
}

/* Inputs are taller here than in the dense tables: this is the one screen
   where someone is typing carefully rather than scanning. */
.auth-form input:not([type='checkbox']) {
  padding: 9px 11px;
  font-size: 14px;
}

.auth-row {
  margin: -4px 0 0;
}

.checkline {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}

.checkline input {
  margin: 2px 0 0;
  flex: 0 0 auto;
}

.block {
  display: block;
}

.auth-submit {
  margin-top: 2px;
  padding: 10px 14px;
  font-size: 14px;
  justify-content: center;
}

.auth-link {
  align-self: center;
  font-size: 13px;
}

.auth-link-note {
  margin: 0;
  text-align: center;
  max-width: 46ch;
  align-self: center;
}

.auth-foot {
  margin: 14px 0 0;
  text-align: center;
}

/* --- account menu in the app header ------------------------------------- */

.account {
  position: relative;
}

.account-button {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-role {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
}

.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 232px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.account-menu[hidden] {
  display: none;
}

.account-who {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.account-who strong {
  display: block;
  font-size: 13px;
}

.account-menu button {
  width: 100%;
  justify-content: flex-start;
  border: 0;
  background: none;
  padding: 7px 10px;
}

.account-menu button:hover:not(:disabled) {
  background: var(--bg);
}

/* --- users, in Settings -------------------------------------------------- */

/* A temporary password is shown exactly once and cannot be recovered, so it
   gets a box of its own rather than a toast that can scroll away. */
.credential {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--warn-soft);
}

.credential code {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--card);
  border: 1px solid var(--line-2);
  user-select: all;
}

.you {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--good-soft);
  color: var(--good);
  margin-left: 6px;
}

/* Read-only banner for a viewer, so the missing buttons are explained rather
   than looking like a bug. */
.readonly-note {
  margin-bottom: 14px;
}
