/* Prudence scam database: a reference site for people who work on scams,
   not the senior's app and not the admin console. Dense 15 px system type,
   tabular numbers, monospace for messages and indicators, a warm paper
   ground, a deep green header and a teal accent. Light and dark follow the
   system; data-theme on <html> pins one. Every colour is a token here;
   no inline style anywhere (strict CSP). */

:root {
  color-scheme: light;
  --head: #14302d;
  --head-ink: #f3f6f4;
  --head-muted: #b9cbc5;
  --ground: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --line: #d9d6ce;
  --line-soft: #e9e6df;
  --ink: #1b2024;
  --muted: #626a70;
  --accent: #0e6f64;
  --accent-ink: #ffffff;
  --link: #0b5f55;
  --focus: #0e6f64;
  --ok: #0f6e3c;
  --ok-wash: #e3f3e8;
  --warn: #9a4f00;
  --warn-wash: #fcefdc;
  --fail: #a61e1e;
  --fail-wash: #fbe7e5;
  --off: #626a70;
  --off-wash: #eceae4;
  --info: #26495c;
  --info-wash: #e4edf2;
  --family: #2f5e54;
  --family-wash: #e0efea;
  --channel: #3b4a7a;
  --channel-wash: #e6e9f5;
  --country: #6a4e1e;
  --country-wash: #f6ecd8;
  --msg: #fbfaf6;
  --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --head: #0d1f1d;
    --head-ink: #eef2f0;
    --head-muted: #9fb3ad;
    --ground: #15181b;
    --surface: #1d2125;
    --surface-2: #22272c;
    --line: #343a41;
    --line-soft: #2a3036;
    --ink: #e6e8ea;
    --muted: #9ba3ab;
    --accent: #3cb4a4;
    --accent-ink: #0b1a18;
    --link: #6fd0c1;
    --focus: #6fd0c1;
    --ok: #62cf8c;
    --ok-wash: #163322;
    --warn: #f0a94f;
    --warn-wash: #3a2a12;
    --fail: #f28f86;
    --fail-wash: #3d1c1a;
    --off: #9ba3ab;
    --off-wash: #2a3036;
    --info: #b7cfdc;
    --info-wash: #1f2e37;
    --family: #9fd6c8;
    --family-wash: #1b3530;
    --channel: #b4bff0;
    --channel-wash: #252c45;
    --country: #e6c88a;
    --country-wash: #3a2f17;
    --msg: #181c20;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --head: #0d1f1d;
  --head-ink: #eef2f0;
  --head-muted: #9fb3ad;
  --ground: #15181b;
  --surface: #1d2125;
  --surface-2: #22272c;
  --line: #343a41;
  --line-soft: #2a3036;
  --ink: #e6e8ea;
  --muted: #9ba3ab;
  --accent: #3cb4a4;
  --accent-ink: #0b1a18;
  --link: #6fd0c1;
  --focus: #6fd0c1;
  --ok: #62cf8c;
  --ok-wash: #163322;
  --warn: #f0a94f;
  --warn-wash: #3a2a12;
  --fail: #f28f86;
  --fail-wash: #3d1c1a;
  --off: #9ba3ab;
  --off-wash: #2a3036;
  --info: #b7cfdc;
  --info-wash: #1f2e37;
  --family: #9fd6c8;
  --family-wash: #1b3530;
  --channel: #b4bff0;
  --channel-wash: #252c45;
  --country: #e6c88a;
  --country-wash: #3a2f17;
  --msg: #181c20;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
ul, ol { margin: 0; padding-left: 1.2em; }

code, pre, .mono, time { font-family: var(--mono); font-size: 13px; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.wrap { overflow-wrap: anywhere; }
.err { color: var(--fail); }
.lead { color: var(--muted); max-width: 72ch; }
.prose { max-width: 72ch; display: grid; gap: 10px; }
.prose h2 { margin-top: 8px; }

.skip-link {
  position: absolute; left: 16px; top: -60px; padding: 6px 10px; z-index: 10;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
}
.skip-link:focus { top: 8px; }

/* Header: brand, nav, the lookup box, the theme button */
.topbar { background: var(--head); color: var(--head-ink); --focus: #ffffff; }
.topbar-inner {
  display: flex; align-items: center; gap: 8px 20px; flex-wrap: wrap;
  max-width: 1360px; margin: 0 auto; padding: 10px 16px;
}
.brand { display: inline-flex; align-items: baseline; gap: 8px; color: inherit; text-decoration: none; white-space: nowrap; }
.brand-mark {
  display: inline-grid; place-items: center; align-self: center; width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink); font-weight: 750; font-size: 15px;
}
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { color: var(--head-muted); font-size: 14px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a {
  color: var(--head-ink); text-decoration: none; padding: 6px 10px; border-radius: var(--radius);
  border-bottom: 2px solid transparent; font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, 0.08); }
.nav a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 650; }
.search { display: flex; gap: 6px; flex: 1 1 280px; max-width: 460px; margin-left: auto; }
.search input {
  flex: 1 1 auto; min-width: 0; font: inherit; font-size: 14px; padding: 6px 10px; border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.1); color: var(--head-ink);
}
.search input::placeholder { color: var(--head-muted); }
.theme { color: var(--head-ink); background: transparent; border-color: rgba(255, 255, 255, 0.3); white-space: nowrap; }
.theme:hover { background: rgba(255, 255, 255, 0.08); }

/* Main and footer */
.main { flex: 1 0 auto; width: 100%; max-width: 1360px; margin: 0 auto; padding: 20px 16px 48px; }
.main h1 { margin-bottom: 14px; }
.view { display: grid; gap: 20px; }
.loading, .empty { color: var(--muted); padding: 8px 0; }
.footer {
  border-top: 1px solid var(--line); padding: 14px 16px 24px; color: var(--muted); font-size: 13px;
  display: grid; gap: 4px; max-width: 1360px; margin: 0 auto; width: 100%;
}

section { display: grid; gap: 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card h2, .card h3 { margin-bottom: 8px; }

/* Chips */
.chip {
  display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 20px;
  white-space: nowrap; color: var(--c); background: var(--w); vertical-align: middle;
}
.chip-family { --c: var(--family); --w: var(--family-wash); }
.chip-channel { --c: var(--channel); --w: var(--channel-wash); }
.chip-country { --c: var(--country); --w: var(--country-wash); }
.chip-ok { --c: var(--ok); --w: var(--ok-wash); }
.chip-warn { --c: var(--warn); --w: var(--warn-wash); }
.chip-fail { --c: var(--fail); --w: var(--fail-wash); }
.chip-off { --c: var(--off); --w: var(--off-wash); }
.chip-info { --c: var(--info); --w: var(--info-wash); }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Tables: a sticky header, dense rows, a row is a link. On a desktop the
   page scrolls and the header sticks to the top of the window; on a phone
   the table scrolls sideways in its own box. */
.table-wrap { overflow: visible; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
.table th, .table td { padding: 7px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
.table th { font-weight: 600; }
.table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); white-space: nowrap; border-bottom-color: var(--line); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr.row-link:hover { background: var(--surface-2); }
.table .num { text-align: right; }
.table .nowrap { white-space: nowrap; }
.table .wrap { overflow-wrap: break-word; }
.table .sub { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.table-wrap .empty { padding: 12px; }
.table .cell-lure { min-width: 18ch; max-width: 34ch; }
.table .cell-ask { min-width: 18ch; max-width: 34ch; }
.table a.row-open { color: inherit; text-decoration: none; font-weight: 600; }
.table a.row-open:hover { text-decoration: underline; }

/* Key/value block */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* Buttons, fields */
.btn {
  font: inherit; font-size: 14px; font-weight: 600; line-height: 20px; padding: 5px 12px; border-radius: var(--radius);
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none;
  display: inline-block;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: default; filter: none; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-small { font-size: 13px; padding: 2px 9px; line-height: 18px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input, select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 5px 9px; max-width: 100%;
}
input[type="search"] { -webkit-appearance: none; appearance: none; }
textarea { width: 100%; padding: 8px 10px; font-family: var(--mono); font-size: 13px; line-height: 1.45; resize: vertical; }
label { font-size: 14px; }
.field { display: grid; gap: 4px; }
.field > label { font-weight: 600; }
.field .help { color: var(--muted); font-size: 13px; }
.form { display: grid; gap: 14px; max-width: 760px; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.counter { color: var(--muted); font-size: 13px; }
.counter.err { color: var(--fail); font-weight: 600; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--fail); }
.checkline { display: flex; gap: 8px; align-items: flex-start; }
.checkline input { margin-top: 3px; }

/* Banner, toast, notice */
.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px;
  background: var(--fail-wash); border: 1px solid var(--fail); border-left-width: 4px; border-radius: var(--radius);
}
.banner p { flex: 1 1 24ch; overflow-wrap: anywhere; }
.notice {
  padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--info); border-left-width: 4px; background: var(--info-wash);
  display: grid; gap: 6px;
}
.notice-ok { border-color: var(--ok); background: var(--ok-wash); }
.notice-warn { border-color: var(--warn); background: var(--warn-wash); }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20; max-width: min(92vw, 60ch);
  padding: 9px 14px; border-radius: var(--radius); background: var(--head); color: #ffffff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); font-size: 14px;
}
.toast-fail { background: #a61e1e; }
.toast-ok { background: #0f6e3c; }

/* Library: the family rail on the left, the filters and the table */
.library { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.rail { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; display: grid; gap: 1px; align-content: start; font-size: 14px; }
.rail h2 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 0 10px 6px; }
.rail a {
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline; color: var(--ink); text-decoration: none;
  padding: 4px 10px; border-radius: var(--radius); border-left: 3px solid transparent; line-height: 1.35;
}
.rail a:hover { background: var(--surface); }
.rail a[aria-current="true"] { background: var(--surface); border-left-color: var(--accent); font-weight: 650; }
.rail .n { color: var(--muted); font-size: 13px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filters .field { gap: 2px; }
.filters .field > label { font-size: 13px; color: var(--muted); font-weight: 500; }
.filters input, .filters select { min-width: 9ch; }
.filters .field-q { flex: 1 1 220px; }
.filters .field-q input { width: 100%; }
.result-line { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; color: var(--muted); font-size: 13px; }
.paging { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.paging .btn-ghost[aria-disabled="true"] { pointer-events: none; }
.family-def { color: var(--muted); max-width: 72ch; }

/* Entry page: the message on the left, the facts on the right */
.entry { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.entry-head { display: grid; gap: 8px; }
.message { background: var(--msg); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; }
.message .meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 10px; font-size: 13px; }
.message .meta dt { color: var(--muted); }
.message .meta dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
.message pre { padding: 8px 0 0; border-top: 1px solid var(--line-soft); font-size: 13.5px; line-height: 1.5; }
.links { list-style: none; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.links li { font-family: var(--mono); overflow-wrap: anywhere; }
.links .arrow { color: var(--muted); }
.reasons { display: grid; gap: 4px; }
.indicators { list-style: none; padding: 0; display: grid; gap: 6px; }
.indicators li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.indicators .value { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; flex: 1 1 16ch; }
.indicators .kind { color: var(--muted); font-size: 12.5px; min-width: 6ch; }
.related { display: grid; gap: 8px; }
.related article { display: grid; gap: 4px; padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--surface-2); }
.side { display: grid; gap: 14px; }

/* About */
.tiles { display: flex; gap: 12px; flex-wrap: wrap; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; display: grid; gap: 0; min-width: 120px; }
.tile .n { font-size: 22px; font-weight: 650; line-height: 1.2; }
.tile .l { color: var(--muted); font-size: 13px; }

/* Phone and narrow tablet: one column, the rail becomes a row of links */
@media (max-width: 900px) {
  .library { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; max-height: none; overflow: visible; display: flex; flex-wrap: wrap; gap: 4px; }
  .rail h2 { flex-basis: 100%; padding: 0 0 4px; }
  .rail a { border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 13px; background: var(--surface); }
  .rail a[aria-current="true"] { background: var(--family-wash); border-color: var(--family); color: var(--family); }
  .entry { grid-template-columns: minmax(0, 1fr); }
  .table-wrap { overflow: auto; }
  .table thead th { position: static; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 6px; }
}
@media (max-width: 600px) {
  .topbar-inner { gap: 8px 12px; }
  .brand-sub { display: none; }
  .search { flex-basis: 100%; max-width: none; margin-left: 0; order: 3; }
  .nav { order: 2; margin-left: auto; }
  .theme { order: 4; }
  .nav a { padding: 6px 7px; font-size: 14px; }
  h1 { font-size: 21px; }
  .message .meta { grid-template-columns: 1fr; }
  /* On a phone the list keeps the date, the family, the country, the brand
     and the lure; the channel and the ask wait on the entry page. */
  .table .col-channel, .table .col-ask { display: none; }
}
