/* Membership Review. Mobile-first at 430px, one column; desktop is the same column, wider. */
:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #d9dde3;
  --accent: #1f2933;

  --red: #c62828;      --red-bg: #fdecea;
  --orange: #d9480f;   --orange-bg: #ffe8d6;
  --amber: #8a5a00;    --amber-bg: #fff1c2;
  --gray: #4b5563;     --gray-bg: #e5e7eb;
  --green: #1b6e32;    --green-bg: #dff3e4;
  --blue: #1558b0;     --blue-bg: #dbeafe;
  --pink: #ec4899;     --pink-bg: #fff0f7;
  --yellow: #fff176;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
body.noscroll { overflow: hidden; }
a { color: #1558b0; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h3 { font-size: 1rem; margin-bottom: 8px; }
h4 { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.error { color: var(--red); font-weight: 600; margin: 6px 0 0; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain > li { padding: 6px 0; border-top: 1px solid var(--line); }
ul.plain > li:first-child { border-top: 0; }

/* ---- shell ---- */
.topbar { background: var(--accent); color: #fff; position: sticky; top: 0; z-index: 20; }
.bar-inner, .topbar nav { max-width: 430px; margin: 0 auto; }
.bar-inner { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px 0; }
.brand { font-weight: 700; }
.userbox { font-size: 0.85rem; }
.userbox .muted { color: #cbd2d9; }
.topbar .linkbtn { color: #fff; }
nav.tabs { display: flex; gap: 2px; padding: 6px 8px 0; }
nav.tabs a {
  flex: 1 1 auto; text-align: center; padding: 8px 4px; color: #cbd2d9; text-decoration: none; font-weight: 600;
  font-size: 0.85rem; line-height: 1.2; border-radius: 8px 8px 0 0; display: flex; align-items: center; justify-content: center; gap: 4px;
}
nav.tabs a[data-route="health"] { flex: 0 0 auto; padding-left: 8px; padding-right: 8px; }
/* R27: the Health tab carries the active-alert count */
nav.tabs a .count { background: rgba(255, 255, 255, 0.2); color: inherit; border-radius: 999px; padding: 0 6px; font-size: 0.72rem; min-width: 18px; }
nav.tabs a.active .count { background: var(--gray-bg); }
nav.tabs a .count.alerting { background: var(--red); color: #fff; }
nav.tabs a.active { background: var(--bg); color: var(--ink); }
.page { max-width: 430px; margin: 0 auto; padding: 12px 10px 60px; }

/* ---- controls ---- */
input, select, button { font: inherit; }
input[type="search"], input[type="text"], input[type="password"], input[type="date"], select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
label { display: block; font-size: 0.75rem; color: var(--muted); }
label > input, label > select { margin-top: 2px; font-size: 0.95rem; color: var(--ink); }
label.check { display: flex; align-items: center; gap: 6px; align-self: end; padding-bottom: 8px; font-size: 0.9rem; color: var(--ink); }
label.check input { width: auto; margin: 0; }
.filters { display: grid; gap: 8px; margin-bottom: 8px; }
.daterow, .frow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
button { cursor: pointer; }
button:disabled { opacity: 0.55; cursor: default; }
.linkbtn { background: none; border: 0; padding: 2px 4px; color: #1558b0; text-decoration: underline; cursor: pointer; font-size: 0.9rem; }
.primary { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 10px 14px; font-weight: 600; width: 100%; }

/* chips: one scrolling row on a phone */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; margin: 0 -10px; padding-left: 10px; padding-right: 10px; scrollbar-width: thin; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); border-radius: 999px; padding: 6px 12px; font-size: 0.85rem; font-weight: 600; white-space: nowrap;
}
.chip .count { background: var(--gray-bg); border-radius: 999px; padding: 0 7px; font-size: 0.75rem; min-width: 22px; text-align: center; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.active .count { background: rgba(255, 255, 255, 0.22); color: #fff; }
/* R15: the "Sources disagree" chip is red so a conflict is never missed */
.chip.chip-disagree { border-color: var(--red); color: var(--red); background: var(--red-bg); }
.chip.chip-disagree .count { background: var(--red); color: #fff; }
.chip.chip-disagree.active { background: var(--red); border-color: var(--red); color: #fff; }

.notice { background: var(--blue-bg); color: var(--blue); padding: 8px 10px; border-radius: 8px; margin-bottom: 8px; font-weight: 600; }
.status { margin: 4px 0 8px; font-size: 0.85rem; }
.more { text-align: center; margin: 12px 0; }
.loadmore { padding: 8px 18px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-weight: 600; }

/* ---- cards ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.subhead { margin: 18px 2px 8px; }

/* tags: status colours */
.tag, .badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  background: var(--gray-bg); color: var(--gray); vertical-align: middle;
}
.tag-mismatch { background: var(--red-bg); color: var(--red); }
.tag-weak, .tag-unverified { background: var(--amber-bg); color: var(--amber); }
.tag-no_capture, .tag-pending, .tag-non_member { background: var(--gray-bg); color: var(--gray); }
.tag-match, .tag-cleared, .tag-member { background: var(--green-bg); color: var(--green); }
.tag-testing { background: var(--blue-bg); color: var(--blue); }
.tag-verdict { background: #fff; color: var(--ink); border: 1px solid var(--line); } /* verdicts are neutral */
.badge-warn { background: var(--amber-bg); color: var(--amber); }
.badge-info { background: var(--gray-bg); color: var(--gray); }
.badge-standing-warned { background: var(--amber-bg); color: var(--amber); }
.badge-standing-banned { background: var(--red-bg); color: var(--red); }
.badge-standing-none { background: var(--green-bg); color: var(--green); }

/* R05: shared plate = circled in pink */
.plate {
  display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700;
  letter-spacing: 0.06em; padding: 1px 8px; border: 1px solid var(--line); border-radius: 4px; background: #fff;
}
.plate.shared { border: 3px solid var(--pink); border-radius: 999px; padding: 0 12px; background: var(--pink-bg); outline: 1px solid var(--pink); outline-offset: 1px; }
.plate mark { background: var(--yellow); color: inherit; border-radius: 2px; padding: 0; }

/* ---- case card ---- */
.case.disagree { border: 2px solid var(--red); }
.banner-disagree { /* R15: loud */
  margin: -12px -12px 10px; padding: 10px 12px; background: var(--red); color: #fff; font-weight: 700;
  border-radius: 10px 10px 0 0; text-transform: none;
}
.banner-disagree strong { text-transform: uppercase; letter-spacing: 0.04em; margin-right: 2px; }
.banner-disagree.small { margin: 0 0 4px; padding: 4px 8px; border-radius: 6px; font-size: 0.8rem; }
/* R19: phone = stacked (photo and time rows on top, facts and buttons below); desktop below = two columns */
.case-grid { display: grid; grid-template-columns: 52% minmax(0, 1fr); grid-template-areas: "media time" "facts facts"; gap: 10px; }
.case-media { grid-area: media; position: relative; min-width: 0; }
.timecol { grid-area: time; min-width: 0; display: grid; gap: 6px; align-content: start; }
.case-facts { grid-area: facts; min-width: 0; }
/* the cursor of a photo comes from Fmt.cursorFor (inline style): zoom-in only where a click opens full size (R23) */
.photo { padding: 0; border: 0; background: #e5e7eb; border-radius: 8px; overflow: hidden; display: block; position: relative; width: 100%; }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo.none { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 0.8rem; cursor: default; }
.casephoto { height: 130px; }
.fullsize {
  position: absolute; right: 6px; bottom: 6px; border: 0; border-radius: 6px; padding: 2px 8px; font-size: 0.75rem; font-weight: 700;
  background: rgba(17, 24, 39, 0.75); color: #fff;
}
/* R24: shown only after the retries ran out; a tap retries */
img.img-failed { display: none !important; }
.img-missing {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: #f3f4f6; color: var(--gray); border: 1px dashed #9ca3af; border-radius: inherit; font-size: 0.75rem; cursor: pointer; text-align: center;
}
.img-missing .im-title { font-weight: 700; }
.img-missing .im-hint { font-size: 0.7rem; color: var(--muted); }
.lightbox figure { position: relative; min-width: 160px; min-height: 90px; }
.trow { display: grid; grid-template-columns: 1fr; padding: 3px 6px; border-radius: 6px; }
.tlabel { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.tval { font-variant-numeric: tabular-nums; font-weight: 600; }
.tnote { font-size: 0.8rem; font-weight: 700; }
.trow.flagged { background: var(--yellow); box-shadow: inset 4px 0 0 #e6c200; } /* R11 */
.trow.flagged .tlabel { color: #5c4a00; }

.ident { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; margin-bottom: 8px; }
.ident .name { font-size: 1.05rem; }
.nowshows { color: var(--orange); font-weight: 600; }
.acct { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.side { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 8px; min-width: 0; }
.side .plate { margin: 0 2px 4px 0; }
.veh { font-size: 0.85rem; margin-top: 2px; }
.veh-note { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }
.correction { font-size: 0.75rem; margin-top: 4px; }
.correction .linkbtn { font-size: 0.75rem; padding: 0 2px; }
.corrected-by { color: var(--blue); font-weight: 600; }
.hcap { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; }
.conf { font-size: 0.8rem; color: var(--muted); }

.statusline { margin: 6px 0; }
.reason { font-size: 0.85rem; color: var(--muted); }
.flagnote { margin: 6px 0; padding: 4px 8px; border-radius: 6px; background: var(--red-bg); color: var(--red); font-weight: 700; font-size: 0.85rem; }
.flagnote.overruled { background: var(--gray-bg); color: var(--gray); }

.verdict { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.vbtns { display: grid; gap: 6px; }
.vbtn {
  text-align: left; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  font-weight: 600; color: var(--ink);
}
.vbtn:hover:not(:disabled) { border-color: var(--accent); }
.vbtn.current { border: 2px solid var(--accent); background: #f3f4f6; }
.vline { margin-bottom: 4px; }
.vwho { font-size: 0.85rem; color: var(--muted); }
.verdict .linkbtn { margin-top: 6px; }
.moved { font-size: 0.85rem; color: var(--blue); font-weight: 600; }
.vhist { font-size: 0.85rem; margin-top: 4px; }
.vhist ul { margin: 4px 0 0; padding-left: 18px; }
.foot { margin-top: 8px; font-size: 0.7rem; }

/* ---- visit card ---- */
.visit { display: flex; gap: 10px; padding: 8px; }
.visit.clickable { cursor: pointer; }
.visit .thumb { flex: 0 0 96px; height: 72px; }
.thumb.small { flex: 0 0 64px; width: 64px; height: 48px; }
.vbody { min-width: 0; flex: 1; }
.vrow1 { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.vmeta { font-size: 0.8rem; color: var(--muted); }
.group-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px; margin: 14px 2px 6px; }

/* ---- lookup rows ---- */
.prow { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pmain { font-size: 1.1rem; }
.expand { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 4px; }
.hvisit { display: flex; gap: 10px; align-items: flex-start; }
.hcase { font-size: 0.9rem; }
.hverdict { margin-top: 4px; }
.vbtns.compact { margin-top: 6px; grid-template-columns: 1fr 1fr; gap: 4px; }
.vbtns.compact .vbtn { padding: 6px 8px; font-size: 0.8rem; }

/* ---- LP Lookup table (R21): tight, content-sized columns ---- */
.table-wrap { overflow-x: auto; margin: 0 -10px; padding: 0 10px; -webkit-overflow-scrolling: touch; }
table.lookup { border-collapse: collapse; background: var(--card); font-size: 0.85rem; width: max-content; min-width: 100%; }
table.lookup th, table.lookup td { padding: 6px 5px; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
table.lookup thead th { position: sticky; top: 0; background: #f8fafc; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); white-space: nowrap; border-top: 0; }
table.lookup th .sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; text-decoration: underline dotted; }
table.lookup th[aria-sort="ascending"] .sort::after { content: " ▲"; }
table.lookup th[aria-sort="descending"] .sort::after { content: " ▼"; }
table.lookup th[aria-sort="ascending"], table.lookup th[aria-sort="descending"] { color: var(--ink); }
table.lookup tr.main { cursor: pointer; }
table.lookup tbody.plate-row.open tr.main { background: #f8fafc; }
.c-plate { white-space: nowrap; }
.c-plate .plate { padding: 0 5px; letter-spacing: 0.03em; font-size: 0.82rem; }
.c-plate .plate.shared { padding: 0 8px; }
/* a plate read longer than 8 characters wraps instead of setting the column width */
.c-plate.wrap { white-space: normal; }
.c-plate.wrap .plate { display: inline-block; max-width: 8.5ch; overflow-wrap: anywhere; word-break: break-all; }
.c-makeModel { min-width: 6em; max-width: 9.5em; }
.c-color, .c-visits, .c-first, .c-last, .c-flagged { white-space: nowrap; }
.c-visits .expbtn { padding: 0; font-weight: 700; }
.c-member { min-width: 7em; max-width: 12em; white-space: normal; }
.c-member .acct { white-space: nowrap; }
.c-member .former { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.c-flagged .flagcount { background: var(--red-bg); color: var(--red); font-weight: 700; border-radius: 999px; padding: 0 7px; }
.blank { color: #9ca3af; }
tr.expand > td { padding: 0; border-top: 0; }
.expand-in { position: sticky; left: 0; width: min(100%, calc(100vw - 20px)); max-width: 410px; padding: 4px 8px 8px; }

/* ---- Health tab (R27) ---- */
.health-head { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 2px 6px; }
.health-head h2 { font-size: 1.1rem; }
.alerts .alert { padding: 8px 0; }
.alert-msg { font-weight: 600; }
.alert.alert-error .alert-msg { color: var(--red); }
.alert.cleared .alert-msg { color: var(--gray); font-weight: 500; }
.badge-ok { background: var(--green-bg); color: var(--green); }
.badge-bad { background: var(--red-bg); color: var(--red); }
.badge-warnlvl { background: var(--amber-bg); color: var(--amber); }
strong.bad { color: var(--red); }
.health-body .kv { grid-template-columns: 110px 1fr; }

/* ---- account page ---- */
.acct-head h2 { font-size: 1.3rem; }
.standing { margin-top: 6px; }
.standing-history { margin: 4px 0 0; padding-left: 18px; font-size: 0.85rem; color: var(--muted); }
.kv { display: grid; grid-template-columns: 80px 1fr; gap: 8px; padding: 4px 0; border-top: 1px solid var(--line); }
.kv:first-of-type { border-top: 0; }
.kv .k { color: var(--muted); font-size: 0.85rem; }
.changes li { font-size: 0.9rem; }
.back { display: inline-block; margin-bottom: 4px; }

/* ---- overlays ---- */
.overlay { position: fixed; inset: 0; z-index: 50; }
.lightbox { background: rgba(0, 0, 0, 0.88); z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: auto; padding: 16px; }
.lb-body { display: flex; flex-direction: column; gap: 12px; align-items: center; max-width: 100%; }
.lightbox figure { margin: 0; text-align: center; color: #e5e7eb; }
.lightbox img { max-width: 100%; max-height: 80vh; border-radius: 6px; background: #000; }
.overlay-close { position: absolute; top: 8px; right: 12px; z-index: 2; background: none; border: 0; color: #fff; font-size: 2rem; line-height: 1; padding: 4px 8px; }
.modal { background: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: flex-start; overflow: auto; padding: 24px 10px; }
.modal-card { background: var(--bg); border-radius: 12px; width: 100%; max-width: 430px; padding: 12px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head .overlay-close { position: static; color: var(--ink); }
.modal-title { font-size: 1.2rem; }

/* ---- login ---- */
.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 12px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 1.3rem; margin-bottom: 14px; }
.login-card form { display: grid; gap: 12px; }

/* ---- desktop: same column, wider ---- */
@media (min-width: 720px) {
  .bar-inner, .topbar nav, .page { max-width: 960px; }
  .page { padding-left: 16px; padding-right: 16px; }
  .chips { flex-wrap: wrap; overflow: visible; margin: 0; padding-left: 0; padding-right: 0; }
  .filters { grid-template-columns: 2fr 1fr; align-items: end; }
  .filters > :only-child { grid-column: 1 / -1; }
  .vfilters { grid-template-columns: 1fr 1fr; }
  .vfilters .frow { grid-template-columns: 1fr 1fr; }
  .case-grid { grid-template-columns: 300px minmax(0, 1fr); }
  .casephoto { height: 190px; }
  .vbtns { grid-template-columns: repeat(2, 1fr); }
  .modal-card { max-width: 640px; }
  .visit .thumb { flex-basis: 140px; height: 100px; }
}

/* ---- desktop width (R19): the evidence photo large on the left, facts and buttons on the right ---- */
@media (min-width: 900px) {
  .bar-inner, .topbar nav, .page { max-width: 1180px; }
  nav.tabs a { flex: 0 0 auto; padding-left: 18px; padding-right: 18px; }
  .case-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-areas: "media time" "media facts";
    grid-template-rows: auto 1fr; gap: 10px 16px;
  }
  .case-media { align-self: start; }
  .casephoto { height: auto; aspect-ratio: 16 / 10; background: #111827; }
  .casephoto img { object-fit: contain; }
  .casephoto.none { background: #e5e7eb; aspect-ratio: 16 / 7; }
  .modal-card { max-width: 760px; }
  .table-wrap { margin: 0; padding: 0; }
}

/* Hand-off sign-in (login page), the support-session banner and the admin cards on the Health tab */
.handoff-signin { display: grid; gap: 8px; margin-bottom: 14px; }
.handoff-signin p { margin: 0; font-size: 0.9rem; }
a.primary { display: block; text-align: center; text-decoration: none; box-sizing: border-box; }
.or-line { text-align: center; font-size: 0.8rem; color: var(--muted); margin: 0 0 10px; }
.support-banner { background: var(--amber-bg); color: var(--amber); font-weight: 600; font-size: 0.85rem; padding: 8px 12px; }
.support-banner .bar-text { max-width: 430px; margin: 0 auto; }
.health-admin .help { font-size: 0.85rem; margin: 0 0 8px; }
.conn-form { display: grid; gap: 8px; margin-top: 8px; }
.conn-form .frow { grid-template-columns: 1fr 1fr; }
.conn-form .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.conn-form .actions .primary { width: auto; }
.conn-form .saved { color: var(--green); font-weight: 600; font-size: 0.85rem; }
.conn-form input[type="email"], .conn-form input[type="number"] { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.slog li { font-size: 0.85rem; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; }
.slog .path { grid-column: 1 / -1; font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
