/*
 * Mamore brand palette.
 *
 * The colours are sampled from the official MTGI mark so the interface and the
 * logo are the same brand rather than two: navy #00306D carries the chrome,
 * red #ED0000 is the action colour, gold #FEAB01 highlights. --forest* are
 * retained as aliases for the many existing var(--forest) call sites.
 *
 * Poppins is the only typeface in the product. It is loaded by the sibling
 * fonts.css (self-hosted woff2) and referenced through --font so the family is
 * declared once. The former Inter body face and Georgia display face are gone:
 * every heading, figure and control now renders in Poppins, which is what
 * makes the numerals in tables, metrics and the receipt line up in one voice.
 */
@import url("fonts.css");
@import url("fontawesome.css");

:root {
  --ink: #0d1b2e;
  --navy: #00306d;
  --navy-2: #0a429a;
  --forest: var(--navy);
  --forest-2: var(--navy-2);
  --red: #ed0000;
  --gold: #feab01;
  --paper: #f2f5fa;
  --surface: #fff;
  --line: #d3dbe6;
  --muted: #5b6b84;
  --accent: var(--red);
  --accent-dark: #b80000;
  --success: #1c7a4d;
  --warning: #b3541e;
  --shadow: 0 16px 45px rgba(0, 48, 109, .12);
  --font: "Poppins", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid rgba(237, 0, 0, .4); outline-offset: 2px; }
[hidden] { display: none !important; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; padding: .75rem 1rem; color: white; background: var(--forest); }
.skip-link:focus { top: 1rem; }
.eyebrow { margin: 0 0 .45rem; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--muted); }
/* Brand lockup: the official MTGI mark beside the wordmark. The mark is a
 * detailed roundel, so it is presented on a white plate to keep its edge crisp
 * against the navy chrome it sits on. */
.brand { display: flex; align-items: center; gap: .75rem; font-size: 1.25rem; font-weight: 800; letter-spacing: -.03em; }
.brand-mark { width: 2.5rem; height: 2.5rem; flex: none; border-radius: 50%; background: #fff; object-fit: contain; box-shadow: 0 0 0 1px rgba(0, 48, 109, .12), 0 2px 8px rgba(0, 0, 0, .18); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { margin-top: .18rem; color: var(--gold); font-size: .58rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.login-story .brand-text small { color: #cfe0ff; }
.login-story .brand-mark { box-shadow: 0 0 0 1px rgba(255, 255, 255, .22), 0 6px 20px rgba(0, 0, 0, .3); }
/* The sidebar is narrow, so it uses the short strapline and a slightly smaller
 * mark; .brand-text is allowed to shrink so the lockup never wraps. */
.sidebar-brand { padding: .25rem .65rem 1.7rem; gap: .6rem; }
.sidebar-brand .brand-mark { width: 2.4rem; height: 2.4rem; }
.sidebar-brand .brand-text { min-width: 0; }
.status-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: #53c88c; box-shadow: 0 0 0 4px rgba(83, 200, 140, .12); }

/* ------------------------------------------------- Font Awesome iconography
 * Icons are decorative by default: the adjacent text or the button's
 * aria-label carries the meaning, so every <i> is marked aria-hidden. A glyph
 * is never the only label on a control.
 *
 * The font is the subset in assets/fontawesome.css, which only ships the ~150
 * codepoints this UI uses, so an icon that is not in that stylesheet renders
 * as an empty box. tests/ui-wiring-test.php fails the build if that happens. */
.fa-solid { font-size: .9em; }
.nav-item .fa-solid { width: 1.25rem; margin-right: .65rem; color: #8fa5c9; font-size: 1rem; }
.nav-item:hover .fa-solid, .nav-item.active .fa-solid { color: var(--gold); }
.nav-item { justify-content: flex-start; }
.nav-item > span { flex: 1; }
.nav-item small { flex: none; margin-left: .5rem; }
.nav-label .fa-solid { margin-right: .4rem; }
/* Buttons that carry an icon keep the label and the glyph on one baseline and
 * centre as a unit, so the gap survives at every button width. */
.primary-button, .secondary-button, .danger-button, .row-action, .sos-button, .sos-confirm { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
.primary-button .fa-solid, .secondary-button .fa-solid { font-size: .95em; }
/* Icon-only controls: the glyph is centred and the box stays square. The
 * display values live on the .icon-button and .dialog-close rules themselves,
 * because a glyph has to be optically centred or it reads as a stray dot. */
.dialog-close .fa-solid { font-size: 1.05rem; }
.topbar .account .secondary-button .fa-solid { font-size: .9em; }
/* The in-field "Show password" toggle keeps its text label and adds the eye. */
.password-field .text-button { display: inline-flex; align-items: center; gap: .35rem; }
.eyebrow .fa-solid { margin-right: .35rem; }
.metric .fa-solid, .domain-kpis .fa-solid { color: var(--forest); }
.status-badge .fa-solid { margin-right: .3rem; }
.toast .fa-solid { margin-right: .45rem; }

/* =============================================================================
 * login-header -- the presentation controls on the sign-in screen
 * =============================================================================

 * The theme, currency and language controls used to exist only inside
 * #app-view, which is hidden until sign-in succeeds. That made the login screen
 * the one screen where a user with a dark-mode desktop or a French or Lingala
 * keyboard could not reach either preference -- and the language control is the
 * one place a wrong-language reader would notice it most, because the whole
 * screen is in the wrong language.
 *
 * The controls themselves are rendered from the shared template, so this is
 * layout only. It spans both grid columns of .login-shell and sits ABOVE the
 * story panel and the form panel; without spanning, it would be squeezed into
 * the story column and the drop-down menus would open against the wrong edge.
 *
 * It is `position: sticky` rather than fixed, so it stays reachable on a long
 * form (the reset-password form scrolls) without overlaying anything, and it
 * carries `no-print` so it never appears on a printed page.
 * ========================================================================== */
.login-header {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar, 60);
  grid-column: 1 / -1;
  padding: var(--space-3, 12px) clamp(1rem, 3vw, 2rem);
  background: var(--surface-raised, #fff);
  border-bottom: 1px solid var(--border-default, #e2e8f0);
}

.login-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3, 12px);
  min-height: var(--topbar-height, 64px);
}

.login-header .brand { display: flex; align-items: center; gap: .6rem; }
.login-header .brand-text { display: flex; flex-direction: column; font-weight: 700; line-height: 1.15; }
.login-header .brand-text small { color: var(--text-muted, #64748b); font-size: .66rem; font-weight: 600; letter-spacing: .06em; }
.login-header__controls { display: flex; align-items: center; gap: var(--space-2, 8px); }

/* On a phone the brand wordmark and the three controls cannot share one row at
 * 320px. The controls keep their own row rather than being dropped: they are the
 * reason this header exists. */
@media (max-width: 639px) {
  .login-header__inner { flex-wrap: wrap; row-gap: var(--space-2, 8px); }
  .login-header__controls { width: 100%; justify-content: flex-end; }
}

/* Below 760px .login-shell becomes a single column and the story panel is a
 * compact header of its own, so the controls' header sits directly above it. */
@media (max-width: 760px) {
  .login-header { padding-block: .7rem; }
  .login-header .brand-mark { width: 28px; height: 28px; }
}

/* The first row is the controls header, the second is the story/form split.
   Declaring the rows explicitly is what keeps the story panel filling exactly
   the height left over: it used to carry `min-height: 100vh`, which now that a
   header sits above it would make the screen 100vh PLUS the header and scroll
   by ~64px on a screen sized to fit. */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(380px, .85fr);
  grid-template-rows: auto minmax(0, 1fr);
}
.login-story { display: flex; flex-direction: column; justify-content: space-between; min-height: 0; padding: clamp(2rem, 5vw, 5rem); color: white; background: var(--forest); position: relative; overflow: hidden; }
.login-story::after { content: ""; position: absolute; width: 22rem; height: 22rem; right: -8rem; bottom: 4rem; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; box-shadow: 0 0 0 5rem rgba(255,255,255,.025), 0 0 0 10rem rgba(255,255,255,.02); }
/* A large, faint impression of the mark anchors the brand on the first screen
 * without competing with the copy layered above it. Two details matter:
 * the "-mark-" asset has a transparent background (the source PNG is opaque
 * white, which would show as a grey rectangle over the navy), and the path is
 * relative to this stylesheet because a "/assets/..." URL would resolve against
 * the web root and break the sub-directory install. Core\AppShell rewrites the
 * HTML document, not this file. */
.login-story::before { content: ""; position: absolute; right: -6rem; bottom: 1.5rem; width: 30rem; height: 30rem; background: url("mtgi-logo-mark-512.png") center / contain no-repeat; opacity: .1; pointer-events: none; }
.story-copy { position: relative; z-index: 1; max-width: 42rem; }
.story-copy h1 { max-width: 14ch; margin: 0; font-size: clamp(3rem, 6.6vw, 6.2rem); font-weight: 600; line-height: .96; letter-spacing: -.03em; }
.story-copy h1::after { content: ""; display: block; width: 4.5rem; height: 4px; margin-top: 1.6rem; background: var(--gold); border-radius: 2px; }
.story-copy > p:last-child { max-width: 38rem; margin: 1.75rem 0 0; color: #ccd9ee; font-size: 1.06rem; line-height: 1.75; }
.story-foot { margin: 0; color: #9db1d4; font-size: .8rem; letter-spacing: .07em; text-transform: uppercase; }
.login-panel { display: grid; place-items: center; padding: 2rem; background: var(--surface); }
.login-form { width: min(100%, 27rem); }
.login-form h2 { margin: 0; font-size: 2.5rem; font-weight: 600; letter-spacing: -.025em; }
.login-form > .muted { margin: .7rem 0 2.2rem; }
label { display: block; margin: 1.1rem 0 .45rem; font-size: .84rem; font-weight: 700; }
input { width: 100%; min-height: 3.15rem; padding: .8rem .95rem; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--ink); }
select { width: 100%; min-height: 3.15rem; padding: .8rem .95rem; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: white; }
textarea { width: 100%; resize: vertical; padding: .8rem .95rem; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: white; }
input:hover { border-color: #a5aaa7; }
.password-field { position: relative; }
.password-field input { padding-right: 4.2rem; }
.text-button { position: absolute; top: 50%; right: .65rem; transform: translateY(-50%); border: 0; color: var(--navy-2); background: transparent; font-size: .78rem; font-weight: 800; }
/* Links below the sign-in form sit in normal flow: .text-button is absolutely
   positioned for the in-field "Show password" control, and without resetting
   that here the two auth links would overlap each other. */
.auth-links { display: flex; flex-wrap: wrap; gap: .35rem 1.25rem; margin-top: 1.4rem; }
.auth-links .text-button { position: static; transform: none; display: inline-flex; align-items: center; gap: .35rem; padding: .25rem 0; color: var(--navy-2); font-size: .82rem; }
.auth-links .text-button:hover { color: var(--red); text-decoration: underline; }
.primary-button, .secondary-button, .icon-button { min-height: 2.7rem; border-radius: 5px; font-weight: 800; }
.primary-button { padding: .75rem 1.15rem; border: 1px solid var(--accent); color: white; background: var(--accent); }
.primary-button:hover { border-color: var(--accent-dark); background: var(--accent-dark); }
.login-form > .primary-button { width: 100%; margin-top: 1.5rem; }
.secondary-button { padding: .68rem 1rem; border: 1px solid var(--line); color: var(--ink); background: var(--surface); }
.secondary-button:hover { border-color: var(--forest-2); }
.icon-button { width: 2.7rem; border: 1px solid var(--line); background: white; display: none; place-items: center; padding: 0; font-size: 1.15rem; }
.form-error { min-height: 1.3rem; margin: .75rem 0 0; color: #a72d1b; font-size: .84rem; }
.system-note { display: flex; align-items: center; gap: .7rem; margin-top: 2rem; padding-top: 1.3rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 16rem minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.5rem 1rem; color: white; background: var(--navy); }
.nav-label { margin: 1.4rem .8rem .5rem; color: #8fa5c9; font-size: .66rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.nav-item { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: .8rem; border: 0; border-left: 3px solid transparent; color: #c2cfe6; background: transparent; text-align: left; }
.nav-item:hover { color: white; background: rgba(255,255,255,.07); }
.nav-item.active { border-left-color: var(--gold); color: white; background: rgba(255,255,255,.09); }
.nav-item small { color: #8fa5c9; font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-foot { display: flex; align-items: center; gap: .7rem; margin-top: auto; padding: 1rem .8rem .3rem; border-top: 1px solid rgba(255,255,255,.14); color: #9db1d4; font-size: .75rem; }
.workspace { min-width: 0; }
.topbar { min-height: 6rem; display: flex; align-items: center; gap: 1rem; padding: 1rem clamp(1.2rem, 4vw, 3.5rem); border-bottom: 1px solid var(--line); border-top: 3px solid var(--navy); background: rgba(242, 245, 250, .94); }
.topbar h1 { margin: 0; font-size: 1.65rem; font-weight: 600; }
.account { display: flex; align-items: center; gap: 1rem; margin-left: auto; text-align: right; }
.account strong, .account small { display: block; }
.account small { margin-top: .2rem; color: var(--muted); font-size: .65rem; letter-spacing: .08em; }
.content { padding: clamp(1.4rem, 4vw, 3.5rem); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.section-heading h2 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.35rem); font-weight: 600; letter-spacing: -.02em; }
.section-heading .muted { max-width: 42rem; margin: .5rem 0 0; line-height: 1.6; }
.section-heading.compact { margin-bottom: 1.1rem; }
.section-heading.compact h2 { font-size: 1.35rem; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.metric { min-width: 0; padding: 1.4rem; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span, .metric small { display: block; color: var(--muted); }
.metric span { font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.metric strong { display: block; margin: .45rem 0 .3rem; font-size: 2.5rem; font-weight: 600; }
.metric small { font-size: .76rem; }
.metric.warning strong { color: var(--warning); }
.dashboard-grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: 1.25rem; margin-top: 1.25rem; }
.data-section { min-width: 0; padding: 1.5rem; border: 1px solid var(--line); background: var(--surface); }
.role-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.role-row:last-child { border-bottom: 0; }
.role-row strong { display: block; font-size: .9rem; }
.role-row small { color: var(--muted); }
.role-count { display: grid; place-items: center; min-width: 2rem; height: 2rem; border-radius: 50%; color: var(--forest); background: #e9ece8; font-weight: 800; }
.activity-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .8rem; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.activity-row:last-child { border-bottom: 0; }
.activity-state { width: .65rem; height: .65rem; border-radius: 50%; background: var(--success); }
.activity-state.failed { background: var(--warning); }
.activity-row strong, .activity-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-row strong { font-size: .84rem; }
.activity-row small, .activity-time { color: var(--muted); font-size: .72rem; }
.sessions-list { border: 1px solid var(--line); background: var(--surface); }
.session-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--line); }
.session-row:last-child { border-bottom: 0; }
.session-row strong, .session-row small { display: block; }
.session-row small { margin-top: .25rem; color: var(--muted); }
.danger-button { align-self: center; padding: .55rem .75rem; border: 1px solid #e4b1a7; border-radius: 4px; color: #9d2b18; background: #fff6f4; font-weight: 800; }
.empty { padding: 2rem; color: var(--muted); text-align: center; }
.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; }
.search-bar { display: grid; grid-template-columns: minmax(15rem, 32rem) auto auto; gap: .6rem; margin-bottom: 1rem; }
.search-bar input { min-height: 2.7rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }
.users-table { width: 100%; border-collapse: collapse; min-width: 48rem; }
.users-table th { padding: .8rem 1rem; color: var(--muted); background: #eeece6; font-size: .7rem; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
.users-table td { padding: 1rem; border-top: 1px solid var(--line); vertical-align: middle; }
.users-table strong, .users-table small { display: block; }
.users-table small { margin-top: .2rem; color: var(--muted); }
.status-badge { display: inline-block; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); background: #f4f3ee; font-size: .68rem; font-weight: 800; letter-spacing: .05em; }
.status-badge.active { color: #1d684c; border-color: #b8dacc; background: #edf8f3; }
.row-action { padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 4px; color: var(--forest); background: transparent; font-weight: 800; }
.dialog { width: min(94vw, 40rem); max-height: 90vh; padding: 0; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(10, 20, 16, .68); }
.dialog form { padding: 1.5rem; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 2rem; font-weight: 600; }
.dialog-close { display: grid; place-items: center; flex: 0 0 auto; font-size: 1.5rem; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid small { display: block; margin-top: .35rem; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .7rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.small-dialog { width: min(94vw, 30rem); }
.rescue-metrics { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 1.25rem; border: 1px solid var(--line); background: var(--forest); color: white; }
.rescue-metrics > div { padding: 1.1rem 1.25rem; border-right: 1px solid rgba(255,255,255,.14); }
.rescue-metrics > div:last-child { border-right: 0; }
.rescue-metrics span { display: block; color: #a9bbb3; font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.rescue-metrics strong { display: block; margin-top: .35rem; font-size: 2rem; font-weight: 600; }
.rescue-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(17rem, .7fr); gap: 1.25rem; }
.incident-board, .unit-board { min-width: 0; padding: 1.25rem; border: 1px solid var(--line); background: var(--surface); }
.incident-card { margin-bottom: .75rem; padding: 1rem; border: 1px solid var(--line); border-left: 4px solid #8d9691; background: white; }
.incident-card:last-child { margin-bottom: 0; }
.incident-card.priority-critical { border-left-color: #c72f1d; }
.incident-card.priority-high { border-left-color: #e97a2c; }
.incident-card.priority-medium { border-left-color: #d1a934; }
.incident-top, .incident-actions { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.incident-code { font-size: .75rem; font-weight: 900; letter-spacing: .06em; }
.priority-label { font-size: .66rem; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.incident-card h3 { margin: .65rem 0 .25rem; font-size: 1rem; }
.incident-card p { margin: .35rem 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.incident-meta { display: flex; flex-wrap: wrap; gap: .5rem 1rem; padding: .7rem 0; color: var(--muted); font-size: .72rem; }
.incident-actions { align-items: end; margin-top: .5rem; padding-top: .7rem; border-top: 1px solid var(--line); }
.incident-actions select { width: auto; min-height: 2.25rem; padding: .35rem 2rem .35rem .55rem; font-size: .75rem; }
.incident-actions .primary-button { min-height: 2.25rem; padding: .4rem .7rem; font-size: .75rem; }
.unit-row { padding: .85rem 0; border-bottom: 1px solid var(--line); }
.unit-row:last-child { border-bottom: 0; }
.unit-row-head { display: flex; justify-content: space-between; gap: .5rem; }
.unit-row strong, .unit-row small { display: block; }
.unit-row small { margin-top: .25rem; color: var(--muted); }
.unit-status { font-size: .64rem; font-weight: 900; letter-spacing: .06em; }
.unit-status.available { color: var(--success); }
.unit-status.dispatched { color: var(--warning); }
.mobility-summary { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 1.25rem; border: 1px solid var(--line); background: var(--surface); }
.mobility-summary > div { padding: 1rem 1.25rem; border-right: 1px solid var(--line); }
.mobility-summary > div:last-child { border-right: 0; }
.mobility-summary span, .mobility-summary strong { display: block; }
.mobility-summary span { color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.mobility-summary strong { margin-top: .35rem; font-size: 1.8rem; font-weight: 600; }
.trip-board { padding: 1.25rem; border: 1px solid var(--line); background: var(--surface); }
.trip-card { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(10rem, .7fr) auto; align-items: center; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.trip-card:last-child { border-bottom: 0; }
.trip-route strong, .trip-route small, .trip-capacity strong, .trip-capacity small { display: block; }
.trip-route strong { font-size: 1.2rem; font-weight: 600; }
.trip-route small, .trip-capacity small { margin-top: .3rem; color: var(--muted); }
.trip-price { margin-top: .4rem; color: var(--forest); font-weight: 800; }
.capacity-track { width: 100%; height: .35rem; margin-top: .5rem; border: 0; background: #e1e3df; accent-color: var(--accent); }
.seat-fieldset { margin: 1.2rem 0; padding: 1rem; border: 1px solid var(--line); }
.seat-fieldset legend { padding: 0 .4rem; font-weight: 800; }
.seat-map { display: grid; grid-template-columns: repeat(5, 2.5rem); gap: .45rem; justify-content: center; }
.seat { min-height: 2.5rem; border: 1px solid #9ea8a3; border-radius: 4px; color: var(--forest); background: white; font-size: .75rem; font-weight: 800; }
.seat:nth-child(5n+3) { margin-left: .7rem; }
.seat.occupied { color: #8d918f; border-color: #d7d8d4; background: #e9e9e6; }
.seat.selected { color: white; border-color: var(--accent); background: var(--accent); }
.fare-preview { padding: .8rem 1rem; border-left: 3px solid var(--accent); background: #f3f1eb; font-size: .82rem; line-height: 1.6; }
.ticket { padding: 1.5rem; text-align: center; }
.ticket h2 { margin: 0; font-size: 2rem; }
.ticket-details { margin: 1rem 0; color: var(--muted); line-height: 1.7; }
.qr-placeholder { display: grid; place-items: center; width: 8rem; height: 8rem; margin: 1rem auto; border: .6rem solid var(--navy); color: var(--navy); background: repeating-linear-gradient(45deg, #fff 0 5px, #0d1b2e 5px 10px); font-weight: 900; }
.finance-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.payment-row, .transaction-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .8rem; align-items: center; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.payment-row:last-child, .transaction-row:last-child { border-bottom: 0; }
.payment-row strong, .payment-row small, .transaction-row strong, .transaction-row small { display: block; }
.payment-row small, .transaction-row small { margin-top: .25rem; color: var(--muted); }
.transaction-amount { text-align: right; }
.variance { color: var(--warning); }
.portal-hero { margin-bottom: 1.5rem; padding: clamp(1.5rem, 5vw, 3.5rem); color: white; background: var(--forest); }
.portal-hero h2 { max-width: 16ch; margin: 0; font-size: clamp(2.5rem, 6vw, 4.5rem); font-weight: 600; line-height: 1; letter-spacing: -.03em; }
.portal-hero > p:last-child { max-width: 40rem; margin: 1rem 0 0; color: #bdcbc5; line-height: 1.7; }
.portal-trip-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.portal-trip { padding: 1.25rem; border: 1px solid var(--line); background: var(--surface); }
.portal-trip-head { display: flex; justify-content: space-between; gap: 1rem; }
.portal-trip h3 { margin: .5rem 0; font-size: 1.5rem; font-weight: 600; }
.portal-trip p { margin: .35rem 0; color: var(--muted); font-size: .82rem; }
.portal-trip-foot { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.portal-price strong, .portal-price small { display: block; }
.portal-price strong { font-size: 1.1rem; }
.portal-price small { margin-top: .2rem; color: var(--muted); }
.my-booking { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; padding: 1.25rem; border: 1px solid var(--line); border-bottom: 0; background: var(--surface); }
.my-booking:last-child { border-bottom: 1px solid var(--line); }
.my-booking h3 { margin: 0 0 .35rem; font-size: 1.25rem; font-weight: 600; }
.my-booking p { margin: .3rem 0; color: var(--muted); font-size: .82rem; }
.ticket-status { text-align: right; }
.ticket-status strong, .ticket-status small { display: block; }
.ticket-status small { margin-top: .3rem; color: var(--muted); }
.tracking-layout { display: grid; grid-template-columns: 1.2fr .8fr; gap: 1.25rem; }
.tracking-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .75rem; align-items: center; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.tracking-row:last-child { border-bottom: 0; }
.tracking-row strong, .tracking-row small { display: block; }
.tracking-row small { margin-top: .25rem; color: var(--muted); }
.signal { font-size: .66rem; font-weight: 900; letter-spacing: .06em; }
.signal.live { color: var(--success); }
.signal.stale, .signal.no_signal { color: var(--warning); }
.sos-button, .sos-confirm { margin-top: 1.25rem; min-height: 3rem; padding: .75rem 1rem; border: 1px solid #ff826c; border-radius: 5px; color: white; background: #bd2e1b; font-weight: 900; }
.sos-button:hover, .sos-confirm:hover { background: #9e2111; }
.full-button { width: 100%; margin-top: .75rem; }
.panic-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-left: 4px solid #bd2e1b; background: var(--surface); margin-bottom: .75rem; }
.panic-row h3 { margin: 0 0 .4rem; font-size: 1rem; }
.panic-row p { margin: .25rem 0; color: var(--muted); font-size: .82rem; }
.my-alert { margin-bottom: 1rem; padding: .8rem 1rem; border-left: 4px solid #bd2e1b; background: #fff0ed; font-size: .84rem; }
.coming { max-width: 43rem; padding: clamp(2rem, 6vw, 5rem); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.coming h2 { margin: 0; font-size: clamp(2.3rem, 6vw, 4.6rem); font-weight: 600; line-height: 1; letter-spacing: -.03em; }
.coming p:not(.eyebrow) { margin: 1.4rem 0; color: var(--muted); line-height: 1.75; }
.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; max-width: 24rem; padding: .8rem 1rem; border-radius: 4px; color: white; background: var(--forest); box-shadow: var(--shadow); opacity: 0; transform: translateY(1rem); pointer-events: none; transition: .2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1000px) {
  .login-shell { grid-template-columns: 1fr 1fr; }
  .story-copy h1 { font-size: clamp(2.7rem, 7vw, 4.5rem); }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .rescue-layout { grid-template-columns: 1fr; }
  .rescue-metrics { grid-template-columns: 1fr 1fr; }
  .rescue-metrics > div:nth-child(2) { border-right: 0; }
  .rescue-metrics > div:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,.14); }
  .finance-layout { grid-template-columns: 1fr; }
  .tracking-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .login-shell { display: block; background: var(--surface); }
  .login-story { min-height: auto; padding: 1.3rem; }
  .story-copy, .story-foot { display: none; }
  /* The panel fills the viewport minus BOTH the story strip and the new
     controls header above it. It previously subtracted only the story strip,
     so adding the header would have left the form panel overflowing the fold by
     the header's height. */
  .login-panel { min-height: calc(100vh - 4.8rem - var(--topbar-height, 64px)); padding: 1.4rem; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; z-index: 50; width: min(19rem, 86vw); transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .icon-button { display: block; }
  .topbar { min-height: 5rem; padding: .8rem 1rem; }
  .topbar .eyebrow, .account > div { display: none; }
  .content { padding: 1.2rem 1rem 2rem; }
  .section-heading { align-items: start; }
  .section-heading > button { flex: 0 0 auto; }
  .users-heading { align-items: end; }
  .search-bar { grid-template-columns: minmax(0, 1fr) auto; }
  .search-bar #clear-user-search { grid-column: 1 / -1; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { padding: 1rem; }
  .metric strong { font-size: 2rem; }
  .trip-card { grid-template-columns: 1fr; align-items: start; }
  .portal-trip-list { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  .account .secondary-button { padding: .6rem .7rem; }
  .metric-grid { display: block; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .activity-row { grid-template-columns: auto minmax(0, 1fr); }
  .activity-time { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .rescue-metrics { grid-template-columns: 1fr 1fr; }
  .rescue-metrics > div { padding: .8rem; }
  .incident-top, .incident-actions { align-items: stretch; flex-direction: column; }
  .incident-actions select { width: 100%; }
  .mobility-summary { grid-template-columns: 1fr; }
  .mobility-summary > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .mobility-summary > div:last-child { border-bottom: 0; }
  .seat-map { grid-template-columns: repeat(5, 2.2rem); }
  .my-booking { grid-template-columns: 1fr; }
  .ticket-status { text-align: left; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* Rescue subscriptions, receipts, audit and portal membership.
   Appended with the panels that introduced them. */

.fee-breakdown { border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; margin: 0 0 1rem; background: var(--surface-soft, #fbfcfd); }
.fee-line { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; font-size: .95rem; }
.fee-line.total { border-top: 2px solid var(--navy, #10233f); margin-top: .4rem; padding-top: .6rem; font-weight: 700; }
.fee-line.subtle { color: #5a6a80; font-size: .88rem; }
.fee-breakdown .eyebrow { margin: .8rem 0 .2rem; }

.detail-list { display: grid; gap: .5rem; margin: 1rem 0; }
.detail-list div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); padding-bottom: .4rem; }
.detail-list dt { color: #5a6a80; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.detail-list dd { margin: 0; text-align: right; word-break: break-all; }
.detail-body pre { max-height: 14rem; overflow: auto; background: #0f1b2a; color: #d7e2f0; padding: .7rem; border-radius: 8px; font-size: .78rem; }
.activity-row.unread { border-left: 3px solid #d8a712; }
.users-table tbody tr[role="button"] { cursor: pointer; }
.users-table tbody tr[role="button"]:hover { background: #f4f7fa; }
.users-table td small { display: block; color: #5a6a80; font-size: .78rem; }

.auth-links { display: flex; gap: 1rem; margin-top: .8rem; flex-wrap: wrap; }
.form-success { color: #1c6b46; font-size: .9rem; margin-top: .6rem; }
label.check { display: flex; gap: .5rem; align-items: flex-start; font-size: .9rem; margin-top: .5rem; }
label.check input { width: auto; }
.login-form .form-grid { margin-top: .4rem; }
@media (max-width: 640px) { .detail-list div { flex-direction: column; } .detail-list dd { text-align: left; } }

/* ---------------------------------------------------- Smart Bus v2 surfaces */
.boarding-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 0.6rem 1rem; margin: 0.7rem 0; padding: 0.7rem 0.9rem;
  border: 1px solid var(--line, rgba(148, 163, 184, 0.25)); border-radius: 10px;
  background: rgba(15, 23, 42, 0.35);
}
.boarding-grid > div { display: flex; flex-direction: column; gap: 0.15rem; }
.boarding-grid span { font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: #94a3b8; }
.boarding-grid strong { font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.boarding-grid em { font-style: normal; font-size: 0.8rem; color: #cbd5f5; font-variant-numeric: tabular-nums; }
.boarding-phase p { margin: 0.2rem 0 0; font-size: 0.78rem; }
.trip-boarding { margin: 0.2rem 0; }
.trip-actions { display: flex; flex-direction: column; gap: 0.4rem; }

.badge-row { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.4rem 0; }
.badge { font-size: 0.68rem; letter-spacing: 0.04em; padding: 0.2rem 0.5rem; border-radius: 4px; border: 1px solid; }
.badge-rescue { color: #7dd3fc; border-color: rgba(125, 211, 252, 0.45); background: rgba(14, 165, 233, 0.12); }
.badge-gps { color: #86efac; border-color: rgba(134, 239, 172, 0.4); background: rgba(34, 197, 94, 0.1); }
.badge-verified { color: #c4b5fd; border-color: rgba(196, 181, 253, 0.4); background: rgba(139, 92, 246, 0.12); }

.manifest-summary, .mobility-summary { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0.8rem 0; }
.manifest-summary > div, .mobility-summary > div {
  flex: 1 1 7rem; padding: 0.7rem 0.9rem; border-radius: 10px;
  border: 1px solid var(--line, rgba(148, 163, 184, 0.25));
}
.manifest-summary span, .mobility-summary span {
  display: block; font-size: 0.68rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: #94a3b8;
}
.manifest-summary strong, .mobility-summary strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }

.safety-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.6rem 1.5rem; }
.safety-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; border-bottom: 1px dashed rgba(148, 163, 184, 0.18); }
.safety-row span { color: #94a3b8; font-size: 0.82rem; }
.safety-row strong { font-size: 0.85rem; letter-spacing: 0.03em; }
.safety-online, .safety-active, .safety-ready, .safety-verified, .safety-synced { color: #86efac; }
.safety-offline, .safety-degraded, .safety-critical { color: #fca5a5; }
.safety-unknown, .safety-partial, .warning { color: #fcd34d; }

.insight-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; margin-top: 1rem; }
.insight { border: 1px solid var(--line, rgba(148, 163, 184, 0.25)); border-radius: 10px; padding: 0.8rem 0.9rem; }
.insight h3 { margin: 0 0 0.5rem; font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; color: #cbd5f5; }
.pill { font-size: 0.7rem; padding: 0.15rem 0.45rem; border-radius: 4px; border: 1px solid; }
.pill-ok { color: #86efac; border-color: rgba(134, 239, 172, 0.4); }
.pill-wait { color: #cbd5f5; border-color: rgba(203, 213, 245, 0.3); }
.pill-bad { color: #fca5a5; border-color: rgba(252, 165, 165, 0.4); }
.field-label { display: block; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: #94a3b8; margin-bottom: 0.25rem; }
.trip-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.4rem 1rem; margin: 0.6rem 0 0; }
.trip-facts dt { font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: #94a3b8; }
.trip-facts dd { margin: 0; font-size: 0.86rem; }

/* ------------------------------------------------ Multi-domain operations */
.domain-switch { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.6rem 0 1rem; }
.domain-tab {
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 0.35rem 0.7rem;
  border: 1px solid var(--line, rgba(148, 163, 184, 0.25)); background: transparent;
  color: #cbd5f5; border-radius: 6px; cursor: pointer;
}
.domain-tab.active { border-color: rgba(201, 162, 39, 0.7); color: #f5d67c; background: rgba(201, 162, 39, 0.1); }
.domain-kpis { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.8rem 0 1.2rem; }
.domain-kpis > div {
  flex: 1 1 7.5rem; padding: 0.6rem 0.8rem; border: 1px solid var(--line, rgba(148, 163, 184, 0.22)); border-radius: 8px;
}
.domain-kpis span { display: block; font-size: 0.66rem; letter-spacing: 0.07em; text-transform: uppercase; color: #94a3b8; }
.domain-kpis strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.domain-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 1.1rem; }
.domain-list { display: flex; flex-direction: column; gap: 0.6rem; }
.domain-asset, .domain-incident {
  border: 1px solid var(--line, rgba(148, 163, 184, 0.22)); border-radius: 8px; padding: 0.7rem 0.8rem;
}
.domain-incident.severity-critical { border-left: 3px solid #fca5a5; }
.domain-incident.severity-high { border-left: 3px solid #fcd34d; }
.domain-incident.severity-medium, .domain-incident.severity-low { border-left: 3px solid rgba(148, 163, 184, 0.5); }
.domain-asset-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.8rem; }
.domain-asset-head h3 { margin: 0; font-size: 0.95rem; }
.domain-asset-head p { margin: 0.15rem 0 0; font-size: 0.8rem; }
.domain-subhead { margin: 1.1rem 0 0.4rem; font-size: 0.76rem; letter-spacing: 0.08em; text-transform: uppercase; color: #cbd5f5; }
.domain-alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.domain-alert { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; font-size: 0.82rem; }
.domain-alert small { color: #94a3b8; }
.domain-kpi-block h3 { margin: 0 0 0.5rem; font-size: 0.78rem; letter-spacing: 0.07em; text-transform: uppercase; color: #cbd5f5; }
.domain-bars { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.domain-bars li { display: grid; grid-template-columns: 9rem 1fr auto; align-items: center; gap: 0.5rem; font-size: 0.82rem; }
/* The bar fill was a raw #c9a227 and the track a raw rgba(148,163,184,.15),
   both outside tokens.css -- which the design system forbids, and which meant
   neither could follow a theme switch. Gold is already the documented chart
   emphasis series, and --chart-grid is already the "faint chart line" token, so
   the bar is now on the same semantic layer as every other chart. */
.domain-bars i { display: block; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--chart-2) var(--bar, 0%), var(--chart-grid) var(--bar, 0%)); }
