/* ============================================================
   SIG-GCMI — tema institucional (escuro por padrão, claro opcional)
   ============================================================ */
:root {
  --bg: #070d18;
  --bg-2: #0b1324;
  --card: #0f1a2e;
  --card-2: #13203a;
  --line: #1f2d48;
  --line-2: #2a3b5c;
  --text: #e6ecf5;
  --muted: #8a9bb8;
  --dim: #5d6f8f;
  --primary: #3b6fe0;
  --primary-2: #2c56b8;
  --gold: #e3b341;
  --ok: #22b573;
  --warn: #f0a92e;
  --danger: #e5484d;
  --violet: #8b6cf0;
  --cyan: #2bb3c9;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --font-h: 'Chakra Petch', system-ui, sans-serif;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar: 248px;
  color-scheme: dark;
}
:root[data-tema="claro"] {
  --bg: #eef2f8; --bg-2: #e5ebf4; --card: #ffffff; --card-2: #f4f7fb;
  --line: #d9e1ed; --line-2: #c6d2e3; --text: #0f1b2d; --muted: #52637e; --dim: #7d8ca3;
  --shadow: 0 8px 24px rgba(16,32,64,.10);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
#app { min-height: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
h1, h2, h3, h4 { font-family: var(--font-h); margin: 0; letter-spacing: .02em; }
input, select, textarea { font-family: inherit; font-size: 15px; }
::selection { background: var(--primary); color: #fff; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; }
.upper { text-transform: uppercase; letter-spacing: .08em; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.center { text-align: center; }
.hide { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* boot */
.boot { min-height: 100vh; display: grid; place-content: center; gap: 14px; justify-items: center; color: var(--muted); font-family: var(--font-h); letter-spacing: .1em; text-transform: uppercase; font-size: 13px; }
.boot-spin, .spin { width: 34px; height: 34px; border: 3px solid var(--line-2); border-top-color: var(--gold); border-radius: 50%; animation: girar .8s linear infinite; }
.spin.sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--card-2); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1a1405; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 60%, transparent); color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--card-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 6px; gap: 5px; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn.sm svg, .btn.xs svg { width: 15px; height: 15px; }
.btn.lg { height: 52px; font-size: 16px; padding: 0 22px; border-radius: 12px; }

/* ---------- formulário ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.field .req { color: var(--danger); }
.field .hint { font-size: 12px; color: var(--dim); }
.input, select.input, textarea.input { width: 100%; height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); outline: none; transition: border-color .15s; }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.input[readonly] { opacity: .75; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 16px; }
.grid-form .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }

/* ---------- cartões ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-h h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; }
.card-b { padding: 16px; }
.pad { padding: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c, var(--primary)); }
.kpi .t { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; gap: 8px; }
.kpi .t svg { width: 16px; height: 16px; margin-left: auto; color: var(--c, var(--primary)); }
.kpi .v { font-family: var(--font-h); font-size: 30px; font-weight: 700; margin-top: 4px; line-height: 1.1; }
.kpi .s { font-size: 12.5px; color: var(--dim); margin-top: 2px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; background: color-mix(in srgb, var(--bc, var(--muted)) 16%, transparent); color: var(--bc, var(--muted)); border: 1px solid color-mix(in srgb, var(--bc, var(--muted)) 35%, transparent); }
.badge.dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }

/* ---------- tabela ---------- */
.table-wrap { overflow: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--card); position: sticky; top: 0; z-index: 1; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tbody tr:hover { background: color-mix(in srgb, var(--primary) 6%, transparent); }
table.t tbody tr.click { cursor: pointer; }
table.t td.acoes { white-space: nowrap; text-align: right; width: 1%; }
.empty { padding: 36px 16px; text-align: center; color: var(--dim); }
.empty svg { width: 34px; height: 34px; opacity: .5; display: block; margin: 0 auto 8px; }
.pager { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* ---------- layout central ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0,1fr); min-height: 100vh; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; border-bottom: 1px solid var(--line); }
.brand img, .brand .emb { width: auto; height: 50px; object-fit: contain; flex: none; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.brand b { font-family: var(--font-h); font-size: 17px; letter-spacing: .06em; display: block; }
.brand span { font-size: 11px; color: var(--muted); display: block; line-height: 1.2; }
.nav { padding: 8px 10px 20px; display: flex; flex-direction: column; gap: 1px; }
.nav .sec { font-size: 10.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .14em; font-weight: 700; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 14px; }
.nav a svg { width: 17px; height: 17px; flex: none; }
.nav a:hover { color: var(--text); background: var(--card); }
.nav a.ativo { color: #fff; background: var(--primary); }
.nav a .count { margin-left: auto; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 22px; min-height: 62px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .ttl small { display: block; font-size: 10.5px; color: var(--gold); text-transform: uppercase; letter-spacing: .14em; font-weight: 700; }
.topbar .ttl h1 { font-size: 19px; }
.content { padding: 20px 22px 40px; display: flex; flex-direction: column; gap: 16px; }
.page-desc { color: var(--muted); font-size: 14px; margin-top: -6px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar .input, .toolbar select.input { width: auto; min-width: 150px; height: 36px; }
.burger { display: none; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; background: var(--card); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; flex-wrap: wrap; }
.tabs button { height: 32px; padding: 0 14px; border-radius: 7px; border: 0; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; font-size: 13.5px; }
.tabs button.on { background: var(--primary); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: color-mix(in srgb, var(--cc, var(--primary)) 18%, transparent); border-color: var(--cc, var(--primary)); color: var(--text); }
.chip .dotc { width: 9px; height: 9px; border-radius: 50%; background: var(--cc, var(--primary)); }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(3,7,15,.66); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(760px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); animation: subir .18s; }
.modal.sm { width: min(460px, 100%); }
.modal.lg { width: min(1040px, 100%); }
@keyframes subir { from { transform: translateY(10px); opacity: 0; } }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-h h2 { font-size: 18px; }
.modal-h small { display: block; color: var(--muted); font-family: var(--font); font-size: 13px; letter-spacing: 0; font-weight: 500; }
.modal-b { padding: 18px 20px; overflow-y: auto; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 300; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 36px)); }
.toast { background: var(--card-2); border: 1px solid var(--line-2); border-left: 4px solid var(--tc, var(--primary)); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: flex-start; animation: subir .2s; cursor: pointer; }
.toast b { display: block; font-size: 14px; }
.toast span { font-size: 13px; color: var(--muted); }
.toast svg { width: 19px; height: 19px; color: var(--tc, var(--primary)); flex: none; margin-top: 1px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 25%, transparent), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--gold) 14%, transparent), transparent 60%), var(--bg); }
.login-box { width: min(410px, 100%); background: color-mix(in srgb, var(--card) 92%, transparent); border: 1px solid var(--line-2); border-radius: 18px; padding: 30px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; }
.login-box .emb-wrap { display: grid; place-items: center; gap: 8px; text-align: center; margin-bottom: 6px; }
.login-box .emb-wrap img, .login-box .emb-wrap .emb { width: auto; height: 150px; object-fit: contain; filter: drop-shadow(0 6px 18px rgba(0,0,0,.45)); }
.login-box h1 { font-size: 26px; letter-spacing: .12em; }
.login-box p { margin: 0; color: var(--muted); font-size: 13.5px; }
.erro { background: color-mix(in srgb, var(--danger) 14%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); color: #ffb3b5; padding: 10px 12px; border-radius: 8px; font-size: 13.5px; }
:root[data-tema="claro"] .erro { color: #a3171c; }
.aviso { background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); padding: 10px 12px; border-radius: 8px; font-size: 13.5px; }

/* ---------- mapa ---------- */
.mapa { position: relative; width: 100%; height: 100%; min-height: 300px; border-radius: var(--radius); overflow: hidden; background: #0a1220; }
.mapa .maplibregl-map { font-family: var(--font); }
.mapa-page { display: grid; grid-template-columns: 340px minmax(0,1fr); gap: 14px; height: calc(100vh - 62px - 40px); min-height: 520px; }
.mapa-side { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; padding-right: 2px; }
.map-ctrl { position: absolute; top: 10px; left: 10px; z-index: 5; display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 70px); }
.map-ctrl .chip { background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(6px); }
.map-ctrl select.input { height: 30px; width: auto; font-size: 13px; padding: 0 8px; background: color-mix(in srgb, var(--card) 92%, transparent); }
.mk-vtr { width: 38px; height: 38px; position: relative; cursor: pointer; }
.mk-vtr .seta { position: absolute; inset: 0; display: grid; place-items: center; transition: transform .6s ease; }
.mk-vtr .corpo { position: absolute; inset: 6px; border-radius: 50%; background: var(--vc, var(--ok)); border: 3px solid #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--vc, var(--ok)) 40%, transparent), 0 4px 12px rgba(0,0,0,.5); display: grid; place-items: center; color: #fff; font-family: var(--font-h); font-size: 11px; font-weight: 700; }
.mk-vtr .rot { position: absolute; top: 40px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: rgba(5,10,20,.85); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; font-family: var(--font-h); }
.mk-vtr.pulso .corpo { animation: pulso 1.4s infinite; }
@keyframes pulso { 0%,100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--vc) 40%, transparent), 0 0 0 0 color-mix(in srgb, var(--vc) 60%, transparent); } 50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--vc) 40%, transparent), 0 0 0 14px transparent; } }
.mk-pin { width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--pc, var(--danger)); border: 2px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.5); cursor: pointer; display: grid; place-items: center; }
.mk-pin i { transform: rotate(45deg); color: #fff; font-style: normal; font-size: 11px; font-weight: 800; font-family: var(--font-h); }
.mk-pin.pulso { animation: pinpulso 1.2s infinite; }
@keyframes pinpulso { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--pc) 30%, transparent); } }
.maplibregl-popup-content { background: var(--card) !important; color: var(--text); border: 1px solid var(--line-2); border-radius: 10px !important; padding: 12px 14px !important; box-shadow: var(--shadow) !important; font-family: var(--font); min-width: 220px; }
.maplibregl-popup-tip { border-top-color: var(--card) !important; border-bottom-color: var(--card) !important; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; right: 4px; top: 2px; }
.mini-map { height: 260px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-2); position: relative; }
.mini-map .alvo { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-100%); pointer-events: none; z-index: 3; }

.lista-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.lista-item:last-child { border-bottom: 0; }
.lista-item:hover { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.lista-item.sel { background: color-mix(in srgb, var(--primary) 14%, transparent); }
.vt-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: color-mix(in srgb, var(--vc, var(--ok)) 18%, transparent); color: var(--vc, var(--ok)); font-family: var(--font-h); font-weight: 700; font-size: 13px; flex: none; }

.timer { font-family: var(--font-h); font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.alerta { color: var(--danger); }
.progress { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--pc, var(--primary)); transition: width 1s linear; }

/* timeline do despacho */
.etapas { display: flex; gap: 4px; }
.etapas span { flex: 1; height: 5px; border-radius: 9px; background: var(--line-2); }
.etapas span.on { background: var(--ok); }

/* chat */
.chat { display: flex; flex-direction: column; gap: 8px; padding: 12px; overflow-y: auto; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 12px; font-size: 14px; background: var(--card-2); border: 1px solid var(--line); align-self: flex-start; }
.msg.eu { align-self: flex-end; background: var(--primary); border-color: var(--primary); color: #fff; }
.msg small { display: block; font-size: 11px; opacity: .75; margin-top: 2px; }

/* calendário de escalas */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 6px; }
.cal .dow { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; text-align: center; padding: 4px 0; }
.cal .dia { min-height: 104px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.cal .dia:hover { border-color: var(--primary); }
.cal .dia.fora { opacity: .35; }
.cal .dia.hoje { border-color: var(--gold); }
.cal .dia .n { font-family: var(--font-h); font-weight: 700; font-size: 13px; color: var(--muted); }
.cal .ev { font-size: 11px; padding: 2px 5px; border-radius: 4px; background: color-mix(in srgb, var(--ec, var(--primary)) 22%, transparent); color: var(--text); border-left: 3px solid var(--ec, var(--primary)); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.heat { display: grid; grid-template-columns: 44px repeat(24, minmax(0,1fr)); gap: 2px; font-size: 10.5px; }
.heat div { height: 20px; border-radius: 3px; display: grid; place-items: center; color: var(--muted); }
.heat .c { background: color-mix(in srgb, var(--danger) calc(var(--i) * 100%), var(--card-2)); }

.perm-grid { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px 14px; align-items: center; }
.perm-grid .seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.perm-grid .seg button { border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; padding: 5px 10px; cursor: pointer; }
.perm-grid .seg button.on { background: var(--primary); color: #fff; }
.perm-grid .seg button.on.n { background: var(--line-2); color: var(--text); }
.perm-grid .seg button.on.l { background: var(--cyan); }

.detalhe { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px 18px; }
.detalhe .full { grid-column: 1 / -1; }
.detalhe dt { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.detalhe dd { margin: 2px 0 0; white-space: pre-wrap; word-break: break-word; }
.fotos { display: flex; gap: 8px; flex-wrap: wrap; }
.fotos img { width: 92px; height: 92px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line-2); cursor: zoom-in; }

/* ============================================================
   APLICATIVO DO AGENTE (celular)
   ============================================================ */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; background: var(--bg); padding-bottom: env(safe-area-inset-bottom); }
.app-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: linear-gradient(180deg, var(--bg-2), color-mix(in srgb, var(--bg-2) 92%, transparent)); border-bottom: 1px solid var(--line); }
.app-top .emb, .app-top img { width: auto; height: 44px; object-fit: contain; }
.app-top b { font-family: var(--font-h); letter-spacing: .08em; font-size: 15px; display: block; line-height: 1.1; }
.app-top .grow { min-width: 0; }
.app-top small { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 99px; font-family: var(--font-h); font-weight: 700; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.pill.on { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 50%, transparent); }
.pill.off { background: var(--card-2); color: var(--muted); border: 1px solid var(--line-2); }
.pill.on::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: piscar 1.2s infinite; }
@keyframes piscar { 50% { opacity: .2; } }
.app-body { flex: 1; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.app-h { display: flex; align-items: center; gap: 10px; }
.app-h h2 { font-size: 18px; }
.status-card { position: relative; overflow: hidden; border-radius: 16px; padding: 16px; background: linear-gradient(135deg, #12244a, #0c1730); border: 1px solid #22355a; color: #fff; display: flex; flex-direction: column; gap: 10px; }
:root[data-tema="claro"] .status-card { background: linear-gradient(135deg, #1d3b78, #13284f); }
.status-card .big { font-family: var(--font-h); font-size: 24px; font-weight: 700; letter-spacing: .04em; }
.status-card .mut { color: #9fb3d6; font-size: 13px; }
.gps { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #9fb3d6; }
.gps i { width: 9px; height: 9px; border-radius: 50%; background: var(--gc, var(--dim)); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 18px 10px; border-radius: 14px; color: #fff; border: 1px solid rgba(255,255,255,.08); background: linear-gradient(145deg, var(--t1), var(--t2)); min-height: 110px; text-align: center; cursor: pointer; }
.tile svg { width: 30px; height: 30px; }
.tile b { font-family: var(--font-h); letter-spacing: .08em; font-size: 14px; text-transform: uppercase; }
.tile span { font-size: 11.5px; opacity: .75; line-height: 1.2; }
.tile .count { position: absolute; top: 8px; right: 8px; }
.tile:active { transform: scale(.98); }
.app-list { display: flex; flex-direction: column; gap: 10px; }
.app-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.app-item .t { font-weight: 700; }
.despacho-ativo { border-radius: 16px; padding: 16px; background: color-mix(in srgb, var(--danger) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); display: flex; flex-direction: column; gap: 10px; }
.despacho-ativo.aceito { background: color-mix(in srgb, var(--primary) 12%, var(--card)); border-color: color-mix(in srgb, var(--primary) 45%, transparent); }

/* alerta de despacho em tela cheia */
.alarme { position: fixed; inset: 0; z-index: 500; display: flex; flex-direction: column; padding: calc(18px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom)); background: radial-gradient(circle at 50% 30%, #6d1015, #2a0508 70%); color: #fff; gap: 14px; animation: alarmeFundo 1s infinite alternate; overflow-y: auto; }
@keyframes alarmeFundo { to { background: radial-gradient(circle at 50% 30%, #8f141b, #3a070b 70%); } }
.alarme .cab { text-align: center; font-family: var(--font-h); letter-spacing: .2em; font-size: 14px; text-transform: uppercase; opacity: .9; }
.alarme h2 { font-size: 26px; text-align: center; line-height: 1.15; }
.alarme .info { background: rgba(0,0,0,.28); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; }
.alarme .relogio { width: 132px; height: 132px; margin: 4px auto; position: relative; }
.alarme .relogio svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.alarme .relogio b { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-h); font-size: 40px; }
.alarme .acoes { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: auto; }
.alarme .btn.lg { height: 64px; font-size: 19px; font-family: var(--font-h); letter-spacing: .08em; }

.app-foot { text-align: center; font-size: 11.5px; color: var(--dim); padding: 6px 14px 14px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; background: none; border: 0; padding: 0; }
.foto-add { width: 92px; height: 92px; border-radius: 8px; border: 2px dashed var(--line-2); display: grid; place-items: center; color: var(--muted); cursor: pointer; }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) {
  .grid3 { grid-template-columns: 1fr; }
  .mapa-page { grid-template-columns: 1fr; height: auto; }
  .mapa-page .mapa { height: 62vh; }
  .mapa-side { max-height: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.aberta { transform: none; }
  .burger { display: inline-flex; }
  .grid2 { grid-template-columns: 1fr; }
  .content { padding: 14px 12px 30px; }
  .topbar { padding: 8px 12px; }
  .grid-form, .detalhe { grid-template-columns: 1fr; }
  .user-chip .nm { display: none; }
  .cal .dia { min-height: 64px; }
  .cal .ev { font-size: 9.5px; }
}
.scrim { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.5); }

@media print {
  .sidebar, .topbar, .toolbar, .btn, .pager, .toasts { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
  .card { border-color: #ccc; background: #fff; }
}

/* ---------- marca d'água do brasão ---------- */
.status-card > * { position: relative; z-index: 1; }
.status-card::after { content: ''; position: absolute; right: -18px; bottom: -26px; width: 150px; height: 210px; background: url(/img/brasao.webp) no-repeat center / contain; opacity: .10; pointer-events: none; }

/* ---------- app: estrutura (vertical por padrão) ---------- */
.click { cursor: pointer; }
.app-item.click:active { transform: scale(.99); }
.inicio, .inicio-esq, .inicio-dir { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.so-horizontal { display: none !important; }
.app-form { display: flex; flex-direction: column; gap: 14px; }
.despacho-acoes { display: flex; flex-direction: column; gap: 8px; }
.alarme-esq, .alarme-dir { display: flex; flex-direction: column; gap: 14px; }
.alarme-dir { flex: 1; }
.gire { display: none; }
@media (orientation: portrait) and (max-width: 900px) {
  [data-app] .gire { display: flex; align-items: center; gap: 10px; margin: 10px 14px 0; padding: 10px 12px; border-radius: 10px; font-size: 13px;
    background: color-mix(in srgb, var(--primary) 14%, var(--card)); border: 1px solid color-mix(in srgb, var(--primary) 40%, transparent); }
  [data-app] .gire span { font-size: 20px; }
}

/* ---------- app na HORIZONTAL (celular deitado / tablet) ---------- */
@media (orientation: landscape) and (min-width: 600px) {
  .app { max-width: 1400px; }
  .app-body { padding: 14px 20px; }
  .inicio { display: grid; grid-template-columns: minmax(300px, .9fr) 1.6fr; align-items: start; gap: 18px; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .so-horizontal { display: inline-flex !important; }
  .so-vertical { display: none !important; }
  .app-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; align-items: start; }
  .app-form .full { grid-column: 1 / -1; }
  .app-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .despacho-acoes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-body > .btn.lg { align-self: flex-end; min-width: 340px; }
  .alarme { flex-direction: row; align-items: stretch; gap: 28px; }
  .alarme-esq { flex: 1; justify-content: center; }
  .alarme-dir { flex: 1.25; justify-content: center; }
  .alarme .acoes { grid-template-columns: 2fr 1fr; margin-top: 0; }
  .card .chat { max-height: 52vh; }
}
@media (orientation: landscape) and (max-height: 540px) {
  .app-top { padding-top: calc(5px + env(safe-area-inset-top)); padding-bottom: 5px; }
  .app-top .emb, .app-top img { height: 36px; }
  .app-body { gap: 10px; padding-top: 10px; }
  .tile { min-height: 76px; padding: 10px 6px; gap: 4px; }
  .tile svg { width: 24px; height: 24px; }
  .tile span { display: none; }
  .status-card { padding: 12px 14px; gap: 6px; }
  .status-card .big { font-size: 20px; }
  .btn.lg { height: 46px; font-size: 15px; }
  .alarme { padding-top: calc(10px + env(safe-area-inset-top)); padding-bottom: calc(10px + env(safe-area-inset-bottom)); gap: 18px; }
  .alarme h2 { font-size: 20px; }
  .alarme .relogio { width: 96px; height: 96px; margin: 0 auto; }
  .alarme .relogio b { font-size: 30px; }
  .alarme .info { padding: 10px 12px; font-size: 14px; gap: 5px; }
  .alarme .btn.lg { height: 54px; font-size: 17px; }
  .app-foot { display: none; }
  .login-box .emb-wrap img { height: 84px; }
  .login-box { padding: 18px 22px; gap: 10px; }
}
.despacho-acoes .btn { white-space: normal; height: auto; min-height: 46px; padding: 8px 12px; line-height: 1.2; text-align: center; }
.inicio .despacho-acoes { display: flex; flex-direction: column; }
.status-card::after { opacity: .07; width: 120px; height: 170px; right: -10px; bottom: -20px; }
@media (orientation: landscape) and (max-height: 540px) {
  .tile b { font-size: 12.5px; letter-spacing: .03em; }
}

/* ---------- bloqueio sem GPS ---------- */
.bloqueio-gps { position: fixed; inset: 0; z-index: 450; display: grid; place-items: center; padding: 18px; background: rgba(4,8,16,.94); backdrop-filter: blur(4px); overflow-y: auto; }
.bloqueio-caixa { width: min(560px, 100%); background: var(--card); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 12px; text-align: center; box-shadow: var(--shadow); }
.bloqueio-caixa h2 { font-size: 22px; }
.bloqueio-caixa p { margin: 0; color: var(--muted); }
.bloqueio-ico { width: 78px; height: 78px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.bloqueio-passos { text-align: left; font-size: 13.5px; background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; line-height: 1.55; }
.trava-servico { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; background: color-mix(in srgb, var(--warn) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); border-radius: 12px; padding: 14px; }
.trava-servico b { font-family: var(--font-h); letter-spacing: .04em; }

/* ---------- barra lateral minimizável (•••) ---------- */
.btn-mini { display: flex; align-items: center; gap: 8px; margin: 8px 12px 0; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-weight: 600; font-size: 12.5px; cursor: pointer; }
.btn-mini:hover { color: var(--text); border-color: var(--primary); }
.btn-mini .pontos { letter-spacing: 1px; font-weight: 800; }
.shell { transition: grid-template-columns .18s; }
@media (min-width: 861px) {
  .shell.mini { grid-template-columns: 72px minmax(0, 1fr); }
  .shell.mini .brand { justify-content: center; padding: 14px 6px; }
  .shell.mini .brand-txt, .shell.mini .nav .rot, .shell.mini .btn-mini .rot { display: none; }
  .shell.mini .btn-mini { justify-content: center; margin: 8px 10px 0; }
  .shell.mini .nav { padding: 8px 8px 20px; }
  .shell.mini .nav .sec { font-size: 0; padding: 10px 0 4px; border-top: 1px solid var(--line); margin-top: 6px; }
  .shell.mini .nav a { justify-content: center; padding: 10px 0; position: relative; }
  .shell.mini .nav a .count { position: absolute; top: 2px; right: 6px; margin: 0; transform: scale(.85); }
  .shell.mini .brand img { height: 42px; }
}
