/* GECAMed Portal. Tokens from brand.md (the orchestrator console's
   globals.css): light and dark by prefers-color-scheme; system fonts only. */
:root {
  --page: #f8fafc; --surface: #ffffff; --sunken: #f8fafc; --hairline: #f1f5f9;
  --border: #e2e8f0; --border-input: #cbd5e1;
  --text: #0f172a; --text-2: #334155; --text-3: #475569; --text-4: #64748b;
  --accent: #0f766e; --accent-soft: #f0fdfa;
  --primary: #0f172a; --primary-fg: #ffffff;
  --danger: #dc2626; --danger-text: #b91c1c;
  --good-bg: #d1fae5; --good-fg: #065f46;
  --updating-bg: #e0f2fe; --updating-fg: #075985;
  --warn-bg: #fef3c7; --warn-fg: #92400e;
  --bad-bg: #fee2e2; --bad-fg: #991b1b;
  --unknown-bg: #f1f5f9; --unknown-fg: #334155;
  --shadow-card: 0 1px 2px rgb(15 23 42 / .04);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0b1220; --surface: #0f172a; --sunken: #111a2e; --hairline: #1e293b;
    --border: #1e293b; --border-input: #334155;
    --text: #e2e8f0; --text-2: #cbd5e1; --text-3: #94a3b8; --text-4: #94a3b8;
    --accent: #5eead4; --accent-soft: #0b2b29;
    --primary: #e2e8f0; --primary-fg: #0f172a;
    --danger: #ef4444; --danger-text: #f87171;
    --good-bg: #052e22; --good-fg: #6ee7b7;
    --updating-bg: #062a43; --updating-fg: #7dd3fc;
    --warn-bg: #3a2306; --warn-fg: #fcd34d;
    --bad-bg: #3b0d0d; --bad-fg: #fca5a5;
    --unknown-bg: #1e293b; --unknown-fg: #cbd5e1;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 26px; line-height: 1.2; font-weight: 650; margin: 0 0 16px; }
h2 { font-size: 14px; font-weight: 600; margin: 20px 0 8px; }
.meta { font-size: 13px; color: var(--text-3); }
.mono, code { font-family: var(--mono); }
.icon { flex: none; vertical-align: -3px; }

/* Environment band: full width, 32 px, on every page. */
.envband {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 32px; padding: 4px 16px; font-size: 12px; font-weight: 700; letter-spacing: .06em;
}
.env-staging { background: var(--warn-bg); color: var(--warn-fg); border-bottom: 2px solid #f59e0b; }
.env-development { background: var(--unknown-bg); color: var(--unknown-fg); }

/* Header */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 24px; min-height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; color: var(--text); text-decoration: none; margin-right: auto; }
.brand-sub { font-weight: 400; color: var(--text-3); }
.menu { position: relative; }
.menu > summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: 6px;
  cursor: pointer; list-style: none; color: var(--text-2); font-weight: 500;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: "▾"; font-size: 11px; }
.menu > summary:hover { background: var(--hairline); }
.menu > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.menu-list {
  position: absolute; right: 0; z-index: 20; min-width: 220px; margin-top: 4px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 12px rgb(15 23 42 / .12);
  display: flex; flex-direction: column; gap: 2px;
}
.menu-list a, .menu-list .btn { display: flex; align-items: center; gap: 8px; justify-content: flex-start; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--text-2); width: 100%; }
.menu-list a:hover, .menu-list .btn:hover { background: var(--hairline); }
.menu-list a[aria-current="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.menu-list form { margin: 0; }
.menu-sep { border-top: 1px solid var(--hairline); margin: 4px 0; }
.menu-head { padding: 4px 10px; }
.practice-label { font-weight: 600; color: var(--text); }
.navgroup { margin: 10px 0 4px; padding: 0 12px; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plist a { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--text); font-weight: 600; }
.plist a:hover { border-color: var(--accent); }

/* Navigation: side (>= 1024 px), bottom bar below. */
.frame { display: flex; min-height: calc(100vh - 88px); }
.sidenav {
  flex: 0 0 240px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.sidenav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 6px;
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.sidenav a:hover { background: var(--hairline); }
.sidenav a.active { background: var(--accent-soft); color: var(--accent); }
.content { flex: 1; min-width: 0; padding: 24px; }

/* Cards, bands, empty states */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow-card); padding: 14px 20px; margin-bottom: 16px;
}
.band {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px;
}
.band[hidden] { display: none; }
.band-warn { background: var(--warn-bg); color: var(--warn-fg); }
.band-bad { background: var(--bad-bg); color: var(--bad-fg); }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 0; color: var(--text-3); }

/* Status component */
.status {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.tone-good { background: var(--good-bg); color: var(--good-fg); }
.tone-updating { background: var(--updating-bg); color: var(--updating-fg); }
.tone-warn { background: var(--warn-bg); color: var(--warn-fg); }
.tone-bad { background: var(--bad-bg); color: var(--bad-fg); }
.tone-unknown { background: var(--unknown-bg); color: var(--unknown-fg); }

/* Buttons and forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
  padding: 6px 14px; border-radius: 6px; border: 1px solid var(--border-input); font: inherit; font-weight: 600;
  background: var(--surface); color: var(--text); cursor: pointer;
}
.btn-primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-2); }
.btn:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.form { display: flex; flex-direction: column; gap: 6px; }
.form label { font-weight: 600; margin-top: 8px; }
.form input, .form select {
  font: inherit; min-height: 40px; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border-input); background: var(--surface); color: var(--text);
}
.form .btn { margin-top: 16px; }
.form fieldset { border: 0; margin: 0 0 16px; min-width: 0; }
.form textarea { font: inherit; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border-input); background: var(--surface); color: var(--text); }
/* One field layout (GW-231): label above, control full width up to 480 px, hint below; checkbox box left of its label. */
.form fieldset { display: flex; flex-direction: column; gap: 6px; }
.form .field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.form .field > label, .form .field-label { margin-top: 8px; font-weight: 600; }
.form .field-row { display: flex; flex-wrap: wrap; gap: 0 16px; }
.form .field-row > .field { flex: 1 1 160px; max-width: 232px; }
.form input:not([type=checkbox]):not([type=radio]):not([type=hidden]), .form select { width: 100%; max-width: 480px; box-sizing: border-box; }
.form textarea { width: 100%; max-width: 720px; box-sizing: border-box; resize: vertical; }
.form label:has(> input[type=checkbox]) { display: flex; align-items: flex-start; gap: 10px; }
.form input[type=checkbox] { min-height: 0; width: 20px; height: 20px; padding: 0; margin: 2px 0 0; flex: none; }
.form fieldset > .meta, .form .field > .meta { margin: 0; font-size: 13px; }
.form fieldset > h2 { margin: 0 0 4px; }
/* Show only the timing field that the chosen mode uses. */
.form:has(#timing_mode option[value=dayBeforeAt]:checked) .f-hours,
.form:has(#timing_mode option[value=hoursBefore]:checked) .f-dayat { display: none; }
.alert, .notice { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 6px; margin: 0 0 12px; }
.alert { background: var(--bad-bg); color: var(--bad-fg); }
.notice { background: var(--good-bg); color: var(--good-fg); }

/* Sign-in and setup: a centred card. */
.center { display: flex; justify-content: center; padding: 48px 16px; }
.signin { width: 100%; max-width: 420px; padding: 24px; }
.product { font-weight: 650; margin: 0 0 16px; }
.qr { display: block; width: 246px; height: 246px; margin: 8px 0; background: #fff; padding: 8px; border-radius: 8px; image-rendering: pixelated; }
.key { font-size: 18px; letter-spacing: .04em; margin: 4px 0; word-spacing: .2em; }

@media (max-width: 1023px) {
  .navgroup { display: none; }
  .frame { display: block; padding-bottom: 60px; }
  .sidenav {
    position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; height: 60px; padding: 0;
    flex-direction: row; border-right: 0; border-top: 1px solid var(--border);
  }
  .sidenav a {
    flex: 1; flex-direction: column; justify-content: center; gap: 2px; min-height: 44px;
    padding: 4px 0; border-radius: 0; font-size: 11px;
  }
  .btn { min-height: 44px; }
  .form input { min-height: 44px; }
}
@media (max-width: 639px) {
  h1 { font-size: 22px; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; gap: 10px; flex-wrap: wrap; }
  /* The bar wraps, so a menu may sit at the left: its list spans the bar instead of hanging off the edge. */
  .topbar { position: relative; }
  .menu { position: static; }
  .menu-list { left: 16px; right: 16px; min-width: 0; }
  .menu > summary, .menu-list a, .menu-list .btn { min-height: 44px; }
  .form .btn { width: 100%; }
}


/* Pages (portal SMS pages. */
.num { font-variant-numeric: tabular-nums; }
.micro { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-4); }
.verdict { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.verdict .status { font-size: 14px; padding: 4px 12px; }
.verdict p { margin: 0; font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
  display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card); color: var(--text); text-decoration: none;
}
.big { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 16px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.events { list-style: none; margin: 0; padding: 0; }
.events li { padding: 6px 0; border-bottom: 1px solid var(--hairline); display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-4); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 8px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.table .num { text-align: right; }
.table tfoot td { font-weight: 650; border-top: 1px solid var(--border); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chips a { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border-input); color: var(--text-2); text-decoration: none; font-size: 13px; }
.chips a.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-fg); font-size: 12px; }
.tone-text-bad { color: var(--bad-fg); font-weight: 600; }
.tone-text-warn { color: var(--warn-fg); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; min-width: 0; max-width: 100%; }
.filters input, .filters select {
  font: inherit; min-height: 36px; padding: 6px 8px; border-radius: 6px;
  border: 1px solid var(--border-input); background: var(--surface); color: var(--text);
  max-width: 100%;
}
.filters fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.filters fieldset label { flex-direction: row; align-items: center; font-weight: 400; font-size: 13px; }
.filters input[type=checkbox] { width: 16px; height: 16px; padding: 0; }
.pager { display: flex; gap: 16px; justify-content: flex-end; }
.headchips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.trail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 0 16px; }
.timeline { margin: 0; padding-left: 20px; }
.timeline li { padding: 6px 0; }
.timeline li.waiting { color: var(--text-3); }
@media (max-width: 899px) {
  .trail { grid-template-columns: 1fr; }
  /* Table to cards: each row a card, each cell labelled. */
  .table.cards thead { display: none; }
  .table.cards, .table.cards tbody, .table.cards tfoot, .table.cards tr, .table.cards td { display: block; width: 100%; }
  .table.cards tr { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; padding: 8px 12px; background: var(--surface); }
  .table.cards td { border: 0; padding: 3px 0; text-align: left; }
  .table.cards td.num { text-align: left; }
  .table.cards td::before { content: attr(data-label); display: inline-block; min-width: 110px; color: var(--text-4); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
  .table.cards td.card-title::before { display: none; }
  .table.cards td.card-title { font-size: 15px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 6px; }
}

/* Access page: small inline forms inside table cells and a one-line grant form. */
.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-end; }
.actions label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.actions select, .actions input { font: inherit; min-height: 36px; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border-input); background: var(--surface); color: var(--text); }
.linkbox { word-break: break-all; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }

/* UX release 1, step 1 (GW-228, GW-229, GW-232): fit. Wide tables scroll inside their card, long values wrap,
   the phone bar scrolls with fixed-width items. */
.card { overflow-x: auto; min-width: 0; }
.grid2 > *, .tiles > *, .trail > * { min-width: 0; }
.card, .band, .verdict, .events li, .linkbox { overflow-wrap: anywhere; }
.linkbox, pre, .mono, code { overflow-wrap: anywhere; word-break: break-word; }
.table { table-layout: auto; }
.table th { white-space: nowrap; }
.table .status { white-space: nowrap; }
@media (max-width: 1023px) {
  .sidenav { overflow-x: auto; overflow-y: hidden; justify-content: flex-start; scroll-snap-type: x proximity; scrollbar-width: none; }
  .sidenav::-webkit-scrollbar { display: none; }
  .sidenav a { flex: 0 0 76px; width: 76px; scroll-snap-align: start; padding: 4px 2px; }
  .sidenav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; font-size: 11px; line-height: 1.2; }
  .sidenav a.active { box-shadow: inset 0 -3px 0 var(--accent); }
}
@media (max-width: 639px) {
  .brand { white-space: nowrap; }
  .brand-sub { display: none; }
  .table.cards td { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 0 10px; }
  .table.cards td::before { min-width: 0; }
  .table.cards td.card-title { display: block; }
}
main > .table { display: block; overflow-x: auto; max-width: 100%; }
.grid2 .table th { white-space: normal; }
.grid2 .table td, .grid2 .table th { overflow-wrap: anywhere; }
.grid2 .table .status, .grid2 .table .chip { white-space: normal; }

/* UX leftovers (GW-267): copy and show-password buttons, password rows, phone card cells, Access forms. */
.pwrow { display: flex; gap: 8px; align-items: center; max-width: 480px; }
.pwrow input { flex: 1 1 auto; min-width: 0; }
.pwrow .pw-toggle, .form .pw-toggle { margin-top: 0; width: auto; flex: none; }
.pw-toggle[hidden], [data-copy-target][hidden] { display: none; }
.linkbox { overflow-wrap: anywhere; word-break: break-all; }
.phonecell .mono { display: inline-block; max-width: 100%; }
.codecell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.actions select, .actions input { max-width: 100%; box-sizing: border-box; }
@media (max-width: 639px) {
  .actions { flex-direction: column; align-items: stretch; }
  .actions label { width: 100%; }
  .actions select, .actions input { width: 100%; min-height: 44px; }
  .actions .btn { width: 100%; }
  .table.cards td form.inline { display: block; }
  .table.cards td form.inline .btn { width: 100%; margin-top: 8px; }
  .table.cards td:has(> form.inline) { display: block; }
  .table.cards td:has(> form.inline)::before { display: block; margin-bottom: 4px; }
  .pwrow { max-width: none; }
}
