/* Breakpoints (MOBILE_PLAN.md §1), the only two widths a media query here may use, written
   desktop-first so desktop rules are never edited:
     phone   (max-width: 639.98px)    one column, lists as cards
     tablet  (max-width: 1023.98px)   phones too: the navigation drawer, 44px touch targets
   Desktop is 1024px and up. JS reads the same values from --bp-*-max
   (static/js/breakpoints.js), and tests/test_web/test_mobile_components.py refuses any other. */
:root {
  --bp-phone-max: 639.98px;
  --bp-tablet-max: 1023.98px;
  color-scheme: light dark;
  --border: #d0d5dd;
  --accent: #2563eb;            /* fills: buttons, counts, the selected tab; white text on it */
  --on-accent: #ffffff;
  --accent-text: #2563eb;       /* the accent as text, links and focus rings (colors.accent_text) */
  --link: var(--accent-text);
  --pay-bg: #15803d;
  --return-bg: #b91c1c;
  --danger: #dc2626;
  --ok: #16a34a;
  --bg: #ffffff;
  --bg-muted: #f3f4f6;
  --text: #111827;
  --text-muted: #374151;
  --text-faint: #6b7280;
  --badge-ok-bg: #dcfce7;
  --badge-ok-fg: #166534;
  --badge-warn-bg: #fef3c7;
  --badge-warn-fg: #92400e;
  --badge-danger-bg: #fee2e2;
  --badge-danger-fg: #991b1b;
}

/* Dark mode: system preference (unless the user forced light via the theme toggle)... */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-text: #5e8cf0;
    --border: #334155;
    --bg: #0f172a;
    --bg-muted: #1e293b;
    --text: #e5e7eb;
    --text-muted: #cbd5e1;
    --text-faint: #94a3b8;
    --badge-ok-bg: #14532d;
    --badge-ok-fg: #86efac;
    --badge-warn-bg: #78350f;
    --badge-warn-fg: #fcd34d;
    --badge-danger-bg: #7f1d1d;
    --badge-danger-fg: #fca5a5;
  }
}
/* ...or forced on regardless of system preference via the theme toggle (web/routers/theme.py). */
:root[data-theme="dark"] {
  --accent-text: #5e8cf0;
  --border: #334155;
  --bg: #0f172a;
  --bg-muted: #1e293b;
  --text: #e5e7eb;
  --text-muted: #cbd5e1;
  --text-faint: #94a3b8;
  --badge-ok-bg: #14532d;
  --badge-ok-fg: #86efac;
  --badge-warn-bg: #78350f;
  --badge-warn-fg: #fcd34d;
  --badge-danger-bg: #7f1d1d;
  --badge-danger-fg: #fca5a5;
}

* { box-sizing: border-box; }

/* One link colour, the accent's readable shade, underlined so colour isn't the only sign; no
   separate visited colour (UI_PLAN.md UI-D3). Components that style their own links (the
   navigation, buttons, tiles) still do. */
a { color: var(--link); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

.skip-link {
  position: absolute; top: -3rem; left: 0.5rem; z-index: 100;
  background: var(--accent); color: var(--on-accent); padding: 0.5rem 1rem; border-radius: 6px;
  text-decoration: none; font-size: 0.9rem;
  transition: top 0.1s ease-in;
}
.skip-link:focus { top: 0.5rem; }

.app-shell { display: flex; align-items: stretch; min-height: 100vh; }

.sidenav {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 0.2rem;
  width: 220px;
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--border);
}

.sidenav a { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; padding: 0.4rem 0.5rem; border-radius: 6px; display: flex; align-items: center; gap: 0.5rem; }
.sidenav a:hover { color: var(--accent-text); background: var(--bg-muted); }
.sidenav a.active { color: var(--accent-text); font-weight: 600; background: var(--bg-muted); }
.sidenav-header { display: flex; align-items: center; justify-content: space-between; }
.sidenav .brand {
  font-weight: 700; color: var(--accent-text); font-size: 1.25rem; display: flex; align-items: center;
  padding: 0 0.5rem; margin-bottom: 1.25rem; min-height: 48px;
}
.sidenav .brand-logo { max-height: 48px; max-width: 100%; display: block; }
.nav-toggle {
  display: none; background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-muted); cursor: pointer; padding: 0.4rem; flex-shrink: 0;
}
.nav-toggle:hover { color: var(--accent-text); border-color: var(--accent-text); }
.sidenav-panel { display: flex; flex-direction: column; flex: 1; gap: 0.2rem; min-height: 0; }
/* Which customer this session sees: a plain label, not a warning (UI_PLAN.md F8). */
.customer-scope-badge {
  margin: 0 0.5rem 1rem; padding: 0.3rem 0.5rem; font-size: 0.8rem; color: var(--text-muted);
  background: var(--bg-muted); border-radius: 6px;
}
.sidenav .nav-links { display: flex; flex-direction: column; gap: 0.2rem; }
.sidenav .nav-section {
  margin: 0.75rem 0.5rem 0.15rem; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--text-faint);
}
.sidenav .nav-links > .nav-section:first-child { margin-top: 0; }
.sidenav .nav-bottom {
  margin-top: auto; display: flex; flex-direction: column; gap: 0.2rem;
  border-top: 1px solid var(--border); padding-top: 0.75rem;
}
.sidenav .inline-form { display: block; }
.sidenav .link-button { display: block; width: 100%; text-align: left; padding: 0.4rem 0.5rem; border-radius: 6px; }
.sidenav .link-button:hover { color: var(--accent-text); background: var(--bg-muted); }

.page { flex: 1; min-width: 0; max-width: 1400px; margin: 0 auto; padding: 1.5rem; position: relative; }

.nav-close { display: none; }

/* The navigation drawer (static/js/app.js initNavToggle): below desktop, the sidebar is a bar
   with the brand and a menu button, and the links slide in from the left over the page. */
@media (max-width: 1023.98px) {
  .app-shell { flex-direction: column; min-height: 0; }
  .sidenav {
    position: relative; width: auto; flex-direction: column;
    border-right: none; border-bottom: 1px solid var(--border); padding: 0.5rem 1rem;
  }
  .sidenav .brand { margin-bottom: 0; min-height: 44px; }
  .nav-toggle { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; }
  .sidenav-panel {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: min(20rem, 85vw);
    background: var(--bg); border-right: 1px solid var(--border); box-shadow: 4px 0 16px rgba(0, 0, 0, 0.2);
    padding: 0.75rem 1rem 1rem; overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(-100%); visibility: hidden; transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }
  .sidenav-panel.open { transform: none; visibility: visible; transition: transform 0.2s ease; }
  .nav-close {
    display: flex; align-items: center; justify-content: center; align-self: flex-end; flex-shrink: 0;
    width: 44px; height: 44px; padding: 0; margin-bottom: 0.25rem;
    background: none; border: 1px solid var(--border); color: var(--text-muted);
  }
  .nav-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(17, 24, 39, 0.5); }
  body.nav-open { overflow: hidden; }
  .sidenav .nav-bottom { margin-top: 0.5rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
  .page { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .sidenav-panel, .sidenav-panel.open { transition: none; }
}

.card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.card-narrow { max-width: 480px; margin: 3rem auto; }

/* One heading scale (UI_PLAN.md UI-D4): a page's title, then its sections, then their parts.
   Before, h2 had no size and came out larger than the page's h1. */
h1 { margin-top: 0; font-size: 1.5rem; line-height: 1.25; }
h2 { font-size: 1.2rem; line-height: 1.3; margin: 1.25rem 0 0.75rem; }
.card > h2:first-child, .card > .toolbar h2 { margin-top: 0; }
h3 { font-size: 1rem; line-height: 1.35; margin: 1rem 0 0.5rem; }

label { display: block; margin-bottom: 0.9rem; font-size: 0.85rem; color: var(--text-muted); }
input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
}
input[type="checkbox"], input[type="radio"] {
  display: inline-block; width: auto; margin: 0 0.4rem 0 0; vertical-align: middle;
}

button, .button {
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
/* Secondary: outlined in the link colour, so it doesn't look disabled (UI_PLAN.md UI-D5). */
button.secondary, .button.secondary { background: transparent; color: var(--link); border: 1px solid var(--link); }
button.secondary:hover, .button.secondary:hover { background: var(--bg-muted); }
/* Disabled has a look of its own. */
button:disabled, .button[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
button.danger, .button.danger { background: var(--danger); }

.inline-form { display: inline; margin: 0; }
.link-button {
  background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0; font-size: 0.9rem;
}
.link-button:hover { color: var(--accent-text); }
/* WCAG 2.2 2.5.8 Target Size (Minimum): row actions are at least 24px at every width (44px below
   desktop, further down). */
:is(.cell-actions, [id$="-actions"]) :is(a, .link-button), .decision-note summary, td a[aria-label^="Edit "] {
  display: inline-flex; align-items: center; min-height: 24px; min-width: 24px;
}

.flash { padding: 0.6rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash-ok { background: var(--badge-ok-bg); color: var(--badge-ok-fg); }
.flash-error { background: var(--badge-danger-bg); color: var(--badge-danger-fg); }
.flash-warn { background: var(--badge-warn-bg); color: var(--badge-warn-fg); }
/* Legal/disclosure text quoted verbatim from configuration (settings/fraud_model.html). */
.disclosure { margin: 0 0 1rem; padding: 0.75rem 1rem; border-left: 3px solid var(--border); background: var(--bg-muted); white-space: pre-line; }
/* Used by several templates for secondary/help text but previously never defined. */
.hint, .text-muted { color: var(--text-muted); font-size: 0.85rem; }
label + .hint { margin: -0.5rem 0 0.9rem; }

/* templates/partials/_banner.html -- tenant/customer Markdown login+banner messages
(services/tenant_service.py::TenantBranding, db/tenancy.py::TenantContext). Deliberately
plainer than .card (no border, muted background) so it reads as an announcement strip,
not another content block. */
.banner-carousel { margin-bottom: 1rem; }
.banner-slide {
  padding: 0.6rem 1rem; border-radius: 6px; margin-bottom: 0.4rem;
  background: var(--bg-muted); border: 1px solid var(--border); font-size: 0.9rem;
}
.banner-slide > *:first-child { margin-top: 0; }
.banner-slide > *:last-child { margin-bottom: 0; }
.banner-dots { display: flex; gap: 0.4rem; justify-content: center; }
.banner-dot {
  width: 8px; height: 8px; padding: 0; border-radius: 999px; border: none;
  background: var(--border); cursor: pointer;
}
.banner-dot.active { background: var(--accent); }

/* Login page's pre-auth message (templates/auth/login.html) -- same visual language as
the post-login banner above, just scoped to .card-narrow's own width. */
.card-narrow .banner { padding: 0.6rem 1rem; border-radius: 6px; margin-bottom: 1rem; background: var(--bg-muted); border: 1px solid var(--border); font-size: 0.9rem; }
.card-narrow .banner > *:first-child { margin-top: 0; }
.card-narrow .banner > *:last-child { margin-bottom: 0; }

.text-muted { color: var(--text-muted); }

/* templates/_macros/markdown_editor.html -- a toolbar + textarea + live preview, used
by Settings → Messages (settings/sections/messages.html) and customers/banner.html. */
.md-editor { margin-bottom: 0.9rem; }
.md-editor-toolbar { display: flex; gap: 0.3rem; margin-top: 0.3rem; margin-bottom: 0.3rem; }
.md-editor-btn {
  background: var(--bg-muted); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.35rem; width: 2rem; height: 2rem;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.md-editor-btn:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
/* The generic `input, select, textarea { display: block; ... }` rule above has higher
specificity than the browser's own default `[hidden] { display: none }` UA rule, so
without this the file input's `hidden` attribute is silently overridden and it renders
as a visible native "Choose File" control right in the toolbar -- confirmed by actually
looking at a screenshot, not assumed. */
.md-editor-file-input { display: none; }
.md-editor-textarea { margin-top: 0; }
.md-editor-hint { font-size: 0.8rem; color: var(--text-faint); margin: 0.3rem 0 0.9rem; }
.md-editor-preview-label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.md-editor-preview {
  padding: 0.6rem 1rem; border-radius: 6px; background: var(--bg-muted); border: 1px solid var(--border);
  font-size: 0.9rem; min-height: 1.5rem;
}
.md-editor-preview > *:first-child { margin-top: 0; }
.md-editor-preview > *:last-child { margin-bottom: 0; }
.md-editor-preview img { max-width: 100%; height: auto; border-radius: 4px; }

table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--text-faint); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }

.table-search {
  display: block; width: 100%; max-width: 280px; margin-top: 0.75rem;
  padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem;
}
th.sortable-col .sort-button { all: unset; cursor: pointer; user-select: none; font: inherit; color: inherit; }
th.sortable-col .sort-button:hover { color: var(--accent-text); }
th.sortable-col .sort-button:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
th.sortable-col .sort-button::after { content: "\2195"; margin-left: 0.35rem; opacity: 0.35; }
th.sort-asc .sort-button::after { content: "\2191"; opacity: 1; }
th.sort-desc .sort-button::after { content: "\2193"; opacity: 1; }

.pagination {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem 1rem;
  margin-top: 1rem; font-size: 0.85rem; color: var(--text-faint);
}
.pagination .pagination-links { display: flex; gap: 0.5rem; align-items: center; }
.pagination a.button, .pagination span.button-disabled {
  padding: 0.35rem 0.75rem; font-size: 0.85rem;
}
.pagination span.button-disabled {
  border: 1px solid var(--border); color: var(--text-faint); border-radius: 6px; display: inline-block; cursor: not-allowed;
}

.badge {
  display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px;
  font-size: 0.75rem; background: var(--bg-muted); color: var(--text-muted);
}
.badge-ok { background: var(--badge-ok-bg); color: var(--badge-ok-fg); }
.badge-warn { background: var(--badge-warn-bg); color: var(--badge-warn-fg); }
.badge-danger { background: var(--badge-danger-bg); color: var(--badge-danger-fg); }

.perm-bar {
  display: inline-block; width: 80px; height: 6px; border-radius: 999px;
  background: var(--bg-muted); margin-left: 0.6rem; vertical-align: middle; overflow: hidden;
}
.perm-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.stat-cards { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat-card {
  flex: 1; min-width: 160px; border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.25rem;
  text-decoration: none; color: inherit;
}
.stat-card:hover { border-color: var(--accent-text); }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-card .stat-label { font-size: 0.85rem; color: var(--text-faint); }

.quick-links { list-style: none; padding: 0; }
.quick-links li { margin-bottom: 0.4rem; }

.toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
/* The page's top row (UI_PLAN.md FL2): the decide banner, then Help (and the theme, on pages
   without the navigation), in the flow of the page so nothing covers either. */
.page-top { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.page-top > .decide-banner { flex: 1; margin-bottom: 0; }
.page-top-tools { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; }
.page-theme label, .nav-theme label { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: 0.85rem; color: var(--text-muted); }
.nav-theme label { padding: 0.4rem 0.5rem; }
.theme-select {
  display: inline-block; width: auto; margin: 0; padding: 0.3rem 0.4rem; font-size: 0.8rem;
}

.help-button {
  width: 2rem; height: 2rem; border-radius: 999px;
  background: var(--bg-muted); color: var(--text-muted); border: 1px solid var(--border);
  font-size: 0.9rem; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}
.help-button:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.help-dialog {
  max-width: 480px; width: calc(100% - 2rem);
  border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  color: var(--text); background: var(--bg);
}
.help-dialog::backdrop { background: rgba(17, 24, 39, 0.5); }
.help-dialog h2 { margin-top: 0; font-size: 1.15rem; }
.help-dialog .help-close {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none; font-size: 1.1rem; color: var(--text-faint); cursor: pointer; padding: 0.25rem;
}
.help-dialog .help-close:hover { color: var(--text); }

/* static/js/session.js's idle / maximum-length warning — same look as .help-dialog. */
.session-dialog {
  max-width: 440px; width: calc(100% - 2rem);
  border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  color: var(--text); background: var(--bg);
}
.session-dialog::backdrop { background: rgba(17, 24, 39, 0.5); }
.session-dialog h2 { margin-top: 0; font-size: 1.15rem; }
.session-dialog .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
.session-dialog [data-session-countdown] { font-variant-numeric: tabular-nums; }

@media (max-width: 1023.98px) {
  /* The theme and Help controls get a strip of their own above the content, instead of
     sitting over the first card's corner. */
}

.app-footer {
  margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text-faint);
}
.app-footer a { color: var(--text-faint); }
.app-footer a:hover { color: var(--accent-text); }

/* Documentation (templates/docs/) */
.doc-shot-dark { display: none; }
:root[data-theme="dark"] .doc-shot-light { display: none; }
:root[data-theme="dark"] .doc-shot-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .doc-shot-light { display: none; }
  :root:not([data-theme="light"]) .doc-shot-dark { display: block; }
}
.doc-screenshot { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; margin: 1rem 0; }

.doc-layout { display: flex; gap: 2rem; align-items: flex-start; }
.doc-toc { flex: 0 0 220px; position: sticky; top: 1.5rem; }
.doc-toc p.nav-section { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); margin: 1rem 0 0.3rem; }
.doc-toc a { display: block; padding: 0.3rem 0.5rem; border-radius: 6px; color: var(--text-muted); text-decoration: none; font-size: 0.88rem; }
.doc-toc a:hover { color: var(--accent-text); background: var(--bg-muted); }
.doc-toc a.active { color: var(--accent-text); font-weight: 600; background: var(--bg-muted); }
.doc-body { flex: 1; min-width: 0; }
.doc-body h1 { margin-bottom: 0.25rem; }
.doc-body h2 { font-size: 1.1rem; margin-top: 1.75rem; }

.doc-index-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 1rem; }
.doc-index-card { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; text-decoration: none; color: inherit; display: block; }
.doc-index-card:hover { border-color: var(--accent-text); }
.doc-index-card h3 { margin: 0 0 0.4rem; font-size: 1rem; color: var(--accent-text); }
.doc-index-card p { margin: 0; font-size: 0.85rem; color: var(--text-muted); }

@media (max-width: 639.98px) {
  .doc-layout { flex-direction: column; }
  .doc-toc { position: static; flex: 1 1 auto; width: 100%; }
}

/* Material icons (templates/_macros/icon.html) */
.icon { width: 1.1em; height: 1.1em; fill: currentColor; flex-shrink: 0; }

/* License page (templates/license.html) */
.app-footer-license { margin-top: 0.3rem; }
.license-text {
  white-space: pre-wrap; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.8rem; max-height: 70vh; overflow-y: auto; margin: 0;
}

/* Mermaid ER diagrams with pan/zoom (templates/_macros/mermaid_diagram.html,
   templates/docs/admin/data-dictionary.html) */
.mermaid-wrap { position: relative; margin-bottom: 1.5rem; }
.mermaid-container {
  position: relative; height: 480px; border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; background: var(--bg);
}
.mermaid-container svg { width: 100%; height: 100%; }
/* Mermaid's dark theme puts relationship labels on a translucent box too faint to read (WCAG 1.4.3):
   the page's own colours instead. */
.mermaid-container .edgeLabel p, .mermaid-container .labelBkg { background: var(--bg) !important; color: var(--text) !important; }
.mermaid-toolbar {
  position: absolute; top: 0.6rem; right: 0.6rem; z-index: 10;
  display: flex; gap: 0.3rem;
}
.mermaid-toolbar button {
  width: 2rem; height: 2rem; padding: 0; border-radius: 6px;
  background: var(--bg-muted); color: var(--text-muted); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.mermaid-toolbar button:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* Exception detail (exceptions/detail.html) */
.fact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem 1.5rem; margin: 0.5rem 0 1rem; }
.fact-label { display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 0.2rem; }
.recommendation { padding: 0.6rem 0.8rem; background: var(--bg-muted); border-radius: 6px; }
table.evidence tr.mismatch td, table.evidence tr.mismatch th { background: var(--badge-danger-bg); color: var(--badge-danger-fg); }
.check-images { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.check-images img { max-width: min(100%, 420px); height: auto; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
[hidden] { display: none !important; }
.nav-count { margin-left: auto; min-width: 1.4rem; padding: 0 0.4rem; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 0.75rem; font-weight: 700; text-align: center; line-height: 1.4rem; }

/* Phone-width layout (FIX_PLAN.md Phase 7, U5). app.js wraps every table in .table-scroll,
   so a wide table scrolls within its card; nothing else may make the page wider than the
   screen. */
.table-scroll { position: relative; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* position: relative keeps an absolutely positioned descendant (a visually hidden label in a
   header cell) inside the scroll box, rather than widening the page. */
.table-scroll > table { margin-top: 0.5rem; }
/* min-width only: a max-width here would override .card-narrow's own width. */
.card, .page > * { min-width: 0; }
pre, code { overflow-wrap: anywhere; }
/* Long addresses and identifiers in table cells break rather than make a phone scroll sideways. */
.wrap-anywhere { overflow-wrap: anywhere; }
.session-list { list-style: none; padding: 0; }
.session-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border, rgba(127,127,127,0.25)); overflow-wrap: anywhere; }
@media (max-width: 1023.98px) {
  /* The root cause of the sideways scrolling: .page's `margin: 0 auto` stops a flex item
     from stretching to the column's width, so it grew to fit its widest table instead of
     the screen. Pin it to the screen width so .table-scroll can do its job. */
  .page { width: 100%; margin: 0; box-sizing: border-box; }
  .actions, .toolbar { flex-wrap: wrap; }
  .actions > *, .toolbar > .actions { max-width: 100%; }
}
.stat-card .stat-action { margin-top: 0.4rem; font-size: 0.8rem; color: var(--accent-text); font-weight: 600; }
.stat-card .stat-value-text { font-size: 1.1rem; line-height: 2.2rem; white-space: nowrap; }
.stat-card-alert { border-color: var(--badge-warn-fg); background: var(--badge-warn-bg); }
/* The accent-color picker: without a fixed size it stretched full-width and rendered as a
   thin blank line, so it didn't look like a color control at all. */
input[type="color"] { width: 3.5rem; height: 2.25rem; padding: 0.15rem; cursor: pointer; }


/* Embedded in a bank's online banking (services/embed_service.py): no navigation, the page
   fills the frame, and the frame sizes itself to it (static/js/app.js). */
body.embedded .app-shell { display: block; }
body.embedded .page { max-width: none; margin: 0; padding: 1rem; }
body.embedded .app-footer { margin-top: 1rem; font-size: 0.75rem; }

/* Server-side list search (web/list_search.py, _macros/list_search.html). */
.list-search { margin: 0.75rem 0; }
.list-search-main { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; }
.list-search-main label { flex: 1 1 18rem; margin: 0; }
.list-search-more { margin-top: 0.5rem; }
.list-search-more summary { cursor: pointer; color: var(--accent-text); }
.list-search-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.5rem 1rem; margin-top: 0.5rem; }
.list-search-grid label { margin: 0; }
.list-tools { margin: 0.25rem 0 0.75rem; }
.list-filter { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
th a.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
th a.sort-link::after { content: " \2195"; opacity: 0.35; }
th a.sort-link.sort-asc::after { content: " \2191"; opacity: 1; }
th a.sort-link.sort-desc::after { content: " \2193"; opacity: 1; }
th a.sort-link:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.empty-state { padding: 1.5rem 0; }
.empty-state .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.back-link { margin: 0 0 0.75rem; }
.back-link a::before { content: "\2190  "; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nav-search { margin: 0 0 0.75rem; }
.nav-search input { width: 100%; }
.search-results { list-style: none; padding: 0; margin: 0; }
.search-results li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }

/* Shared components: confirmation dialog, toasts, busy buttons (UX_PLAN.md U12). */
.confirm-dialog { border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem 1.5rem; max-width: 28rem; background: var(--bg); color: var(--text); }
.confirm-dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.confirm-dialog h2 { margin-top: 0; }
.confirm-dialog .actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.toast-region { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 1000; max-width: min(24rem, calc(100vw - 2rem)); }
.toast { background: var(--badge-ok-bg); color: var(--badge-ok-fg); border: 1px solid var(--ok); border-radius: 6px; padding: 0.6rem 2.2rem 0.6rem 0.9rem; position: relative; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.toast-undo { margin-left: .75rem; background: none; border: 1px solid currentColor; color: inherit; border-radius: 6px; padding: .2rem .7rem; font-weight: 700; cursor: pointer; }
.toast-close { position: absolute; top: 0.2rem; right: 0.3rem; background: none; border: none; color: inherit; font-size: 1.1rem; cursor: pointer; padding: 0.2rem 0.4rem; }
form[aria-busy="true"] button[disabled] { cursor: progress; opacity: 0.7; }

/* "Decide now" banner (UX_PLAN.md U5): calm, soon (under 2 hours), urgent (under 30 minutes). */
.decide-banner { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; justify-content: space-between; padding: .6rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.decide-banner a { font-weight: 600; }
.decide-banner-calm { background: var(--bg-muted); }
.decide-banner-soon { background: var(--badge-warn-bg); color: var(--badge-warn-fg); }
.decide-banner-urgent { background: var(--badge-danger-bg); color: var(--badge-danger-fg); }
.decide-banner-soon a, .decide-banner-urgent a { color: inherit; }

/* Deciding (UX_PLAN.md U4–U6): Pay and Return, never colour alone (each has a word and an icon). */
.button-pay, .button-return { display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; border-radius: 6px; cursor: pointer; padding: .7rem 1.2rem; }
/* Solid, darker than the badge colours, so white text passes WCAG AA (4.5:1) in both themes. */
.button-pay { background: var(--pay-bg); border: 1px solid var(--pay-bg); color: #fff; }
.button-return { background: var(--return-bg); border: 1px solid var(--return-bg); color: #fff; }
.button-pay:hover, .button-return:hover { filter: brightness(1.08); }
.button-pay:focus-visible, .button-return:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }
.recommended-tag { font-size: .75rem; font-weight: 600; background: rgba(255,255,255,.25); border-radius: 999px; padding: 0 .45rem; }
.decision-panel { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-start; }
.decision-pay { display: grid; gap: .5rem; }
.decision-note summary, .more-details > summary { cursor: pointer; color: var(--accent-text); }
.decision-return { flex: 1 1 18rem; }
.decision-return > summary { list-style: none; }
.decision-return > summary::-webkit-details-marker { display: none; }
.decision-return[open] > summary { margin-bottom: .75rem; }
.decision-return form { display: grid; gap: .6rem; border: 1px solid var(--border); border-radius: 8px; padding: .75rem; }
.reason-list { border: 0; padding: 0; margin: 0; display: grid; gap: .35rem; }
.reason-list legend { font-weight: 600; margin-bottom: .25rem; }
.reason-list label { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.reason-list input { width: auto; }
.why-here { margin: .25rem 0 .5rem; }
.decide-layout { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); margin-bottom: 1rem; }
.decide-layout.has-image { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.decide-layout .card { margin-bottom: 0; }
.decide-main { display: grid; gap: 1rem; align-content: start; min-width: 0; }
.decide-image img { max-width: 100%; height: auto; }
/* Controls (templates/admin/controls.html): each control's id, and one line per check. */
.control-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }
.control-check { margin: 0 0 0.35rem; }
.nowrap { white-space: nowrap; }
/* A check's last 30 days (templates/admin/control_check.html): the worst status each day. */
.status-strip { display: flex; gap: 3px; list-style: none; padding: 0; margin: 0.5rem 0 0; }
.status-day { flex: 1 1 0; height: 1.5rem; border-radius: 3px; background: var(--border); }
.status-pass { background: var(--badge-ok-fg); }
.status-warn { background: var(--badge-warn-fg); }
.status-fail { background: var(--badge-danger-fg); }
/* Plugins' UI slots (templates/plugins/_slot.html). */
.plugin-toolbar { display: inline-flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.75rem; }
.plugin-row-actions { display: block; font-size: 0.85rem; }
.plugin-row-actions > * { margin-right: 0.75rem; }
.plugin-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0 0; }
.control-check:last-child { margin-bottom: 0; }
.no-image { display: flex; align-items: center; gap: 0.5rem; margin: 0.75rem 0 0; color: var(--text-muted); }
.more-details > summary h2 { display: inline; font-size: 1rem; }
.select-col { width: 2.5rem; }
.select-col input { width: 1.15rem; height: 1.15rem; }
label.select-target { display: contents; }
tr.row-focused { outline: 2px solid var(--accent-text); outline-offset: -2px; }
/* A card scrolls sideways (.card's overflow-x), which would make it the bar's scroll container
   and the bar would never stick; the queue's table scrolls inside .table-scroll instead. */
.card:has(> .bulk-form) { overflow: visible; }
.bulk-form { position: sticky; bottom: 0; z-index: 5; }
/* WCAG 2.2 2.4.11 Focus Not Obscured: what the keyboard focuses scrolls clear of the bar. */
html:has(.bulk-bar:not([hidden])) { scroll-padding-bottom: 5rem; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; background: var(--text); color: var(--bg); border-radius: 8px; padding: .6rem .8rem; margin: .5rem 0; }
.bulk-return-body { display: grid; gap: .5rem; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: .75rem; margin-top: .5rem; min-width: min(22rem, 80vw); }
.bulk-return > summary { list-style: none; }

/* Phones and narrow embedded frames (UX_PLAN.md U6): the list becomes cards, and the
   decision buttons are full-width and stay in reach at the bottom of the screen. */
.item-history .history-latest { display: block; margin: .25rem 0 0 1.1rem; color: var(--text-muted); font-size: .9rem; }
.item-history[open] .history-latest { display: none; }
.history-list { list-style: none; padding: 0; margin: .75rem 0; display: grid; gap: .5rem; }
.history-list li { display: grid; gap: .1rem; border-left: 3px solid var(--border); padding-left: .6rem; }
.history-list time { font-size: .85rem; color: var(--text-faint); }
.image-sides { display: flex; gap: .5rem; margin-bottom: .5rem; }
.image-sides button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
@media (max-width: 639.98px) {
  .decide-layout.has-image { grid-template-columns: minmax(0, 1fr); }
  /* On a phone the check comes first, one side at a time. */
  .decide-layout.has-image > .decide-image { order: -1; }
  /* The bulk bar: the count, then Pay and Return side by side (Return's reasons in a sheet). */
  .bulk-bar:not([hidden]) { display: grid; grid-template-columns: 1fr 1fr; }
  .bulk-bar [data-bulk-count] { grid-column: 1 / -1; }
  .bulk-bar .button-pay, .bulk-bar .button-return { padding-inline: .5rem; }
  .bottom-sheet .bulk-return-body { border: 0; padding: 0; margin: 0; min-width: 0; }
}
.decision-score { display: none; }
.item-view { display: contents; }
/* Two panes on a landscape tablet (static/js/app.js initQueuePane): the list, then the chosen
   item, scrolling on its own. A touch screen, so targets are 44px here whatever the width. */
.queue-split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 1rem; align-items: start; }
.queue-split > .card, .queue-pane .card:last-child { margin-bottom: 0; }
.queue-split table.responsive .hide-tablet { display: none; }
.queue-split td.cell-primary a[aria-current] { font-weight: 700; }
.queue-split tr:has(a[aria-current]) { background: var(--bg-muted); }
.queue-pane { position: sticky; top: .5rem; max-height: calc(100dvh - 1rem); overflow-y: auto; overscroll-behavior: contain; }
.queue-pane .item-view { display: block; }
.queue-pane .back-link { display: none; }
.queue-pane .decide-layout.has-image { grid-template-columns: minmax(0, 1fr); }
.queue-pane .decide-layout.has-image > .decide-image { order: -1; }
.queue-split :is(button, .button, summary, td a, select) { min-height: 44px; }
.queue-split td a { display: inline-flex; align-items: center; }
.queue-split label.select-target { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
/* Below desktop the decision card is a compact bar along the bottom of the screen (MOBILE_PLAN.md
   R2): the fraud risk, Pay and Return in one row, a note below; Return's reasons in a sheet. */
@media (max-width: 1023.98px) {
  .decision-card { position: sticky; bottom: 0; z-index: 4; box-shadow: 0 -4px 14px rgba(0,0,0,.12); padding: .75rem 1rem; }
  html:has(.decision-card) { scroll-padding-bottom: 12rem; }  /* clear of the bar when focused (WCAG 2.4.11) */
  /* Two cards (revising a recommendation and approving it): only the last one sticks. */
  .decision-card:has(~ .decision-card) { position: static; box-shadow: none; }
  .decision-heading { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .decision-hint { margin: 0 0 .5rem; }
  .decision-panel { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); gap: .25rem .6rem; align-items: center; }
  .decision-panel:not(:has(> .decision-score)) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .decision-pay { display: contents; }
  .decision-score, .decision-pay > .button-pay, .decision-panel > .button-return { grid-row: 1; }
  .decision-score { display: flex; flex-direction: column; gap: .1rem; margin: 0; font-size: .8rem; }
  .decision-score .fact-label { font-size: .75rem; }
  .decision-note { grid-row: 2; grid-column: 1 / -1; }
  .decision-note summary { padding-block: .6rem; min-height: 44px; display: flex; align-items: center; }
  .button-pay, .button-return { width: 100%; justify-content: center; padding-block: .8rem; font-size: 1.05rem; min-height: 48px; }
  .bottom-sheet .decision-return form { border: 0; padding: 0; }
  .bottom-sheet .sheet-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .bottom-sheet .reason-list label { min-height: 44px; }
  .confirm-dialog { width: calc(100vw - 2rem); }
  .toast-undo { min-height: 44px; min-width: 44px; }
  .toast-close { min-width: 44px; min-height: 44px; top: 0; right: 0; }
  .toast { padding-right: 2.9rem; display: flex; align-items: center; justify-content: space-between; }
  .confirm-dialog .actions button { flex: 1 1 0; }
}
@media (max-width: 639.98px) {
  .decision-hint { display: none; }
  .decision-panel { column-gap: .5rem; }
  .button-pay, .button-return { padding-inline: .5rem; }
}

/* The control panel (templates/settings/panel.html; UX_PLAN.md U11). */
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.5rem; }
.panel-head h1 { margin: 0; }
.panel-search input { min-width: 16rem; margin: 0; }
.panel-section { margin: 1.25rem 0 0; }
.panel-section h2 { font-size: 1rem; color: var(--text-muted); text-transform: none; margin: 0 0 0.5rem; }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.75rem; }
.tiles > li[hidden], .panel-section[hidden] { display: none; }
.tile { display: flex; gap: 0.75rem; align-items: flex-start; height: 100%; box-sizing: border-box; padding: 0.85rem 1rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); text-decoration: none; }
.tile:hover { border-color: var(--accent-text); }
.tile:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }
.tile-icon { flex: none; display: inline-flex; padding: 0.4rem; border-radius: 6px; background: var(--bg-muted); color: var(--accent-text); }
.tile-icon .icon { margin: 0; }
.tile-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.tile-title { font-weight: 600; }
.tile-state { font-size: 0.9rem; color: var(--text-muted); overflow-wrap: anywhere; }
.tile-state.tone-ok { color: var(--badge-ok-fg); }
.tile-state.tone-warn { color: var(--badge-warn-fg); }
.tile-state.tone-danger { color: var(--badge-danger-fg); font-weight: 600; }
.tile-desc { font-size: 0.85rem; color: var(--text-faint); }

/* A setting in a modal over the panel, full-screen on phones. */
.settings-dialog { border: 1px solid var(--border); border-radius: 10px; padding: 0; width: min(36rem, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem); background: var(--bg); color: var(--text); }
.settings-dialog::backdrop { background: rgba(17, 24, 39, 0.5); }
.settings-dialog-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--bg); }
.settings-dialog-head h2 { margin: 0; font-size: 1.15rem; }
.settings-dialog-close { background: none; border: 0; padding: 0.25rem; color: var(--text-muted); cursor: pointer; }
.settings-dialog-close:hover { color: var(--text); }
.settings-dialog-close .icon { margin: 0; }
.settings-dialog-body { padding: 1rem 1.25rem 1.25rem; }
.settings-dialog-body[aria-busy="true"] { min-height: 6rem; }
.settings-dialog-body form + form, .settings-page form + form { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.indented { margin-left: 1.6rem; }
.settings-page { max-width: 44rem; }
@media (max-width: 639.98px) {
  .settings-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .panel-search, .panel-search input { width: 100%; min-width: 0; }
}

/* Drag and drop onto a file input (static/js/app.js initDropzones). */
.dropzone { border: 2px dashed var(--border); border-radius: 8px; padding: 0.85rem 1rem; margin: 0.25rem 0 0.75rem; }
.dropzone.dropzone-over { border-color: var(--accent-text); background: var(--bg-muted); }
.dropzone input[type=file] { margin: 0; }
.dropzone-hint { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--text-faint); }

/* The issue-file layout builder (templates/layouts/form.html). */
.layout-builder fieldset { margin: 0 0 1rem; }
.inline-fields { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: flex-end; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.25rem 1rem; }
.sample-grid select { min-width: 9rem; margin: 0; }
.sample-grid td, .sample-col-name { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; white-space: pre; }
.sample-col-name { font-weight: normal; color: var(--text-faint); margin-top: 0.25rem; }
.sample-lines { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; line-height: 1.5;
  background: var(--bg-muted); padding: 0.75rem; border-radius: 6px; overflow-x: auto; margin: 0 0 0.5rem; }
.sample-lines .ruler { color: var(--text-faint); user-select: none; }
.sample-lines .sample-line::selection { background: var(--accent); color: var(--on-accent); }
.layout-preview .row-error td { background: var(--badge-danger-bg); }
.cell-error { color: var(--badge-danger-fg); font-weight: 600; }
.plain-list { padding-left: 1.2rem; }
.plain-list li { margin: 0.35rem 0; }

/* Fixing failed upload rows (templates/bulk_uploads/fix.html). */
.fix-row { border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1rem; margin: 0 0 1rem; }
.fix-row legend { font-weight: 600; padding: 0 0.35rem; }
.field-error { display: block; color: var(--badge-danger-fg); font-size: 0.85rem; margin: 0.15rem 0 0.35rem; }
.input-error { border-color: var(--danger) !important; }
.callout { border-left: 4px solid var(--accent-text); background: var(--bg-muted); padding: 0.5rem 1rem; margin: 1rem 0; border-radius: 4px; }

/* A fieldset is min-width: min-content by default, so a wide table inside one widened the
   whole page on a phone instead of scrolling inside its own box. */
fieldset { min-width: 0; }
.tone-ok { color: var(--badge-ok-fg); }
.tone-warn { color: var(--badge-warn-fg); }
.tone-danger { color: var(--badge-danger-fg); font-weight: 600; }

/* A support session (services/support_access_service.py): always visible. */
.support-banner { background: var(--badge-warn-bg); color: var(--badge-warn-fg); border-bottom: 2px solid var(--badge-warn-fg);
  padding: 0.5rem 1rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; justify-content: space-between; }
.support-banner form { margin: 0; }

/* Responsive tables (templates/_macros/responsive_table.html; MOBILE_PLAN.md §1). Desktop:
   an ordinary table. Below desktop, hide-tablet columns go; on a phone, hide-phone columns
   too, and each row is a card: the primary cell is its title with the money beside it, then
   the status, "label: value" lines, and the actions along the bottom. The sortable headers
   stay, as a row of buttons above the cards. */
@media (max-width: 1023.98px) {
  table.responsive .hide-tablet { display: none; }
  table.responsive > tbody td :is(a, .link-button) { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
  /* A long address or code may break, so a table that doesn't fit narrows instead of
     scrolling (a table that fits is laid out as before). */
  table.responsive > tbody td { overflow-wrap: anywhere; }
  /* Row actions in a sheet (a sheet: "tablet" column below desktop, the rest on phones). */
  .row-menu { width: 44px; justify-content: center; padding: 0; }
  .bottom-sheet .sheet-content :is(a, .link-button) {
    display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 0.25rem; border-bottom: 1px solid var(--border);
  }
  .bottom-sheet .sheet-content .inline-form { display: block; }
}
/* Desk work (bulk uploads, exports) isn't offered on a phone; the pages still answer there. */
@media (max-width: 639.98px) {
  .not-phone { display: none !important; }
}
@media (max-width: 639.98px) {
  table.responsive .hide-phone { display: none; }
  table.responsive, table.responsive > tbody { display: block; width: 100%; }
  table.responsive > thead { display: block; }
  table.responsive > thead > tr { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
  table.responsive > thead th { border: 0; padding: 0; }
  table.responsive > thead th:not(:has(.sort-link, .sort-button)) { display: none; }
  table.responsive > thead th :is(.sort-link, .sort-button) {
    padding: 0 0.75rem; border: 1px solid var(--border); border-radius: 999px; text-transform: none;
  }
  table.responsive > tbody > tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.15rem 0.75rem; position: relative;
    border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem 0.75rem 0.6rem; margin-bottom: 0.6rem;
  }
  table.responsive > tbody > tr > td { display: block; grid-column: 1 / -1; border: 0; padding: 0; overflow-wrap: anywhere; }
  table.responsive td.cell-primary { grid-column: 1; grid-row: 1; font-size: 1.05rem; font-weight: 600; }
  table.responsive td.cell-primary a { display: inline-flex; align-items: center; min-height: 44px; }
  table.responsive td.cell-money { grid-column: 2; grid-row: 1; align-self: center; text-align: right; font-weight: 700; }
  table.responsive td.cell-meta::before { content: attr(data-label) ": "; color: var(--text-faint); font-size: 0.85rem; }
  table.responsive td.cell-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; margin-top: 0.35rem; }
  table.responsive td.cell-actions:empty { display: none; }
  table.responsive td.cell-actions a:not(.button) { display: inline-flex; align-items: center; min-height: 44px; }
  /* A checkbox goes down the card's left edge, clear of the title and the amount. */
  table.responsive > tbody > tr:has(> td.cell-select) { padding-left: 3rem; }
  table.responsive td.cell-select { position: absolute; top: 0.4rem; left: 0.15rem; width: auto; grid-column: auto; grid-row: auto; }
  table.responsive td.cell-select label, table.responsive td.cell-select input { margin: 0; }
  /* With no amount beside the title, the ⋯ button goes there instead of a row of its own. */
  table.responsive tr:not(:has(td.cell-money)) td.cell-actions:has(> .row-menu) { grid-column: 2; grid-row: 1; margin-top: 0; align-self: start; }
}

/* The dashboard's and billing's figures on a phone: two to a row, so they fit on one screen. */
@media (max-width: 639.98px) {
  .stat-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .stat-card { min-width: 0; padding: 0.75rem 0.85rem; }
  .stat-card .stat-value { font-size: 1.5rem; }
  .stat-card .stat-value.stat-value-text { font-size: 1.1rem; white-space: normal; line-height: 1.3; min-height: 2.25rem; display: flex; align-items: center; }
}

/* On a phone: an upload form's column guide, one column per card; the evidence and
   comparison tables, narrower cells that may break a long value. */
@media (max-width: 639.98px) {
  table.column-guide thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.column-guide, table.column-guide tbody, table.column-guide tr, table.column-guide td { display: block; }
  table.column-guide tr { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
  table.column-guide td { border: 0; padding: 0.1rem 0; overflow-wrap: anywhere; }
  table.column-guide td:first-child { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; }
  table.column-guide td:nth-child(2)::before { content: "Required: "; color: var(--text-faint); font-size: 0.85rem; }
  table.column-guide td:nth-child(3)::before { content: "Example: "; color: var(--text-faint); font-size: 0.85rem; }
  table.evidence :is(th, td), table.comparison :is(th, td) { padding-inline: 0.35rem; }
  table.evidence td, table.comparison td { overflow-wrap: anywhere; }
  /* Each row's label with its mismatch badge on one line, expected and presented below. */
  table.evidence, table.evidence > :is(thead, tbody) { display: block; }
  table.evidence tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; border-bottom: 1px solid var(--border); }
  table.evidence :is(th, td) { border: 0; }
  table.evidence > thead th:first-child { display: none; }
  table.evidence > tbody th[scope="row"] { grid-row: 1; grid-column: 1 / -1; padding-bottom: 0; }
  table.evidence > tbody td:nth-of-type(1) { grid-row: 2; grid-column: 1; }
  table.evidence > tbody td:nth-of-type(2) { grid-row: 2; grid-column: 2; }
  table.evidence tr.mismatch { background: var(--badge-danger-bg); }
}

/* Bottom sheets (templates/_macros/bottom_sheet.html): in place, the wrapper isn't there for
   layout; in the sheet (phones), a panel along the bottom of the screen. */
.sheet-content { display: contents; }
.sheet-only { display: none; }
.bottom-sheet {
  margin: auto 0 0; width: 100%; max-width: 100%; max-height: 85dvh; overflow-y: auto;
  border: 0; border-radius: 12px 12px 0 0; padding: 0 1rem 1rem; background: var(--bg); color: var(--text);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.2);
}
.bottom-sheet::backdrop { background: rgba(17, 24, 39, 0.5); }
.bottom-sheet-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 0; margin-bottom: 0.75rem; border-bottom: 1px solid var(--border); background: var(--bg);
}
.bottom-sheet-head h2 { margin: 0; font-size: 1.1rem; }
.bottom-sheet .sheet-content { display: block; }
.bottom-sheet > details > summary { display: none; }
.bottom-sheet .sheet-only { display: inline-flex; }
.bottom-sheet .list-search-grid { grid-template-columns: minmax(0, 1fr); }

/* Touch targets (MOBILE_PLAN.md §1): below desktop, and on any touch screen however wide (a
   landscape iPad is 1024px and up), everything tapped is at least 44x44px. A mouse at desktop
   widths keeps the desktop's sizes. */
@media (max-width: 1023.98px), (pointer: coarse) {
  table.responsive > tbody td :is(a, .link-button) { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
  button, .button, select, .table-search,
  input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="hidden"]) { min-height: 44px; }
  .sidenav a, .sidenav .link-button { min-height: 44px; }
  .theme-select { min-height: 44px; }
  .help-button { width: 44px; height: 44px; }
  .link-button { min-height: 44px; }
  summary { padding-block: 0.8rem; }
  .back-link a, .link-line a, a.link-line, th a.sort-link, th.sortable-col .sort-button { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
  table.key-values td a { display: inline-flex; align-items: center; min-height: 44px; overflow-wrap: anywhere; }
  .settings-dialog-close { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  input[type="color"] { width: 4rem; height: 44px; }
  .pagination a.button, .pagination span.button-disabled { display: inline-flex; align-items: center; min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { width: 1.25rem; height: 1.25rem; }
  /* The box beside the first line, the text running on as one paragraph (a flex label would
     split it around a <code> or a link). */
  label:is(:has(> input[type="checkbox"]), :has(> input[type="radio"])):not(.select-target) {
    display: block; position: relative; min-height: 44px; box-sizing: border-box; padding: 0.7rem 0 0.7rem 1.9rem;
  }
  label:not(.select-target) > :is(input[type="checkbox"], input[type="radio"]) { position: absolute; left: 0; top: 0.7rem; margin: 0; }
  .select-col input { width: 1.5rem; height: 1.5rem; }
  /* The checkbox's label is the target: 44px square around it. */
  label.select-target { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
  th.select-col, td.select-col { width: 44px; padding-inline: 0; }
}

/* The Branding setting's preview of the accent in each theme (UI_PLAN.md UI-D2). */
.accent-preview { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; }
.accent-preview > span { display: inline-flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.75rem; border-radius: 6px; border: 1px solid var(--border); }
.accent-preview-light { background: #ffffff; }
.accent-preview-dark { background: #0f172a; }
.accent-swatch { color: #ffffff; padding: 0.3rem 0.7rem; border-radius: 6px; font-size: 0.85rem; }

/* Getting Started checklists (UI_PLAN.md FL9): each step's state in words. */
.checklist-state { width: 6rem; vertical-align: top; white-space: nowrap; }
.link-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }

/* Tabs between kinds of one list (File layouts: issued checks, posted checks). */
.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; border-bottom: 1px solid var(--border); margin: 0 0 1rem; }
.tabs a { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 0.1rem; color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--accent-text); border-bottom-color: var(--accent-text); font-weight: 600; }

/* An upload's result (UI_PLAN.md FL5): the outcome first; undoing the upload set apart. */
.upload-outcome { font-size: 1.05rem; }
.file-details { margin: 1.5rem 0; }
.danger-zone { margin-top: 1.5rem; padding: 1rem; border: 1px solid var(--badge-danger-bg); border-radius: 8px; }
.danger-zone h2 { margin-top: 0; font-size: 1rem; }

/* The comparison's "Doesn't match" sits with the row's name, not in a column of its own (UI_PLAN.md F17). */
table.evidence th[scope="row"] .badge { margin-left: 0.5rem; font-weight: 600; text-transform: none; letter-spacing: 0; }

/* Field widths for short values, instead of inline styles (UI_PLAN.md F17). */
.field-xs { max-width: 4em; }
.field-s { max-width: 6em; }
.field-m { max-width: 8em; }
.field-l { max-width: 12em; }
.field-xl { max-width: 15em; }

/* The account menu at the foot of the navigation (UI_PLAN.md UI-D6). */
.account-menu summary { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.5rem; border-radius: 6px; cursor: pointer;
  color: var(--text-muted); font-size: 0.9rem; list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary:hover { background: var(--bg-muted); color: var(--accent-text); }
.account-menu[open] summary { color: var(--text); font-weight: 600; }
.account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.account-menu-items { display: flex; flex-direction: column; gap: 0.2rem; padding-left: 0.5rem; }
.account-menu-items .link-button { display: flex; align-items: center; gap: 0.5rem; }
@media (max-width: 1023.98px) {
  .account-menu summary { min-height: 44px; }
}

/* A customer's dashboard leads with its two jobs (UI_PLAN.md UI-D8). */
.jobs { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.job { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.job h2 { margin-top: 0; }

/* Filters that belong together sit together, not at opposite edges (UI_PLAN.md F14). */
.toolbar.toolbar-start { justify-content: flex-start; gap: 0.75rem 1.5rem; }
.file-format { margin-top: 1.5rem; }
