/* Panel Clínica de mama · design tokens first, then components.
   Spacing is a 4px scale; radii come in four steps; every color has a light and a dark value.
   Glass (blur) only on small or sticky surfaces: blur cost grows with area, so tables use solid surfaces. */

:root {
  color-scheme: light;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 24px; --radius-full: 999px;
  --control: 40px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Brand, from the ribbon logo */
  --brand-teal: #137f9e; --brand-coral: #f36b72; --brand-green: #8dd03e; --brand-yellow: #fdd520;

  --bg: #f2f5f6;
  --blob-1: rgba(19, 127, 158, .13); --blob-2: rgba(243, 107, 114, .10); --blob-3: rgba(141, 208, 62, .09);
  --surface: rgba(255, 255, 255, .74);
  --surface-strong: rgba(255, 255, 255, .92);
  --surface-solid: #ffffff;
  --surface-inset: rgba(16, 47, 56, .05);
  --hover: rgba(16, 47, 56, .045);
  --border: rgba(16, 47, 56, .09);
  --border-strong: rgba(16, 47, 56, .17);
  --highlight: rgba(255, 255, 255, .85);
  --text: #0f2a32; --text-2: #4b6168; --text-3: #75888e;
  --accent: #137f9e; --accent-hover: #0e6c87; --accent-contrast: #ffffff; --accent-soft: rgba(19, 127, 158, .11);
  --focus-ring: rgba(19, 127, 158, .28);
  --success: #1c7a4b; --success-soft: rgba(28, 122, 75, .10); --success-border: rgba(28, 122, 75, .22);
  --warning: #955700; --warning-soft: rgba(214, 140, 0, .13); --warning-border: rgba(214, 140, 0, .30);
  --danger: #bf3328; --danger-soft: rgba(191, 51, 40, .09); --danger-border: rgba(191, 51, 40, .22);
  --info: #13789a; --info-soft: rgba(19, 127, 158, .10); --info-border: rgba(19, 127, 158, .22);
  --neutral: #55696f; --neutral-soft: rgba(85, 105, 111, .10); --neutral-border: rgba(85, 105, 111, .20);
  --bubble: #fdeced; --bubble-text: #5b2730;
  --shadow-sm: 0 1px 2px rgba(16, 47, 56, .06);
  --shadow-md: 0 1px 2px rgba(16, 47, 56, .04), 0 10px 28px -12px rgba(16, 47, 56, .16);
  --shadow-lg: 0 2px 4px rgba(16, 47, 56, .04), 0 28px 64px -24px rgba(16, 47, 56, .28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a1317;
    --blob-1: rgba(19, 127, 158, .22); --blob-2: rgba(243, 107, 114, .10); --blob-3: rgba(141, 208, 62, .06);
    --surface: rgba(22, 36, 42, .72); --surface-strong: rgba(21, 34, 40, .94); --surface-solid: #15232a;
    --surface-inset: rgba(255, 255, 255, .05); --hover: rgba(255, 255, 255, .045);
    --border: rgba(255, 255, 255, .08); --border-strong: rgba(255, 255, 255, .15); --highlight: rgba(255, 255, 255, .07);
    --text: #e8f0f2; --text-2: #a4b6bb; --text-3: #7d9197;
    --accent: #4cc0db; --accent-hover: #74d1e6; --accent-contrast: #052530; --accent-soft: rgba(76, 192, 219, .14);
    --focus-ring: rgba(76, 192, 219, .32);
    --success: #5fd49b; --success-soft: rgba(95, 212, 155, .12); --success-border: rgba(95, 212, 155, .26);
    --warning: #f2b64c; --warning-soft: rgba(242, 182, 76, .12); --warning-border: rgba(242, 182, 76, .28);
    --danger: #ff7d73; --danger-soft: rgba(255, 125, 115, .12); --danger-border: rgba(255, 125, 115, .28);
    --info: #63cbe3; --info-soft: rgba(76, 192, 219, .12); --info-border: rgba(76, 192, 219, .26);
    --neutral: #a4b6bb; --neutral-soft: rgba(164, 182, 187, .10); --neutral-border: rgba(164, 182, 187, .22);
    --bubble: rgba(243, 107, 114, .14); --bubble-text: #ffd9db;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, .25), 0 12px 32px -12px rgba(0, 0, 0, .5);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 32px 72px -24px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1317;
  --blob-1: rgba(19, 127, 158, .22); --blob-2: rgba(243, 107, 114, .10); --blob-3: rgba(141, 208, 62, .06);
  --surface: rgba(22, 36, 42, .72); --surface-strong: rgba(21, 34, 40, .94); --surface-solid: #15232a;
  --surface-inset: rgba(255, 255, 255, .05); --hover: rgba(255, 255, 255, .045);
  --border: rgba(255, 255, 255, .08); --border-strong: rgba(255, 255, 255, .15); --highlight: rgba(255, 255, 255, .07);
  --text: #e8f0f2; --text-2: #a4b6bb; --text-3: #7d9197;
  --accent: #4cc0db; --accent-hover: #74d1e6; --accent-contrast: #052530; --accent-soft: rgba(76, 192, 219, .14);
  --focus-ring: rgba(76, 192, 219, .32);
  --success: #5fd49b; --success-soft: rgba(95, 212, 155, .12); --success-border: rgba(95, 212, 155, .26);
  --warning: #f2b64c; --warning-soft: rgba(242, 182, 76, .12); --warning-border: rgba(242, 182, 76, .28);
  --danger: #ff7d73; --danger-soft: rgba(255, 125, 115, .12); --danger-border: rgba(255, 125, 115, .28);
  --info: #63cbe3; --info-soft: rgba(76, 192, 219, .12); --info-border: rgba(76, 192, 219, .26);
  --neutral: #a4b6bb; --neutral-soft: rgba(164, 182, 187, .10); --neutral-border: rgba(164, 182, 187, .22);
  --bubble: rgba(243, 107, 114, .14); --bubble-text: #ffd9db;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, .25), 0 12px 32px -12px rgba(0, 0, 0, .5);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 32px 72px -24px rgba(0, 0, 0, .6);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 400 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
/* Soft color fields behind the glass, fixed and painted once (no animation, no scroll repaint). */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40rem 28rem at 8% -6%, var(--blob-1), transparent 70%),
    radial-gradient(34rem 26rem at 100% 0%, var(--blob-2), transparent 70%),
    radial-gradient(40rem 30rem at 70% 110%, var(--blob-3), transparent 70%);
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
h1 { margin: 0; font-size: 1.75rem; line-height: 1.15; font-weight: 650; letter-spacing: -.022em; }
h2 { margin: var(--space-10) 0 var(--space-3); font-size: 1.125rem; line-height: 1.3; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
.muted { color: var(--text-2); }
.small { font-size: .8125rem; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
::selection { background: var(--accent-soft); }

/* Glass material: translucent, blurred, with a bright top edge catching the light. */
.glass, .top, .stats > div, .notice, .auth {
  background: var(--surface);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-md);
}

/* ---------- Header ---------- */
.top { position: sticky; top: 0; z-index: 20; border-width: 0 0 1px; border-radius: 0; box-shadow: inset 0 -1px 0 var(--highlight), var(--shadow-sm); }
.top-inner {
  max-width: 1200px; margin: 0 auto; min-height: 64px;
  padding: var(--space-3) max(var(--space-6), env(safe-area-inset-left));
  display: flex; align-items: center; gap: var(--space-4);
}
.brand { display: inline-flex; align-items: center; gap: var(--space-3); color: var(--text); text-decoration: none; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand img { display: block; width: 22px; height: 32px; }
.brand small {
  margin-left: var(--space-1); padding: 2px var(--space-2); border-radius: var(--radius-full);
  background: var(--accent-soft); color: var(--accent); font-size: .6875rem; font-weight: 650; letter-spacing: .02em; vertical-align: 2px;
}
.tabs {
  display: flex; gap: var(--space-1); padding: var(--space-1); margin-left: var(--space-4);
  background: var(--surface-inset); border-radius: var(--radius-md);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 6px var(--space-3); border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-size: .875rem; font-weight: 550; white-space: nowrap;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.tabs a:hover { color: var(--text); background: var(--hover); }
.tabs a[aria-current="page"] { color: var(--text); background: var(--surface-solid); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.icon-button {
  width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); border: 1px solid transparent; box-shadow: none;
}
.icon-button:hover { background: var(--hover); color: var(--text); }
.theme-icon { display: none; line-height: 0; }
:root:not([data-theme]) .theme-auto, :root[data-theme="light"] .theme-light, :root[data-theme="dark"] .theme-dark { display: block; }
.account { display: flex; align-items: center; gap: var(--space-2); }
.avatar {
  width: 32px; height: 32px; border-radius: var(--radius-full); display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-teal), #1797b2); color: #fff; font-size: .8125rem; font-weight: 650;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
.account-name { color: var(--text-2); font-size: .875rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Page ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: var(--space-8) max(var(--space-6), env(safe-area-inset-left)) var(--space-12); }
.page > * { animation: rise .42s var(--ease-out) both; }
.page > :nth-child(2) { animation-delay: 30ms; }
.page > :nth-child(3) { animation-delay: 60ms; }
.page > :nth-child(4) { animation-delay: 90ms; }
.page > :nth-child(n+5) { animation-delay: 120ms; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.heading { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6); }
.heading h1 + p, .heading p.muted { margin-top: var(--space-2); max-width: 64ch; }
.heading > div:first-child { min-width: min(100%, 320px); flex: 1; }
.heading .stats { margin: var(--space-2) 0 0; flex: 1 1 100%; }
.page > h1 + :not(.muted), .page > h2 + .table-wrap { margin-top: var(--space-6); }
.page > h2 + .table-wrap, .page > h2 + form { margin-top: var(--space-3); }
h1 + p.muted, h1 + .muted { margin-top: var(--space-2); margin-bottom: var(--space-6); max-width: 64ch; }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3); margin: 0 0 var(--space-6); }
.stats > div { border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); animation: rise .42s var(--ease-out) both; }
.stats > div:nth-child(2) { animation-delay: 40ms; } .stats > div:nth-child(3) { animation-delay: 80ms; }
.stats > div:nth-child(4) { animation-delay: 120ms; } .stats > div:nth-child(n+5) { animation-delay: 160ms; }
.stats dt { color: var(--text-2); font-size: .8125rem; font-weight: 550; }
.stats dd { margin: var(--space-1) 0 0; font-size: 1.625rem; line-height: 1.2; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow: auto; background: var(--surface-strong); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-3); font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; background: var(--surface-inset); }
tbody tr { transition: background-color .12s; }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
td.actions { display: flex; justify-content: flex-end; gap: var(--space-3); }
td.actions form { margin: 0; }
td a { font-weight: 550; }

/* ---------- Badges: one tone per meaning ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 var(--space-2) 0 7px;
  border-radius: var(--radius-full); font-size: .75rem; font-weight: 600; white-space: nowrap;
  color: var(--tone); background: var(--tone-soft); box-shadow: inset 0 0 0 1px var(--tone-border);
  --tone: var(--neutral); --tone-soft: var(--neutral-soft); --tone-border: var(--neutral-border);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-delivered, .badge-read, .badge-done { --tone: var(--success); --tone-soft: var(--success-soft); --tone-border: var(--success-border); }
.badge-sent, .badge-running, .badge-sending { --tone: var(--info); --tone-soft: var(--info-soft); --tone-border: var(--info-border); }
.badge-paused, .badge-optout, .badge-skipped { --tone: var(--warning); --tone-soft: var(--warning-soft); --tone-border: var(--warning-border); }
.badge-failed { --tone: var(--danger); --tone-soft: var(--danger-soft); --tone-border: var(--danger-border); }
.badge-running::before, .badge-sending::before { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Notices ---------- */
.notice {
  display: flex; align-items: flex-start; gap: var(--space-3); margin: 0 0 var(--space-6);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  border-color: var(--tone-border); background: linear-gradient(var(--tone-soft), var(--tone-soft)), var(--surface);
  --tone: var(--info); --tone-soft: var(--info-soft); --tone-border: var(--info-border);
}
.notice svg { flex-shrink: 0; color: var(--tone); margin-top: 1px; }
.notice p { font-size: .9375rem; }
.notice-ok { --tone: var(--success); --tone-soft: var(--success-soft); --tone-border: var(--success-border); }
.notice-error { --tone: var(--danger); --tone-soft: var(--danger-soft); --tone-border: var(--danger-border); }
.empty {
  padding: var(--space-10) var(--space-6); text-align: center; color: var(--text-2);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface);
}

/* ---------- Buttons ---------- */
button, .button {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control); padding: 0 var(--space-4); border-radius: var(--radius-md);
  border: 1px solid transparent; background: var(--accent); color: var(--accent-contrast);
  font: 600 .875rem/1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 1px 2px rgba(16, 47, 56, .18);
  transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s, transform .1s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
button:hover, .button:hover { background: var(--accent-hover); color: var(--accent-contrast); }
button:active, .button:active { transform: scale(.97); }
button.secondary, .pager a {
  background: var(--surface-solid); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm);
}
button.secondary:hover, .pager a:hover { background: var(--surface-solid); border-color: var(--text-3); color: var(--text); }
button.ghost { background: transparent; color: var(--text-2); box-shadow: none; padding: 0 var(--space-3); min-height: 36px; }
button.ghost:hover { background: var(--hover); color: var(--text); }
button.link {
  min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; color: var(--accent);
  font-weight: 550; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
}
button.link:hover { background: none; color: var(--accent-hover); }
button.link:active { transform: none; }
/* Busy state set by panel.js on submit: a small spinner, the button stays readable. */
button[aria-busy="true"] { cursor: progress; opacity: .85; }
button[aria-busy="true"]::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
label { display: grid; gap: 6px; color: var(--text-2); font-size: .8125rem; font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: var(--control); padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface-solid); color: var(--text); font: 400 .9375rem/1.4 var(--font);
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus-ring); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
select {
  -webkit-appearance: none; appearance: none; padding-right: var(--space-10);
  background-image: url("/static/chevron.svg"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
textarea { resize: vertical; min-height: 96px; }
input[type="file"] { padding: 6px; cursor: pointer; }
input[type="file"]::file-selector-button {
  margin-right: var(--space-3); padding: 6px var(--space-3); border: 0; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent); font: 600 .8125rem var(--font); cursor: pointer;
}
input[type="radio"], input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--accent); }
.stack { display: grid; gap: var(--space-4); }
.form-wide { max-width: 760px; }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; margin: var(--space-4) 0; }
.inline-form label { flex: 1 1 200px; }
fieldset {
  margin: 0; padding: var(--space-4) var(--space-5) var(--space-5); display: grid; gap: var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-strong);
}
fieldset .inline-form { margin: 0; }
legend { padding: 0 var(--space-2); color: var(--text-2); font-size: .8125rem; font-weight: 650; }
.template {
  display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-solid);
  color: var(--text); font-size: .9375rem; font-weight: 400; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.template:hover { border-color: var(--border-strong); }
.template:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.template > input { margin-top: 2px; flex-shrink: 0; }
.template > span { display: grid; gap: var(--space-2); min-width: 0; flex: 1; }
.template select { width: auto; min-height: 36px; margin-left: var(--space-2); display: inline-block; }
.template textarea, .template input[type="file"] { margin-top: var(--space-1); }
.filters label { flex: 1 1 180px; }
.filters button { flex: 0 0 auto; }

/* WhatsApp-like preview of a template */
.bubble {
  display: block; max-width: 560px; padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-6);
  background: var(--bubble); color: var(--bubble-text); border-radius: 16px 16px 16px 4px;
  white-space: pre-line; font-size: .9375rem; line-height: 1.5; box-shadow: var(--shadow-sm);
}
.template .bubble { margin: 0; }

progress {
  -webkit-appearance: none; appearance: none; width: 120px; height: 6px; margin-right: var(--space-2);
  vertical-align: middle; border: 0; border-radius: var(--radius-full); overflow: hidden; background: var(--neutral-soft);
}
progress::-webkit-progress-bar { background: var(--neutral-soft); border-radius: var(--radius-full); }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--accent), var(--brand-green)); border-radius: var(--radius-full); transition: width .4s var(--ease-out); }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--accent), var(--brand-green)); border-radius: var(--radius-full); }

.pager { display: flex; justify-content: space-between; gap: var(--space-3); margin: var(--space-4) 0; }
.pager a { display: inline-flex; align-items: center; min-height: var(--control); padding: 0 var(--space-4); border: 1px solid var(--border-strong); border-radius: var(--radius-md); font-weight: 600; font-size: .875rem; text-decoration: none; }
.danger { margin: var(--space-6) 0; }
.danger summary { cursor: pointer; color: var(--text-2); font-size: .875rem; font-weight: 550; width: fit-content; }
.danger summary:hover { color: var(--danger); }
.danger[open] summary { color: var(--danger); margin-bottom: var(--space-2); }
p.muted.small, p.small { margin-top: var(--space-3); }
.page > .small:first-child { margin-bottom: var(--space-4); }
.page > .small:first-child a { text-decoration: none; font-weight: 550; }

/* ---------- Sign-in ---------- */
.auth {
  max-width: 420px; margin: var(--space-10) auto; padding: var(--space-8);
  border-radius: var(--radius-xl); box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-lg);
  animation: materialize .5s var(--ease-out) both !important;
}
.auth-logo { display: block; width: 180px; height: auto; margin: 0 auto var(--space-6); }
.auth h1 { text-align: center; font-size: 1.5rem; }
.auth > p.muted { text-align: center; margin: var(--space-2) 0 0; }
.auth form { margin-top: var(--space-6); }
.auth button[type="submit"] { width: 100%; min-height: 44px; }
.auth input { min-height: 44px; }
.auth input[name="code"] { text-align: center; font-size: 1.375rem; letter-spacing: .35em; font-variant-numeric: tabular-nums; }
.auth > p.small { text-align: center; }
@keyframes materialize { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* Theme switch: colors cross-fade only during the switch, never on regular renders. */
.theme-switching *, .theme-switching *::before, .theme-switching *::after {
  transition: background-color .3s ease, color .3s ease, border-color .3s ease, box-shadow .3s ease !important;
}

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .top-inner { flex-wrap: wrap; gap: var(--space-2) var(--space-3); padding: var(--space-2) var(--space-4); min-height: 56px; }
  .tabs { order: 3; width: 100%; margin: 0 0 var(--space-1); }
  .account-name { display: none; }
  .page { padding: var(--space-5) var(--space-4) var(--space-10); }
  h1 { font-size: 1.5rem; }
  .heading { flex-direction: column; align-items: stretch; }
  .heading .button { align-self: flex-start; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > div { padding: var(--space-3) var(--space-4); }
  .stats dd { font-size: 1.375rem; }
  th, td { padding: var(--space-3); }
  table { min-width: 640px; }
  td { white-space: nowrap; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .auth { margin: var(--space-6) auto; padding: var(--space-6) var(--space-5); }
}

/* ---------- Accessibility preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  button:active, .button:active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .top, .stats > div, .notice, .auth { background: var(--surface-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --border: rgba(16, 47, 56, .3); --border-strong: rgba(16, 47, 56, .5); }
  .glass, .top, .stats > div, .notice, .auth, .table-wrap { background: var(--surface-solid); }
}

/* The logo's teal lettering is dark; lift it slightly on dark backgrounds. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .auth-logo { filter: brightness(1.3) saturate(1.05); } }
:root[data-theme="dark"] .auth-logo { filter: brightness(1.3) saturate(1.05); }

/* Honeypot: invisible to people and screen readers, filled only by bots. */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
