/* ============================================================
   ASX Analyser Portal — Quiet Ledger
   Component stylesheet. Tokens come from tokens.css.
   BEM-ish: .block, .block__elem, .block--mod
   No preprocessor. No build. Pure CSS.
   ============================================================ */

/* ─── Self-hosted IBM Plex (place .woff2 in /static/fonts/) ─── */
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/IBMPlexSans-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/IBMPlexSans-Medium.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/IBMPlexSans-SemiBold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/IBMPlexMono-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/IBMPlexMono-Medium.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/IBMPlexMono-SemiBold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Serif";
  src: url("/static/fonts/IBMPlexSerif-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Serif";
  src: url("/static/fonts/IBMPlexSerif-Medium.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}

/* ─── Global reset ─── */
*, *::before, *::after { box-sizing: border-box; }

/* ─── Topbar / shell ─── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar__left { display: flex; align-items: center; gap: 32px; }
.topbar__right { display: flex; align-items: center; gap: 16px; }

.topbar__burger {
  display: none;
  background: transparent;
  border: 0;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.topbar__burger:hover { background: var(--surface-alt); }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.brand__name {
  font-family: var(--font-serif);
  font-size: var(--fs-brand);
  font-weight: 500;
  letter-spacing: -0.2px;
}
.brand__mark { color: var(--text); }

/* ─── Primary nav ─── */
.nav { display: flex; gap: 4px; align-items: center; }
.nav__item {
  position: relative;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: 400;
  color: var(--text-dim);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color var(--t-fast);
}
.nav__item:hover { color: var(--text); }
.nav__item--active { color: var(--text); font-weight: 500; }
.nav__item--active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  background: var(--text);
}

/* ─── Badge / pill ─── */
.badge {
  font-family: var(--font-mono);
  font-size: var(--fs-badge);
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
  line-height: 1.4;
}
.badge--signal { background: var(--signal); color: #fff; }
[data-theme="dark"] .badge--signal { color: #16161a; }

.pill {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: var(--fs-mono-tiny);
  font-weight: 500;
  letter-spacing: 0;
}
.pill--quoted { color: var(--quoted); }
.pill--unquoted { color: var(--unquoted); }

/* ─── Clock + account ─── */
.clock {
  font-family: var(--font-mono);
  font-size: var(--fs-mono-tiny);
  color: var(--text-muted);
  letter-spacing: 0.4px;
}

.account { position: relative; }
.account__summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
}
.account__summary::-webkit-details-marker { display: none; }
.avatar {
  width: 28px; height: 28px;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.account__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 0;
  z-index: 40;
}
.account__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.account__name { font-size: 13px; font-weight: 500; color: var(--text); }
.account__email { font-size: 12px; color: var(--text-dim); }
.account__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: 0;
  text-align: left;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.account__item:hover { background: var(--surface-alt); }
.account__hint { font-size: 12px; color: var(--text-muted); }
.account__form { margin: 0; }
.account__item--danger { color: var(--text); }

/* ─── Iconbutton + helpers ─── */
.iconbtn {
  background: transparent;
  border: 0;
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.iconbtn:hover { background: var(--surface-alt); }
.icon { display: block; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: var(--fs-button);
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.btn:disabled { cursor: default; }
.btn--primary { background: var(--text); color: var(--bg); }
.btn--primary:hover { background: var(--text); opacity: 0.92; }
.btn--muted { background: var(--surface-alt); color: var(--text-muted); cursor: default; }
.btn--ghost { color: var(--text-dim); }
.btn--ghost:hover { color: var(--text); background: var(--surface-alt); }
.btn--outline { border-color: var(--border); color: var(--text); background: var(--surface); }
.btn--outline:hover { border-color: var(--border-strong); }
.btn--link { background: transparent; padding: 0 4px; color: var(--text-dim); }
.btn--link:hover { color: var(--text); text-decoration: underline; }
.btn--block { width: 100%; height: 36px; }

/* ─── Page chrome ─── */
.main { display: block; }
.page { display: block; }
.page-head {
  padding: 32px 32px 20px;
  border-bottom: 1px solid var(--rule);
}
.page-head__row {
  display: flex;
  align-items: baseline;
  gap: 24px;
  flex-wrap: wrap;
}
.page-head__title {
  font-family: var(--font-serif);
  font-size: var(--fs-h1);
  font-weight: 500;
  letter-spacing: -0.6px;
  color: var(--text);
  margin: 0 0 4px;
}
.page-head__meta {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
}
.page-head__meta strong { font-weight: 600; color: var(--text); }
.page-head__lede {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  color: var(--text-dim);
  max-width: 640px;
  margin: 0 0 18px;
  line-height: 1.5;
}
.breadcrumb {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 8px;
}

/* ─── Filter bar (desktop) ─── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.filter-bar__group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.filter-bar__group--grow { flex: 0 1 280px; }
.filter-bar__group--cluster { gap: 6px; }
.filter-bar__label {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.filter-bar__sep { color: var(--text-muted); font-size: 12px; }
.filter-bar__spacer { flex: 1; }
.filter-bar__mobile-trigger { display: none; }

.search {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 220px;
  width: 100%;
  transition: border-color var(--t-fast);
}
.search:focus-within { border-color: var(--border-strong); }
.icon--search { color: var(--text-muted); }
.search__input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  color: var(--text);
  padding: 0;
  min-width: 0;
}
.search__input::placeholder { color: var(--text-muted); }

/* ─── Segmented control ─── */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.segmented__btn {
  background: transparent;
  border: 0;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  border-left: 1px solid var(--border);
  transition: background var(--t-fast), color var(--t-fast);
}
.segmented__btn:first-child { border-left: 0; }
.segmented__btn:hover { color: var(--text); }
.segmented__btn--active {
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 500;
}
.segmented--block { display: flex; width: 100%; }
.segmented--block .segmented__radio {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  border-left: 1px solid var(--border);
}
.segmented--block .segmented__radio:first-child { border-left: 0; }
.segmented--block input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented--block input[type="radio"]:checked + span {
  font-weight: 500;
  color: var(--text);
}
.segmented--block .segmented__radio:has(input:checked) {
  background: var(--surface-alt);
}

/* ─── Field / input ─── */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field__label {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
}
.field__input {
  height: 36px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  color: var(--text);
  outline: 0;
  transition: border-color var(--t-fast);
}
.field__input:focus { border-color: var(--border-strong); }
.field__input--narrow { width: 88px; padding: 0 8px; height: 30px; font-size: 13px; }
.field__input[type="date"] { font-family: var(--font-mono); font-size: 12px; }

/* ─── Mark all + filter button states ─── */
.mark-all { /* base in .btn; modifiers above handle styling */ }

/* ─── Alert grid + alert row ─── */
.alert-grid { display: block; }

/* Hybrid alert row: <details>/<summary> grid that expands on click.
   Reverse-engineered from OLD/quiet-ledger.jsx (LedgerAlertItem).      */
details.alert-row {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  transition: background var(--t-fast);
}
details.alert-row:last-of-type { border-bottom: 0; }
details.alert-row:hover { background: var(--surface-alt); }
details.alert-row--unseen { background: color-mix(in srgb, var(--signal-soft) 40%, transparent); }
details.alert-row--unseen:hover { background: var(--signal-soft); }
details.alert-row--error { box-shadow: inset 3px 0 0 0 var(--signal); }

details.alert-row > summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: 20px 80px 110px 1fr 100px 32px;
  gap: 14px;
  padding: 12px 32px;
  align-items: center;
}
details.alert-row > summary::-webkit-details-marker { display: none; }
details.alert-row > summary::marker { content: ""; }

.alert-row__indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  justify-self: center;
}
.alert-row--unseen .alert-row__indicator {
  background: var(--signal);
  border: none;
}

.alert-row__code {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text);
}
.alert-row--seen .alert-row__code { font-weight: 500; color: var(--text-dim); }

.alert-row__label {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

.alert-row__title {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.alert-row--seen .alert-row__title { color: var(--text-dim); font-weight: 400; }

.alert-row__time {
  font-family: var(--font-mono);
  font-size: var(--fs-mono-meta);
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.alert-row__mark {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
.alert-row__mark:hover { color: var(--text); background: var(--surface-alt); }
.alert-row__mark:disabled { cursor: default; opacity: 0.6; }
.alert-row__mark--retry {
  border: 1px solid var(--signal);
  background: var(--signal-soft);
  color: var(--signal);
}

/* Expanded panel - aligned with the title column (20+80+110+gap*3 = 252-ish; use 146 to match the JSX) */
.alert-row__expanded {
  padding: 0 32px 18px 146px;
}
.alert-row__message {
  margin: 0;
  padding: 14px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  white-space: pre-wrap;
  line-height: 1.6;
}
.alert-row__expanded-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* Error meta (kept in case templates re-introduce inline error chips) */
.meta-error {
  font-family: var(--font-sans);
  font-size: var(--fs-mono-tiny);
  color: var(--signal);
}
.meta-error__retry {
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--signal);
  text-decoration: underline;
  cursor: pointer;
}

/* Pagination footer */
.alert-grid__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 32px;
  border-top: 1px solid var(--rule);
  flex-wrap: wrap;
}
.alert-grid__foot-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-mono-meta);
  color: var(--text-dim);
}
.alert-grid__foot-meta strong { color: var(--text); }
.alert-grid__foot-actions { display: flex; gap: 8px; }

/* ─── Empty state ─── */
.empty-state {
  padding: 64px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty-state__title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
}
.empty-state__body {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 12px;
  max-width: 360px;
}

/* ─── Reports landing card ─── */
.report-grid {
  padding: 24px 32px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}
.report-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--t-fast);
}
.report-card:hover { border-color: var(--border-strong); }
.report-card__title {
  font-family: var(--font-serif);
  font-size: var(--fs-h2);
  font-weight: 500;
  margin: 0;
}
.report-card__body {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
  max-width: 480px;
  line-height: 1.5;
}
.report-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.report-card__meta {
  font-family: var(--font-mono);
  font-size: var(--fs-mono-meta);
  color: var(--text-muted);
}
.report-card__cta {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}

/* ─── Active filter chips ─── */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--t-fast);
}
.chip:hover { border-color: var(--border-strong); }
.chip__x { color: var(--text-muted); font-size: 14px; line-height: 1; }
.chip--clear { border-color: transparent; color: var(--text-dim); padding-left: 6px; }
.chip--clear:hover { color: var(--text); border-color: transparent; text-decoration: underline; }

/* ─── Data table ─── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
}
.data-table__th {
  position: sticky;
  top: var(--header-h);
  z-index: 10;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: var(--fs-mono-tiny);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  text-align: left;
}
.data-table__th--right { text-align: right; }
.data-table__sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}
.data-table__sort:hover { color: var(--text); }
.data-table__sort--active { color: var(--text); }

.data-table__row { transition: background var(--t-fast); }
.data-table__row:hover { background: var(--surface-alt); }
.data-table__td {
  padding: 12px 24px;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}
.data-table__td--right { text-align: right; }
.data-table__td--dim { color: var(--text-dim); font-size: 12px; }

/* Tabular numerics */
.num {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.num--bold { font-weight: 600; }

/* Mobile card list — hidden until breakpoint */
.card-list { display: none; list-style: none; padding: 0; margin: 0; }

/* ─── Login ─── */
.login-body {
  background: var(--bg);
  min-height: 100vh;
}
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-card__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}
.login-card__title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
  text-align: center;
}
.login-card__subtitle {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  margin: 0 0 8px;
}
.login-card__error {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--signal);
  margin: 0;
  text-align: center;
}
.login-card__submit { position: relative; }
.login-card__submit-busy {
  display: none;
  align-items: center;
  gap: 8px;
}
.login-card.is-busy .login-card__submit-default { display: none; }
.login-card.is-busy .login-card__submit-busy { display: inline-flex; }
.login-card.is-busy .login-card__submit { opacity: 0.7; pointer-events: none; }
.login-card__foot {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin: 8px 0 0;
}

/* ─── Spinner ─── */
.spinner {
  width: 12px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── CSV download busy state ─── */
.csv-download__busy { display: none; align-items: center; gap: 6px; }
.csv-download.is-busy .csv-download__default { display: none; }
.csv-download.is-busy .csv-download__busy { display: inline-flex; }
.csv-download.is-busy { pointer-events: none; opacity: 0.85; }

/* ─── Drawer ─── */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 29, 24, 0.4);
  opacity: 0;
  transition: opacity 200ms ease;
}
.drawer.drawer--open .drawer__backdrop { opacity: 1; }
.drawer__panel {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 200ms ease;
}
.drawer--left .drawer__panel {
  top: 0; bottom: 0; left: 0;
  width: 320px;
  transform: translateX(-100%);
  border-top: 0; border-bottom: 0; border-left: 0;
}
.drawer--left.drawer--open .drawer__panel { transform: translateX(0); }
.drawer--bottom .drawer__panel {
  left: 0; right: 0; bottom: 0;
  height: 80vh;
  border-radius: 12px 12px 0 0;
  border-bottom: 0; border-left: 0; border-right: 0;
  transform: translateY(100%);
}
.drawer--bottom.drawer--open .drawer__panel { transform: translateY(0); }

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
}
.drawer__title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  margin: 0;
}
.drawer__nav { display: flex; flex-direction: column; padding: 8px 0; }
.drawer__nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-dim);
  text-decoration: none;
  min-height: 44px;
}
.drawer__nav-item:hover { background: var(--surface-alt); color: var(--text); }
.drawer__nav-item--active { color: var(--text); font-weight: 500; }

.drawer__meta {
  padding: 12px 20px;
  border-top: 1px solid var(--rule);
}
.drawer__account { padding-top: 8px; border-top: 1px solid var(--rule); }
.drawer__account .account__header { border-bottom: 0; }
.drawer__foot {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--rule);
  margin-top: auto;
  background: var(--surface);
  position: sticky;
  bottom: 0;
}
.drawer__foot .btn { flex: 1; height: 40px; }
.filter-sheet {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  width: 100%;
  max-width: 100%;
}
.filter-sheet .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.filter-sheet .field__input { width: 100%; max-width: 100%; }
.filter-sheet__range {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.filter-sheet__range > .field__input { flex: 1 1 0; min-width: 0; width: auto; }
.filter-sheet__sep { color: var(--text-muted); font-size: 12px; flex: 0 0 auto; }

/* ─── Modal ─── */
.modal {
  width: 420px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 32px;
  color: var(--text);
}
.modal::backdrop { background: rgba(31, 29, 24, 0.4); }
[data-theme="dark"] .modal::backdrop { background: rgba(0, 0, 0, 0.6); }
.modal__title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 8px;
}
.modal__body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-dim);
  margin: 0 0 24px;
  line-height: 1.5;
}
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ─── Mobile breakpoint ─── */
@media (max-width: 768px) {
  .topbar { padding: 0 16px; }
  .topbar__left { gap: 12px; }
  .topbar__burger { display: inline-flex; }
  .nav--primary { display: none; }
  .clock { display: none; }

  .page-head { padding: 20px 16px 16px; }
  .page-head__title { font-size: 26px; }

  /* Filter bar collapses to one input + a "Filters" button */
  .filter-bar > .filter-bar__group:not(.filter-bar__group--grow) { display: none; }
  .filter-bar__mobile-trigger { display: inline-flex; }
  .filter-bar__group--grow { flex: 1 1 100%; }
  .filter-bar__spacer { display: none; }

  /* Alert row mobile: drop the "New options" label column, shrink time. */
  details.alert-row > summary {
    grid-template-columns: 16px 64px 1fr 72px 28px;
    gap: 10px;
    padding: 12px 16px;
  }
  .alert-row__label { display: none; }
  .alert-row__time { font-size: 11px; }
  .alert-row__expanded { padding: 0 16px 16px 90px; }
  .alert-grid__foot { padding: 16px; }

  .report-grid { padding: 16px; }

  /* Report: hide table, show card list */
  .table-wrap { display: none; }
  .card-list { display: flex; flex-direction: column; gap: 0; }
  .card-list__item {
    border-bottom: 1px solid var(--rule);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .card-list__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .card-list__company {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    margin: 0;
    color: var(--text);
  }
  .card-list__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
    margin: 4px 0 0;
  }
  .card-list__grid > div { display: flex; gap: 6px; }
  .card-list__grid dt {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    min-width: 48px;
  }
  .card-list__grid dd { margin: 0; font-family: var(--font-mono); font-size: 13px; color: var(--text); }
  .card-list__dim { color: var(--text-dim); font-family: var(--font-sans); font-size: 12px; }

  .login-card { padding: 32px 24px; }
  .modal { padding: 24px; }
}

/* ─── Print ─── */
@media print {
  .topbar, .filter-bar, .drawer, .modal, .btn, .alert-grid__foot { display: none !important; }
  .alert-row, .data-table__row { break-inside: avoid; }
}
