/* Layout: mapa ocupa a tela à esquerda, painel de bairros à direita; no celular o mapa fica em cima e o painel embaixo. */
:root {
  --bg: #f3f4f1;
  --panel: #ffffff;
  --ink: #17202e;
  --muted: #5b6573;
  --line: #dde0dc;
  --accent: #d0213a;
  --accent-ink: #ffffff;
  --ok: #1d7a4c;
  --ok-soft: #dff2e7;
  --warn: #9a6200;
  --warn-soft: #fdf0d5;
  --sea: #cfdde6;
  --land: #fbfbf8;
  --land-line: #9aa3ab;
  --bairro-line: #c3c8c6;
  --dot: #6b7480;
  --font-display: "Bricolage Grotesque", "Archivo", system-ui, sans-serif;
  --font-body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161d; --panel: #18202a; --ink: #e8ebee; --muted: #9aa5b1; --line: #2a3441;
    --accent: #ff4d63; --accent-ink: #1a0508; --ok: #4fd08f; --ok-soft: #173326; --warn: #f2b84b; --warn-soft: #3a2c10;
    --sea: #0c1219; --land: #1c2530; --land-line: #4c5866; --bairro-line: #2f3a47; --dot: #8f9aa6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11161d; --panel: #18202a; --ink: #e8ebee; --muted: #9aa5b1; --line: #2a3441;
  --accent: #ff4d63; --accent-ink: #1a0508; --ok: #4fd08f; --ok-soft: #173326; --warn: #f2b84b; --warn-soft: #3a2c10;
  --sea: #0c1219; --land: #1c2530; --land-line: #4c5866; --bairro-line: #2f3a47; --dot: #8f9aa6;
  color-scheme: dark;
}
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.45; }
* { box-sizing: border-box; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: minmax(0, 1fr) 420px; height: 100%; }
.mapwrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--sea); }
.side { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; min-width: 0; }

.head { padding: 20px 20px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
h1 { font-family: var(--font-display); font-weight: 800; font-size: 28px; line-height: 1.05; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
.lede { margin: 0; color: var(--muted); max-width: 60ch; }
.adminbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: 14px; }
.mine { padding: 10px 12px; border-radius: 8px; font-size: 14px; border: 1px solid var(--line); }
.mine.pendente { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.mine.aprovado { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.mine.recusado { color: var(--muted); }

.list { padding: 12px 20px 24px; display: grid; gap: 10px; }
.search { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.rows { display: grid; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: baseline; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 10px 2px; cursor: pointer; width: 100%; }
.row:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.row .nm { font-weight: 600; min-width: 0; }
.row .mn { color: var(--muted); font-size: 12px; grid-column: 1; }
.row .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; text-align: right; grid-row: 1; grid-column: 2; }
.row .vol { grid-column: 2; grid-row: 2; font-size: 12px; text-align: right; color: var(--muted); }
.row .vol.has { color: var(--ok); font-weight: 600; }
.colhead { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 4px 2px; }

.detail { padding: 16px 20px 28px; display: grid; gap: 16px; }
.back { justify-self: start; background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font-size: 14px; }
.back:hover { color: var(--ink); }
h2 { font-family: var(--font-display); font-weight: 800; font-size: 26px; line-height: 1.1; margin: 0; text-wrap: balance; }
.sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.stat b { display: block; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 500; }
.stat span { font-size: 12px; color: var(--muted); }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 6px; }
.locais { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 14px; }
.locais li { display: grid; gap: 1px; }
.locais small { color: var(--muted); }
.cta { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 12px 16px; font-weight: 700; cursor: pointer; font-size: 15px; }
.cta:disabled { opacity: .5; cursor: not-allowed; }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 600; }
.note { font-size: 13px; color: var(--muted); }
.vols { display: grid; gap: 10px; }
.volcard { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 6px; font-size: 14px; }
.volcard .who { font-weight: 700; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.volcard .contact { font-family: var(--font-mono); font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.tag.yes { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.no { color: var(--muted); text-decoration: line-through; }
.empty { border: 1px dashed var(--line); border-radius: 10px; padding: 14px; color: var(--muted); font-size: 14px; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-size: 13px; font-weight: 600; }

/* formulário */
form { display: grid; gap: 14px; }
.field { display: grid; gap: 4px; }
.field label, .field legend { font-weight: 600; font-size: 14px; }
.field input[type=text], .field input[type=tel], .field input[type=email], .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.field textarea { min-height: 64px; resize: vertical; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; min-width: 0; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.opt span { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 13px; }
.opt input:checked + span { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.dias .opt span { font-family: var(--font-mono); font-size: 12px; min-width: 64px; text-align: center; }
.err { color: var(--accent); font-size: 13px; }
.formactions { display: flex; gap: 8px; flex-wrap: wrap; }

/* modal do admin */
.overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--ink) 45%, transparent); display: grid; place-items: center; padding: 16px; z-index: 2000; }
.modal { background: var(--panel); border-radius: 14px; max-width: 460px; width: 100%; max-height: calc(100% - 32px); overflow-y: auto; padding: 20px; display: grid; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h2 { font-size: 22px; }
.modal dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: 14px; }
.modal dt { color: var(--muted); }
.modal dd { margin: 0; overflow-wrap: anywhere; }
.approve { background: var(--ok); color: var(--panel); border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 700; cursor: pointer; }
.reject { background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 600; }
.counter { font-size: 13px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 3000; max-width: calc(100% - 32px); }

/* mapa */
.leaflet-container { background: var(--sea); font-family: var(--font-body); }
.leaflet-control-zoom a { background: var(--panel) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.blabel { background: transparent; border: 0; box-shadow: none; color: var(--muted); font-size: 11px; font-weight: 600; padding: 0; white-space: nowrap; text-shadow: 0 0 3px var(--land), 0 0 3px var(--land); }
.blabel::before { display: none; }
.map-hide-labels .blabel { display: none; }
.tip { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.15); font-size: 13px; }
.tip::before { display: none; }
.legend { position: absolute; left: 12px; bottom: 12px; z-index: 500; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; display: grid; gap: 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.leaflet-tile-pane { filter: saturate(.55) contrast(.95); }
.map-escuro .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.4); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--panel) 85%, transparent) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: inherit !important; }
.foot { margin-top: auto; padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.foot a { color: inherit; }
.foot .aviso { flex-basis: 100%; margin: 0 0 4px; max-width: 60ch; line-height: 1.45; }
.foot .aviso b { color: var(--ink); font-weight: 600; }
.setup { margin: 20px; padding: 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.setup code { font-family: var(--font-mono); font-size: 12px; }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 46vh auto; height: auto; }
  .mapwrap { height: 46vh; }
  .side { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  h1 { font-size: 24px; }
  .head, .list, .detail, .foot { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* veículos e trios (admin) */
.tag.veic { background: var(--warn-soft); color: var(--warn); border-color: transparent; font-weight: 600; }
.row .vol .veic { color: var(--warn); }
.trio .membros { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.trio .membros li { display: grid; gap: 2px; }
.trio .membros small { color: var(--muted); font-weight: 400; }
.trio .aviso-trio { color: var(--warn); }
