/* Tocha 360 — cores de praiadatocha.pt (azul-marinho, oceano, dourado, areia) e a onda como transição.
   Letras: Young Serif nos títulos; Public Sans no texto, na interface e em TODOS os números. */
:root {
  --navy: #072848;
  --navy-2: #0b3a66;
  --ocean: #006dc8;
  --ocean-dark: #0056a2;
  --gold: #e2b74d;
  --sun: #dc9e2e;
  --sun-dark: #c4861a;
  --sand: #fdfaf0;
  --sand-2: #faf2d9;
  --sand-line: #efe3c2;
  --amber-text: #7a4f0e;
  --text: #173a5e;
  --muted: #587390;
  --card: #ffffff;
  --success: #1f7a4a;
  --success-soft: #e3f3ea;
  --error: #b3262b;
  --error-soft: #fbeaea;
  --warn: #8a5a00;
  --warn-soft: #fff3d6;
  --info-soft: #e5f1fb;
  --font: 'Public Sans Variable', 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Young Serif', Georgia, 'Times New Roman', serif;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-pill: 999px;
  --focus: 0 0 0 3px rgba(0, 109, 200, 0.28);
  --lift: 0 10px 30px -12px rgba(7, 40, 72, 0.28);
  --side: 420px;
  --wave-navy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 24' preserveAspectRatio='none'%3E%3Cpath d='M0 0h1440v8c-120 10-240 16-360 12S840 4 720 6 480 22 360 22 120 10 0 6z' fill='%23072848'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--sand);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: lining-nums;
}
a { color: var(--ocean); text-underline-offset: 2px; }
a:hover { color: var(--ocean-dark); }
h1, h2, h3 { color: var(--navy); margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.15rem; font-weight: 600; margin-top: 1.5rem; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
img { max-width: 100%; }
:focus-visible { outline: none; box-shadow: var(--focus); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.app { display: grid; grid-template-rows: auto 1fr; height: 100dvh; }

/* ---------- Cabeçalho com a onda ---------- */
.header {
  position: relative;
  z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--navy);
  color: #fff;
}
.header::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -14px; height: 15px;
  background: var(--wave-navy) center / 100% 100% no-repeat;
  pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-logo { width: 40px; height: 40px; flex: none; }
.brand-text { display: flex; flex-direction: column; }
.brand strong { font-family: var(--display); font-weight: 400; font-size: 23px; line-height: 1.1; color: #fff; letter-spacing: -0.01em; }
.num, .brand .num { font-family: var(--font); font-weight: 700; font-variant-numeric: lining-nums tabular-nums; letter-spacing: 0; }
.brand small { font-size: 12px; color: rgba(255, 255, 255, .62); }
.header-nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.header-link, .header-nav a, .linkish {
  color: var(--gold); font-family: var(--font); font-size: 14.5px; text-decoration: none; font-weight: 600;
}
.header-nav a:hover, .linkish:hover { color: #fff; }
.header-link-soft { color: rgba(255, 255, 255, .75) !important; }
.lang-toggle {
  min-width: 40px; min-height: 32px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1.5px solid rgba(255, 255, 255, .45); color: #fff;
  font: 700 13px/1 var(--font); letter-spacing: .04em;
}
.lang-toggle:hover { border-color: var(--gold); color: var(--gold); }
.lang-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.header-nav .who { color: rgba(255, 255, 255, .7); font-size: 13px; }
.linkish { background: none; border: 0; padding: 0; cursor: pointer; }

/* ---------- Corpo: painel + mapa ---------- */
.body { display: grid; grid-template-columns: var(--side) 1fr; min-height: 0; }
.side { overflow-y: auto; padding: 34px 24px 48px; min-width: 0; background: var(--sand); }
.workspace { position: relative; isolation: isolate; min-height: 0; min-width: 0; }
.map { position: absolute; inset: 0; background: #dfe8ee; }

.map-tools { position: absolute; top: 28px; left: 14px; z-index: 1000; display: flex; gap: 8px; }
.glass {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 16px; border-radius: var(--r-pill);
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(7, 40, 72, .72); color: #fff;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font: 600 14px/1 var(--font); cursor: pointer;
}
.glass:hover { background: rgba(7, 40, 72, .88); }
.glass svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.mapfoot {
  position: absolute; left: 14px; bottom: 26px; z-index: 1000; max-width: calc(100% - 28px);
  padding: 8px 14px; border-radius: var(--r-pill);
  background: rgba(7, 40, 72, .78); color: #fff; font-size: 13px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.mapfoot:empty { display: none; }
.foot-ok { color: #9be3b8; font-weight: 600; }
.foot-error { color: #ffc2c2; font-weight: 600; }

body[data-auth='out'] .workspace { display: none; }
body[data-auth='out'] .body { grid-template-columns: 1fr; }
body[data-auth='out'] .side { max-width: 440px; margin: 9vh auto 0; width: 100%; }

/* ---------- Tipografia ---------- */
.hero { font-family: var(--display); font-weight: 400; font-size: 34px; line-height: 1.14; letter-spacing: -0.015em; color: var(--navy); margin-bottom: 12px; text-wrap: balance; }
.lead { color: var(--muted); font-size: 16px; max-width: 34em; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--sun-dark); margin: 14px 0 2px; }
.detail-title { font-family: var(--display); font-size: 1.6rem; font-weight: 400; letter-spacing: -.01em; margin-top: 2px; text-wrap: balance; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.warn-text { color: var(--warn); font-weight: 600; }
.display { font-family: var(--display); font-weight: 400; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 18px; border-radius: var(--r);
  border: 1px solid var(--sand-line); background: var(--card); color: var(--navy);
  font: 600 14px/1.2 var(--font); cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: #e0cf9f; color: var(--navy); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--sun); border-color: var(--sun); color: var(--navy); }
.btn-primary:hover { background: var(--sun-dark); border-color: var(--sun-dark); }
.btn-ocean { background: var(--ocean); border-color: var(--ocean); color: #fff; }
.btn-ocean:hover { background: var(--ocean-dark); color: #fff; }
.btn-soft { background: var(--sand-2); border-color: var(--sand-2); color: var(--amber-text); border-radius: var(--r-pill); }
.btn-danger { background: var(--error); border-color: var(--error); color: #fff; }
.btn-danger:hover { background: #921d21; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; padding-left: 0; padding-right: 6px; color: var(--ocean); }
.btn-ghost:hover { background: transparent; text-decoration: underline; color: var(--ocean-dark); }
.form > .btn-ghost, .side > .btn-ghost { align-self: flex-start; }
.btn-active { background: var(--info-soft); border-color: var(--ocean); color: var(--ocean-dark); }
.btn-small { min-height: 34px; padding: 5px 14px; }
.btn-block { width: 100%; min-height: 52px; font-size: 16px; border-radius: var(--r-pill); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; align-items: center; }
.inline { display: flex; gap: 8px; margin-top: 6px; }
.inline input { flex: 1; }

/* ---------- Formulários ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-step { font-family: var(--display); font-weight: 400; font-size: 21px; color: var(--navy); margin: 12px 0 -4px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 13.5px; font-weight: 600; color: var(--navy); }
.hint { font-size: 12.5px; color: var(--muted); }
input, select, textarea {
  width: 100%; font: 400 16px/1.4 var(--font); color: var(--navy);
  padding: 11px 13px; border: 1px solid var(--sand-line); border-radius: var(--r); background: var(--card);
}
input::placeholder, textarea::placeholder { color: #9aaabb; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--ocean); }
textarea { resize: vertical; }
input[readonly] { background: var(--sand-2); border-color: var(--sand-2); color: var(--amber-text); font-weight: 600; }
input[type='search'] { border-radius: var(--r-pill); padding-left: 40px; background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23587390' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 14px center / 18px no-repeat; }
input[type='checkbox'] { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--ocean); }
input[type='file'] { padding: 9px; font-size: 14px; }
input[type='file']::file-selector-button {
  font: 600 13px var(--font); color: var(--amber-text); background: var(--sand-2);
  border: 0; border-radius: var(--r-pill); padding: 8px 14px; margin-right: 10px; cursor: pointer;
}
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; padding: 4px 0; }
.check.entity { padding: 8px 0; border-bottom: 1px solid var(--sand-line); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; font-size: 14px; color: var(--navy); padding: 0; margin-bottom: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.loc { display: flex; gap: 8px; }
.loc input { flex: 1; min-width: 0; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.filters { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
altcha-widget.captcha {
  --altcha-border-radius: 12px;
  --altcha-color-border: var(--sand-line);
  --altcha-color-base: #fff;
  --altcha-color-text: var(--navy);
  --altcha-max-width: 100%;
  display: block;
}

/* ---------- Blocos ---------- */
.box { background: var(--card); border: 1px solid var(--sand-line); border-radius: var(--r-lg); padding: 16px 18px; margin: 16px 0; }
.box-approval { border: 2px solid var(--gold); background: #fffcf2; }
details > summary { cursor: pointer; font-weight: 600; color: var(--navy); }
details[open] > summary { margin-bottom: 10px; }
.danger summary { color: var(--error); }
.alert { padding: 11px 14px; border-radius: var(--r); font-size: 14px; margin: 10px 0; }
.alert-error { background: var(--error-soft); color: var(--error); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-ok { background: var(--success-soft); color: var(--success); }

.thanks { padding: 30px 0 10px; }
.thanks h2 { font-family: var(--display); font-weight: 400; font-size: 40px; margin: 0 0 6px; }
.thanks .ref { display: inline-block; font-weight: 700; color: var(--navy); background: var(--sand-2); padding: 6px 14px; border-radius: var(--r-pill); }

/* Números: Public Sans em negrito, algarismos alinhados */
.stats { display: flex; gap: 34px; margin: 26px 0 4px; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-family: var(--font); font-weight: 750; font-size: 30px; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: lining-nums tabular-nums; color: var(--ocean-dark); }
.stats small { font-size: 13px; color: var(--muted); }

/* ---------- Lista de ocorrências ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--sand-line); border-radius: var(--r);
  padding: 12px 14px; font: inherit; color: inherit;
}
.item:hover { border-color: var(--gold); }
.item-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-body strong { color: var(--navy); font-weight: 600; overflow-wrap: anywhere; }
.item-body small { color: var(--muted); font-size: 12.5px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; margin-top: 5px; box-shadow: 0 0 0 3px rgba(255, 255, 255, 1), 0 0 0 4px var(--sand-line); }

.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: var(--r-pill); background: var(--sand-2); color: var(--amber-text); white-space: nowrap; }
.chip-ok { background: var(--success-soft); color: var(--success); }
.status-nova { background: var(--sand-2); color: var(--amber-text); }
.status-encaminhada { background: var(--info-soft); color: var(--ocean-dark); }
.status-em-resolucao { background: #fff1cf; color: #7a5300; }
.status-resolvida { background: var(--success-soft); color: var(--success); }
.status-arquivada { background: #eceff3; color: #56606b; }
.mod-pendente { background: var(--gold); color: var(--navy); }
.mod-aprovada { background: var(--success-soft); color: var(--success); }
.mod-rejeitada { background: var(--error-soft); color: var(--error); }
.d-chip-enviado, .d-chip-submetido { background: var(--success-soft); color: var(--success); }
.d-chip-simulado, .d-chip-por_submeter { background: var(--warn-soft); color: var(--warn); }
.d-chip-erro { background: var(--error-soft); color: var(--error); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }

/* Fotografia com cartão de legenda sobreposto (como "Arte Xávega" no site) */
.photo-figure { position: relative; margin: 14px 0 34px; }
.photo-figure img { display: block; width: 100%; max-height: 300px; object-fit: cover; border-radius: var(--r-lg); box-shadow: var(--lift); background: var(--sand-2); }
.photo-figure figcaption {
  position: absolute; left: -8px; bottom: -22px; max-width: 75%;
  background: #fff; border-radius: var(--r); padding: 9px 14px; box-shadow: var(--lift);
}
.photo-figure figcaption strong { display: block; font-family: var(--display); font-weight: 400; font-size: 17px; color: var(--navy); line-height: 1.25; }
.photo-figure figcaption span { font-size: 12px; color: var(--muted); }
.photo { display: block; width: 100%; max-height: 320px; object-fit: cover; border-radius: var(--r-lg); margin: 8px 0; background: var(--sand-2); }
.photo-wrap { display: flex; flex-direction: column; align-items: flex-start; }

/* ---------- Separadores (admin) ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--sand-2); border-radius: var(--r-pill); margin: -6px 0 16px; overflow-x: auto; }
.tab { flex: 1; background: none; border: 0; border-radius: var(--r-pill); padding: 9px 12px; font: 600 14px var(--font); cursor: pointer; color: var(--amber-text); white-space: nowrap; }
.tab.active { background: var(--navy); color: #fff; }

.dispatches { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.dispatch { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--sand-line); border-radius: var(--r); padding: 12px; }
.dispatch.d-por_submeter { border-color: var(--gold); background: #fffcf2; }
.dispatch.d-erro { border-color: #f0c4c5; background: #fdf6f6; }
.manual { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.manual .actions { margin: 0; }
.message { white-space: pre-wrap; font: 12.5px/1.5 var(--font); background: var(--sand); padding: 12px; border-radius: var(--r); max-height: 260px; overflow: auto; }
.history { margin: 0; padding-left: 18px; }
.entity-form.inactive { opacity: .6; }

/* ---------- Página de texto ---------- */
.page { max-width: 720px; margin: 0 auto; padding: 40px 20px 64px; }
.page h2 { margin-top: 1.75rem; }
.page .hero { font-size: 40px; }

/* ---------- Aviso flutuante ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--navy); color: #fff; padding: 12px 20px; border-radius: var(--r-pill); box-shadow: var(--lift);
  font-size: 14px; font-weight: 500; z-index: 3000; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--error); }

/* ---------- Leaflet ---------- */
.leaflet-container { font-family: var(--font); }
.leaflet-bar { border: 0 !important; box-shadow: var(--lift) !important; border-radius: var(--r) !important; overflow: hidden; }
.leaflet-bar a { color: var(--navy) !important; width: 36px !important; height: 36px !important; line-height: 36px !important; }
.leaflet-top.leaflet-left { top: 70px; }
.leaflet-top.leaflet-right { top: 20px; }
.leaflet-control-layers { border: 0 !important; border-radius: var(--r) !important; box-shadow: var(--lift) !important; }
.leaflet-control-scale { margin-bottom: 70px !important; }
.leaflet-tooltip { font: 600 12.5px var(--font); color: var(--navy); border: 0; border-radius: var(--r-sm); box-shadow: var(--lift); }

/* ---------- Telemóvel: mapa em cima, painel sobe como uma folha ---------- */
@media (max-width: 760px) {
  .app { height: auto; min-height: 100dvh; }
  .header { padding: 8px 16px; }
  .brand-logo { width: 34px; height: 34px; }
  .brand strong { font-size: 21px; }
  .header-link-soft { display: none; }
  .body { grid-template-columns: 1fr; }
  .workspace { order: -1; height: 50dvh; min-height: 300px; }
  body[data-view='form'] .workspace { height: 44dvh; }
  .side {
    position: relative; z-index: 30;
    margin-top: -26px; border-radius: 26px 26px 0 0;
    padding: 30px 18px calc(44px + env(safe-area-inset-bottom));
    overflow: visible; box-shadow: 0 -8px 24px -12px rgba(7, 40, 72, .35);
  }
  .side::before {
    content: ''; position: absolute; top: 10px; left: 50%; width: 44px; height: 5px; margin-left: -22px;
    border-radius: 3px; background: var(--sand-line);
  }
  body[data-auth='out'] .side { margin-top: 32px; border-radius: 0; box-shadow: none; }
  body[data-auth='out'] .side::before { display: none; }
  .mapfoot { bottom: 40px; }
  .leaflet-control-scale { display: none; }
  .hero { font-size: 30px; }
  .row3 { grid-template-columns: 1fr; }
  .cat-grid { grid-template-columns: 1fr; }
}

/* ======================================================================
   Componentes personalizados: seletores, botões segmentados, mosaicos, pinos
   ====================================================================== */
.ic { display: inline-block; vertical-align: -0.2em; flex: none; }

/* Seletor (substitui <select>) */
.picker { position: relative; }
.picker-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px;
  padding: 8px 12px 8px 10px; border: 1px solid var(--sand-line); border-radius: var(--r); background: var(--card);
  font: 500 15px/1.2 var(--font); color: var(--navy); cursor: pointer; text-align: left;
}
.picker-btn:hover { border-color: #e0cf9f; }
.picker.open .picker-btn { border-color: var(--ocean); box-shadow: var(--focus); }
.picker-value { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.picker-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-text.placeholder { color: #9aaabb; }
.picker-chev { color: var(--muted); transition: transform .15s; }
.picker.open .picker-chev { transform: rotate(180deg); }
.picker-pop {
  position: absolute; z-index: 50; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--card); border: 1px solid var(--sand-line); border-radius: var(--r-lg);
  box-shadow: var(--lift); padding: 6px; max-height: 340px; display: flex; flex-direction: column;
}
.picker-head { display: none; }
.picker-search { margin: 2px 2px 6px; width: auto; }
.picker-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; outline: none; }
.picker-opt {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm);
  cursor: pointer; color: var(--navy); font-size: 15px;
}
.picker-opt.active { background: var(--sand); }
.picker-opt[aria-selected='true'] { font-weight: 600; }
.picker-group { padding: 10px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.picker-empty { padding: 12px 10px; color: var(--muted); }
.opt-label { flex: 1; min-width: 0; }
.opt-count { font-size: 12.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.opt-check { width: 18px; color: var(--ocean); }
.opt-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
/* Ícone sobre um "ponto" redondo, na cor da categoria */
.opt-ic, .item-ic, .tile-ic {
  display: inline-grid; place-items: center; flex: none; border-radius: 50%;
}
.opt-ic { width: 32px; height: 32px; }
.picker-backdrop { display: none; }

/* Botões segmentados (Estado, Moderação, Prioridade) */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.seg.scroll::-webkit-scrollbar { display: none; }
.seg-btn {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  min-height: 38px; padding: 6px 13px; border-radius: var(--r-pill);
  border: 1px solid var(--sand-line); background: var(--card); color: var(--navy);
  font: 500 14px/1 var(--font); cursor: pointer; white-space: nowrap;
}
.seg-btn:hover { border-color: #e0cf9f; }
.seg-btn[aria-checked='true'] { background: var(--navy); border-color: var(--navy); color: #fff; }
.seg-count { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; padding: 2px 7px; border-radius: var(--r-pill); background: var(--sand-2); color: var(--amber-text); }
.seg-btn[aria-checked='true'] .seg-count { background: rgba(255, 255, 255, .16); color: #fff; }

/* Mosaicos (tipo de problema no formulário) */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 10px;
  border: 1px solid var(--sand-line); border-radius: var(--r); background: var(--card);
  font: 500 13.5px/1.25 var(--font); color: var(--navy); text-align: left; cursor: pointer;
}
.tile:hover { border-color: color-mix(in srgb, var(--c) 45%, var(--sand-line)); }
.tile-ic { width: 36px; height: 36px; color: var(--c); background: color-mix(in srgb, var(--c) 13%, #fff); }
.tile[aria-checked='true'] { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, #fff); box-shadow: inset 0 0 0 1px var(--c); font-weight: 600; }
.tile[aria-checked='true'] .tile-ic { background: var(--c); color: #fff; }

/* Lista: ícone da categoria num ponto */
.item-ic { width: 38px; height: 38px; color: var(--c); background: color-mix(in srgb, var(--c) 13%, #fff); }
.item { align-items: center; }
.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 1.5rem; }
.list-head h2 { margin: 0 0 .5rem; }
.btn-link { background: none; border: 0; padding: 0; font: 600 14px var(--font); color: var(--ocean); cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.chip-cat { display: inline-flex; align-items: center; gap: 5px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); }
.filters .field > input[type='search'] { width: 100%; }

/* Pinos do mapa com ícone */
.pin-wrap { background: none; border: 0; }
.pin {
  position: absolute; left: 2px; top: 0; width: 30px; height: 30px;
  border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--c); border: 2.5px solid #fff; box-shadow: 0 4px 10px -2px rgba(7, 40, 72, .45);
  display: grid; place-items: center; transition: transform .12s;
}
.pin-ic { transform: rotate(45deg); color: #fff; display: grid; }
.pin-pending { border: 2.5px dashed var(--navy); opacity: .85; }
.pin-rejected { opacity: .6; }
.leaflet-marker-icon.hot .pin, .pin-wrap:hover .pin { transform: rotate(-45deg) scale(1.18); }
.leaflet-marker-icon.hot { z-index: 1000 !important; }

/* <select> nativos restantes com o mesmo aspeto */
select {
  appearance: none; -webkit-appearance: none; padding-right: 38px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23587390' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='m6.5 9.5 5.5 5.5 5.5-5.5'/%3E%3C/svg%3E") right 12px center / 18px no-repeat;
}

/* Símbolo da app (ponto de mapa com o palheiro) */
.brand-mark { width: 38px; height: 44px; flex: none; }

/* Telemóvel: o seletor abre como folha de baixo */
@media (max-width: 760px) {
  .picker-pop {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 2600;
    max-height: 72dvh; border-radius: 22px 22px 0 0; border: 0;
    padding: 10px 10px calc(14px + env(safe-area-inset-bottom));
  }
  .picker-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 2500; background: rgba(7, 40, 72, .45); }
  .picker-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 10px; color: var(--navy); font-size: 16px; }
  .picker-close { background: var(--sand-2); border: 0; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--navy); cursor: pointer; }
  .picker-opt { padding: 12px 10px; font-size: 16px; }
  .brand-mark { width: 32px; height: 38px; }
}

/* ======================================================================
   Página de teste do território (freguesias)
   ====================================================================== */
.freg-label { background: none; border: 0; pointer-events: none; display: none; }
.freg-label span {
  display: inline-block; transform: translate(-50%, -50%); white-space: nowrap;
  font: 600 12px/1.2 var(--font); color: var(--navy);
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 6px #fff;
}
.labels-concelho .freg-label.concelho { display: block; }

.freg-list { display: flex; flex-direction: column; gap: 4px; }
.freg-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border: 1px solid transparent; border-radius: var(--r-sm); background: none;
  font: 500 14.5px var(--font); color: var(--navy); cursor: pointer; text-align: left;
}
.freg-row:hover { background: var(--card); border-color: var(--sand-line); }
.freg-row.on { background: var(--card); border-color: var(--gold); font-weight: 600; }
.freg-name { flex: 1; min-width: 0; }
.freg-meta { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.freg-card { border-left: 5px solid var(--c); }
.freg-card .stats { margin: 10px 0 12px; }

.legend { margin-top: 20px; }
.legend p { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 13.5px; }
.lg { width: 28px; height: 14px; border-radius: 3px; flex: none; }
.lg-limite { border: 3px solid var(--navy); }
.lg-freg { background: rgba(226, 183, 77, .3); border: 1.5px solid rgba(7, 40, 72, .55); }
.lg-margem { border: 2px dashed var(--navy); }
.demo-flag { display: inline-block; font-size: 12.5px; font-weight: 600; color: var(--amber-text); background: var(--sand-2); padding: 4px 12px; border-radius: var(--r-pill); margin-bottom: 12px; }
.probe-freguesia, .probe-margem { border-left: 5px solid var(--success); }
.probe-fora { border-left: 5px solid var(--error); }
.lg-fora { background: rgba(7, 40, 72, .32); }

/* ======================================================================
   Fase 2: votos, acompanhamento, zonas, levantamentos, avisos, erosão
   ====================================================================== */
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 4px; }
.quick-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 10px;
  border: 1px solid var(--sand-line); border-radius: var(--r-pill); background: var(--card);
  font: 600 13.5px var(--font); color: var(--navy); text-decoration: none; cursor: pointer;
}
.quick-btn:hover { border-color: var(--gold); color: var(--navy); }

.campaign { display: flex; gap: 12px; border: 2px solid var(--ocean); background: var(--info-soft); }
.campaign h3 { margin: 2px 0 4px; }
.campaign-ic { color: var(--ocean); flex: none; margin-top: 2px; }
.campaign-row.on { border-color: var(--ocean); }

.queue { display: flex; align-items: center; gap: 12px; background: var(--warn-soft); border-color: #f1dc9c; color: var(--warn); }
.queue strong { color: var(--navy); }

.mine h3 { margin-bottom: 8px; }
.mine-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mine-row { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 6px 0; cursor: pointer; font: 500 14px var(--font); color: var(--navy); text-align: left; }
.mine-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mine-row:hover .mine-title { text-decoration: underline; }

.notices h2, .points h2 { margin-top: 1.25rem; }
.notice {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer; margin-bottom: 6px;
  background: var(--card); border: 1px solid var(--sand-line); border-left: 4px solid var(--navy); border-radius: var(--r); padding: 10px 12px; font: inherit; color: inherit;
}
.notice:hover { border-color: var(--gold); border-left-color: var(--navy); }
.notice-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; flex: none; }
.notice-ic.point { background: #0e7490; }
.notice-kind { color: var(--muted); font-size: 12px; }
.points .notice { border-left-color: #0e7490; }

.item-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.counts { display: inline-flex; gap: 10px; color: var(--muted); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.counts span { display: inline-flex; align-items: center; gap: 3px; }
.counts.big { font-size: 13.5px; margin: 0 0 10px; color: var(--ocean-dark); }

/* Votos */
.votes { display: grid; gap: 8px; margin: 14px 0; }
.vote {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; text-align: left; cursor: pointer;
  border: 1px solid var(--sand-line); border-radius: var(--r); background: var(--card); font: inherit; color: var(--navy);
}
.vote:hover:not([disabled]) { border-color: var(--ocean); }
.vote-ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--info-soft); color: var(--ocean); flex: none; }
.vote-text { flex: 1; display: flex; flex-direction: column; }
.vote-text small { color: var(--muted); font-size: 12.5px; }
.vote-count { font-weight: 750; font-size: 20px; color: var(--ocean-dark); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.vote.done { background: var(--success-soft); border-color: #bfe0cc; }
.vote.done:hover { border-color: var(--success); }
.vote.done .vote-ic { background: var(--success); color: #fff; }

/* Duplicados no formulário */
.dup { border: 2px solid var(--gold); background: #fffcf2; margin: 0; }
.dup-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--sand-line); }
.dup-row .item-ic { width: 32px; height: 32px; }
.dup-row .item-body { flex: 1; }
.box-check { background: var(--info-soft); border-radius: var(--r); padding: 10px 12px; }

/* Antes e depois / galeria */
.before-after { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.before-after figure, .gallery figure { margin: 0; }
.before-after img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r); background: var(--sand-2); }
.before-after figcaption { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 8px 0 14px; }
.gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r); background: var(--sand-2); }
.gallery figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Linha temporal do acompanhamento */
.timeline { list-style: none; margin: 16px 0; padding: 0; }
.timeline li { position: relative; display: flex; gap: 12px; padding-bottom: 16px; }
.timeline li:not(:last-child)::before { content: ''; position: absolute; left: 11px; top: 26px; bottom: 0; width: 2px; background: var(--sand-line); }
.timeline li.done:not(:last-child)::before { background: var(--success); }
.tl-dot { width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center; border: 2px solid var(--sand-line); background: var(--card); color: #fff; }
.timeline li.done .tl-dot { background: var(--success); border-color: var(--success); }
.timeline strong { color: var(--navy); }

/* Pinos de avisos e pontos de fotografia */
.pin-notice, .pin-point { border-radius: 50% 50% 50% 0; }

/* Indicadores */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--sand-line); }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 9.5rem) 1fr 2.5ch; gap: 8px; align-items: center; font-size: 13px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; background: var(--sand-2); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--ocean); border-radius: 999px; }
.bar-n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--navy); }
.cols { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; height: 130px; padding-top: 10px; }
.col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.col-bar { width: 100%; max-width: 22px; background: var(--ocean); border-radius: 4px 4px 0 0; min-height: 0; }
.col-n { font-size: 11px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.col-l { font-size: 10.5px; color: var(--muted); }

/* Página "O que já se resolveu" */
.page.wide { max-width: 1080px; }
.solved-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 18px; margin-top: 20px; }
.solved { background: var(--card); border: 1px solid var(--sand-line); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; }
.solved .before-after { margin: 0; gap: 2px; }
.solved .before-after img, .solved-photo img { border-radius: 0; }
.solved .before-after figcaption { position: relative; margin: -26px 0 0 8px; color: #fff; text-shadow: 0 1px 3px #0009; height: 26px; }
.solved-photo { margin: 0; }
.solved-photo img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.solved-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.solved-title { font-family: var(--display); font-weight: 400; font-size: 1.25rem; margin: 2px 0 0; }
body.embed { background: transparent; }
body.embed .page { padding: 8px; }
.embed-title { font-family: var(--display); font-weight: 400; font-size: 22px; margin: 0; }
body.embed .solved-grid { margin-top: 10px; gap: 10px; }

@media (max-width: 760px) {
  .quick { grid-template-columns: 1fr; }
}

/* ======================================================================
   Botão voltar, câmara, equipamentos no mapa, percurso
   ====================================================================== */
.btn-back {
  align-self: flex-start; min-height: 40px; padding: 7px 16px 7px 10px; gap: 4px;
  border: 1.5px solid var(--sand-line); border-radius: var(--r-pill); background: var(--card); color: var(--navy);
  box-shadow: 0 1px 2px rgba(7, 40, 72, .06); margin-bottom: 6px;
}
.btn-back:hover { border-color: var(--navy); background: var(--card); }
.side > .btn-back, .form > .btn-back { display: inline-flex; }

.chip { display: inline-flex; align-items: center; gap: 5px; }
.tabs { flex-wrap: wrap; border-radius: var(--r-lg); overflow: visible; }
.tab { flex: 0 1 auto; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.photo-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-btns .btn { cursor: pointer; }
.photo-btns label:focus-within { box-shadow: var(--focus); }

/* Equipamentos da categoria escolhida */
.asset-wrap { background: none; border: 0; }
.asset {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px;
  background: var(--c); color: var(--navy); border: 1.5px solid #fff;
  box-shadow: 0 2px 6px -1px rgba(7, 40, 72, .45);
}
.asset-wrap .asset { position: absolute; left: 1px; top: 0; }
.asset-wrap .asset::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -4px; border: 4px solid transparent; border-top-color: var(--c); }
.asset-ecoponto, .asset-contentor, .asset-papeleira, .asset-bebedouro, .asset-banco, .asset-mesa { color: #fff; }
.asset-chosen { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--gold); border-radius: var(--r); background: #fffcf2; }
.asset-chosen .asset { flex: none; }
.asset-popup .leaflet-popup-content { display: flex; flex-direction: column; gap: 8px; font: 500 14px var(--font); color: var(--navy); margin: 12px 14px; }
.asset-popup .leaflet-popup-content-wrapper { border-radius: var(--r); }
.hint .ic { display: inline-block; vertical-align: -2px; }

.timeline li.entity .tl-dot { background: var(--ocean); border-color: var(--ocean); }
.timeline li.todo strong { color: var(--muted); font-weight: 500; }
.box > .timeline { margin: 6px 0 0; }

.timeline small { display: block; margin-top: 1px; }
.btn-link { display: inline-flex; align-items: center; gap: 6px; }

/* Fotografias múltiplas, rejeição */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-top: 8px; }
.thumb { position: relative; margin: 0; }
.thumb img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-sm); background: var(--sand-2); }
.thumb-del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(7, 40, 72, .8); color: #fff; cursor: pointer; }
.reject-panel { margin-top: 12px; padding: 14px; border: 2px solid var(--error); border-radius: var(--r); background: var(--error-soft); display: flex; flex-direction: column; gap: 12px; }
.reject-panel h3 { margin: 0; color: var(--error); }
.tl-note { background: var(--card); border-left: 3px solid var(--gold); padding: 8px 10px !important; border-radius: 0 var(--r-sm) var(--r-sm) 0; margin-top: 4px !important; color: var(--text); }

/* Rodapé: quem desenvolveu e trata os dados */
.site-foot { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--sand-line); font-size: 13px; color: var(--muted); }
.site-foot p { margin: 0 0 6px; }
.site-foot strong { color: var(--navy); font-weight: 600; }
