/* GlobalTransitStats Portal - visual identity.
 *
 * Extends the public GTS site identity (`app/web/style.css`); it does not invent a
 * second look. The palette values below are the same tokens that file declares, and
 * the card / chip / status-cap / uppercase-micro-label / tabular-numeral idioms are
 * the same. The section tab strip is the site's `city-hub-tabs` pattern (single row,
 * horizontal scroll, 2px accent underline on the active tab).
 *
 * Deliberate identity choices (AESTHETICS.md section 3 - must not read as a template):
 *   - asymmetric auth split (narrow editorial rail + form column), not a centred card;
 *   - hairline 1px borders and one 1px shadow: no gradients, no glow, no blobs;
 *   - accent (#0a7ea4, the site's civic teal) used only for the active state, links,
 *     and exactly one primary action per view;
 *   - uppercase 11px micro-labels on every field and section heading;
 *   - tabular numerals for every count, id, date and quantity.
 *
 * Theme note: GTS is a light-theme product (AESTHETICS.md section 2.1 allows light as
 * a per-app opt-in; the public site opted in). The Portal matches the site rather than
 * shipping a dark surface that would not belong to the same product.
 */

:root {
  /* palette: verbatim from app/web/style.css */
  --bg: #f4f6fa;
  --panel: #ffffff;
  --card: #ffffff;
  --line: #d9dee6;
  --text: #1b2330;
  --muted: #5c6776;
  --accent: #0a7ea4;
  --accent-ink: #086786;      /* the site's accent:hover value */
  --ok: #0f7a37;
  --danger: #d23035;
  --warn: #b87514;
  --unknown: #8b97a8;
  /* status-cap pairs, verbatim from the site's .status-cap rules */
  --ok-bg: #dcfce7;   --ok-fg: #0a7a3f;
  --warn-bg: #fef3c7; --warn-fg: #92400e;
  --bad-bg: #fee2e2;  --bad-fg: #b3261e;
  --info-bg: #e6f2f7; --info-fg: #075c78;

  /* type ramp (AESTHETICS 2.2 - components reference the ramp, never a literal) */
  --t-3xl: 26px;
  --t-2xl: 22px;
  --t-xl: 17px;
  --t-lg: 15px;
  --t-md: 13.5px;   /* the site's body-control size */
  --t-sm: 12px;
  --t-xs: 11px;

  /* 4px spacing grid (AESTHETICS 2.3) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;

  --r-sm: 6px; --r-md: 10px; --r-lg: 12px; --r-pill: 999px;
  --shadow-hair: 0 1px 2px rgba(16, 24, 40, 0.04);
  --font-ui: -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --dur: 160ms;
  --col: 1100px;          /* the site's content column width */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-ui);
  font-size: var(--t-md);
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* 2.6: every text surface breaks rather than spills. Set once at the root so a
     400-char unbroken token cannot introduce a horizontal scrollbar anywhere. */
  overflow-wrap: anywhere;
}

/* Nothing in this app may produce a horizontal scrollbar (2.7 hard-fail). */
html, body { max-width: 100%; overflow-x: hidden; }
[hidden] { display: none !important; }

h1, h2, h3, h4 { line-height: 1.18; letter-spacing: -0.2px; font-weight: 700; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ============================================================= chrome === */

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 2000;
  background: var(--accent); color: #fff; padding: var(--s2) var(--s4);
  border-radius: 0 0 var(--r-sm) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: var(--col); margin: 0 auto;
  padding: var(--s3) var(--s4);
  display: flex; align-items: center; gap: var(--s3);
  min-width: 0;
}
.brand { display: flex; align-items: baseline; gap: var(--s2); min-width: 0; }
.brand .pulse {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(10, 126, 164, 0.7);
  animation: pulse 2s infinite;
  align-self: center;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(10, 126, 164, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(10, 126, 164, 0); }
  100% { box-shadow: 0 0 0 0 rgba(10, 126, 164, 0); }
}
@media (prefers-reduced-motion: reduce) { .brand .pulse { animation: none; } }
.brand-name {
  font-size: var(--t-lg); font-weight: 700; letter-spacing: -0.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.brand-sub {
  font-size: var(--t-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.9px; color: var(--muted); flex: none;
}
.topbar-spacer { flex: 1 1 auto; min-width: 0; }

/* Portal shell: one responsive navigation surface shared by every route. */
.portal-header { background: var(--panel); border-bottom: 1px solid var(--line); }
.portal-header-in { max-width: var(--col); margin: 0 auto; padding: var(--s3) var(--s4); display: flex; align-items: center; gap: var(--s4); min-width: 0; }
.portal-brand { display: inline-flex; align-items: center; gap: var(--s2); color: var(--text); font-weight: 700; white-space: nowrap; flex: none; }
.portal-brand:hover { color: var(--accent); text-decoration: none; }
.portal-brand-mark { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
.portal-brand-sub { color: var(--muted); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .8px; }
.portal-nav, .portal-account-nav { display: flex; align-items: center; gap: var(--s1); min-width: 0; }
.portal-nav { flex: 1 1 auto; flex-wrap: wrap; }
.portal-nav::-webkit-scrollbar { display: none; }
.portal-nav a, .portal-account-nav a { color: var(--muted); padding: var(--s2) var(--s3); border-radius: var(--r-sm); white-space: nowrap; font-size: var(--t-sm); }
.portal-nav a:hover, .portal-account-nav a:hover { color: var(--accent); text-decoration: none; background: var(--info-bg); }
.portal-account-primary { border: 1px solid var(--accent); color: var(--accent) !important; font-weight: 600; }
.portal-account-nav { flex-wrap: wrap; }
.portal-account-nav button, .portal-account-nav select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s2) var(--s3); min-height: 40px; max-width: 100%; }
.portal-account-nav button { cursor: pointer; }
.portal-account-nav button:hover { color: var(--accent); background: var(--info-bg); }
.portal-footer { margin-top: auto; }
.portal-footer-in { max-width: var(--col); margin: 0 auto; padding: var(--s3) var(--s4); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); }
#portal-view { outline: none; }
#portal-feedback:empty { display: none; }
#portal-feedback { margin-bottom: var(--s3); }
@media (max-width: 900px) {
  .portal-header-in { flex-wrap: wrap; gap: var(--s2) var(--s3); }
  .portal-nav { order: 3; flex-basis: 100%; }
}
@media (max-width: 560px) {
  .portal-header-in { padding-left: var(--s3); padding-right: var(--s3); }
  .portal-brand-sub { display: none; }
  .portal-account-nav { margin-left: auto; }
  .portal-nav a { padding-left: var(--s2); padding-right: var(--s2); }
}

.whoami {
  display: flex; align-items: center; gap: var(--s2);
  min-width: 0; font-size: var(--t-sm); color: var(--muted);
}
.whoami-email {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 34vw;
}
@media (max-width: 560px) { .whoami-email { display: none; } }

/* Section tabs - the site's .city-hub-tabs idiom. Never wraps; scrolls. */
.sections { background: var(--panel); border-bottom: 1px solid var(--line); }
.sections-in {
  max-width: var(--col); margin: 0 auto; padding: 0 var(--s4);
  display: flex; gap: var(--s1); min-width: 0;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.sections-in::-webkit-scrollbar { display: none; }
.section-tab {
  appearance: none; background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent;
  padding: var(--s3); min-height: 44px;
  font: inherit; font-size: var(--t-md); color: var(--muted);
  white-space: nowrap; flex: none;
  display: inline-flex; align-items: center; gap: var(--s2);
}
.section-tab:hover { color: var(--text); }
.section-tab[aria-current="page"] {
  color: var(--accent); border-bottom-color: var(--accent); font-weight: 600;
}
.section-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-sm); }

/* In-section sub-navigation: same tab language, scoped to a page group. */
.subnav {
  display: flex; gap: var(--s1); min-width: 0; margin-bottom: var(--s4);
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav .section-tab { text-decoration: none; }
.subnav .section-tab:hover { text-decoration: none; }

main {
  flex: 1 1 auto; min-height: 0; min-width: 0;
  width: 100%; max-width: var(--col); margin: 0 auto;
  padding: var(--s5) var(--s4) var(--s10);
}

footer {
  background: var(--panel); border-top: 1px solid var(--line);
  font-size: var(--t-xs); color: var(--muted);
}
.footer-in {
  max-width: var(--col); margin: 0 auto; padding: var(--s2) var(--s4);
  display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); min-width: 0;
}

/* ========================================================= primitives === */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--s4);
  margin-bottom: var(--s3); box-shadow: var(--shadow-hair);
  min-width: 0;
}
.card > * + * { margin-top: var(--s3); }
.card-h {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); font-weight: 700;
}
.card-t { font-size: var(--t-xl); }
.muted { color: var(--muted); font-size: var(--t-sm); line-height: 1.5; }
.lead { font-size: var(--t-md); color: var(--text); max-width: 62ch; }
.num { font-variant-numeric: tabular-nums; }
.mono {
  font-family: var(--font-mono); font-size: var(--t-sm);
  /* 2.6: ids, hashes, key prefixes and 400-char tokens break inside the box. */
  overflow-wrap: anywhere; word-break: break-all; min-width: 0;
}

.page-head { margin-bottom: var(--s4); min-width: 0; }
.page-head h1 { font-size: var(--t-2xl); }
.page-head p { margin-top: var(--s2); }

.row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; min-width: 0; }
.row-end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.grow { flex: 1 1 auto; min-width: 0; }

/* buttons - the site's radius/size language, three weights only */
.btn {
  appearance: none; font: inherit; font-size: var(--t-md); cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: var(--r-sm); padding: var(--s2) var(--s4);
  min-height: 38px; display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2); transition: background var(--dur) ease-out, border-color var(--dur) ease-out;
  min-width: 0; max-width: 100%;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:active:not(:disabled) { background: var(--bg); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn-danger-solid:hover:not(:disabled) { background: #b3262a; border-color: #b3262a; color: #fff; }
.btn-quiet { background: none; border-color: transparent; color: var(--muted); }
.btn-quiet:hover:not(:disabled) { color: var(--accent); border-color: var(--line); }
.btn-sm { min-height: 32px; padding: var(--s1) var(--s3); font-size: var(--t-sm); }
/* Mobile touch targets (AESTHETICS 2.3) */
@media (pointer: coarse) { .btn, .btn-sm { min-height: 44px; } }

.btn .spin {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn .spin { animation-duration: 2400ms; } }

/* forms */
.field { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.field > label {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); font-weight: 700;
}
.field input, .field select, .field textarea {
  font: inherit; font-size: var(--t-md); color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: var(--s2) var(--s3);
  min-height: 40px; width: 100%; min-width: 0;
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field input:disabled, .field select:disabled, .field textarea:disabled {
  background: var(--bg); color: var(--muted); cursor: not-allowed;
}
.field input[readonly] { background: var(--bg); color: var(--muted); }
.field-hint { font-size: var(--t-xs); color: var(--muted); }
.field-err { font-size: var(--t-xs); color: var(--bad-fg); font-weight: 600; }
fieldset { border: none; min-width: 0; }
legend {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); font-weight: 700; margin-bottom: var(--s2);
}
.check { display: flex; gap: var(--s2); align-items: flex-start; font-size: var(--t-md); min-width: 0; }
.check input { accent-color: var(--accent); margin-top: 3px; flex: none; width: 16px; height: 16px; }
.checks { display: grid; gap: var(--s2); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s1); }

/* chips / caps - verbatim idiom from the site */
.chip {
  background: var(--bg); color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: var(--s1) var(--s3); font-size: var(--t-sm);
  display: inline-flex; align-items: center; gap: var(--s1); max-width: 100%; min-width: 0;
}
.cap {
  display: inline-block; font-size: var(--t-xs); font-weight: 700;
  padding: 2px var(--s2); border-radius: var(--r-pill); white-space: nowrap;
  background: var(--line); color: var(--text);
}
.cap-ok   { background: var(--ok-bg);   color: var(--ok-fg); }
.cap-warn { background: var(--warn-bg); color: var(--warn-fg); }
.cap-bad  { background: var(--bad-bg);  color: var(--bad-fg); }
.cap-info { background: var(--info-bg); color: var(--info-fg); }
.cap-planned {
  background: var(--bg); color: var(--muted); border: 1px dashed var(--line);
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}

/* definition rows - the site's .stat-row idiom */
.dl { display: flex; flex-direction: column; min-width: 0; }
.dl-row {
  display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4);
  justify-content: space-between; align-items: baseline;
  padding: var(--s2) 0; border-bottom: 1px solid var(--line); min-width: 0;
}
.dl-row:last-child { border-bottom: none; }
.dl-k { font-size: var(--t-sm); color: var(--muted); flex: none; }
.dl-v { font-weight: 600; min-width: 0; text-align: right; flex: 1 1 12ch; }
@media (max-width: 560px) { .dl-v { text-align: left; flex-basis: 100%; } }

/* tables - .cmp idiom, wrapped in their own scroll container (2.6) */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-md); min-width: 520px; }
table.tbl thead th {
  text-align: left; font-size: var(--t-xs); text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted); font-weight: 700;
  padding: 0 var(--s2) var(--s2); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl td {
  padding: var(--s2); border-bottom: 1px solid var(--line);
  vertical-align: top; min-width: 0;
}
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
table.tbl td.actions { text-align: right; white-space: nowrap; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 600; }
.cell-sub { display: block; font-size: var(--t-xs); color: var(--muted); }

/* Below 560px tables become stacked cards - no horizontal scroll on phones. */
@media (max-width: 560px) {
  table.tbl { min-width: 0; }
  table.tbl thead { display: none; }
  table.tbl, table.tbl tbody, table.tbl tr, table.tbl td { display: block; width: 100%; }
  table.tbl tr {
    border: 1px solid var(--line); border-radius: var(--r-md);
    padding: var(--s2); margin-bottom: var(--s2);
  }
  table.tbl td { border-bottom: none; padding: var(--s1) 0; }
  table.tbl td::before {
    content: attr(data-label); display: block;
    font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--muted); font-weight: 700;
  }
  table.tbl td.actions { text-align: left; white-space: normal; }
}

/* ================================================= state surfaces (1.3) === */

.state {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--bg); padding: var(--s5) var(--s4);
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2);
  min-width: 0;
}
.state-icon { color: var(--muted); }
.state-t { font-size: var(--t-lg); font-weight: 700; }
.state-b { font-size: var(--t-sm); color: var(--muted); max-width: 60ch; }
.state-loading .state-icon { color: var(--accent); }
.state-error { border-color: var(--danger); background: var(--bad-bg); }
.state-error .state-icon, .state-error .state-t { color: var(--bad-fg); }
.state-offline { border-color: var(--warn); background: var(--warn-bg); }
.state-offline .state-icon, .state-offline .state-t { color: var(--warn-fg); }

.skel { display: flex; flex-direction: column; gap: var(--s2); width: 100%; }
.skel i {
  display: block; height: 12px; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--line), var(--bg), var(--line));
  background-size: 300% 100%;
  animation: skel 1.4s ease-in-out infinite;
}
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .skel i { animation: none; } }

.notice {
  border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--r-sm);
  padding: var(--s3); font-size: var(--t-sm); min-width: 0;
}
.notice-ok   { border-left-color: var(--ok);     background: var(--ok-bg);   color: var(--ok-fg); }
.notice-warn { border-left-color: var(--warn);   background: var(--warn-bg); color: var(--warn-fg); }
.notice-bad  { border-left-color: var(--danger); background: var(--bad-bg);  color: var(--bad-fg); }
.notice-info { border-left-color: var(--accent); background: var(--info-bg); color: var(--info-fg); }
.notice strong { font-weight: 700; }
.notice .req-id {
  display: block; margin-top: var(--s1); font-family: var(--font-mono);
  font-size: var(--t-xs); opacity: 0.85; overflow-wrap: anywhere;
}

/* offline banner */
.offline-bar {
  background: var(--warn-bg); color: var(--warn-fg);
  border-bottom: 1px solid var(--warn);
  font-size: var(--t-sm); font-weight: 600;
}
.offline-bar-in {
  max-width: var(--col); margin: 0 auto; padding: var(--s2) var(--s4);
  display: flex; gap: var(--s2); align-items: center; min-width: 0;
}

/* ====================================================== auth split view === */

.auth { display: grid; gap: var(--s6); grid-template-columns: minmax(0, 1fr); align-items: start; }
/* Asymmetric editorial split: rail sits left and is narrower than the form
   column. Deliberately NOT a centred hero card (AESTHETICS 3). */
@media (min-width: 820px) {
  .auth { grid-template-columns: minmax(0, 0.78fr) minmax(340px, 0.95fr); gap: var(--s10); }
}
.auth-rail { min-width: 0; border-left: 3px solid var(--accent); padding-left: var(--s4); }
.auth-rail h1 { font-size: var(--t-3xl); letter-spacing: -0.6px; }
.auth-kicker {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 1px;
  color: var(--accent); font-weight: 700; margin-bottom: var(--s2);
}
.auth-rail p { margin-top: var(--s3); color: var(--muted); font-size: var(--t-md); max-width: 46ch; }
.auth-facts { list-style: none; margin-top: var(--s5); display: flex; flex-direction: column; gap: var(--s3); }
.auth-facts li { display: flex; gap: var(--s3); align-items: flex-start; min-width: 0; }
.auth-facts .gi { color: var(--accent); flex: none; margin-top: 2px; }
.auth-facts b { display: block; font-size: var(--t-md); }
.auth-facts span { font-size: var(--t-sm); color: var(--muted); }
.auth-form { min-width: 0; }
.auth-alt { font-size: var(--t-sm); color: var(--muted); }

/* ============================================================ dashboard === */

.tiles { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s4); box-shadow: var(--shadow-hair); min-width: 0;
  display: flex; flex-direction: column; gap: var(--s1);
}
.tile-k {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); font-weight: 700;
}
.tile-v {
  font-size: var(--t-2xl); font-weight: 700; font-variant-numeric: tabular-nums;
  letter-spacing: -0.4px; min-width: 0;
}
.tile-v.small { font-size: var(--t-lg); letter-spacing: 0; }
.tile-s { font-size: var(--t-sm); color: var(--muted); }
.tile-a { margin-top: var(--s2); }

/* no-org state - the designed D1 surface, not an empty dashboard */
.noorg { border-left: 3px solid var(--accent); }
.noorg ol { margin: var(--s3) 0 0 var(--s5); font-size: var(--t-md); }
.noorg ol li { margin-bottom: var(--s2); }

/* ======================================================= secret display === */

.secret {
  border: 1px solid var(--warn); background: var(--warn-bg);
  border-radius: var(--r-md); padding: var(--s4); min-width: 0;
}
.secret-h {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.6px;
  font-weight: 700; color: var(--warn-fg);
}
.secret code {
  display: block; margin-top: var(--s2); padding: var(--s3);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: var(--t-sm);
  overflow-wrap: anywhere; word-break: break-all; min-width: 0;
  user-select: all;
}
.codes {
  list-style: none; display: grid; gap: var(--s1);
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-top: var(--s2);
}
.codes li {
  font-family: var(--font-mono); font-size: var(--t-sm); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s1) var(--s2);
  overflow-wrap: anywhere; min-width: 0;
}

/* =============================================================== modal === */

.modal-scrim {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(16, 24, 40, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s4); overflow-y: auto;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.18);
  width: 100%; max-width: 460px; padding: var(--s5);
  display: flex; flex-direction: column; gap: var(--s3);
  min-width: 0; max-height: calc(100vh - 2 * var(--s4)); overflow-y: auto;
}
.modal h2 { font-size: var(--t-xl); }
.modal-what {
  font-size: var(--t-md); border-left: 3px solid var(--danger);
  background: var(--bad-bg); color: var(--bad-fg);
  padding: var(--s2) var(--s3); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  overflow-wrap: anywhere; min-width: 0;
}
.modal-actions { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: flex-end; }
@media (max-width: 420px) {
  .modal-actions { justify-content: stretch; }
  .modal-actions .btn { flex: 1 1 100%; }
}
/* reauth overlay keeps the page (and its unsaved draft) mounted underneath */
.reauth .modal { max-width: 400px; }

/* ============================================================== toasts === */

.toasts {
  position: fixed; z-index: 1100; right: var(--s4); bottom: var(--s4);
  display: flex; flex-direction: column; gap: var(--s2);
  max-width: min(380px, calc(100vw - 2 * var(--s4)));
  pointer-events: none;
}
@media (max-width: 560px) {
  .toasts { left: var(--s3); right: var(--s3); bottom: var(--s3); max-width: none; }
}
.toast {
  pointer-events: auto; background: var(--panel);
  border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--r-sm);
  padding: var(--s3); font-size: var(--t-sm); box-shadow: 0 4px 14px rgba(16, 24, 40, 0.12);
  display: flex; gap: var(--s2); align-items: flex-start; min-width: 0;
}
.toast-ok  { border-left-color: var(--ok); }
.toast-bad { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--accent); }
.toast .grow { overflow-wrap: anywhere; }

/* =============================================================== pager === */

.pager { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s3); }
.pager-info { font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; }

/* =============================================================== icons === */

.gi { vertical-align: -2px; flex: none; }

/* ============================================================ noscript === */

.noscript {
  max-width: 62ch; margin: 0 auto; padding: var(--s8) var(--s4);
  display: flex; flex-direction: column; gap: var(--s3);
}
.noscript h1 { font-size: var(--t-2xl); }

/* ============================================ visually-hidden utilities === */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ======================================================= shrink safety === */
/* Exercised at 1920 / 1440 / 1180 / 1040 / 820 / 768 / 560 / 360 (AESTHETICS 2.7). */
@media (max-width: 820px) {
  .topbar-in, .sections-in, main, .footer-in, .offline-bar-in {
    padding-left: var(--s3); padding-right: var(--s3);
  }
}
@media (max-width: 560px) {
  main { padding-top: var(--s4); }
  .page-head h1 { font-size: var(--t-xl); }
  .auth-rail { padding-left: var(--s3); }
  .auth-rail h1 { font-size: var(--t-2xl); }
  /* Shed non-essential chrome rather than letting it collide. */
  .brand-sub { display: none; }
}
