/* nossoambiente: estilos compartilhados (início, registrar, painel, termos). */

:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6b6a65;
  --line: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #1a7f37;
  --accent-ink: #ffffff;
  --point: #008300;
  --danger: #b42318;
  --before: #eb6834;
  --after: #2a78d6;
  --outfall: #52514e;
  --water: #cfe0ea;
  --badge-bg: #fff1cc;
  --badge-ink: #5c4300;
  --ok: #006300;
  --ring: rgba(11, 11, 11, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.05);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --max: 1120px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #a3a29a;
    --line: #2c2c2a;
    --axis: #383835;
    --accent: #4cc38a;
    --accent-ink: #0b0b0b;
    --point: #3fbf6a;
    --danger: #f97066;
    --before: #d95926;
    --after: #3987e5;
    --outfall: #c3c2b7;
    --water: #1d3640;
    --badge-bg: #3a2f12;
    --badge-ink: #f3d58a;
    --ok: #0ca30c;
    --ring: rgba(255, 255, 255, 0.10);
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242422;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #a3a29a;
  --line: #2c2c2a;
  --axis: #383835;
  --accent: #4cc38a;
  --accent-ink: #0b0b0b;
  --point: #3fbf6a;
  --danger: #f97066;
  --before: #d95926;
  --after: #3987e5;
  --outfall: #c3c2b7;
  --water: #1d3640;
  --badge-bg: #3a2f12;
  --badge-ink: #f3d58a;
  --ok: #0ca30c;
  --ring: rgba(255, 255, 255, 0.10);
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.15; letter-spacing: -0.015em; margin: 0 0 0.5em; }
h1 { font-size: clamp(2rem, 5.5vw, 3.3rem); font-weight: 750; }
h2 { font-size: clamp(1.5rem, 3.6vw, 2.1rem); font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 650; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: 3px; }
small, .small { font-size: 0.875rem; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }

/* Header */

.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand svg { width: 24px; height: 24px; color: var(--before); flex: none; }
.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-size: 0.95rem; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); font-weight: 600; }

/* Buttons and chips */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--axis); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.btn:focus-visible, .chip:focus-visible, .nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font: inherit; font-size: 0.9rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--page); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--badge-bg); color: var(--badge-ink);
  font-size: 0.8rem; font-weight: 650; letter-spacing: 0.02em;
}

/* Cards and numbers */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
@media (min-width: 720px) {
  .grid.c2 { grid-template-columns: repeat(2, 1fr); }
  .grid.c3 { grid-template-columns: repeat(3, 1fr); }
  .grid.c4 { grid-template-columns: repeat(4, 1fr); }
}

.stat .label { color: var(--ink-2); font-size: 0.9rem; }
.stat .value { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.stat .sub { color: var(--muted); font-size: 0.85rem; }

/* Horizontal bars (plain HTML): one series, labels in text ink */

.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(96px, 34%) 1fr auto; align-items: center; gap: 10px; font-size: 0.9rem; }
.bar-row .name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { position: relative; height: 14px; }
.bar-row .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .fill + .fill { top: 8px; bottom: -2px; }
.bar-row .val { font-variant-numeric: tabular-nums; color: var(--ink); min-width: 3.5em; text-align: right; }
.bar-row.pair .track { height: 20px; }
.bar-row.pair .fill.a { top: 0; bottom: 11px; }
.bar-row.pair .fill.b { top: 11px; bottom: 0; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.875rem; color: var(--ink-2); margin: 0 0 10px; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Columns per section (SVG) */

.cols svg { display: block; width: 100%; height: auto; overflow: visible; }
.cols .axis { stroke: var(--axis); stroke-width: 1; }
.cols .grid-line { stroke: var(--line); stroke-width: 1; }
.cols text { fill: var(--muted); font: 11px var(--sans); }
.cols .hit { fill: transparent; cursor: default; }

.tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 0.85rem; box-shadow: var(--shadow);
  max-width: 240px;
}
.tip[hidden] { display: none; }

/* Tables */

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-2); font-weight: 600; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Maps */

.map { width: 100%; height: 420px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.map-fallback { display: grid; place-items: center; height: 100%; color: var(--muted); padding: 16px; text-align: center; }
.maplibregl-popup-content { background: var(--surface); color: var(--ink); border-radius: 10px; font: 14px/1.45 var(--sans); padding: 10px 14px; }
.maplibregl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.maplibregl-popup-close-button { color: var(--ink-2); font-size: 18px; }

/* Data notice */

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 10px; background: var(--badge-bg); color: var(--badge-ink); font-size: 0.92rem; }
.notice b { font-weight: 700; }

.foot { border-top: 1px solid var(--line); margin-top: 56px; padding: 24px 0 40px; color: var(--muted); font-size: 0.875rem; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* Formulários */

label.field { display: grid; gap: 6px; font-weight: 600; font-size: 0.95rem; }
input[type="text"], input[type="email"], input[type="number"], textarea, select {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 650; background: var(--surface-2); color: var(--ink-2); }
.status.approved { background: rgba(26,127,55,0.14); color: var(--ok); }
.status.rejected { background: rgba(180,35,24,0.12); color: var(--danger); }
.status.pending { background: var(--badge-bg); color: var(--badge-ink); }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--page); padding: 10px 16px; border-radius: 10px; max-width: calc(100vw - 32px); }
.thumb { width: 100%; max-height: 50vh; object-fit: contain; border-radius: 10px; background: var(--surface-2); display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn.primary .kbd { background: transparent; color: inherit; border-color: currentColor; }
