/* Tudo à Mão — mesma linguagem visual do AutoGreen, paleta azul-atlântico + coral. Mobile-first. */
:root {
  --acc: #3d63ff; --acc-ink: #ffffff; --acc-soft: rgba(61,99,255,.12);
  --sos: #ff4d3d; --ok: #16a34a; --warn: #f59e0b; --bad: #e5484d; --unk: #9aa0aa;
  --bg: #f2f4f8; --surface: #ffffff; --surface-2: #e9edf4; --ink: #0b1020; --mut: #667085; --line: rgba(11,16,32,.08);
  --glass: rgba(255,255,255,.86);
  --g-saude: #e5484d; --g-seg: #2563eb; --g-trans: #0ea5a4; --g-estado: #7c3aed; --g-dia: #f59e0b; --g-alert: #ea580c;
  --r: 22px; --r-sm: 14px;
  --shadow: 0 10px 30px -10px rgba(11,16,32,.35), 0 2px 6px rgba(11,16,32,.08);
  --display: "Bricolage Grotesque", ui-rounded, system-ui, sans-serif;
  --tabs-h: 64px; --safe-b: env(safe-area-inset-bottom); --safe-t: env(safe-area-inset-top);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070b16; --surface: #111729; --surface-2: #1b2338; --ink: #eef1f7; --mut: #8b93a7; --line: rgba(255,255,255,.08);
    --glass: rgba(17,23,41,.88); --shadow: 0 12px 34px -10px rgba(0,0,0,.7), 0 2px 6px rgba(0,0,0,.3); --acc: #5b7cff; --acc-soft: rgba(91,124,255,.18);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #070b16; --surface: #111729; --surface-2: #1b2338; --ink: #eef1f7; --mut: #8b93a7; --line: rgba(255,255,255,.08);
  --glass: rgba(17,23,41,.88); --shadow: 0 12px 34px -10px rgba(0,0,0,.7), 0 2px 6px rgba(0,0,0,.3); --acc: #5b7cff; --acc-soft: rgba(91,124,255,.18);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: var(--bg); color: var(--ink); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:active { transform: scale(.97); }
a { color: var(--acc); }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; }
.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#map { position: fixed; inset: 0; }
.maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { display: none; }
.small { font-size: 13px; color: var(--mut); }
.mut { color: var(--mut); }
h2 { font-family: var(--display); font-size: 24px; letter-spacing: -.03em; margin: 6px 0 4px; }
h3 { font-family: var(--display); letter-spacing: -.02em; }
h4 { margin: 18px 0 8px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--mut); }

/* ---------------------------------------------------------- topo */
.top { position: fixed; z-index: 10; top: 0; left: 0; right: 0; display: flex; gap: 8px; padding: calc(var(--safe-t) + 10px) 12px 0; pointer-events: none; }
.top > * { pointer-events: auto; }
.search { flex: 1; min-width: 0; max-width: 560px; height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 16px; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-radius: 26px; box-shadow: var(--shadow); }
.search > .i { color: var(--mut); width: 20px; height: 20px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 16px; height: 100%; }
.search input::placeholder { color: var(--mut); }
.search input::-webkit-search-cancel-button { display: none; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); }
.sos-top { height: 52px; min-width: 52px; padding: 0 16px; border-radius: 26px; background: var(--sos); color: #fff; font-family: var(--display); font-weight: 800; font-size: 17px; box-shadow: var(--shadow); letter-spacing: .02em; }
.catpill { position: fixed; z-index: 9; top: calc(var(--safe-t) + 70px); left: 12px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 8px 0 12px; border-radius: 19px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-weight: 700; font-size: 14px; max-width: calc(100% - 24px); }
.catpill .x { width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 14px; color: inherit; }
.catpill .sub { opacity: .7; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filters { position: fixed; z-index: 9; top: calc(var(--safe-t) + 116px); left: 12px; right: 12px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.results { position: fixed; z-index: 11; top: calc(var(--safe-t) + 70px); left: 12px; right: 12px; max-width: 560px; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden auto; max-height: 60vh; }
.results button { width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.results button:last-child { border-bottom: 0; }
.results .ri { width: 36px; height: 36px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; flex: none; font-size: 17px; }
.results small { display: block; color: var(--mut); font-size: 13px; }
.results .grow { min-width: 0; flex: 1; }
.results .grow b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.locate { position: fixed; z-index: 8; right: 12px; bottom: calc(var(--tabs-h) + var(--safe-b) + var(--deck-h, 0px) + 12px); width: 48px; height: 48px; border-radius: 50%; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow); display: grid; place-items: center; transition: bottom .3s; }
.locate.on { color: var(--acc); }

/* ---------------------------------------------------------- cartões */
.deck { position: fixed; z-index: 8; left: 0; right: 0; bottom: calc(var(--tabs-h) + var(--safe-b) + 8px); display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 12px 8px; scrollbar-width: none; }
.deck::-webkit-scrollbar { display: none; }
.card { flex: none; width: min(86vw, 360px); scroll-snap-align: center; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 10px; border: 2px solid transparent; cursor: pointer; }
.card.active { border-color: var(--acc); }
.card-head { display: flex; gap: 12px; align-items: center; }
.ic { width: 44px; height: 44px; flex: none; border-radius: 14px; display: grid; place-items: center; font-size: 22px; background: var(--surface-2); }
.card-title { flex: 1; min-width: 0; }
.card-title h3 { margin: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-title p { margin: 1px 0 0; font-size: 13px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-stats { display: flex; gap: 6px; }
.card-stats > div { flex: 1; background: var(--surface-2); border-radius: 12px; padding: 7px 8px; min-width: 0; }
.card-stats b { display: block; font-family: var(--display); font-size: 16px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-stats span { display: block; font-size: 11px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: flex; gap: 8px; }
.card.empty { align-items: center; justify-content: center; text-align: center; min-height: 140px; color: var(--mut); cursor: default; }
.card.empty b { color: var(--ink); font-family: var(--display); font-size: 18px; }
.btn { flex: 1; height: 44px; border-radius: 14px; background: var(--surface-2); font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; padding: 0 12px; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn.pri { background: var(--acc); color: var(--acc-ink); }
.btn.sos { background: var(--sos); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.sm { height: 34px; font-size: 13px; border-radius: 11px; flex: none; }
.btn .i { width: 18px; height: 18px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.open { color: var(--ok); } .status.closed { color: var(--bad); } .status.soon { color: var(--warn); } .status.unk { color: var(--unk); }
.chip { flex: none; height: 34px; padding: 0 12px; border-radius: 17px; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow); font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip.on { background: var(--acc); color: var(--acc-ink); }
.chip.flat { box-shadow: none; background: var(--surface-2); backdrop-filter: none; }
.chip.flat.on { background: var(--acc); }
.chipline { display: flex; gap: 6px; flex-wrap: wrap; }
.line-badge { display: inline-grid; place-items: center; min-width: 34px; height: 24px; padding: 0 7px; border-radius: 7px; font-weight: 800; font-size: 12px; background: var(--ink); color: var(--bg); white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------- painel */
.panel { position: fixed; z-index: 12; left: 0; right: 0; bottom: 0; max-height: 62%; background: var(--surface); border-radius: 28px 28px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.25); padding: 0 16px calc(var(--tabs-h) + var(--safe-b) + 16px); overflow-y: auto; overscroll-behavior: contain; animation: up .32s cubic-bezier(.2,.9,.3,1); }
.panel.full { max-height: calc(100% - var(--safe-t) - 70px); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.handle { position: sticky; top: 0; z-index: 2; height: 26px; margin: 0 -16px; background: var(--surface); display: grid; place-items: center; cursor: grab; }
.handle::after { content: ""; width: 40px; height: 5px; border-radius: 3px; background: var(--surface-2); }
.p-head { display: flex; gap: 12px; align-items: flex-start; }
.p-head .grow { flex: 1; min-width: 0; }
.close { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; flex: none; font-size: 16px; }
.row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; width: 100%; text-align: left; }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .grow b { display: block; }
.row .grow small { display: block; color: var(--mut); font-size: 13px; }
.row .end { text-align: right; flex: none; }
.row .end b { font-family: var(--display); font-size: 18px; }
.box { background: var(--surface-2); border-radius: var(--r-sm); padding: 12px 14px; }
.box + .box { margin-top: 8px; }
.box .btn:not(.pri):not(.sos):not(.ok) { background: var(--surface); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv span { color: var(--mut); }
.hours { width: 100%; border-collapse: collapse; font-size: 14px; }
.hours td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.hours td:last-child { text-align: right; }
.hours tr.today td { font-weight: 800; }

/* grelha de categorias */
.cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (min-width: 520px) and (max-width: 899px) { .cats { grid-template-columns: repeat(6, 1fr); } }
.cat { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 8px; border-radius: 16px; background: var(--surface-2); font-size: 12px; font-weight: 600; text-align: center; line-height: 1.15; min-height: 86px; }
.cat .e { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 22px; background: var(--surface); }
.cat.on { outline: 2.5px solid var(--acc); }
.grp-title { display: flex; align-items: center; gap: 8px; }
.grp-title::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--gc, var(--acc)); }
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.hero button { text-align: left; border-radius: 18px; padding: 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; min-height: 92px; }
.hero button b { font-family: var(--display); font-size: 16px; }
.hero button small { color: var(--mut); font-size: 12px; }
.hero .big { grid-column: span 2; background: linear-gradient(135deg, var(--acc), #7c5cff); color: #fff; }
.hero .big small { color: rgba(255,255,255,.85); }
.hero .sosb { background: var(--sos); color: #fff; } .hero .sosb small { color: rgba(255,255,255,.85); }

/* formulários */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; position: relative; }
.field label { font-size: 12px; font-weight: 700; color: var(--mut); }
.field input, .field select, .field textarea { height: 46px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--surface-2); padding: 0 12px; outline: 0; font-size: 16px; }
.field textarea { height: 80px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--acc); }
.sugg { position: absolute; top: 100%; left: 0; right: 0; z-index: 5; background: var(--surface); border-radius: 13px; box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; }
.sugg button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.swap { position: absolute; right: 8px; top: 25px; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); z-index: 2; }

/* partidas */
.dep { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.dep .grow { flex: 1; min-width: 0; }
.dep .grow b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dep .t { text-align: right; flex: none; }
.dep .t b { font-family: var(--display); font-size: 18px; display: block; }
.dep .t small { color: var(--mut); font-size: 12px; }
.rt { color: var(--ok); font-weight: 800; font-size: 11px; letter-spacing: .04em; }
.timeline { position: relative; margin-left: 8px; padding-left: 18px; border-left: 3px solid var(--acc); }
.timeline .st { position: relative; padding: 6px 0; display: flex; justify-content: space-between; gap: 8px; }
.timeline .st::before { content: ""; position: absolute; left: -26px; top: 11px; width: 11px; height: 11px; border-radius: 50%; background: var(--surface); border: 3px solid var(--acc); }
.timeline .st.me { font-weight: 800; }
.leg { border-radius: 16px; background: var(--surface-2); padding: 12px; margin-bottom: 8px; width: 100%; text-align: left; display: block; }
.leg-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.leg-head b { font-family: var(--display); font-size: 20px; }

/* SOS */
.sos-big { width: 100%; height: 120px; border-radius: 28px; background: var(--sos); color: #fff; font-family: var(--display); font-size: 44px; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 16px 40px -12px rgba(255,77,61,.7); text-decoration: none; }
.sos-big small { font-family: system-ui; font-size: 14px; font-weight: 600; opacity: .9; }
.coords { font-family: ui-monospace, Menlo, monospace; font-size: 15px; }
.medcard { border-radius: 20px; padding: 16px; background: linear-gradient(135deg, #ff4d3d, #ff7a59); color: #fff; }
.medcard .kv span { color: rgba(255,255,255,.8); }
.flash { position: fixed; inset: 0; z-index: 100; background: #fff; display: grid; place-items: center; color: #000; font-weight: 800; }
.flash.red { animation: strobe .5s steps(2) infinite; }
@keyframes strobe { 50% { background: #ff2a1a; } }

/* tempo */
.wx { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: center; }
.wx > div { background: var(--surface-2); border-radius: 14px; padding: 8px 2px; font-size: 12px; }
.wx .e { font-size: 24px; display: block; }
.wx b { font-family: var(--display); font-size: 15px; }
.lvl { display: inline-block; width: 12px; height: 12px; border-radius: 4px; flex: none; }
.lvl.yellow { background: #facc15; } .lvl.orange { background: #f97316; } .lvl.red { background: #dc2626; }

/* separadores */
.tabs { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: flex; background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--line); }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--mut); }
.tabs button.on { color: var(--acc); }
.tabs button.sos-tab.on { color: var(--sos); }
.tabs .i { width: 23px; height: 23px; }

.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.4); }
.drawer { position: fixed; z-index: 31; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 26px 26px 0 0; padding: 18px 16px calc(var(--safe-b) + 18px); max-height: 85%; overflow-y: auto; animation: up .3s; }
.toast { position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + var(--safe-b) + 18px); background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--acc); animation: rot .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes rot { to { transform: rotate(360deg); } }
.empty-note { padding: 18px 4px; color: var(--mut); text-align: center; }
.src { font-size: 11px; color: var(--mut); margin-top: 10px; }

/* marcadores de veículos */
.veh { width: 26px; height: 26px; border-radius: 50%; background: #ffdd00; color: #000; border: 2px solid #fff; font-size: 9px; font-weight: 900; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.maplibregl-popup-content { background: var(--surface); color: var(--ink); border-radius: 12px; padding: 8px 10px; font-size: 13px; }
.maplibregl-popup-tip { border-top-color: var(--surface) !important; }

@media (min-width: 900px) {
  .panel { left: 12px; right: auto; width: 440px; bottom: calc(var(--tabs-h) + 12px); border-radius: 26px; max-height: calc(100% - var(--tabs-h) - var(--safe-t) - 96px); padding-bottom: 20px; }
  .deck { left: 464px; }
  .tabs { left: 50%; right: auto; transform: translateX(-50%); width: 520px; bottom: 12px; border-radius: 22px; border: 1px solid var(--line); height: var(--tabs-h); padding: 0; box-shadow: var(--shadow); }
  .deck { bottom: calc(var(--tabs-h) + 24px); }
}
