:root {
  color-scheme: light;
  --bg: #eaeee7;
  --surface: #ffffff;
  --surface-2: #f4f6f1;
  --ink: #16201b;
  --muted: #68706a;
  --line: #dde2da;
  --line-strong: #cbd2c8;
  --green: #1f5c48;
  --green-2: #2f7a5f;
  --amber: #a96716;
  --red: #9f2f2f;
  --teal: #266f75;
  --blue: #315f8c;
  --purple: #7d3c98;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(22, 32, 27, 0.06), 0 2px 6px rgba(22, 32, 27, 0.05);
  --shadow: 0 10px 28px rgba(22, 32, 27, 0.1), 0 2px 8px rgba(22, 32, 27, 0.06);
  --shadow-lg: 0 24px 64px rgba(22, 32, 27, 0.2);
  --sidebar-bg: linear-gradient(180deg, #1d2924 0%, #131c17 100%);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(238, 241, 236, 0.88), rgba(238, 241, 236, 0.92)),
    repeating-linear-gradient(90deg, #d9ded6 0 1px, transparent 1px 86px),
    repeating-linear-gradient(0deg, #d9ded6 0 1px, transparent 1px 86px);
}

.login-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
}

.login-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
  color: #29342e;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(47, 122, 95, 0.16);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.sidebar {
  background: var(--sidebar-bg);
  color: #f6faf6;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-logout {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: transparent;
  color: #e7b6b6;
  padding: 11px 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.sidebar-logout:hover {
  background: rgba(159, 47, 47, 0.2);
  border-color: rgba(220, 110, 110, 0.5);
  color: #ff9b9b;
}

.sidebar-logout svg {
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #e9f2ec;
  color: #18231f;
  font-weight: 900;
}

.brand small {
  display: block;
  color: #afbab4;
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 6px;
  position: relative;
}

.nav button {
  position: relative;
  text-align: left;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #cdd8d0;
  padding: 11px 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav button:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.nav button.active {
  background: #2a4339;
  color: #fff;
}

.nav button.active::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #4fd39a, var(--green-2));
}

.nav-more {
  font-weight: 700;
}

.nav-more[aria-expanded="true"] {
  background: #294239;
  color: #fff;
}

.nav-extra {
  position: fixed;
  z-index: 2500;
  top: 76px;
  left: 14px;
  width: 232px;
  display: grid;
  gap: 4px;
  padding: 8px;
  background: #20322b;
  border: 1px solid #36493f;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.nav-extra button {
  text-align: left;
  border-radius: 8px;
  background: transparent;
  color: #dce5df;
  padding: 10px 12px;
  white-space: nowrap;
}

.nav-extra button:hover,
.nav-extra button.active {
  background: #294239;
  color: #fff;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  margin: 3px 0 0;
  font-size: 28px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0;
  color: var(--green);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 12px;
}

.session {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.session-id {
  display: flex;
  align-items: center;
  gap: 10px;
}

#sessionRole {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--green);
  background: #f1f6f2;
  font-weight: 800;
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.logout-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

.logout-btn:active {
  transform: translateY(1px);
}

.logout-btn svg {
  flex: 0 0 auto;
}

@media (max-width: 520px) {
  .logout-label {
    display: none;
  }
  .logout-btn {
    padding: 8px 10px;
  }
}

.notice {
  margin: 18px 28px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--amber);
  background: #fff7ea;
  color: #5d3b0b;
  border-radius: 6px;
  font-weight: 700;
}

.content {
  padding: 20px 28px 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.map-modebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(118px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.map-modebar .segmented {
  grid-template-columns: repeat(5, minmax(104px, 1fr));
}

.register-tabs {
  grid-template-columns: repeat(2, minmax(132px, 1fr));
}

.segmented button {
  min-height: 40px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button.active {
  background: linear-gradient(180deg, #338a69, var(--green));
  color: #fff;
  box-shadow: 0 1px 2px rgba(22, 32, 27, 0.2);
}

.map-count {
  color: var(--muted);
  font-weight: 800;
}

.primary,
.secondary,
.danger {
  min-height: 40px;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.06s ease, border-color 0.16s ease;
}

.primary {
  background: linear-gradient(180deg, #338a69 0%, var(--green) 100%);
  color: #fff;
  box-shadow: 0 1px 2px rgba(22, 32, 27, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.primary:hover {
  background: linear-gradient(180deg, #3a9774 0%, #24634d 100%);
}

.primary:active {
  transform: translateY(1px);
}

.secondary {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.secondary:hover {
  border-color: var(--green-2);
  color: var(--green);
}

.secondary:active {
  transform: translateY(1px);
}

.danger {
  background: #f8e7e7;
  color: var(--red);
}

.primary:focus-visible,
.secondary:focus-visible,
.danger:focus-visible,
.nav button:focus-visible,
.segmented button:focus-visible {
  outline: 2px solid var(--green-2);
  outline-offset: 2px;
}

.full {
  width: 100%;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel,
.list-row,
.metric,
.detail-pane,
.report-sheet {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel,
.metric,
.detail-pane,
.report-sheet {
  box-shadow: var(--shadow-sm);
}

.panel {
  padding: 18px;
}

.panel h3,
.detail-pane h3,
.report-sheet h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.metric {
  padding: 15px;
  display: grid;
  gap: 5px;
}

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.metric span,
.muted {
  color: var(--muted);
}

.list {
  display: grid;
  gap: 10px;
}

.list-row {
  padding: 12px;
  display: grid;
  gap: 7px;
}

.person-row {
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
}

.list-row.clickable {
  cursor: pointer;
}

.list-row.clickable:hover {
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(47, 122, 95, 0.1);
}

.row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef3ef;
  color: #234236;
  font-size: 12px;
  font-weight: 800;
}

.tag.amber {
  background: #fff1d9;
  color: #74480e;
}

.tag.red {
  background: #f8e5e5;
  color: var(--red);
}

.tag.blue {
  background: #eaf1f7;
  color: var(--blue);
}

.tag.green {
  background: #e6f1eb;
  color: var(--green);
}

.tag.purple {
  background: #f1e7f5;
  color: var(--purple);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.map-wrap {
  position: relative;
  min-height: 590px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.55) 0 1px, transparent 1px 100%),
    linear-gradient(0deg, rgba(255, 255, 255, 0.55) 0 1px, transparent 1px 100%),
    #dfe7df;
  background-size: 56px 56px;
}

.map-label {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1200;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.map-label .ic {
  width: 15px;
  height: 15px;
  color: var(--green);
}

body.theme-dark .map-label {
  background: rgba(18, 26, 22, 0.88);
  color: var(--ink);
}

.map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: #2b3a31;
}

/* Marcadores com icone (substituem os pontos coloridos; o icone identifica o tipo) */
.mk-wrap {
  background: transparent;
  border: 0;
}

.mk {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  color: #fff;
  background: #555;
}

/* Carregando */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 20px;
  color: var(--muted);
  font-weight: 700;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--green);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Estado vazio */
.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
  padding: 44px 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty-ic {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--green-2);
  margin-bottom: 4px;
}

.empty-state h3 { margin: 0; }
.empty-state p { margin: 0; max-width: 320px; }
.empty-state .primary { margin-top: 8px; }

/* Toasts (feedback discreto, sem pop-ups nativos) */
.toast-host {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 4000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 16px;
}

.toast {
  max-width: 440px;
  width: fit-content;
  padding: 11px 16px;
  border-radius: 999px;
  background: #16201b;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast--ok {
  background: linear-gradient(180deg, #2f7a5f, #1f5c48);
}

.toast--error {
  background: linear-gradient(180deg, #b0413f, #8a2e2e);
}

.ficha-admin {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.ficha-admin-toggle {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  font-size: 13px;
  color: var(--green);
  padding: 4px 0;
}

.ficha-admin-toggle::-webkit-details-marker { display: none; }
.ficha-admin-toggle .ic { width: 15px; height: 15px; }

.ficha-admin-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.ficha-admin-body button {
  flex: 1 1 auto;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.ficha-admin-body .ic { width: 15px; height: 15px; }

/* Placa de veiculo estilizada */
.plate {
  display: inline-grid;
  width: max-content;
  border: 2px solid #111;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  font-family: "Courier New", monospace;
  line-height: 1;
}

.plate-top {
  background: #173a8a;
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-align: center;
  padding: 2px 0 1px;
}

.plate-num {
  color: #111;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 3px 10px 4px;
}

/* Acoes rapidas de status / vinculo na ficha */
.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.status-actions button {
  flex: 1 1 auto;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 13px;
}

.status-actions .ic { width: 15px; height: 15px; }

/* Botao editar no card */
.list-row { position: relative; }

.row-edit {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--green);
}

.row-edit:hover {
  background: var(--green);
  color: #fff;
}

.person-row > div { padding-right: 38px; }

.mk--person { background: #1f5c48; }
.mk--location { background: #9f2f2f; }
.mk--approach { background: #315f8c; }
.mk--denuncia { background: #7d3c98; }

.mk.active {
  width: 38px;
  height: 38px;
  border-width: 3px;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.35), 0 2px 8px rgba(0, 0, 0, 0.5);
}

.mk .ic {
  width: 16px;
  height: 16px;
}

.map-legend-box {
  position: absolute;
  top: 52px;
  left: 14px;
  z-index: 1100;
  display: grid;
  gap: 5px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 700;
}

.legend-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
}

.legend-dot {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  flex: 0 0 auto;
}

.legend-dot--foragido {
  background: #1f5c48;
}

.legend-dot--mandado {
  background: #9f2f2f;
}

.legend-dot--abordado {
  background: #315f8c;
}

.legend-dot--denuncia {
  background: #7d3c98;
}

.map-offline {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

.leaflet-popup-content {
  margin: 12px 14px;
  font-weight: 700;
  color: var(--ink);
}

.ficha-popup .leaflet-popup-content-wrapper {
  border-radius: 12px;
}

.ficha {
  display: grid;
  gap: 8px;
}

.ficha-title {
  font-size: 15px;
  line-height: 1.25;
}

.ficha-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.ficha-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.ficha-head-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ficha-photo {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #e3ebe5;
}

.ficha-photo.fallback {
  display: grid;
  place-items: center;
  color: var(--green);
  font-weight: 900;
  font-size: 18px;
}

.ficha-type {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ficha-brief {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.ficha-hover {
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: 250px;
}

.ficha-hover-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ficha-hover-body strong {
  font-size: 14px;
  line-height: 1.2;
}

.ficha-tooltip.leaflet-tooltip {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  white-space: normal;
}

.ficha-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.ficha-actions button {
  flex: 1 1 auto;
  min-height: 40px;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 800;
}

.map-tools {
  position: absolute;
  left: 12px;
  bottom: 16px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.map-tool-btn {
  min-height: 44px;
  border-radius: 999px;
  padding: 11px 18px;
  font-weight: 800;
  letter-spacing: 0.01em;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.06s ease, box-shadow 0.16s ease;
}

.map-tool-btn:active {
  transform: translateY(1px);
}

.map-tool-btn.primary {
  background: linear-gradient(180deg, #338a69, var(--green));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(31, 92, 72, 0.36), 0 2px 6px rgba(22, 32, 27, 0.18);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(23, 33, 28, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-card {
  width: min(440px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
}

.modal-close {
  font-size: 26px;
  line-height: 1;
  background: transparent;
  color: var(--muted);
  padding: 0 6px;
}

.modal-body {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .primary {
  flex: 1;
}

.modal-gps {
  font-size: 13px;
}

.modal-foot {
  margin: 0;
  font-size: 12px;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2900;
  background: rgba(23, 33, 28, 0.45);
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3000;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -16px 42px rgba(23, 33, 28, 0.22);
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 86vh;
  overflow: auto;
  transform: translateY(100%);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  margin: 4px auto 12px;
}

.sheet-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  padding: 2px 6px;
  z-index: 1;
}

.sheet-body {
  display: grid;
  gap: 10px;
}

.sheet-title {
  margin: 0 0 2px;
  font-size: 18px;
}

.sheet-form {
  display: grid;
  gap: 12px;
}

@media (min-width: 1041px) {
  .sheet {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: 380px;
    border-radius: 16px;
    max-height: 80vh;
    transform: translateY(130%);
  }

  .sheet-backdrop {
    background: rgba(23, 33, 28, 0.22);
  }
}

body.view-map .notice {
  display: none;
}

/* Mapa ocupa toda a area disponivel: cadeia de altura cheia */
body.view-map .app-shell {
  height: 100vh;
  grid-template-rows: 1fr;
}

body.view-map .main {
  min-height: 0;
}

body.view-map .content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
}

body.view-map .map-modebar {
  flex: 0 0 auto;
  border-radius: 0;
  border-width: 0 0 1px;
}

body.view-map .split {
  flex: 1 1 auto;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

body.view-map .detail-pane {
  display: none;
}

body.view-map .map-wrap {
  min-height: 0;
  height: 100%;
  border-radius: 0;
  border-width: 0;
}


.highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.highlight-card {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 14px 14px 12px 40px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 10px;
  background: var(--surface-2);
}

.highlight-num {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--amber);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.highlight-text {
  margin: 0;
  font-weight: 700;
  line-height: 1.35;
}

.highlight-edit {
  justify-self: start;
  min-height: 32px;
  padding: 6px 12px;
  font-size: 13px;
}

.ficha-notes {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.ficha-sub {
  margin: 0;
  font-size: 14px;
}

.ficha-note-list {
  display: grid;
  gap: 8px;
}

.ficha-note {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border-left: 3px solid var(--teal);
}

.ficha-note p {
  margin: 0;
}

.ficha-note-form {
  display: grid;
  gap: 8px;
}

.ficha-note-form textarea {
  min-height: 64px;
}

.graph-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.activity-list {
  max-height: 520px;
  overflow: auto;
  padding-right: 3px;
}

.detail-pane {
  padding: 16px;
  align-self: start;
}

.avatar {
  width: 78px;
  height: 78px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e3ebe5;
  color: var(--green);
  font-weight: 900;
  font-size: 28px;
}

.thumb,
.profile-photo,
.photo-card img {
  object-fit: cover;
  background: #e3ebe5;
}

.thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.thumb.fallback {
  display: grid;
  place-items: center;
  color: var(--green);
  font-weight: 900;
}

.profile-photo {
  width: 132px;
  height: 152px;
  border-radius: 8px;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.photo-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.feed-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}

.feed-list {
  display: grid;
  gap: 14px;
}

.feed-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.feed-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.feed-head h3 {
  margin: 0 0 6px;
}

.feed-photo {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #e3ebe5;
}

.feed-photo.fallback {
  display: grid;
  place-items: center;
  color: var(--green);
  font-weight: 900;
}

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.photo-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f1f6f2;
  color: var(--green);
  padding: 7px 10px;
  font-weight: 800;
  font-size: 12px;
}

.inline-form {
  margin: 12px 0 16px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.denuncia-card {
  border-left: 4px solid var(--purple);
}

.denuncia-card.active {
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(47, 122, 95, 0.12);
}

.denuncia-card .denunciaUpdateForm {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.denuncia-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.filter-field {
  gap: 5px;
  flex: 1 1 180px;
  min-width: 160px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.filter-field select {
  text-transform: none;
  letter-spacing: normal;
  font-size: 14px;
  color: var(--ink);
}

.filter-field.filter-grow {
  flex: 2 1 220px;
}

.filter-count {
  margin-left: auto;
  align-self: center;
  font-weight: 800;
}

.denuncia-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 13px;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.last-return {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 4px solid var(--green-2);
  background: #e9f2ec;
}

.last-return-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.last-return-label {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--green);
}

.last-return p {
  margin: 0;
}

.no-return {
  margin: 0;
  font-style: italic;
}

.update-row.latest {
  border-left: 4px solid var(--green-2);
  background: #f1f6f2;
}

.photo-card {
  display: grid;
  gap: 10px;
}

.photo-card img {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.profile-head {
  display: flex;
  gap: 14px;
  align-items: center;
}

.profile-head.compact {
  align-items: flex-start;
  margin-bottom: 16px;
}

.timeline {
  position: relative;
  display: grid;
  gap: 10px;
}

.timeline-item {
  border-left: 3px solid var(--green-2);
  padding: 8px 0 8px 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.graph-canvas {
  position: relative;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8f5;
  overflow: hidden;
}

.graph-label {
  font-size: 12px;
  font-weight: 800;
  fill: #17211c;
  text-anchor: middle;
}

.report-sheet {
  position: relative;
  padding: 22px;
  overflow: hidden;
}

.report-sheet::before {
  content: attr(data-watermark);
  position: absolute;
  inset: 40% auto auto 4%;
  transform: rotate(-18deg);
  color: rgba(159, 47, 47, 0.12);
  font-size: 42px;
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 9px;
  text-align: left;
  vertical-align: top;
}

.table th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

.spec-doc {
  max-height: 68vh;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.55;
}

.sample-box {
  margin: 0;
  min-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8f5;
  padding: 12px;
  white-space: pre-wrap;
  line-height: 1.45;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  body.view-map .app-shell {
    grid-template-rows: 1fr;
  }

  .sidebar {
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
  }

  .brand {
    min-height: 0;
    flex: 0 0 auto;
  }

  .nav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
  }

  .nav button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .nav-extra {
    top: 60px;
    left: 8px;
    right: 8px;
    width: auto;
    grid-template-columns: 1fr 1fr;
  }

  .split,
  .feed-layout,
  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .map-wrap {
    min-height: 58vh;
  }
}

@media (max-width: 640px) {
  .topbar,
  .session,
  .toolbar,
  .map-modebar {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .map-modebar .segmented {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .map-modebar .segmented button {
    flex: 0 0 auto;
    min-width: 104px;
  }

  .modal-card .segmented {
    grid-template-columns: repeat(2, 1fr);
  }

  .map-wrap {
    min-height: 64vh;
  }

  .map-tool-btn {
    min-height: 48px;
    font-size: 15px;
  }

  .content,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .notice {
    margin-left: 16px;
    margin-right: 16px;
  }

  .nav {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .denuncia-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-count {
    margin-left: 0;
    align-self: flex-start;
  }
}

@media (display-mode: standalone) {
  .sidebar,
  .topbar {
    padding-top: calc(18px + env(safe-area-inset-top));
  }
}

/* ===== Refinamentos premium (visual de aplicativo de alto padrao) ===== */
html {
  scroll-behavior: smooth;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 2px solid var(--surface);
}

::-webkit-scrollbar-thumb:hover {
  background: #aeb7a9;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* Tipografia mais sofisticada */
.topbar h2,
.login-panel h1 {
  letter-spacing: -0.02em;
}

.eyebrow {
  letter-spacing: 0.08em;
}

/* Cartoes de metrica com acento e numeros tabulares */
.metric {
  position: relative;
  overflow: hidden;
  padding: 18px 18px 18px 20px;
}

.metric::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #4fd39a, var(--green));
}

.metric span {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  font-weight: 800;
}

.metric strong {
  font-size: 32px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Micro-interacoes suaves */
.list-row {
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.08s ease;
}

.list-row.clickable:hover {
  transform: translateY(-1px);
}

.feed-card {
  transition: box-shadow 0.16s ease, transform 0.08s ease;
}

.feed-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

/* Tags e chips mais finos */
.tag {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

#sessionRole {
  box-shadow: var(--shadow-sm);
}

/* Login (caso apareca) com cara premium */
.login-panel {
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

/* Campos com cantos consistentes e transicao */
input,
select,
textarea {
  border-radius: var(--radius-sm);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

/* Avatares/thumbs com cantos consistentes */
.avatar,
.thumb {
  border-radius: 10px;
}

/* Ficha (bottom sheet) com leve sofisticacao */
.sheet .ficha-actions button {
  border-radius: var(--radius-sm);
}

/* ===== Tema escuro (visual premium de operacao) ===== */
body.theme-dark {
  --bg: #0e1512;
  --surface: #161f1a;
  --surface-2: #1b2520;
  --ink: #e9efe9;
  --muted: #9aa49d;
  --line: #28332d;
  --line-strong: #3a463f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.62);
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #0f1714;
  color: var(--ink);
  border-color: var(--line);
}

body.theme-dark .map-label,
body.theme-dark .map-legend-box {
  background: rgba(18, 26, 22, 0.92);
  color: var(--ink);
  border-color: var(--line);
}

body.theme-dark .map-tool-btn {
  background: rgba(18, 26, 22, 0.96);
  color: var(--ink);
  border-color: var(--line);
}

body.theme-dark .map-tool-btn.primary {
  color: #fff;
}

body.theme-dark .avatar,
body.theme-dark .thumb,
body.theme-dark .profile-photo,
body.theme-dark .photo-card img,
body.theme-dark .feed-photo,
body.theme-dark .ficha-photo {
  background: #233029;
}

body.theme-dark .avatar,
body.theme-dark .thumb.fallback,
body.theme-dark .feed-photo.fallback,
body.theme-dark .ficha-photo.fallback {
  color: #6fd3a6;
}

body.theme-dark .notice {
  background: #2a2412;
  color: #ecd6a4;
}

body.theme-dark .last-return {
  background: #15241c;
}

body.theme-dark .update-row.latest {
  background: #15231b;
}

body.theme-dark .graph-canvas,
body.theme-dark .sample-box {
  background: var(--surface-2);
}

body.theme-dark .map-wrap {
  background: #0e1512;
}

body.theme-dark .login-shell {
  background: #0e1512;
}

/* ===== Redesign enxuto: drawer + barra fina + icones ===== */
.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: transparent;
  border: 0;
  color: var(--ink);
  flex: 0 0 auto;
}

.icon-btn:hover {
  background: rgba(127, 134, 128, 0.14);
}

.ic {
  display: block;
}

/* Menu lateral retratil (drawer) */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 268px;
  z-index: 3200;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
}

body.nav-open .sidebar {
  transform: translateX(0);
  box-shadow: var(--shadow-lg);
}

.nav {
  display: grid;
  gap: 6px;
  overflow: visible;
}

.nav button {
  flex: none;
  white-space: normal;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav button .ic {
  flex: 0 0 auto;
  opacity: 0.85;
}

.nav-extra button {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-extra {
  position: static;
  top: auto;
  left: auto;
  right: auto;
  width: auto;
  grid-template-columns: 1fr;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 2px 0 0;
}

.nav-extra button {
  color: #cdd8d0;
  white-space: normal;
}

.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3100;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

body.nav-open .nav-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* Topbar (telas fora do mapa) compacta com hamburger */
.topbar {
  gap: 12px;
  padding: 10px 16px;
  min-height: 0;
}

.topbar h2 {
  font-size: 20px;
}

/* No mapa: esconde a topbar grande; usa barra fina propria */
body.view-map .topbar {
  display: none;
}

.map-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.map-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex: 1 1 auto;
  scrollbar-width: none;
}

.map-tabs::-webkit-scrollbar {
  display: none;
}

.map-tab {
  display: grid;
  place-items: center;
  width: 44px;
  height: 40px;
  border-radius: 10px;
  background: transparent;
  border: 0;
  color: var(--muted);
  flex: 0 0 auto;
  transition: background 0.16s ease, color 0.16s ease;
}

.map-tab:hover {
  color: var(--ink);
}

.map-tab.active {
  background: var(--green);
  color: #fff;
}

/* Ferramentas do mapa como icones redondos */
.map-icon-btn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.06s ease;
}

.map-icon-btn:active {
  transform: translateY(1px);
}

.map-icon-btn.primary {
  background: linear-gradient(180deg, #338a69, var(--green));
  border-color: transparent;
  color: #fff;
}

body.theme-dark .map-icon-btn {
  background: rgba(18, 26, 22, 0.96);
  color: var(--ink);
  border-color: var(--line);
}

body.theme-dark .map-icon-btn.primary {
  color: #fff;
}

/* Legenda discreta + esconder */
.map-legend-box {
  padding-right: 26px;
}

.legend-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.legend-show {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1100;
  display: none;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
}

body.theme-dark .legend-show {
  background: rgba(18, 26, 22, 0.94);
  color: var(--ink);
}

body.legend-off .map-legend-box {
  display: none;
}

body.legend-off .legend-show {
  display: grid;
}

/* Filtros das listas no estilo Android (compactos) */
@media (max-width: 640px) {
  .filter-field,
  .filter-field.filter-grow {
    flex: 0 0 auto;
    width: 100%;
  }
}

.filter-field select,
.filter-field input {
  min-height: 48px;
}

/* ===== Linha do tempo (cards estilo publicacao) ===== */
.timeline {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.tl-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.tl-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

.tl-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  font-weight: 900;
  font-size: 13px;
  flex: 0 0 auto;
}

/* Cor do avatar/icone por categoria de card */
.tl-avatar--foragido { background: #1f5c48; }
.tl-avatar--mandado { background: #9f2f2f; }
.tl-avatar--abordado { background: #315f8c; }
.tl-avatar--denuncia { background: #7d3c98; }
.tl-avatar--local { background: #266f75; }
.tl-avatar--veiculo { background: #a96716; }

.tl-head-body {
  min-width: 0;
}

/* Badges de tipo (icone + titulo discreto) e de status operacional */
.tl-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.type-badge .ic {
  width: 13px;
  height: 13px;
  color: var(--green-2);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: #eef3ef;
  color: #234236;
}

.status-badge .ic { width: 13px; height: 13px; }
.status-badge.st-preso { background: #f8e5e5; color: var(--red); }
.status-badge.st-ok { background: #e6f1eb; color: var(--green); }
.status-badge.st-neutro { background: #ececec; color: #555; }

/* Lista: thumb com mini-badge de tipo */
.thumb-wrap {
  position: relative;
  flex: 0 0 auto;
  display: inline-grid;
}

.thumb-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 2px solid var(--surface);
  color: #fff;
  background: #266f75;
}

.thumb-badge--foragido { background: #1f5c48; }
.thumb-badge--mandado { background: #9f2f2f; }
.thumb-badge--abordado { background: #315f8c; }
.thumb-badge--denuncia { background: #7d3c98; }
.thumb-badge--local { background: #266f75; }
.thumb-badge--veiculo { background: #a96716; }

.thumb.fallback .ic { color: var(--green); }

.tl-head-body strong {
  display: block;
  line-height: 1.2;
}

.tl-meta {
  font-size: 12px;
}

.tl-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e3ebe5;
  display: block;
}

.tl-noimg {
  aspect-ratio: 16 / 7;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface-2);
}

.tl-body {
  padding: 10px 14px;
  display: grid;
  gap: 4px;
}

.tl-fato {
  margin: 0;
  line-height: 1.4;
}

.tl-time {
  font-size: 12px;
}

.tl-comments {
  padding: 0 14px 6px;
  display: grid;
  gap: 6px;
}

.tl-comment {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
}

.tl-comment strong {
  color: var(--green-2);
}

.tl-comment-form {
  display: flex;
  gap: 8px;
  padding: 8px 14px 12px;
  border-top: 1px solid var(--line);
}

.tl-comment-form input {
  flex: 1;
  min-height: 42px;
}

.tl-comment-form .primary {
  min-height: 42px;
}

body.theme-dark .tl-photo {
  background: #233029;
}

body.theme-dark .tl-comment strong {
  color: #6fd3a6;
}

/* Banner de instalacao (PWA) */
.install-bar {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: min(440px, calc(100vw - 20px));
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(16, 24, 20, 0.28);
  animation: install-rise 0.28s ease;
}

@keyframes install-rise {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.install-bar.hidden { display: none; }

.install-bar__txt {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 160px;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
}

.install-bar__txt .ic { flex: 0 0 auto; color: var(--green); }

.install-bar__go {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  font-size: 13.5px;
  color: #fff;
  background: linear-gradient(180deg, #338a69 0%, var(--green) 100%);
  box-shadow: 0 1px 2px rgba(22, 32, 27, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  cursor: pointer;
}

.install-bar__go:active { transform: translateY(1px); }

.install-bar__x {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
}

body.theme-dark .install-bar {
  background: #1c2a23;
  border-color: #2c3b32;
}

body.theme-dark .install-bar__x {
  background: #233029;
  border-color: #2c3b32;
}

/* Galeria de fotos na ficha */
.photo-gallery {
  margin: 4px 0 2px;
}

.pgal-count {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.pgal-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.pgal-thumb {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
}

.pgal-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pgal-thumb:active { transform: scale(0.97); }

/* Lightbox (foto em tela cheia) */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 10, 0.92);
  padding: env(safe-area-inset-top, 0px) 12px env(safe-area-inset-bottom, 0px);
}

.lightbox-img {
  max-width: 96vw;
  max-height: 86vh;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  object-fit: contain;
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.lightbox-close {
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: 14px;
  width: 44px;
  height: 44px;
  font-size: 26px;
  line-height: 1;
}

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  font-size: 30px;
  line-height: 1;
}

.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

.lightbox-count {
  position: absolute;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 12px;
  border-radius: 999px;
}

/* ===== Menu lateral no celular: lista vertical padrao (estilo Android) ===== */
@media (max-width: 1040px) {
  body.nav-open .sidebar .nav {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    grid-template-columns: none !important;
    overflow: visible;
  }
  body.nav-open .sidebar .nav > button,
  body.nav-open .sidebar .nav-extra > button {
    width: 100%;
    flex: 0 0 auto;
    min-height: 0;
    height: auto;
    padding: 13px 14px;
    justify-content: flex-start;
    text-align: left;
    white-space: normal;
    font-size: 15px;
    line-height: 1.25;
  }
  body.nav-open .sidebar .nav-extra {
    display: flex !important;
    flex-direction: column;
    gap: 2px;
    grid-template-columns: none !important;
  }
  /* O "Sair" fica logo abaixo da lista, sem ser empurrado pra base */
  body.nav-open .sidebar .sidebar-logout {
    margin-top: 10px;
  }
}

/* ===== Vinculos na ficha (rede navegavel) ===== */
.related {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.related-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}
.related-title .ic {
  color: var(--blue);
}
.related-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rel-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 10px 11px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease;
}
.rel-chip:hover {
  border-color: var(--blue);
  background: var(--surface);
}
.rel-chip:active {
  transform: translateY(1px);
}
.rel-chip > .ic {
  flex: 0 0 auto;
  color: var(--blue);
}
.rel-chip-txt {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.rel-chip-txt strong {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rel-chip-txt small {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: capitalize;
}

/* ===== Selos operacionais (toggle aceso/apagado) ===== */
.status-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.seal-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.seal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 28%;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.seal-btn:active {
  transform: translateY(1px);
}
.seal-btn.on {
  background: linear-gradient(180deg, #b5481f 0%, #9f2f2f 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 1px 2px rgba(22, 32, 27, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.seal-btn .ic {
  opacity: 0.92;
}
