/* AreaGPS - painel próprio sobre o Traccar
   Layout: barra superior + (lista de veículos | mapa). No celular, mapa em cima e lista embaixo.
   Para trocar a identidade visual, mude só os tokens abaixo (cores e fontes). */
/* Identidade AreaGPS: laranja + preto + cinza (do logo) */
:root {
  --bg: #f5f4f2;
  --surface: #ffffff;
  --ink: #141414;
  --muted: #62605d;
  --line: #e4e1dd;
  --brand: #ff6f0f;        /* laranja do logo */
  --brand-dark: #cc5a0a;   /* laranja escuro do logo */
  --brand-text: #b34e08;   /* laranja legível para texto/links sobre fundo claro */
  --brand-ink: #141414;    /* texto sobre botão laranja */
  --moving: #16a34a;       /* em movimento */
  --stopped: #2563eb;      /* parado (azul, para não confundir com o laranja da marca) */
  --offline: #8a8784;      /* sem comunicação */
  --danger: #c2362b;
  --map-empty: #ebe8e4;
  --logo-light: block; --logo-dark: none;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-mark: "Orbitron", "Space Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111; --surface: #1b1b1b; --ink: #ededed; --muted: #a6a3a0; --line: #2f2d2b;
    --brand: #ff7a1f; --brand-dark: #e0670f; --brand-text: #ff9445; --brand-ink: #141414;
    --moving: #34c46a; --stopped: #5b8ff0; --offline: #75726f; --danger: #ef6b5f; --map-empty: #1e1d1c;
    --logo-light: none; --logo-dark: block; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111111; --surface: #1b1b1b; --ink: #ededed; --muted: #a6a3a0; --line: #2f2d2b;
  --brand: #ff7a1f; --brand-dark: #e0670f; --brand-text: #ff9445; --brand-ink: #141414;
  --moving: #34c46a; --stopped: #5b8ff0; --offline: #75726f; --danger: #ef6b5f; --map-empty: #1e1d1c;
  --logo-light: none; --logo-dark: block; color-scheme: dark;
}

html, body { height: 100%; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: 14px; }
* { box-sizing: border-box; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Login ---------- */
.login {
  min-height: 100%; display: grid; place-items: center;
  padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; display: grid; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.brand-pin { height: 30px; width: auto; display: block; }
.wordmark { font-family: var(--font-mark); font-weight: 800; letter-spacing: 0.02em; font-size: 18px; }
.wordmark b { color: var(--brand); font-weight: 800; }
.logo-full { width: 100%; max-width: 260px; height: auto; margin: 0 auto 4px; }
.logo-full.on-light { display: var(--logo-light); }
.logo-full.on-dark { display: var(--logo-dark); }
.login-card { border-top: 4px solid var(--brand); }
.login h1 { margin: 0; font-family: var(--font-display); font-size: 22px; text-wrap: balance; }
.login p { margin: 0; color: var(--muted); line-height: 1.5; }
.field { display: grid; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase; }
.field input, .field textarea { padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.btn { border: 0; border-radius: 8px; padding: 11px 14px; font-weight: 600; cursor: pointer; background: var(--brand); color: var(--brand-ink); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); padding: 7px 12px; }
.error { color: var(--danger); font-size: 13px; min-height: 1em; margin: 0; }
.demo-note { font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 12px; }

/* ---------- App ---------- */
.app { height: 100%; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  display: flex; align-items: center; gap: 14px; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.topbar .brand { font-size: 17px; }
.topbar .spacer { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--offline); }
.live[data-state="on"] .live-dot { background: var(--moving); box-shadow: 0 0 0 3px color-mix(in srgb, var(--moving) 25%, transparent); }
.live[data-state="wait"] .live-dot { background: var(--stopped); }
.who { font-size: 13px; color: var(--muted); }

.main { display: grid; grid-template-columns: 340px 1fr; min-height: 0; }
.side { border-right: 1px solid var(--line); background: var(--surface); display: grid; grid-template-rows: auto auto 1fr; min-height: 0; }
.side-head { padding: 14px 16px 8px; display: grid; gap: 10px; }
.side-head input { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.counts { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 10px; border-bottom: 1px solid var(--line); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.s-moving { background: var(--moving); } .s-stopped { background: var(--stopped); } .s-offline { background: var(--offline); }

.list { overflow-y: auto; min-height: 0; margin: 0; padding: 0; list-style: none; }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:hover { background: var(--bg); }
.item[aria-selected="true"] { background: color-mix(in srgb, var(--brand) 10%, var(--surface)); }
.item .name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .speed { font-variant-numeric: tabular-nums; font-weight: 600; }
.item .sub { grid-column: 2 / -1; color: var(--muted); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 24px 16px; color: var(--muted); line-height: 1.5; }

.mapwrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--map-empty); }
#map.no-tiles {
  background-color: var(--map-empty);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
}
.detail {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 500; max-width: 460px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); display: grid; gap: 10px;
}
.detail-head { display: flex; align-items: center; gap: 10px; }
.detail-head h2 { margin: 0; font-family: var(--font-display); font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.close { background: transparent; border: 0; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px 14px; margin: 0; }
.stats div { display: grid; gap: 2px; }
.stats dt { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.detail a { color: var(--brand-text); font-size: 13px; }
.map-note { position: absolute; top: 60px; right: 12px; z-index: 500; max-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--muted); line-height: 1.4; }
.pos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--brand) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line)); }
.pos .when, .pos .where { grid-column: 1 / -1; }
.pos .where dd { font-family: var(--font-ui); font-size: 14px; font-weight: 600; line-height: 1.4; }
.item .addr-line { grid-column: 2 / -1; font-size: 12px; color: var(--ink); line-height: 1.35; }
.pos dt { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pos dd { margin: 0; font-family: var(--font-mono); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pos .when dd { font-family: var(--font-ui); font-size: 16px; }
.pos .recv { font-family: var(--font-ui); font-weight: 400; font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand-text); text-decoration: underline; cursor: pointer; font-size: 13px; }
.item .coords { grid-column: 2 / -1; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.addr { color: var(--muted); font-size: 13px; margin: 0; }

/* Configurações (administrador) */
.icon-btn { display: inline-grid; place-items: center; padding: 7px 9px; }
.overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.45); display: grid; place-items: center;
  padding-block: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.sheet { width: 100%; max-width: 520px; max-height: 100%; overflow-y: auto; background: var(--surface); border: 1px solid var(--line);
  border-top: 4px solid var(--brand); border-radius: 14px; padding: 20px; display: grid; gap: 14px; }
.sheet h2 { margin: 0; font-family: var(--font-display); font-size: 19px; flex: 1; }
.sheet h3 { margin: 4px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-text); }
.sheet select, .sheet input { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.hint { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.hint:empty { display: none; }
.hint.warn { color: var(--danger); }
.actions.end { justify-content: flex-end; }

/* Botão "Mapa" (troca do tipo de mapa) */
.leaflet-control-layers { border-radius: 8px !important; border: 1px solid var(--line) !important; background: var(--surface) !important; color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.15) !important; }
.leaflet-control-layers-toggle {
  width: auto !important; height: 36px !important; padding: 0 12px 0 34px; display: flex !important; align-items: center;
  background: no-repeat 10px center / 18px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ff6f0f' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2 2 7l10 5 10-5-10-5z'/%3E%3Cpath d='m2 17 10 5 10-5'/%3E%3Cpath d='m2 12 10 5 10-5'/%3E%3C/svg%3E") !important;
  color: var(--ink) !important; text-decoration: none; font-weight: 600; font-size: 13px;
}
.leaflet-control-layers-toggle::after { content: "Mapa"; }
.leaflet-control-layers-expanded { padding: 8px 12px 8px 8px !important; font-size: 13px; }
.leaflet-control-layers-base label { padding: 5px 2px; cursor: pointer; }
.leaflet-control-layers-selector { accent-color: var(--brand); }
.toast { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1500; max-width: min(420px, calc(100% - 24px));
  background: var(--ink); color: var(--surface); border-radius: 8px; padding: 9px 12px; font-size: 13px; }

/* Street View */
.sv-sheet { max-width: 960px; }
.sv-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; max-width: 100%; border-radius: 10px; overflow: hidden; background: var(--map-empty); }
.sv-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.sv-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); line-height: 1.5; }
.sv-sheet a { color: var(--brand-text); font-size: 13px; }
@media (max-width: 760px) { .sv-frame { aspect-ratio: 3 / 4; } }

/* Cadastro em lote */
.btn-label { margin-left: 6px; font-size: 13px; }
#adm-menu-btn, #open-hist { display: inline-flex; align-items: center; padding: 7px 11px; }
#adm-menu[hidden], .adm-pop[hidden], .menu-item[hidden], #open-hist[hidden] { display: none !important; }
.imp-sheet { max-width: 880px; grid-template-columns: minmax(0, 1fr); }
.eq-sheet .sub2.emp { color: var(--ink); font-weight: 500; }
.imp-sheet textarea { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-family: var(--font-mono); font-size: 12.5px; resize: vertical; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }
.imp-table { overflow-x: auto; }
.imp-table:empty { display: none; }
.imp-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.imp-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.imp-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
.imp-table .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line); }
.st-pronto .pill { background: color-mix(in srgb, var(--stopped) 18%, transparent); color: var(--ink); }
.st-criado .pill { background: color-mix(in srgb, var(--moving) 22%, transparent); }
.st-erro .pill { background: color-mix(in srgb, var(--danger) 18%, transparent); }
.why { font-size: 11.5px; color: var(--danger); margin-top: 3px; white-space: normal; }
@media (max-width: 760px) { .btn-label { display: none; } }

/* Cadastro de rastreadores: abas e formulário */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 12px; font-weight: 600; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); }
.dev-form { display: grid; gap: 12px; }
.dev-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.dev-grid .span2 { grid-column: 1 / -1; }
.dev-form input { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.req { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--brand-text); margin-left: 4px; }
.hint.ok { color: var(--moving); }
.stats .wide { grid-column: 1 / -1; }
.stats .wide dd { font-family: var(--font-mono); font-size: 13px; overflow-wrap: anywhere; }
@media (max-width: 560px) { .dev-grid { grid-template-columns: 1fr; } }

/* marcador do veículo */
.veh { width: 34px; height: 34px; }
.veh svg { width: 34px; height: 34px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); transition: transform .4s; }
.veh-label { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 11px; font-weight: 600; box-shadow: none; }
.veh-label::before { display: none; }

@media (max-width: 760px) {
  .main { grid-template-columns: 1fr; grid-template-rows: 55% 45%; }
  .side { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  .mapwrap { order: 1; }
  .who { display: none; }
  /* No celular o cartão do veículo vira uma "gaveta" que sobe por cima da lista, deixando o mapa livre */
  .detail { position: fixed; left: 0; right: 0; bottom: 0; max-width: none; max-height: 52%; overflow-y: auto; z-index: 1000;
    border-radius: 16px 16px 0 0; padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); gap: 10px; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .wordmark { font-size: 15px; }
  .map-note { display: none; }
}
@media (prefers-reduced-motion: reduce) { .veh svg { transition: none; } }

/* Verificação de segurança (Configurações, administrador) */
.sec-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sec-item { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 13px; }
.sec-item .sec-mark { grid-row: 1 / 3; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: var(--offline); }
.sec-item.ok .sec-mark { background: var(--moving); }
.sec-item.bad .sec-mark { background: var(--danger); }
.sec-item b { font-weight: 600; }
.sec-item .hint { grid-column: 2; }
.sec-item .linkbtn { grid-column: 2; justify-self: start; margin-top: 4px; }
.sec-item.warn .sec-mark { background: var(--brand-dark); }

/* ---------- Clientes (só administrador) ---------- */
.cli-sheet { max-width: 920px; }
.cli-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.cli-bar input { flex: 1 1 240px; width: auto; }
.cli-table { overflow-x: auto; }
.cli-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cli-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.cli-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cli-table tr.off td { opacity: .55; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub2 { font-size: 12px; color: var(--muted); font-weight: 400; }
.cli-form { display: grid; gap: 14px; }
.cli-form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0; min-width: 0; }
.cli-form legend { padding: 0 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-text); }
.dev-grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dev-grid.g3 .span2 { grid-column: span 2; }
.lbl { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase; }
.chk { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.sheet .chk input { width: auto; padding: 0; accent-color: var(--brand); }
.radios { display: flex; gap: 18px; padding: 9px 0; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
.cli-devices { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 14px; }
.cli-form .field .linkbtn { justify-self: start; font-size: 12.5px; }
.buscando-cep #cli-cep { background-image: linear-gradient(90deg, transparent, color-mix(in srgb, var(--brand) 18%, transparent), transparent); }
.cli-form .hint.erro { color: var(--danger); }
@media (max-width: 760px) {
  .dev-grid.g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dev-grid.g3 .span2 { grid-column: 1 / -1; }
}
@media (max-width: 560px) { .dev-grid.g3 { grid-template-columns: 1fr; } }
.cli-form .radios label { text-transform: none; letter-spacing: 0; font-size: 13.5px; font-weight: 500; color: var(--ink); }
.cli-perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 12px; margin: 10px 0 6px; }
.sw { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.sheet .sw input { appearance: none; -webkit-appearance: none; flex: none; width: 36px; height: 20px; padding: 0; margin: 0; border-radius: 999px; border: 0;
  background: var(--offline); position: relative; cursor: pointer; transition: background .15s; }
.sheet .sw input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.sheet .sw input:checked { background: var(--brand); }
.sheet .sw input:checked::after { transform: translateX(16px); }
.sw:has(input:checked) { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); }
.sw .tag { display: inline-block; margin-left: 4px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--moving); }
@media (prefers-reduced-motion: reduce) { .sheet .sw input, .sheet .sw input::after { transition: none; } }
.cli-devices { max-height: 320px; overflow-y: auto; padding: 2px; }
.cli-dev[hidden] { display: none; }
.placa { display: inline-block; min-width: 76px; text-align: center; font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; letter-spacing: .04em;
  padding: 2px 6px; border: 1.5px solid var(--ink); border-top-width: 4px; border-top-color: #1f4fa3; border-radius: 4px; background: var(--surface); }
.placa.sem { border-color: var(--line); border-top-color: var(--line); color: var(--muted); font-family: var(--font-ui); font-weight: 400; letter-spacing: 0; }

/* ---------- Usuários e níveis ---------- */
.usr-filters { padding: 0 0 12px; border-bottom: 0; }
.nivel { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.nivel.admin { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand-text); border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
.nivel.admin2 { background: color-mix(in srgb, var(--moving) 14%, transparent); color: var(--moving); border-color: color-mix(in srgb, var(--moving) 35%, transparent); }
.nivel.gerente { background: color-mix(in srgb, var(--stopped) 14%, transparent); color: var(--stopped); border-color: color-mix(in srgb, var(--stopped) 35%, transparent); }
.nivel.usuario { background: color-mix(in srgb, var(--offline) 14%, transparent); color: var(--muted); border-color: var(--line); }
.sit-ok { color: var(--moving); font-weight: 600; } .sit-off { color: var(--danger); font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tags span { font-size: 11.5px; padding: 1px 7px; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }

/* ---------- Menu do administrador ---------- */
.adm-menu { position: relative; }
.adm-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 1500; min-width: 230px; display: grid; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.menu-item:hover, .menu-item:focus-visible { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.menu-item svg { color: var(--brand-text); flex: none; }
.adm-pop .btn-label { display: inline !important; margin-left: 0; font-size: 14px; }

/* ---------- Equipamentos do sistema ---------- */
.eq-sheet { max-width: 1180px; }
.eq-sheet td.end { min-width: 220px; max-width: 320px; }
.vinc { display: flex; flex-direction: column; gap: 4px; }
.vinc div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.vinc .nivel { font-size: 11px; padding: 1px 7px; }
.st { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* ---------- Históricos ---------- */
.hist-tabs { overflow-x: auto; scrollbar-width: thin; }
.hist-tabs .tab { white-space: nowrap; }
.hist-tabs .tab[hidden] { display: none; }
.hist-form { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin: 14px 0 8px; }
.hist-form .field { flex: 1 1 170px; }
.hist-form .field[hidden] { display: none; }
.hist-form .hf-veic { flex: 2 1 220px; }
.hist-form .hf-lim { flex: 0 1 120px; }
.hist-form #hist-go { flex: 0 0 auto; }
.hist-out { overflow-x: auto; }
.hist-out table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hist-out th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.hist-out td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.hist-out tr.over td { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 6px 0 14px; }
.kpi { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kpi b { display: block; font-family: var(--font-display); font-size: 20px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi.warn b { color: var(--danger); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 8px; }
.tipo { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--line); }
.tipo.app { color: var(--stopped); border-color: color-mix(in srgb, var(--stopped) 40%, transparent); }
.tipo.web { color: var(--brand-text); border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
.tipo.falha { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.aviso-box { border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; line-height: 1.5; }
.route-bar { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 900; width: min(720px, calc(100% - 24px));
  display: grid; gap: 8px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--brand);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.route-bar[hidden] { display: none; }
.rb-text { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.rb-play { display: flex; gap: 10px; align-items: center; }
.rb-play input { flex: 1; accent-color: var(--brand); }
.rb-actions { display: flex; gap: 12px; justify-content: flex-end; align-items: center; }
.rota-pin { width: 14px; height: 14px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
.rota-pin.ini { background: var(--moving); } .rota-pin.fim { background: var(--danger); }
.rota-pin.agora { background: var(--brand); width: 18px; height: 18px; }
.logsw { display: flex; flex-direction: column; gap: 6px; }
.sw.mini { padding: 4px 8px; font-size: 12.5px; gap: 8px; white-space: nowrap; }
.sheet .sw.mini input { width: 30px; height: 17px; }
.sheet .sw.mini input::after { width: 13px; height: 13px; }
.sheet .sw.mini input:checked::after { transform: translateX(13px); }
.hist-acoes { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.hist-acoes[hidden], .hist-mail[hidden] { display: none; }
.hist-mail { display: grid; gap: 10px; border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.hist-mail textarea { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font: inherit; resize: vertical; }
.cli-bar .spacer { flex: 1; }

/* ---------- Compartilhar localização ---------- */
.radios.wrap { flex-wrap: wrap; gap: 8px 18px; }
.sh-res { display: grid; gap: 10px; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 12px; }
.sh-res[hidden] { display: none; }
.sh-res a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.sh-prev-sheet { max-width: 480px; padding: 12px; }
.sh-prev-root { height: min(640px, 75vh); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.shr-body { margin: 0; height: 100dvh; }
.shr-page { height: 100dvh; }
.shr { display: grid; grid-template-rows: auto 1fr auto; height: 100%; background: var(--bg); }
.shr-top { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); border-bottom: 3px solid var(--brand); }
.shr-title { display: grid; min-width: 0; }
.shr-title b { font-family: var(--font-display); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shr-conta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.shr-map { min-height: 200px; background: var(--map-empty); }
.shr-info { display: grid; gap: 8px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.shr-linha { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.shr-vel { font-weight: 700; }
.shr-coords { font-size: 12.5px; color: var(--muted); }
.shr-botoes { display: flex; flex-wrap: wrap; gap: 8px; }
.shr-ir { flex: 1 1 220px; text-align: center; text-decoration: none; }
.shr-ir[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.shr-pin { width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--brand); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.shr-eu { width: 18px; height: 18px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26,115,232,.2); }
.shr-fim { margin: auto; max-width: 360px; padding: 40px 20px; text-align: center; grid-row: 1 / -1; }
.shr-fim h2 { font-family: var(--font-display); margin: 0 0 8px; }
.shr-fim p { color: var(--muted); line-height: 1.5; }

/* ---------- Contratos (Clicksign) ---------- */
.ct-canais { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 10px 0 4px; }
.ct-canais .btn { margin-left: auto; }
.ct-canais label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ct-canais input { width: auto; margin: 0; }
.ct-dados td { overflow-wrap: anywhere; }
#ct-box summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--brand-text); }
.ct-dados th { width: 130px; text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.ct-falta { color: var(--danger); font-weight: 600; }
.ct-env { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-top: 10px; }
.ct-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.ct-st { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--line); }
.ct-ok { background: color-mix(in srgb, var(--moving) 22%, transparent); }
.ct-pend { background: color-mix(in srgb, #f59e0b 26%, transparent); }
.ct-erro { background: color-mix(in srgb, var(--danger) 20%, transparent); }
.ct-off { opacity: .7; }
.ct-sig { margin: 8px 0 4px; padding-left: 18px; font-size: 13px; }
.ct-sig li.ok b { color: var(--moving); }
.ct-sig li.erro b { color: var(--danger); }
.ct-env .actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 8px; }
.ct-demo { font-size: 12px; color: var(--muted); }
@media (max-width: 560px) { .ct-canais .btn { margin-left: 0; width: 100%; } }
.ct-extra { margin: 10px 0 4px; display: grid; gap: 10px; }
.ct-veic { border-top: 1px dashed var(--line); padding-top: 8px; }
.ct-veic .dev-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 6px; }
.ct-docs { margin-top: 6px; }
.ct-extra .dev-grid { align-items: start; }

/* Equipamentos: status das falhas de comunicação (+12 h) */
.eq-status { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 2px; margin: 4px 0 12px; }
.eq-st-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; }
.eq-st-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.eq-status .kpi small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.falha { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.falha.f12 { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand-text); }
.ok-txt { color: var(--moving); font-weight: 600; }
.eq-status .kpis { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

/* Clientes: veículo pela placa e exclusão */
.cv-box { border: 1px dashed var(--line); border-radius: var(--radius); padding: 8px 12px; margin: 0 0 12px; }
.cv-box > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.cv-box[open] > summary { margin-bottom: 8px; }
.cv-row { display: flex; gap: 8px; }
.cv-row input { flex: 1; min-width: 0; }
#cv-placa { text-transform: uppercase; font-family: var(--font-mono); }
#cv-chassi { text-transform: uppercase; font-family: var(--font-mono); }
.cli-del-box { border: 1px solid var(--danger); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; background: color-mix(in srgb, var(--danger) 6%, transparent); }
.cli-del-box ul { margin: 8px 0 4px; padding-left: 20px; }
.cli-del-box li { margin: 4px 0; }
.btn.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.linkbtn.danger { color: var(--danger); margin-right: auto; }

/* Equipamentos: formulário de incluir/editar (esconde a lista enquanto edita) */
.eq-sheet.editando > :not(.detail-head):not(#eq-form) { display: none; }
#ef-placa, #ef-chassi { text-transform: uppercase; font-family: var(--font-mono); }
.usr-sheet.editando > :not(.detail-head):not(#uf-form) { display: none; }
.uf-niveis { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.uf-niveis small { margin-left: 4px; }
.uf-semlim { align-self: end; padding-bottom: 10px; }

/* Temas festivos (temas.js): faixa no topo, selo com mensagem e confete/neve por alguns segundos */
:root[data-tema] .topbar { position: relative; }
:root[data-tema] .topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 4px; background: var(--tema-faixa); pointer-events: none; }
:root[data-tema="junina"] .topbar::after { height: 9px; bottom: -9px;
  -webkit-mask: conic-gradient(from -45deg at 50% 100%, #000 90deg, #0000 0) 0 0 / 18px 100%; mask: conic-gradient(from -45deg at 50% 100%, #000 90deg, #0000 0) 0 0 / 18px 100%;
  background: repeating-linear-gradient(90deg, #dc2626 0 18px, #2563eb 18px 36px, #facc15 36px 54px, #16a34a 54px 72px, #f97316 72px 90px); }
.tema-selo { display: inline-flex; align-items: center; gap: 6px; margin-left: 12px; padding: 4px 6px 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); max-width: 46vw; white-space: nowrap; }
.tema-selo .tema-txt { overflow: hidden; text-overflow: ellipsis; }
.tema-selo svg { flex: none; color: var(--brand-text); }
.tema-x { border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 2px 4px; border-radius: 50%; }
.tema-x:hover { color: var(--ink); }
@media (max-width: 760px) { .tema-selo .tema-txt { display: none; } .tema-selo { margin-left: 6px; padding: 4px; } }
.tema-fx { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 3000; }
.tema-fx i { position: absolute; top: -20px; display: block; animation-name: tema-cai; animation-timing-function: linear; animation-fill-mode: forwards; opacity: .9; }
.tema-fx.confete i { width: 8px; height: 12px; border-radius: 2px; }
.tema-fx.neve i { width: 8px; height: 8px; border-radius: 50%; background: #fff; box-shadow: 0 0 3px rgba(0,0,0,.25); }
@keyframes tema-cai { 0% { transform: translate3d(0, 0, 0) rotate(0); } 100% { transform: translate3d(40px, 105vh, 0) rotate(540deg); opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .tema-fx { display: none; } }

/* Polícia mais próxima (policia.js) */
.pol-box { position: absolute; top: 12px; left: 56px; z-index: 900; width: min(360px, calc(100% - 68px)); max-height: calc(100% - 24px); overflow: auto;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid #1d4ed8; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.pol-box[hidden] { display: none; }
.pol-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pol-lista { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 6px; }
.pol-it { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-left: 4px solid #1d4ed8; border-radius: 8px; padding: 6px 8px; }
.pol-it.prf { border-left-color: #ca8a04; }
.pol-ir { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink); font: inherit; }
.pol-ir b, .pol-ir span { display: block; }
.pol-fonte { margin: 4px 0 0; }
.pol-pin { display: flex !important; align-items: center; justify-content: center; border-radius: 50%; background: #1d4ed8; color: #fff; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pol-pin.prf { background: #ca8a04; }
.pol-pin.civil { background: #334155; }
.tema-pop { min-width: 260px; gap: 6px; padding: 12px; }
.tema-opcoes { display: grid; gap: 4px; margin: 4px 0; }
.tema-opcoes small { margin-left: 4px; }
@media (max-width: 520px) { .tema-selo { display: none; } }
/* Topo em celular estreito: cabe Temas, Históricos, Menu e Sair sem rolar para o lado */
@media (max-width: 480px) {
  .topbar { gap: 8px; padding-left: max(10px, env(safe-area-inset-left, 0px)); padding-right: max(10px, env(safe-area-inset-right, 0px)); }
  .topbar .icon-btn { padding: 7px 8px; }
  .topbar #logout { padding: 7px 10px; }
  /* com Modo noturno e Trocar senha no topo: o nome AREAGPS sai e fica só o pino do logo */
  .topbar .wordmark { display: none; }
  .topbar { gap: 6px; }
  .topbar .icon-btn { padding: 7px 7px; }
}
@media (max-width: 400px) {
  #live-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar .brand { font-size: 15px; gap: 6px; } .topbar .brand-pin { height: 24px; }
}

/* Limite da via (vias.js): parece uma placa de velocidade */
.lim-via { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 3px; border-radius: 50%; border: 3px solid #dc2626; background: #fff; color: #111;
  font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; }
.hf-via { align-self: end; padding-bottom: 8px; max-width: 360px; }

/* Sensores: ignição, bloqueio e odômetro (lista e cartão do veículo) */
.item .sens { grid-column: 2 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sen { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); font-size: 11.5px; color: var(--muted); line-height: 1; }
.sen svg { width: 14px; height: 14px; flex: none; }
.sen b { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.sen.ign-on, .sen-c.ign-on svg { color: var(--moving); }
.sen.ign-on { border-color: color-mix(in srgb, var(--moving) 45%, var(--line)); background: color-mix(in srgb, var(--moving) 10%, transparent); }
.sen.blq-on, .sen-c.blq-on svg { color: var(--danger); }
.sen.blq-on { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.sen.blq-off, .sen-c.blq-off svg { color: var(--moving); }
.sen-c.ign-off svg, .sen-c.ign-nd svg, .sen-c.blq-nd svg { color: var(--offline); }
.sen-c.odo svg { color: var(--brand-text); }
.sens-c { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sen-c { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.sen-c svg { width: 20px; height: 20px; flex: none; }
.sen-c > span { display: grid; gap: 1px; }
.sen-c .sen-l { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sen-c b { font-size: 13px; font-variant-numeric: tabular-nums; }
.sen-c.blq-on { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.sen-c.ign-on { border-color: color-mix(in srgb, var(--moving) 50%, var(--line)); background: color-mix(in srgb, var(--moving) 8%, transparent); }
.odo-form { display: grid; gap: 6px; }
.odo-form label { font-size: 12px; font-weight: 600; color: var(--muted); }
.odo-form input { flex: 1; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.odo-form .btn { padding: 8px 12px; }
@media (max-width: 760px) { .sen-c { padding: 6px 8px; gap: 6px; } .sen-c svg { width: 18px; height: 18px; } }

/* Lápis de edição em cada veículo da lista (só administrador) */
.item.ed { grid-template-columns: auto 1fr auto auto; }
.item-ed { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--brand-text); cursor: pointer; }
.item-ed:hover, .item-ed:focus-visible { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, var(--surface)); }

/* Frota grande: lista e tabela mostram 100 por vez */
.list-mais { display: grid; gap: 6px; padding: 12px 16px 18px; justify-items: start; list-style: none; }
.eq-mais { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 12px 0; }

/* Usuários: veículos que o usuário vê */
.uf-veic { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 14px; max-height: 300px; overflow-y: auto; padding: 2px; }
.uf-veic .uf-v { align-items: flex-start; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.uf-veic .uf-v span { min-width: 0; overflow-wrap: anywhere; }
.uf-veic .placa { min-width: 0; font-size: 11px; padding: 0 4px; margin-left: 4px; }
.hint.ok { color: var(--moving); }

/* Controle de acesso */
.ctl-sheet { max-width: 1000px; }
.ctl-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 12px; }
@media (max-width: 1100px) { .ctl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ctl-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 10px; align-content: start; }
.ctl-card h3 { margin: 0; }
.ctl-regra { display: grid; gap: 8px; }
.ctl-campos { display: grid; gap: 6px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px; }
.ctl-campos .chk { font-size: 13px; }
.sheet .ctl-campos .chk input { width: auto; accent-color: var(--brand); }
.ctl-nunca { padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--danger) 7%, transparent); }
.ctl-exc { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand-text); }
.sw .tag.trava, .ctl-regra .tag { color: var(--stopped); }
@media (max-width: 760px) { .ctl-grid { grid-template-columns: 1fr; } }

/* Bloquear / desbloquear no cartão */
.cmd-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cmd-b { display: inline-flex; align-items: center; gap: 6px; }
.cmd-b svg { width: 16px; height: 16px; }
#cmd-blq { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.cmd-box.conf { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.cmd-box.conf.blq { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); background: color-mix(in srgb, var(--danger) 7%, transparent); }

/* Atividades */
.atv { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.atv-exclusao, .atv-bloqueio { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.atv-desbloqueio { color: var(--moving); border-color: color-mix(in srgb, var(--moving) 40%, transparent); }
.atv-edicao, .atv-criacao { color: var(--stopped); border-color: color-mix(in srgb, var(--stopped) 40%, transparent); }
.atv-relatorio { color: var(--brand-text); border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
.atv-det { min-width: 240px; overflow-wrap: anywhere; }

/* Hierarquia: super administrador e administrador secundário */
.ctl-super { margin-top: 12px; background: color-mix(in srgb, var(--brand) 6%, transparent); }
.ctl-aviso { border-left: 3px solid #d9480f; padding: 6px 10px; background: color-mix(in srgb, #d9480f 8%, transparent); border-radius: 6px; }
.ctl-aviso ul { margin: 6px 0 0; padding-left: 18px; }
.ctl-serv { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }

/* Equipamento: data com botão Hoje e anotações */
.ef-datawrap { display: flex; gap: 8px; align-items: center; }
.ef-datawrap input { flex: 1; min-width: 0; }
#ef-notas { width: 100%; resize: vertical; font: inherit; }

/* Senha: trocar e recuperar */
.esqueci { justify-self: center; font-size: 14px; }
.senha-sheet { width: min(420px, 100%); display: grid; gap: 14px; }
.login-card .hint-ok { margin: 0; }

/* Modo noturno: botão lua/sol e mapa de ruas escurecido */
.noturno-btn .ico-sol { display: none; }
:root[data-escuro] .noturno-btn .ico-sol { display: inline; }
:root[data-escuro] .noturno-btn .ico-lua { display: none; }
.login { position: relative; }
.login-noturno { position: absolute; top: 14px; right: 14px; }
:root[data-escuro] #map.ruas .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.8); }

/* ---------- Integração AREAGPS Inteligência (Controle de acesso, só o super) ---------- */
#ctl-integracao { display: grid; gap: 14px; }
#ctl-integracao[hidden] { display: none; }
.ctl-grid.int-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0; }
.int-card textarea { width: 100%; font-family: var(--font-mono); font-size: 12.5px; resize: vertical; }
.int-nova { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, var(--surface)); }
.int-nova input { font-size: 12.5px; }
@media (max-width: 760px) { .ctl-grid.int-grid { grid-template-columns: 1fr; } }

/* ---------- Saúde do servidor (Controle de acesso, só o super) ---------- */
#ctl-saude { display: grid; gap: 12px; }
#ctl-saude[hidden] { display: none !important; }
.sd-cab { display: flex; align-items: center; gap: 12px; }
.sd-cab > div { flex: 1; min-width: 0; display: grid; gap: 2px; }
.sd-cab h3 { text-transform: none; letter-spacing: 0; font-size: 17px; color: var(--ink); font-family: var(--font-display); }
.sd-sel { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 18px; color: #fff; background: var(--moving); }
.sd-geral { border-left: 4px solid var(--moving); }
.sd-geral.aviso { border-left-color: var(--brand); } .sd-geral.aviso .sd-sel { background: var(--brand-dark); }
.sd-geral.grave { border-left-color: var(--danger); } .sd-geral.grave .sd-sel { background: var(--danger); }
.sd-prob { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13.5px; }
.sd-prob li.grave b { color: var(--danger); } .sd-prob li.aviso b { color: var(--brand-text); }
.ctl-grid.sd-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 0; }
.ctl-grid.sd-grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0; }
.sd-kpi { gap: 2px; }
.sd-kpi .sd-rot { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sd-kpi b { font-family: var(--font-display); font-size: 24px; font-variant-numeric: tabular-nums; }
.sd-kpi.aviso b { color: var(--brand-text); } .sd-kpi.grave b { color: var(--danger); }
.sd-gwrap { position: relative; margin-top: 8px; }
.sd-graf { display: block; width: 100%; height: 64px; overflow: visible; cursor: crosshair; }
.sd-linha { fill: none; stroke: var(--brand); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.sd-lim { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; opacity: .6; }
.sd-cursor { stroke: var(--muted); stroke-width: 1; vector-effect: non-scaling-stroke; }
.sd-ponto { fill: var(--brand); stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.sd-tip { position: absolute; bottom: calc(100% + 4px); transform: translateX(-50%); white-space: nowrap; pointer-events: none; z-index: 5;
  background: var(--ink); color: var(--surface); border-radius: 6px; padding: 3px 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
.sd-servs, .sd-ev, .sd-limp { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.sd-servs li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
.sd-servs li > span:last-child { display: grid; gap: 1px; min-width: 0; }
.sd-mk { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; background: var(--moving); }
.sd-servs li.aviso .sd-mk { background: var(--brand-dark); } .sd-servs li.grave .sd-mk { background: var(--danger); }
.sd-ev li { line-height: 1.4; }
.sd-tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); }
.sd-ev li.grave .sd-tag { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.sd-ev li.aviso .sd-tag { color: var(--brand-text); border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
.sd-ev li.rein .sd-tag { color: var(--stopped); border-color: color-mix(in srgb, var(--stopped) 40%, transparent); }
.sd-ev li.ok .sd-tag { color: var(--moving); border-color: color-mix(in srgb, var(--moving) 40%, transparent); }
@media (max-width: 900px) { .ctl-grid.sd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .ctl-grid.sd-grid2 { grid-template-columns: 1fr; } }
@media (max-width: 420px) { .ctl-grid.sd-grid { grid-template-columns: 1fr; } }
#ctl .tabs { overflow-x: auto; scrollbar-width: thin; }
#ctl .tab { white-space: nowrap; }

/* Agrupamento de veículos no mapa (app.js: desenharGrupos) */
.veh-grupo { cursor: pointer; }
.veh-grupo .vg-anel { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; padding: 4px; box-sizing: border-box; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.veh-grupo .vg-num { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; background: var(--surface); color: var(--ink); font: 700 13px/1 var(--font-ui); }
.veh-grupo:hover .vg-anel, .veh-grupo:focus-visible .vg-anel { transform: scale(1.08); }
.agrupar-btn { font: 600 12px/1 var(--font-ui); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.agrupar-btn[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.agrupar-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
/* Busca por nome ou placa em cima das listas dos Históricos (historicos.js: comBusca) */
.sel-busca { width: 100%; box-sizing: border-box; margin-bottom: 6px; }
