/* Identidade E-RIO — Manual de Identidade Gráfica v2.0 (2026).
   Cores: Azul Céu 387ED6, Verde Aquático 6FE2C1, Branco Pedra EDFFF7, Azul Talvegue 071E2D, Laranja Alcedo EF6023
   (HEX das secundárias impressos no manual estão errados; usados os valores das amostras de cor).
   Tipografia: Lexend — títulos Bold, subtítulos Medium, texto Regular.
   Layout: mapa em ecrã inteiro, barra superior navy, painel inferior. Alto contraste para uso ao sol. */
@font-face { font-family: "Lexend"; font-weight: 400; font-display: swap; src: url("fonts/lexend-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Lexend"; font-weight: 500; font-display: swap; src: url("fonts/lexend-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Lexend"; font-weight: 700; font-display: swap; src: url("fonts/lexend-latin-700-normal.woff2") format("woff2"); }
:root {
  --river: #071E2D;      /* Azul Talvegue: barra, botões principais */
  --river-2: #387ED6;    /* Azul Céu (cor principal): destaques, rótulos */
  --bank: #EDFFF7;       /* Branco Pedra: fundos de campos */
  --surface: #ffffff;
  --ink: #0A222F;        /* texto corrente E-RIO */
  --muted: #5C7185;      /* CINZENTO E-RIO */
  --line: #C9DCE8;       /* AZUL CLARO E-RIO */
  --aqua: #6FE2C1;       /* Verde Aquático (cor principal) */
  --planned: #EF6023;    /* Laranja Alcedo: ponto por visitar */
  --done: #071E2D;       /* ponto visitado (navy com contorno água) */
  --pres: #EF6023;       /* Presença */
  --ext: #B3261E;        /* Presente extensivo */
  --danger: #B3261E;
  --ok: #138A6A;
  --shadow: 0 6px 24px rgba(4, 20, 31, .24);
  --radius: 14px;
  --font: "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bank: #04141F; --surface: #0A222F; --ink: #EDFFF7; --muted: #8FA8BC; --line: #1C3A52;
    --river: #071E2D; --river-2: #6FA6EA; --done: #387ED6; color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); font-size: 16px; color: var(--ink); background: var(--bank);
  overflow: hidden; overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* Barra superior */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 1000;
  display: flex; gap: 8px; align-items: stretch;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
  background: var(--river); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.tb-project, .tb-troco {
  flex: 1 1 0; min-width: 0; text-align: left; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.1); color: #fff; padding: 6px 10px; display: flex; flex-direction: column;
}
.tb-troco { flex: 0 1 38%; background: rgba(255,255,255,.18); }
.tb-label { font-size: 11px; letter-spacing: .12em; font-weight: 500; color: var(--aqua); text-transform: uppercase; opacity: .75; }
.tb-value { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-brand { flex: none; display: grid; place-items: center; width: 34px; }
.tb-brand img { width: 26px; height: auto; display: block; }
.brand-band { background: var(--river); border-radius: 12px; padding: 18px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand-band img { height: 46px; width: auto; display: block; }
.brand-band span { color: var(--aqua); font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; }
.icon-btn { border: 0; background: transparent; color: #fff; width: 44px; border-radius: 10px; display: grid; place-items: center; }

#map { position: fixed; inset: 0; z-index: 1; background: #cfd8d4; }

.gps-pill {
  position: fixed; z-index: 900; left: max(10px, env(safe-area-inset-left));
  top: calc(env(safe-area-inset-top, 0px) + 74px);
  background: var(--surface); color: var(--ink); border-radius: 999px; padding: 5px 11px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow); font-variant-numeric: tabular-nums;
}
.gps-pill.good { color: var(--ok); }
.gps-pill.weak { color: var(--pres); }
.gps-pill.bad { color: var(--danger); }

.map-tools {
  position: fixed; z-index: 900; right: max(10px, env(safe-area-inset-right));
  top: calc(env(safe-area-inset-top, 0px) + 74px); display: flex; flex-direction: column; gap: 10px;
}
.round-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--surface); color: var(--river-2);
  box-shadow: var(--shadow); display: grid; place-items: center;
}
.fab {
  position: fixed; z-index: 900; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  display: flex; align-items: center; gap: 8px; border: 0; border-radius: 999px;
  padding: 15px 24px; font-size: 17px; font-weight: 700; background: var(--river); color: #fff; box-shadow: var(--shadow);
}
.fab:active { transform: translateX(-50%) scale(.97); }

/* Painel inferior */
.sheet-backdrop { position: fixed; inset: 0; z-index: 1100; background: rgba(5,15,13,.35); }
.sheet {
  position: fixed; z-index: 1200; left: 0; right: 0; bottom: 0; max-height: 86vh; max-height: 86dvh;
  background: var(--surface); color: var(--ink); border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 760px) { .sheet { left: auto; right: 16px; bottom: 16px; width: 440px; border-radius: 18px; max-height: calc(100dvh - 110px); } }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 2px; flex: none; }
.sheet-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 6px max(16px, env(safe-area-inset-right)) 18px max(16px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 16px;
}
.sheet h2 { margin: 4px 0 0; font-size: 21px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; text-wrap: balance; }
.sheet h3 { margin: 0 0 8px; font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--river-2); }
.sub { color: var(--muted); font-size: 14px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 12px; padding: 12px 14px; font-weight: 500; min-height: 46px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn.primary { background: var(--river); border-color: var(--river); color: #EDFFF7; font-weight: 700; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.grow { flex: 1 1 0; }
.btn:disabled { opacity: .5; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 500; }
input[type=text], input[type=date], textarea, select {
  font: inherit; color: var(--ink); background: var(--bank); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; width: 100%; font-size: 16px;
}
textarea { min-height: 84px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Classificação P1..Pn */
.class-list { display: flex; flex-direction: column; gap: 8px; }
.class-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.class-name { font-weight: 500; font-size: 15px; }
.class-name b { display: inline-block; min-width: 30px; color: var(--muted); font-variant-numeric: tabular-nums; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 10px 4px; font-size: 14px; font-weight: 500; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on[data-v="A"] { background: var(--bank); color: var(--ink); }
.seg button.on[data-v="P"] { background: var(--pres); color: #fff; }
.seg button.on[data-v="E"] { background: var(--ext); color: #fff; }

/* Chips de pressões no ponto */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 13px;
  font-size: 14px; font-weight: 500; color: var(--ink);
}
.chip.on { background: var(--river); border-color: var(--river); color: #fff; }

/* Fotos */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 0; padding: 0; background: var(--bank); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .tag { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.thumb.sketch-thumb { background: #fff; }
.thumb.sketch-thumb img { object-fit: contain; }
.empty { color: var(--muted); font-size: 14px; }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; letter-spacing: .02em; white-space: nowrap; }
.badge.done { background: color-mix(in srgb, var(--aqua) 35%, transparent); color: var(--ink); }
.badge.planned { background: color-mix(in srgb, var(--planned) 18%, transparent); color: var(--planned); }

.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.list button { text-align: left; border: 0; background: var(--surface); padding: 13px 14px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.list button + button { border-top: 1px solid var(--line); }
.list button.on { background: color-mix(in srgb, var(--river-2) 12%, var(--surface)); }
.list .meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-list .btn { justify-content: flex-start; text-align: left; }
.note { font-size: 13px; color: var(--muted); line-height: 1.45; }

/* Esboço */
.sketch { position: fixed; inset: 0; z-index: 1500; background: var(--bank); display: flex; flex-direction: column; }
.sketch-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.sk-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sk-color { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface); background: var(--c); box-shadow: 0 0 0 1px var(--line); }
.sk-color.on { box-shadow: 0 0 0 3px var(--river-2); }
.sk-tool { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 10px; font-weight: 500; min-width: 40px; }
#skCanvas { flex: 1; width: 100%; touch-action: none; background: #fff; display: block; }
.sk-hint { font-size: 12px; color: var(--muted); text-align: center; padding: 6px 12px calc(env(safe-area-inset-bottom, 0px) + 6px); background: var(--surface); }

/* Visualizador de foto */
.viewer { position: fixed; inset: 0; z-index: 1600; background: #000; display: flex; flex-direction: column; }
.viewer img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px max(14px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom, 0px) + 10px) max(14px, env(safe-area-inset-left));
  color: #fff; font-size: 13px; background: #111; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; z-index: 2000; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 92px);
  background: #04141F; color: #EDFFF7; padding: 11px 16px; border-radius: 12px; font-weight: 500; font-size: 15px;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px); text-align: center;
}

/* Marcadores */
.pt-icon { display: grid; place-items: center; border-radius: 50%; font-weight: 700; font-size: 12px; color: #fff; border: 2.5px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.45); font-family: var(--font); }
.pt-icon.done { background: var(--done); border-color: var(--aqua); }
.pt-icon.planned { background: #fff; color: var(--planned); border: 3px solid var(--planned); }
.pt-icon.other { background: var(--muted); }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(26,115,232,.35), 0 1px 4px rgba(0,0,0,.4); }
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-bottom.leaflet-left, .leaflet-bottom.leaflet-right { margin-bottom: env(safe-area-inset-bottom, 0px); }

@media (prefers-reduced-motion: no-preference) {
  .sheet:not([hidden]) { animation: up .18s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
}
