/* Observatorio cívico · mobile-first stylesheet.
   Tokens: warm neutrals, one green accent, 4px spacing rhythm, 44px minimum touch targets. */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efeee8;
  --ink: #1b2527;
  --ink-2: #384548;
  --muted: #626e71;
  --line: #e2e0d8;
  --line-strong: #ccc9bf;
  --accent: #1f5f50;
  --accent-hover: #184c40;
  --accent-soft: #e2eee8;
  --amber: #85560f;
  --amber-soft: #f6ebd7;
  --blue: #2c5574;
  --blue-soft: #e5edf4;
  --green: #256b4f;
  --green-soft: #e1f0e7;
  --red: #9e3a31;
  --case: #b56a22;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(20 30 30 / 5%), 0 6px 20px rgb(20 30 30 / 6%);
  --shadow-lg: 0 24px 64px rgb(15 25 28 / 24%);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --appbar-h: 60px;
  --tabbar-h: 66px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --max: 1160px;
  --gutter: 16px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font: 16px/1.55 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; }
h2 { font-size: 1.2rem; line-height: 1.3; letter-spacing: -0.01em; font-weight: 650; }
h3 { font-size: 1rem; line-height: 1.35; font-weight: 650; }
a { color: var(--accent); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { opacity: 0.55; cursor: progress; }
:focus-visible { outline: 3px solid #7fb9a4; outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 200; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.icon { width: 1.25em; height: 1.25em; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small, small { font-size: 0.8125rem; }
.eyebrow { font-size: 0.75rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.lead { font-size: 1.0625rem; color: var(--ink-2); }
.link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.9375rem; text-decoration: none; color: var(--accent); }
.link:hover { text-decoration: underline; }
.link .icon { width: 1em; height: 1em; }

/* ---------- Buttons, chips, badges ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px;
  font-weight: 600; font-size: 0.9375rem; line-height: 1.2; text-decoration: none; white-space: nowrap;
  border: 1px solid transparent; transition: background-color 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink-2); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-lg { min-height: 52px; padding: 14px 22px; font-size: 1rem; }
.btn-sm { min-height: 38px; padding: 8px 14px; font-size: 0.875rem; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--ink-2); flex-shrink: 0; }
.icon-btn:hover { background: var(--surface-2); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface);
  font-size: 0.875rem; font-weight: 550; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-admin { background: var(--amber-soft); border-color: #e7d3ad; color: var(--amber); min-height: 34px; padding: 6px 12px; font-size: 0.8125rem; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-outline { background: none; border: 1px solid var(--line-strong); color: var(--muted); }
.badge-accent { background: var(--accent); color: #fff; display: inline-flex; align-items: center; gap: 4px; }
.badge-accent svg { width: 13px; height: 13px; }
.chip .count { margin-left: 8px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 0.75rem; display: inline-grid; place-items: center; }

/* ---------- App bar and tab bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: var(--appbar-h); padding: 0 var(--gutter);
  /* Solid background on purpose: backdrop-filter would become the containing block of the fixed tab bar. */
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 0.975rem; }
.brand-text small { font-size: 0.75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-actions { display: flex; align-items: center; gap: 10px; }
.appbar-report { display: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding: 0 4px var(--safe-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a, .tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: var(--tabbar-h); font-size: 0.6875rem; font-weight: 600; color: var(--muted); text-decoration: none; text-align: center; line-height: 1.1;
}
.tabbar .icon { width: 24px; height: 24px; }
.tabbar a[aria-current] { color: var(--accent); }
.tab-report { color: var(--accent) !important; }
.tab-report .icon {
  width: 46px; height: 46px; padding: 11px; margin-top: -18px; border-radius: 50%;
  background: var(--accent); color: #fff; stroke-width: 2.4; box-shadow: 0 6px 16px rgb(31 95 80 / 35%);
}

.offline-bar { position: sticky; top: var(--appbar-h); z-index: 40; background: var(--amber-soft); color: var(--amber); padding: 8px var(--gutter); font-size: 0.875rem; text-align: center; }

/* ---------- Layout ---------- */
main { max-width: var(--max); margin: 0 auto; padding: 24px var(--gutter) 48px; outline: none; }
.view { display: flex; flex-direction: column; gap: 28px; animation: fade 0.2s ease-out; }
.section { display: flex; flex-direction: column; gap: 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.page-head p { color: var(--muted); }
.page-head-actions { max-width: none; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.pad { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.two-col, .value-grid { display: grid; gap: 16px; }
.block { display: flex; flex-direction: column; gap: 10px; }
.block-title { margin-top: 12px; }
.group-title { font-size: 0.8125rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 8px 0 4px; }
.loading { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 80px 20px; color: var(--muted); text-align: center; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 20px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.footer { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter) 28px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; font-size: 0.8125rem; color: var(--muted); }

/* ---------- Home ---------- */
.hero { display: flex; flex-direction: column; gap: 16px; padding: 8px 0 4px; max-width: 760px; }
.hero-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.steps li { display: flex; gap: 14px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.steps h2 { font-size: 1rem; margin-bottom: 4px; }
.steps p { color: var(--muted); font-size: 0.9375rem; }
.step-num { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.pilot-note { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink-2); font-size: 0.9375rem; }
.pilot-note .icon { color: var(--muted); margin-top: 2px; }
.figures { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.figure { display: flex; flex-direction: column; gap: 2px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.figure strong { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.figure span { font-weight: 600; font-size: 0.9375rem; }
.figure small { color: var(--muted); font-size: 0.75rem; }
.home-grid { display: grid; gap: 16px; }
.recent-card { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.recent { display: flex; flex-direction: column; gap: 8px; }
.topic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.topic { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 14px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.topic:hover { border-color: var(--line-strong); }
.topic .cat-icon { grid-row: span 2; }
.topic span:not(.cat-icon) { font-weight: 600; font-size: 0.9375rem; }
.topic small { color: var(--muted); font-size: 0.75rem; }
.cat-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }

/* ---------- Map ---------- */
.map-card { overflow: hidden; }
.map-frame { position: relative; display: flex; flex-direction: column; background: var(--surface); }
.map-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--line); }
.map { height: 340px; background: #e9ebe6; }
.map-placeholder { position: absolute; inset: 61px 0 30px; display: grid; place-items: center; padding: 20px; text-align: center; color: var(--muted); background: #e9ebe6; }
.map-credit { padding: 6px 12px; font-size: 0.75rem; color: var(--muted); }
.map-credit a { color: inherit; }
.map-label { font-size: 12px; font-weight: 600; color: #6b7a70; text-shadow: 0 1px #fff, 1px 0 #fff, -1px 0 #fff, 0 -1px #fff; pointer-events: none; white-space: nowrap; }
.marker { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid #fff; background: var(--case); color: #fff; box-shadow: 0 3px 10px rgb(20 30 30 / 30%); }
.marker .icon { width: 17px; height: 17px; stroke-width: 2.2; }
.marker-proposal { background: var(--accent); }
.marker-institution { width: 28px; height: 28px; background: var(--blue); }
.marker-institution .icon { width: 14px; height: 14px; }
.maplibregl-ctrl-logo { display: none !important; }
.pick-bar { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 16px; border-radius: 14px; background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); font-weight: 600; }
.pick-bar > span { display: flex; align-items: center; gap: 8px; }
.map-frame.picking { position: fixed; inset: 0; z-index: 100; }
.map-frame.picking .map { height: 100dvh; cursor: crosshair; }
.map-frame.picking .map-bar, .map-frame.picking .map-credit { display: none; }
.map-frame.picking .marker { pointer-events: none; opacity: 0.6; }
.map-frame.picking .map-placeholder { inset: 0; }

.toggle-group { display: flex; gap: 6px; flex-wrap: wrap; }
.toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.toggle span { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 14px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 0.875rem; font-weight: 550; background: var(--surface); }
.toggle input:checked + span { background: var(--accent-soft); border-color: #b9d6ca; color: var(--accent); }
.toggle input:checked + span::before { content: "✓"; margin-right: 6px; font-weight: 700; }
.toggle input:focus-visible + span { outline: 3px solid #7fb9a4; outline-offset: 2px; }

/* ---------- Cases ---------- */
.track-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; background: var(--accent-soft); border-color: #cfe2d9; }
.track-card p { color: var(--ink-2); font-size: 0.9375rem; }
.track-row { display: flex; gap: 8px; }
.track-row input { flex: 1; min-width: 0; font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.04em; text-transform: uppercase; }
.my-cases { display: flex; flex-direction: column; gap: 8px; }
.toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; }
.toolbar > .segmented, .toolbar > .search { grid-column: 1 / -1; }
.toolbar > .toggle { grid-column: 1 / -1; justify-self: start; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; min-height: 46px; padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--surface); font-size: 1rem;
}
textarea { resize: vertical; min-height: 110px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; text-overflow: ellipsis; }
.search { position: relative; display: block; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input[type="search"] { padding-left: 44px; }
.track-row input::placeholder { font-family: var(--font); text-transform: none; letter-spacing: 0; }
.segmented { display: inline-flex; padding: 4px; gap: 4px; border-radius: 14px; background: var(--surface-2); }
.segmented button { flex: 1; min-height: 40px; padding: 8px 16px; border-radius: 10px; font-weight: 600; font-size: 0.9375rem; color: var(--muted); white-space: nowrap; }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(20 30 30 / 12%); }
.segmented-wide { display: flex; }
.segmented-wide button { min-width: 0; white-space: normal; line-height: 1.25; }
.result-count { color: var(--muted); font-size: 0.875rem; margin-top: -12px; }
.case-grid { display: grid; gap: 12px; }
.case-card { display: flex; gap: 14px; align-items: flex-start; width: 100%; padding: 16px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color 0.15s, box-shadow 0.15s; }
.case-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.case-card.compact { padding: 12px; border-radius: 12px; }
.case-card.compact .cat-icon { width: 34px; height: 34px; border-radius: 10px; }
.case-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.case-meta { font-size: 0.75rem; color: var(--muted); font-weight: 550; }
.case-title { font-size: 1rem; line-height: 1.35; }
.case-zone { display: flex; align-items: center; gap: 4px; font-size: 0.875rem; color: var(--muted); min-width: 0; }
.case-zone .icon { width: 1em; height: 1em; }
.case-progress { display: flex; align-items: center; gap: 10px; font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); }
.meter { display: inline-flex; gap: 3px; }
.meter i { width: 14px; height: 5px; border-radius: 3px; background: var(--line); }
.meter i.on { background: var(--accent); }

/* ---------- Case detail ---------- */
.case-heading { font-size: 1.375rem; line-height: 1.3; }
.case-description { color: var(--ink-2); white-space: pre-wrap; }
.stepper { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.stepper li { position: relative; display: flex; align-items: center; gap: 12px; padding: 7px 0; color: var(--muted); font-size: 0.9375rem; }
.stepper li:not(:last-child)::after { content: ""; position: absolute; left: 11px; top: 32px; bottom: -8px; width: 2px; background: var(--line); }
.stepper .dot { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); flex-shrink: 0; z-index: 1; }
.stepper .dot .icon { width: 14px; height: 14px; stroke-width: 3; }
.stepper li.done { color: var(--ink-2); }
.stepper li.done .dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper li.done::after { background: var(--accent); }
.stepper li.current { color: var(--ink); font-weight: 650; }
.stepper li.current .dot { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.route-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 14px; background: var(--surface-2); }
.route-card strong { font-size: 1.0625rem; }
.route-card .btn { align-self: flex-start; margin-top: 6px; }
.facts { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px 16px; margin: 0; font-size: 0.9375rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.link-list li { display: flex; flex-direction: column; }
.link-list a { display: inline-flex; align-items: center; gap: 6px; font-weight: 550; }
.link-list .icon { width: 0.95em; height: 0.95em; }
.link-list small { color: var(--muted); }
/* Private message thread: the reader's own messages align right on the accent tint. */
.messages h3 { display: flex; align-items: center; gap: 8px; }
.messages h3 svg { width: 18px; height: 18px; color: var(--accent); }
.thread { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 14px 14px 14px 4px; background: var(--surface-2); }
.msg.mine { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: var(--accent-soft); }
.msg p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-meta { font-size: 0.75rem; color: var(--muted); }
.msg-form { display: flex; gap: 8px; align-items: flex-end; }
.msg-form textarea { flex: 1; min-width: 0; min-height: 64px; }
.history summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; }
.history ol { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.history li { font-size: 0.9375rem; color: var(--ink-2); }
.history time { display: block; font-size: 0.75rem; color: var(--muted); }
.callout { padding: 12px 14px; border-radius: 12px; font-size: 0.9375rem; }
.callout-amber { background: var(--amber-soft); color: var(--amber); }

/* Moderation: review queue, reviewer hints, text edit and publication checklist. */
.review-queue { margin-bottom: 16px; border-color: #e7d3ad; }
.review-queue h2 { margin: 0 0 4px; }
.queue { list-style: none; margin: 12px 0 4px; padding: 0; display: flex; flex-direction: column; }
.queue li + li { border-top: 1px solid var(--line); }
.queue-item { width: 100%; min-height: 56px; padding: 10px 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; text-align: left; background: none; border: 0; cursor: pointer; }
.queue-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.queue-item:hover strong { color: var(--accent); }
.review { display: flex; flex-direction: column; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.review .callout:not(.callout-amber) { background: var(--surface-2); }
.review .chip-row { margin-top: 8px; }
.review .chip { white-space: normal; text-align: left; max-width: 100%; height: auto; min-height: 40px; }
.redact summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; color: var(--accent); }
.redact form { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.criteria { border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0; padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.criteria .check { font-weight: 500; }
.code-box { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 14px; background: var(--accent-soft); border: 1px solid #cfe2d9; }
.code-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: clamp(0.95rem, 4.2vw, 1.25rem); letter-spacing: 0.02em; white-space: nowrap; user-select: all; }
.admin-form { display: flex; flex-direction: column; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ---------- Who responds ---------- */
.lookup { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.lookup .chip .icon { width: 1.1em; height: 1.1em; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 24px; }
.chain { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: chain; }
.chain > li { counter-increment: chain; position: relative; }
.chain > li .unit::before { content: counter(chain); position: absolute; top: 16px; right: 16px; font-weight: 700; color: var(--line-strong); font-size: 1.25rem; }
.unit-grid { display: grid; gap: 12px; }
.unit { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; height: 100%; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-align: left; }
.unit p { font-size: 0.9375rem; color: var(--ink-2); }
.unit-button:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.refs { font-size: 0.75rem !important; color: var(--muted) !important; margin-top: auto; }
.plain-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.numbered { margin: 0 0 6px; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 0.9375rem; }

/* ---------- About ---------- */
.value-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.value-icon .icon, .value-grid .icon { width: 22px; height: 22px; }
.value-grid .card > .icon { width: 44px; height: 44px; padding: 11px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.admin-card { display: flex; flex-direction: column; gap: 14px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Sheets (dialogs) ---------- */
dialog.sheet {
  width: 100%; max-width: 100%; max-height: 94dvh; margin: auto 0 0; padding: 0; border: 0;
  border-radius: 22px 22px 0 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-up 0.22s ease-out; }
dialog.sheet::backdrop { background: rgb(16 26 28 / 45%); }
.sheet > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 20px; border-bottom: 1px solid var(--line); }
.sheet-head .sheet-title, .sheet-head > div { flex: 1; min-width: 0; }
#report-sheet .sheet-head { padding-left: 10px; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.sheet-foot { display: flex; justify-content: space-between; gap: 10px; padding: 12px 16px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--line); }
.sheet-foot .btn-primary { flex: 1; max-width: 260px; margin-left: auto; }
#case-sheet .sheet-body, #info-sheet .sheet-body { padding-bottom: calc(24px + var(--safe-bottom)); }
.progress { height: 3px; background: var(--line); }
.progress span { display: block; height: 100%; width: 33%; background: var(--accent); transition: width 0.25s; }

/* ---------- Form ---------- */
fieldset.step { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9375rem; }
.field small { font-weight: 400; color: var(--muted); }
.field-label { font-weight: 600; font-size: 0.9375rem; padding: 0; }
.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.choice span { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 12px; font-size: 0.9375rem; font-weight: 550; cursor: pointer; }
.choice .icon { color: var(--accent); }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input:focus-visible + span { outline: 3px solid #7fb9a4; outline-offset: 2px; }
.location-status { font-size: 0.9375rem; color: var(--muted); }
.location-status .ok { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-weight: 600; }
.location-status .link { font-size: inherit; }
.summary { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; }
.summary-head { display: flex; gap: 12px; align-items: center; }
.summary .muted { display: flex; align-items: center; gap: 6px; font-size: 0.9375rem; }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 600; font-size: 0.9375rem; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.check small { display: block; font-weight: 400; color: var(--muted); }
.form-error { color: var(--red); font-size: 0.9375rem; font-weight: 550; }
.form-error:empty { display: none; }
.done-step { display: flex; flex-direction: column; gap: 16px; }
.done-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--green-soft); color: var(--green); }
.done-icon .icon { width: 30px; height: 30px; stroke-width: 2.4; }
.next-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); font-size: 0.9375rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px); transform: translateX(-50%); z-index: 300;
  width: max-content; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 0.9375rem; box-shadow: var(--shadow-lg);
}

@keyframes sheet-up { from { transform: translateY(28px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Tablet ---------- */
@media (min-width: 640px) {
  :root { --gutter: 24px; }
  .hero-actions { flex-direction: row; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .steps li { flex-direction: column; }
  .figures { grid-template-columns: repeat(4, 1fr); }
  .topic-grid { grid-template-columns: repeat(3, 1fr); }
  .case-grid, .unit-grid, .two-col, .value-grid { grid-template-columns: repeat(2, 1fr); }
  .value-grid { grid-template-columns: repeat(3, 1fr); }
  .chain { grid-template-columns: repeat(2, 1fr); }
  .toolbar { grid-template-columns: auto minmax(200px, 1fr) 190px 190px auto; }
  .toolbar > .segmented, .toolbar > .search, .toolbar > .toggle { grid-column: auto; }
  #panel-institutions .toolbar { grid-template-columns: 1fr 220px; }
  .choice-grid { grid-template-columns: repeat(3, 1fr); }
  .page-head-actions { flex-direction: row; align-items: flex-end; justify-content: space-between; }
  .admin-card { flex-direction: row; align-items: center; justify-content: space-between; }
  .map { height: 420px; }
  dialog.sheet { width: min(600px, calc(100vw - 48px)); max-height: 88dvh; margin: auto; border-radius: 22px; }
  dialog.sheet-side { width: min(540px, 100vw); height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; border-radius: 22px 0 0 22px; }
  dialog.sheet-side[open] { animation: sheet-in 0.22s ease-out; }
  .sheet-foot { padding-bottom: 14px; }
}
@media (min-width: 640px) and (max-width: 959px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar > .segmented, .toolbar > .search { grid-column: 1 / -1; }
}
@keyframes sheet-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Desktop: tabs move into the app bar ---------- */
@media (min-width: 960px) {
  :root { --appbar-h: 68px; --gutter: 32px; }
  body { padding-bottom: 0; }
  .appbar { padding: 0 max(var(--gutter), calc((100vw - var(--max)) / 2 + var(--gutter))); }
  .tabbar { position: static; display: flex; align-items: center; gap: 4px; height: auto; padding: 0; background: none; border: 0; }
  .tabbar a { flex-direction: row; gap: 8px; height: 40px; padding: 0 14px; border-radius: 10px; font-size: 0.9375rem; color: var(--ink-2); }
  .tabbar a:hover { background: var(--surface-2); }
  .tabbar a[aria-current] { background: var(--accent-soft); color: var(--accent); }
  .tabbar .icon { width: 18px; height: 18px; }
  .tab-report { display: none !important; }
  .appbar-report { display: inline-flex; }
  main { padding-top: 40px; }
  .view { gap: 36px; }
  .hero { padding: 24px 0 8px; gap: 20px; }
  .hero .lead { font-size: 1.1875rem; max-width: 640px; }
  .home-grid { grid-template-columns: minmax(0, 1fr) 340px; }
  .topic-grid { grid-template-columns: repeat(5, 1fr); }
  .case-grid, .unit-grid { grid-template-columns: repeat(3, 1fr); }
  .chain { grid-template-columns: repeat(5, 1fr); }
  .track-card { flex-direction: row; align-items: center; flex-wrap: wrap; justify-content: space-between; }
  .track-row { width: min(460px, 100%); }
  .my-cases { flex-basis: 100%; }
  .map { height: 460px; }
  .toast { bottom: 24px; }
}
