:root { color-scheme: light; --brand: #0E7C66; --brand-dark: #0a5f4e; --accent: #F59E0B; --black: #14161a; --ink: #14161a; --muted: #6b7280; --bg: #f4f5f7; --surface: #f4f5f7; --card: #fff; --line: #e5e7eb; --field-line: #d1d5db; --hover: #fafbfc; --side: #0d2722; --green: #16a34a; --red: #dc2626; --amber: #b45309; }
/* Tema escuro: escolhido no botão do menu (fica guardado) ou herdado do computador. */
:root[data-theme="dark"] { color-scheme: dark; --ink: #eef0f3; --muted: #9ba3af; --bg: #0e1014; --surface: #232730; --card: #181b21; --line: #2b303a; --field-line: #3b414d; --hover: #1e222a; --side: #090a0d; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
[hidden] { display: none !important; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 24px; letter-spacing: -.5px; }
.mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M22 50 50 26l28 24v26H22Z' fill='none' stroke='%23fff' stroke-width='8' stroke-linejoin='round'/%3E%3Ccircle cx='50' cy='60' r='9' fill='%23F59E0B'/%3E%3C/svg%3E") center/100% no-repeat; }

/* Botões e formulários */
.btn { font: inherit; font-weight: 700; border: 1px solid var(--field-line); background: var(--card); color: var(--ink); border-radius: 10px; padding: 9px 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px; vertical-align: middle; }
.btn .ic { flex: none; }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger.solid:hover { background: #b91c1c; }
.btn:hover { background: var(--surface); }
.btn:focus-visible, input:focus-visible, a:focus-visible, select:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--red); border-color: #fca5a5; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.link { border: 0; background: none; text-decoration: underline; font-weight: 600; padding: 8px 0; }
.btn[disabled] { opacity: .55; cursor: default; }
label { display: grid; gap: 4px; font-weight: 600; margin-bottom: 12px; }
label small { font-weight: 400; color: var(--muted); }
input, select { font: inherit; padding: 10px 12px; border: 1px solid var(--field-line); border-radius: 10px; background: var(--card); width: 100%; }
.error { color: #b91c1c; font-weight: 600; background: #fee2e2; border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }
.notice { color: #422006; background: #fef3c7; border-radius: 10px; padding: 10px 12px; margin: 0 0 14px; }

/* Entrada: o mapa nocturno enche o ecrã; a mensagem fica à esquerda e o cartão à direita. */
#auth { min-height: 100%; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 40px; padding: 32px clamp(20px, 6vw, 88px); background: #101216 url("fundo.svg") center / cover no-repeat; }
.auth-hero { color: #fff; max-width: 520px; }
.brand.light { color: #fff; font-size: 30px; }
.brand .thin { font-weight: 500; margin-left: -4px; }
.brand.light .mark { width: 44px; height: 44px; border-radius: 12px; }
.tagline { font-size: clamp(34px, 4.6vw, 58px); line-height: 1.05; font-weight: 900; letter-spacing: -1.5px; margin: 28px 0 14px; text-shadow: 0 2px 24px rgba(0,0,0,.6); }
.auth-hero .sub { font-size: 18px; color: #d7dbe2; max-width: 440px; margin: 0; text-shadow: 0 1px 12px rgba(0,0,0,.7); }
.auth-card { background: var(--card); border-radius: 20px; padding: 28px; width: min(420px, 100%); box-shadow: 0 24px 60px rgba(0,0,0,.45); }
.auth-card h1 { margin-top: 18px; }
.auth-card form { margin-top: 18px; display: grid; }
@media (max-width: 860px) {
  #auth { grid-template-columns: 1fr; justify-items: center; }
  .auth-hero { display: none; }
}

/* Faixa com a mesma imagem no topo do resumo. */
.hero { background: #101216 url("fundo.svg") 70% 45% / cover no-repeat; color: #fff; border-radius: 16px; padding: 26px 24px; margin-bottom: 20px; min-height: 132px; display: flex; flex-direction: column; justify-content: end; }
.hero h1 { font-size: 28px; text-shadow: 0 2px 16px rgba(0,0,0,.7); }
.hero p { margin: 0; color: #d7dbe2; text-shadow: 0 1px 10px rgba(0,0,0,.8); }

/* Estrutura */
#app { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
aside { background: var(--side); color: #e8eaee; padding: 16px 12px 12px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; height: 100vh; }
aside .brand { color: #fff; padding: 0 6px; }
.who { display: grid; padding: 8px 12px; background: rgba(255,255,255,.06); border-radius: 12px; }
.who strong { color: #fff; }
.who .muted { color: #9aa1ad; font-size: 13px; }
nav { display: grid; gap: 1px; flex: 1; align-content: start; overflow-y: auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; scrollbar-color: #3a3f48 transparent; }
nav .group { margin: 8px 10px 2px; font-size: 11px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase; color: #7d8592; }
nav a { display: flex; align-items: center; gap: 10px; padding: 5px 10px; font-size: 14.5px; border-radius: 10px; color: #d5d9e0; text-decoration: none; font-weight: 600; }
nav a .t { flex: 1; }
nav a .ic { flex: none; opacity: .85; }
nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
nav a[aria-current="page"] { background: var(--brand); color: #fff; }
nav a[aria-current="page"] .ic { opacity: 1; }
nav a:focus-visible, .logout:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.count { background: var(--red); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 1px 8px; }
.foot { display: grid; border-top: 1px solid rgba(255,255,255,.1); padding-top: 6px; }
.logout { display: flex; align-items: center; gap: 10px; font: inherit; font-weight: 600; color: #d5d9e0; background: none; border: 0; border-radius: 10px; padding: 6px 10px; cursor: pointer; text-align: left; }
.logout:hover { color: #fff; }
#view { padding: 26px 28px 60px; min-width: 0; outline: none; }
.head { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.head p { margin: 0; max-width: 70ch; }
.head-title { display: flex; gap: 14px; align-items: center; min-width: 0; flex: 1 1 320px; }
.head-ic { flex: none; width: 46px; height: 46px; border-radius: 14px; background: var(--brand); color: #fff; display: grid; place-items: center; }

/* Cartões e tabelas */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 22px; }
.card { background: var(--card); border-radius: 14px; padding: 16px; border: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.card .n { font-size: 26px; font-weight: 800; line-height: 1.15; }
.card-ic { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); color: var(--ink); }
.card-ic.green { background: #dcfce7; color: #166534; }
.card-ic.yellow { background: #fff3c4; color: #7a5b00; }
.card-ic.blue { background: #dbeafe; color: #1e40af; }
.card-ic.amber { background: #ffedd5; color: #9a3412; }
.card .l { color: var(--muted); font-size: 13px; }
.card.alert { border-color: var(--red); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 18px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.badge { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.wait { background: #fef3c7; color: #92400e; }
.badge.bad { background: #fee2e2; color: #991b1b; }
.badge.off { background: #e5e7eb; color: #374151; }
.badge.trip { background: #fde7c0; color: #8a4b00; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.inline-form label { margin: 0; flex: 1 1 180px; }
.code { color: var(--black); font: 800 26px/1 ui-monospace, Menlo, monospace; letter-spacing: 4px; background: var(--accent); border-radius: 10px; padding: 10px 14px; display: inline-block; }

/* Revisão de documentos */
.who-row { display: flex; gap: 12px; align-items: center; }
.who-row h2 { margin: 0; }
.face { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 2px solid var(--line); }
.review { display: grid; gap: 14px; }
.doc-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: start; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.doc-row .info { flex: 1 1 220px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs button { border: 1px solid var(--line); border-radius: 10px; padding: 0; background: var(--surface); width: 132px; height: 88px; overflow: hidden; cursor: zoom-in; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.reject { display: flex; gap: 6px; margin-top: 8px; }
dialog { border: 0; border-radius: 14px; padding: 12px; max-width: min(92vw, 900px); color: var(--ink); background: var(--card); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog img { max-width: 100%; max-height: 78vh; display: block; margin-bottom: 10px; border-radius: 8px; }

/* Mapa */
#map { height: min(68vh, 640px); border-radius: 14px; border: 1px solid var(--line); }
.pin { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; border: 3px solid #fff; box-shadow: 0 0 5px rgba(0,0,0,.5); background: var(--green); }
.pin.trip { background: var(--accent); }
.legend { display: flex; gap: 16px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; }

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  aside { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  nav { grid-auto-flow: column; overflow-x: auto; flex: 1 1 100%; order: 3; }
  nav a { white-space: nowrap; }
  #view { padding: 18px 14px 50px; }
}
@media (prefers-reduced-motion: no-preference) { .btn, nav a { transition: background .12s; } }
textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; resize: vertical; margin: 6px 0 10px; }

/* ── Painel renovado ─────────────────────────────────────────────────────── */
.ic { display: block; }
h2 { margin-top: 4px; }
h3 { font-size: 15px; margin: 0; }
.small { font-size: 13px; }
a { color: inherit; }
.notice a, .muted a { font-weight: 600; }
tbody tr:hover td { background: var(--hover); }
.row-actions { justify-content: flex-end; }

/* Resumo: o que pede atenção, gráfico e valores */
.todo { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin-bottom: 22px; }
.todo a { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid #fcd9a0; border-left: 5px solid var(--accent); border-radius: 12px; padding: 13px 14px; text-decoration: none; }
.todo a span { flex: 1; }
.todo a b { font-size: 20px; margin-right: 2px; }
.todo a .ic:last-child { transform: scaleX(-1); color: var(--muted); }
.todo a:hover { background: var(--hover); }
.todo a.urgent { border-color: #fca5a5; border-left-color: var(--red); }
.todo a.urgent .ic:first-child { color: var(--red); }
.allgood { display: flex; align-items: center; gap: 12px; background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; border-radius: 12px; padding: 13px 14px; margin-bottom: 22px; font-weight: 600; }
.split { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; align-items: stretch; }
.split .panel { margin-bottom: 22px; }
.chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; height: 170px; align-items: end; }
.bar { display: grid; grid-template-rows: auto 1fr auto; height: 100%; justify-items: center; gap: 5px; font-size: 12.5px; }
.bar i { display: block; width: min(100%, 44px); min-height: 4px; background: var(--field-line); border-radius: 8px 8px 3px 3px; align-self: end; }
.bar.today i { background: var(--brand); }
.bar .v { font-weight: 700; }
.bar .d { color: var(--muted); text-transform: capitalize; }
.bar.today .d { color: var(--ink); font-weight: 700; }
table.mini th { text-transform: none; letter-spacing: 0; font-size: 14px; }
table.mini tbody th { color: var(--ink); font-weight: 500; white-space: normal; }
table.mini td { font-weight: 700; }

/* Definições */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-bottom: 20px; }
.setting { display: flex; gap: 14px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.setting .body { flex: 1; min-width: 0; }
.setting .value { font-size: 26px; font-weight: 800; margin: 2px 0 4px; line-height: 1.2; }
.setting .value .badge { font-size: 14px; padding: 4px 12px; }
.setting p { margin: 0; font-size: 13.5px; }
.panel-head { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.panel-head > div { flex: 1 1 320px; }
.panel-head p { margin: 0 0 12px; font-size: 13.5px; }
.fees { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.fees div { background: var(--surface); border-radius: 12px; padding: 10px 12px; display: grid; }
.fees b { font-size: 17px; }
.toolbar { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar label { margin: 0; flex: 0 1 260px; }
.toolbar p { margin: 0 0 10px; flex: 1 1 260px; }
#map { margin-bottom: 20px; }

/* Janela de criar e editar */
#modal { padding: 0; width: min(560px, calc(100vw - 28px)); max-height: calc(100vh - 28px); border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.4); overflow: auto; }
#modal::backdrop { background: rgba(16,18,22,.62); }
.modal { padding: 22px 22px 20px; }
.modal header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.modal header h2 { font-size: 20px; margin: 4px 0 0; }
.modal .x { flex: none; width: 36px; height: 36px; border: 0; border-radius: 10px; background: var(--surface); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.modal .x:hover { background: var(--line); }
.modal .x:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
.modal > .muted { margin: 0 0 14px; }
.modal .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; margin-top: 10px; }
.modal .fields label { grid-column: 1 / -1; align-content: start; }
.modal .fields label.half { grid-column: auto; }
.modal textarea { margin: 0; border-color: var(--field-line); }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.modal .code { display: block; text-align: center; margin: 4px 0 14px; user-select: all; }
@media (max-width: 520px) { .modal .fields label.half { grid-column: 1 / -1; } }

@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  aside { padding: 12px; gap: 10px; min-width: 0; }
  nav { min-width: 0; }
  .split .panel, .panel, .table-wrap { min-width: 0; }
  aside .who { display: none; }
  nav { display: flex; overflow-x: auto; overflow-y: hidden; margin: 0; padding: 0 0 4px; }
  nav .group { display: none; }
  nav a .t { flex: none; }
  .foot { border-top: 0; padding: 0; margin-left: auto; grid-auto-flow: column; }
  .logout span { display: none; }
  .head-ic { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .todo a, .card { transition: background .12s, transform .12s; }
}

/* Acertos do tema escuro: avisos e destaques com fundo próprio. */
:root[data-theme="dark"] .notice { background: #3a2d08; color: #fde68a; }
:root[data-theme="dark"] .error { background: #3f1518; color: #fecaca; }
:root[data-theme="dark"] .allgood { background: #0f2a1b; border-color: #1f5133; color: #86efac; }
:root[data-theme="dark"] .todo a { border-color: #6b4410; border-left-color: var(--accent); }
:root[data-theme="dark"] .todo a.urgent { border-color: #7f1d1d; border-left-color: var(--red); }
:root[data-theme="dark"] .card-ic.green { background: #12301f; color: #86efac; }
:root[data-theme="dark"] .card-ic.yellow { background: #3a2f08; color: #fde047; }
:root[data-theme="dark"] .card-ic.blue { background: #152642; color: #93c5fd; }
:root[data-theme="dark"] .card-ic.amber { background: #3b1f0d; color: #fdba74; }
:root[data-theme="dark"] .badge.ok { background: #12301f; color: #86efac; }
:root[data-theme="dark"] .badge.wait { background: #3a2d08; color: #fde68a; }
:root[data-theme="dark"] .badge.bad { background: #3f1518; color: #fecaca; }
:root[data-theme="dark"] .badge.off { background: #2b303a; color: #cbd5e1; }
:root[data-theme="dark"] .btn.danger { color: #fca5a5; border-color: #7f1d1d; }
:root[data-theme="dark"] .btn.danger.solid { color: #fff; border-color: var(--red); }
:root[data-theme="dark"] .card.alert { border-color: #b91c1c; }
:root[data-theme="dark"] .btn:focus-visible, :root[data-theme="dark"] input:focus-visible, :root[data-theme="dark"] select:focus-visible, :root[data-theme="dark"] a:focus-visible { outline-color: #93c5fd; }
:root[data-theme="dark"] .leaflet-container { background: #1b1e24; }

/* Fotos nas listas de pessoas */
.person { display: flex; align-items: center; gap: 12px; }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 16px; color: #14161a; overflow: hidden; border: 0; padding: 0; background: var(--surface); }
button.avatar { cursor: zoom-in; }
button.avatar:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
td:has(.person) { vertical-align: middle; }

/* ── Barra do topo ───────────────────────────────────────────────────────── */
.main { min-width: 0; display: flex; flex-direction: column; }
#topbar { position: sticky; top: 0; z-index: 500; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 28px; background: var(--card); border-bottom: 1px solid var(--line); }
.crumb { margin: 0; display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--field-line); background: var(--card); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface); }
.icon-btn:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
.user { display: flex; align-items: center; gap: 10px; padding: 0 6px 0 2px; }
.user .avatar { width: 36px; height: 36px; background: var(--brand); color: #fff; font-size: 15px; }
.user-text { display: grid; line-height: 1.2; }
.user-text .muted { font-size: 12.5px; }
#view { flex: 1; }
@media (max-width: 760px) {
  #topbar { padding: 8px 14px; position: static; }
  .user-text { display: none; }
  #logout span { display: none; }
}

/* Botões nunca partem o texto; a pesquisa fica numa só linha. */
.btn { white-space: nowrap; }
td .btn.small { margin: 2px 0; }
#search { flex-wrap: nowrap; }
#search input { width: min(280px, 52vw); }

/* Ficha do motorista */
#modal.wide { width: min(880px, calc(100vw - 28px)); }
.ficha h3 { margin: 18px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.person.big .avatar { width: 64px; height: 64px; font-size: 24px; }
.person.big strong { font-size: 18px; }
.ficha .notice, .ficha .flags, .ficha .allgood { margin: 14px 0 0; }
.flags { background: #fef2f2; border: 1px solid #fecaca; color: #7f1d1d; border-radius: 12px; padding: 11px 14px; }
.flags strong { display: flex; align-items: center; gap: 7px; }
.flags ul { margin: 6px 0 0; padding-left: 20px; }
.allgood.small { font-size: 14px; padding: 10px 12px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; margin-top: 14px; }
.fact { background: var(--surface); border-radius: 12px; padding: 10px 12px; display: grid; }
.fact b { font-size: 20px; }
.fact span { font-size: 12.5px; color: var(--muted); }
.fact.bad { background: #fef2f2; }
.fact.bad b { color: #b91c1c; }
.bad-text { color: #b91c1c; font-weight: 700; }
.ficha .doc-row { border-top: 0; padding-top: 0; margin-top: 6px; background: var(--surface); border-radius: 12px; padding: 12px; }
.ficha .thumbs button { width: 104px; height: 70px; background: var(--card); }
.ficha table.mini td { font-weight: 400; padding: 7px 8px; }
:root[data-theme="dark"] .flags { background: #3f1518; border-color: #7f1d1d; color: #fecaca; }
:root[data-theme="dark"] .fact.bad { background: #3f1518; }
:root[data-theme="dark"] .fact.bad b, :root[data-theme="dark"] .bad-text { color: #fca5a5; }

/* Alertas de perigo (entidades) */
.danger-banner { display: flex; align-items: center; gap: 14px; background: #fef2f2; border: 1px solid #fca5a5; border-left: 6px solid var(--red); color: #7f1d1d; border-radius: 12px; padding: 14px 16px; margin: 0 0 18px; }
.danger-banner .ic { flex: none; color: var(--red); }
tr.row-danger td { background: #fef2f2; }
tbody tr.row-danger:hover td { background: #fee2e2; }
#alert-map { height: 300px; border-radius: 12px; border: 1px solid var(--line); margin: 14px 0 6px; }
:root[data-theme="dark"] .danger-banner { background: #3f1518; border-color: #7f1d1d; border-left-color: var(--red); color: #fecaca; }
:root[data-theme="dark"] tr.row-danger td, :root[data-theme="dark"] tbody tr.row-danger:hover td { background: #2b1114; }
@media (prefers-reduced-motion: no-preference) { .danger-banner .ic { animation: pulse 1.1s ease-in-out infinite; } @keyframes pulse { 50% { opacity: .35; } } }

/* Postos policiais */
.station h2 { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 2px; }
.station .panel-head p { margin-bottom: 10px; }
.station .table-wrap { border: 0; border-top: 1px solid var(--line); border-radius: 0; }

/* Turnos: escolha dos dias */
.days { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.day { display: block; margin: 0; }
.day input { position: absolute; opacity: 0; width: 0; height: 0; }
.day span { display: block; padding: 8px 12px; border: 1px solid var(--field-line); border-radius: 10px; font-weight: 700; cursor: pointer; }
.day input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.day input:focus-visible + span { outline: 3px solid #2563eb; outline-offset: 2px; }
td .badge { margin: 1px 0; }

/* Tarifas e procura: fórmula e simulador */
.formula-box { background: var(--surface); border-radius: 12px; padding: 14px 16px; font-size: 16px; line-height: 1.9; }
.formula-box .f-term { font-weight: 800; }
.formula-box .f-var { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1px 8px; white-space: nowrap; font-weight: 600; }
.formula-box .f-op { color: var(--muted); }
.formula-box .f-sub { color: var(--muted); font-size: 14px; }
.f-legend { margin: 12px 0 0; padding-left: 20px; font-size: 13.5px; }
.f-legend li { margin: 4px 0; }
.sim { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 12px; }
.sim label { margin: 0; }
.sim-steps { list-style: none; margin: 0; padding: 0; max-width: 520px; }
.sim-steps li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.sim-steps li span { color: var(--muted); }
.sim-steps li.sum { font-weight: 700; }
.sim-steps li.total { border-bottom: 0; font-size: 18px; font-weight: 800; }
.sim-steps li.total span { color: var(--ink); }
.tiers { margin: 8px 0 0; padding-left: 18px; font-size: 13.5px; }

/* ── SemIntermediário: editor de tipos, fotos por lugar, conversas ─────── */
.badge.brand { background: #d1fae5; color: #065f46; }
:root[data-theme="dark"] .badge.brand { background: #0f3a30; color: #6ee7b7; }
.editor h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.rows { display: grid; gap: 8px; }
.row-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.row-item .order { display: grid; gap: 4px; }
.row-item .order button, .row-item .del { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--field-line); background: var(--card); color: var(--ink); cursor: pointer; display: grid; place-items: center; padding: 0; }
.row-item .order button[disabled] { opacity: .35; cursor: default; }
.row-item .del { color: var(--red); }
.row-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 10px; }
.row-grid label { margin: 0; font-size: 13px; }
.row-grid input, .row-grid select { padding: 7px 9px; font-size: 14px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; grid-column: 1 / -1; }
.checks label, label.check { display: flex; flex-direction: row; align-items: center; gap: 6px; font-weight: 600; margin: 0; font-size: 13px; }
.checks input, label.check input { width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12.5px; }
.slot-photos { display: grid; gap: 12px; }
.slot-photos .slot h4 { margin: 0 0 6px; font-size: 14px; }
.slot-photos .thumbs button { width: 140px; height: 100px; }
.slot.missing h4 { color: var(--red); }
.thumb-list { display: flex; gap: 6px; }
.thumb-list img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.chat { display: grid; gap: 8px; max-height: 420px; overflow: auto; background: var(--surface); border-radius: 12px; padding: 12px; }
.msg { max-width: 80%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.msg.sys { justify-self: center; background: transparent; border: 0; color: var(--muted); font-size: 13px; text-align: center; }
.msg.reported { border-color: var(--red); box-shadow: 0 0 0 2px #fecaca; }
.msg small { display: block; color: var(--muted); font-size: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.timeline li span { color: var(--muted); font-size: 12.5px; margin-right: 8px; }
.terr details { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; }
.terr summary { cursor: pointer; font-weight: 700; }
.terr .mun { margin: 8px 0 8px 12px; }
.terr .mun b { display: block; margin-bottom: 4px; }
.chip .x { border: 0; background: none; color: var(--red); cursor: pointer; padding: 0 0 0 4px; font: inherit; }

/* O nome é comprido: cabe na barra lateral. */
aside .brand { font-size: 18px; letter-spacing: -.3px; gap: 8px; }
aside .brand .mark { width: 30px; height: 30px; flex: none; }

/* Condições «Mostrar só quando…» no editor de tipos */
.conds { grid-column: 1 / -1; display: grid; gap: 6px; border-top: 1px dashed var(--line); padding-top: 8px; }
.cond-row { display: grid; grid-template-columns: 1fr auto 1.4fr auto; gap: 6px; align-items: center; }
.cond-row select, .cond-row input { padding: 6px 8px; font-size: 13.5px; }
.cond-text { margin: 0; font-style: italic; }
.conds .btn.small { justify-self: start; }
@media (max-width: 600px) { .cond-row { grid-template-columns: 1fr 1fr; } }
