/* GPSWanp — estilos da aplicação */
:root {
  --brand: #057f69;
  --brand-d: #1557b0;
  --brand-l: #e8f0fc;
  --top: #1b2433;
  --top-2: #263247;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --line: #e3e7ee;
  --line-2: #eef1f5;
  --text: #1f2937;
  --muted: #6b7280;
  --muted-2: #9aa3b0;
  --ok: #16a34a;
  --warn: #f59e0b;
  --err: #dc2626;
  --info: #0284c7;
  --st-moving: #16a34a;
  --st-idle: #f59e0b;
  --st-stopped: #dc2626;
  --st-offline: #8b95a5;
  --st-nodata: #3f4652;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .22);
  --sidebar: 350px;
  --topbar: 52px;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.ti { font-size: 18px; line-height: 1; vertical-align: -3px; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.wrap { flex-wrap: wrap; }
.right { margin-left: auto; }
.center { text-align: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 12px; }

/* ---------- barra superior ---------- */
#topbar {
  height: var(--topbar); background: var(--top); color: #dfe6f1; display: flex; align-items: center; gap: 4px;
  padding: 0 10px; position: relative; z-index: 1100; box-shadow: 0 1px 0 rgba(0,0,0,.2);
}
#topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: #fff; padding: 0 8px 0 4px; white-space: nowrap; }
#topbar .brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; }
#topbar .brand .logo .ti { font-size: 20px; color: #fff; }
.topnav { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.topnav::-webkit-scrollbar { display: none; }
.topbtn {
  display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border-radius: 6px; border: 0; background: transparent;
  color: #c9d3e2; cursor: pointer; white-space: nowrap; font-size: 13px;
}
.topbtn:hover, .topbtn.active { background: var(--top-2); color: #fff; }
.topbtn .ti { font-size: 19px; }
.topright { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.badge-dot { position: relative; }
.badge-dot .count {
  position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--err);
  color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center;
}
#clock { font-size: 12px; color: #9fb0c8; padding: 0 8px; font-variant-numeric: tabular-nums; }
#btn-menu { display: none; }

/* ---------- layout ---------- */
#main { position: absolute; top: var(--topbar); left: 0; right: 0; bottom: 0; display: flex; }
#sidebar {
  width: var(--sidebar); background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  z-index: 900; transition: margin-left .2s; min-height: 0;
}
body.sb-collapsed #sidebar { margin-left: calc(-1 * var(--sidebar)); }
#mapwrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: #e8e6e1; }
.sb-toggle {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%); z-index: 850; width: 18px; height: 56px; border: 1px solid var(--line);
  border-left: 0; background: #fff; border-radius: 0 6px 6px 0; cursor: pointer; display: grid; place-items: center; padding: 0; color: var(--muted);
  box-shadow: var(--shadow);
}
.sb-toggle .ti { font-size: 14px; }

/* abas */
.tabs { display: flex; border-bottom: 1px solid var(--line); background: #fafbfc; flex-shrink: 0; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 7px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 11.5px; border-bottom: 2px solid transparent; position: relative;
}
.tab .ti { font-size: 20px; }
.tab:hover { color: var(--text); background: #f1f4f8; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); background: #fff; }
.tab .count { position: absolute; top: 3px; right: calc(50% - 22px); background: var(--err); color: #fff; font-size: 9.5px; border-radius: 8px; padding: 0 4px; min-width: 15px; font-weight: 700; }
.subtabs { display: flex; gap: 4px; padding: 8px 10px 0; }
.subtab { flex: 1; border: 1px solid var(--line); background: #fff; padding: 6px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 12.5px; }
.subtab.active { background: var(--brand-l); color: var(--brand-d); border-color: #bcd3f5; font-weight: 600; }
.pane { flex: 1; min-height: 0; display: none; flex-direction: column; }
.pane.active { display: flex; }
.pane-head { padding: 10px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line-2); flex-shrink: 0; }
.pane-body { flex: 1; overflow-y: auto; min-height: 0; }
.pane-foot { padding: 8px 10px; border-top: 1px solid var(--line-2); flex-shrink: 0; }

/* ---------- controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--text); font-size: 13px; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: #f5f7fa; border-color: #d3d9e2; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eef2f7; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12px; }
.btn.icon { width: 34px; padding: 0; }
.btn.sm.icon { width: 28px; }
.btn .ti { font-size: 17px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 6px 6px 0; }
.btn-group .btn.active { background: var(--brand-l); color: var(--brand-d); border-color: #bcd3f5; z-index: 1; }

.input, select.input, textarea.input {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid #d5dbe4; border-radius: 6px; background: #fff; outline: none; font-size: 13px;
}
textarea.input { height: auto; min-height: 70px; padding: 8px 10px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(30, 111, 217, .15); }
.input.sm { height: 30px; font-size: 12.5px; }
.search { position: relative; }
.search .ti { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted-2); font-size: 16px; }
.search .input { padding-left: 32px; }
input[type=color].input { padding: 2px 4px; width: 60px; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 15px; height: 15px; margin: 0; cursor: pointer; }
label.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label { font-size: 12px; font-weight: 600; color: #4b5563; }
.field .help { font-size: 11.5px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line-2); padding: 8px 0 5px; margin-top: 4px; }
.req::after { content: " *"; color: var(--err); }

.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 13px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 12px; color: var(--muted); white-space: nowrap;
}
.chip.active { background: var(--brand-l); border-color: #bcd3f5; color: var(--brand-d); font-weight: 600; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip b { font-weight: 700; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; background: #eef1f5; color: #4b5563; white-space: nowrap; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.err { background: #fee2e2; color: #991b1b; }
.badge.info { background: #e0f2fe; color: #075985; }
.badge.brand { background: var(--brand-l); color: var(--brand-d); }
.st-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.st-moving { background: var(--st-moving); } .st-idle { background: var(--st-idle); } .st-stopped { background: var(--st-stopped); }
.st-offline { background: var(--st-offline); } .st-nodata { background: var(--st-nodata); }

.empty { padding: 30px 16px; text-align: center; color: var(--muted); }
.empty .ti { font-size: 34px; display: block; margin: 0 auto 8px; color: var(--muted-2); }

/* ---------- lista de objetos ---------- */
.grp-head {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: #f6f8fb; border-bottom: 1px solid var(--line-2); font-weight: 600;
  font-size: 12.5px; cursor: pointer; position: sticky; top: 0; z-index: 2; color: #374151;
}
.grp-head .ti-chevron-down { transition: transform .15s; font-size: 15px; color: var(--muted); }
.grp.collapsed .ti-chevron-down { transform: rotate(-90deg); }
.grp.collapsed .grp-items { display: none; }
.obj {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-bottom: 1px solid var(--line-2); cursor: pointer; position: relative;
}
.obj:hover { background: #f7f9fc; }
.obj.sel { background: var(--brand-l); box-shadow: inset 3px 0 0 var(--brand); }
.obj .oicon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex-shrink: 0; position: relative; }
.obj .oicon .ti { font-size: 17px; }
.obj .oicon .sdot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; }
.obj .oname { font-weight: 600; font-size: 13px; }
.obj .osub { font-size: 11.5px; color: var(--muted); }
.obj .osens { display: flex; flex-wrap: wrap; gap: 1px 9px; font-size: 11px; color: #475569; margin-top: 1px; }
.obj .osens .ti { font-size: 12px; color: var(--muted); }
.obj .ometa { text-align: right; font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.obj .ometa .spd { font-weight: 700; color: var(--text); font-size: 12.5px; }
.obj .omenu { opacity: 0; }
.obj:hover .omenu, .obj.sel .omenu { opacity: 1; }

/* lista genérica */
.list-item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.list-item:hover { background: #f7f9fc; }
.list-item .li-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.list-item .li-title { font-weight: 600; font-size: 13px; }
.list-item .li-sub { font-size: 11.5px; color: var(--muted); }
.list-item.unread .li-title::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); margin-right: 6px; vertical-align: 2px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; border: 1px solid rgba(0,0,0,.1); }

/* ---------- ferramentas do mapa ---------- */
.map-tools { position: absolute; top: 10px; right: 10px; z-index: 800; display: flex; flex-direction: column; gap: 6px; }
.mtool {
  width: 38px; height: 38px; border-radius: 8px; background: #fff; border: 0; box-shadow: var(--shadow); cursor: pointer; display: grid;
  place-items: center; color: #3c4655; position: relative;
}
.mtool:hover { background: #f4f6f9; }
.mtool.active { color: var(--brand); background: var(--brand-l); }
.mtool .ti { font-size: 20px; }
.mtool[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; right: 46px; top: 50%; transform: translateY(-50%); background: #1f2937; color: #fff;
  padding: 4px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; pointer-events: none;
}
.map-search { position: absolute; top: 10px; left: 10px; z-index: 800; width: min(360px, calc(100% - 70px)); }
.map-search .input { height: 38px; box-shadow: var(--shadow); border: 0; }
.map-search .results { background: #fff; border-radius: 8px; box-shadow: var(--shadow-lg); margin-top: 4px; overflow: hidden; }
.map-search .results div { padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--line-2); }
.map-search .results div:hover { background: #f4f7fb; }
.popover {
  position: absolute; z-index: 1200; background: #fff; border-radius: 8px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; border: 1px solid var(--line);
}
.popover .pop-title { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: 6px 8px 4px; letter-spacing: .04em; }
.menu-item { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.menu-item:hover { background: #f1f4f8; }
.menu-item.active { color: var(--brand-d); font-weight: 600; }
.menu-item.active::after { content: "✓"; margin-left: auto; }
.menu-item .ti { font-size: 17px; color: var(--muted); }
.menu-sep { height: 1px; background: var(--line-2); margin: 4px 0; }

body.drawing .leaflet-overlay-pane .leaflet-interactive,
body.drawing .leaflet-marker-pane .leaflet-marker-icon:not(.draw-handle),
body.drawing .leaflet-tooltip-pane { pointer-events: none !important; }
.draw-bar {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%); z-index: 850; background: #1f2937; color: #fff; padding: 8px 10px 8px 14px;
  border-radius: 8px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-lg); font-size: 13px; max-width: calc(100% - 20px);
}
.draw-bar .btn { height: 28px; font-size: 12px; }

/* ---------- marcadores ---------- */
.vm { position: relative; width: 36px; height: 36px; }
.vm-body {
  position: absolute; inset: 3px; border-radius: 50%; background: var(--c, #1e6fd9); border: 3px solid #fff; display: grid; place-items: center;
  box-shadow: 0 1px 5px rgba(0,0,0,.35); color: #fff; z-index: 2;
}
.vm-body .ti { font-size: 15px; }
.vm-ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--s, #16a34a); z-index: 1; }
.vm-arrow {
  position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: 0; transform-origin: 0 0;
}
.vm-arrow::before {
  content: ""; position: absolute; left: -7px; top: -27px; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 11px solid var(--s, #16a34a);
}
.vm.st-idle-m, .vm.st-stopped-m, .vm.st-offline-m, .vm.st-nodata-m { }
.vm .vm-arrow { display: none; }
.vm.moving .vm-arrow { display: block; }
.vm-label {
  position: absolute; left: 50%; top: 38px; transform: translateX(-50%); background: rgba(255,255,255,.95); border-radius: 4px; padding: 1px 6px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,.25); color: #1f2937; pointer-events: none;
}
.hide-labels .vm-label { display: none; }
.vm.sel .vm-body { box-shadow: 0 0 0 4px rgba(30,111,217,.45), 0 1px 5px rgba(0,0,0,.35); }
.vm.alarm .vm-ring { animation: pulse 1s infinite; border-color: var(--err); }
/* tipos de ícone do veículo (aba "Ícone"): imagem personalizada, ícone que gira e seta que gira */
.vm-body img { width: 20px; height: 20px; object-fit: contain; pointer-events: none; }
.vm.vm-img .vm-body { inset: 0; background: transparent; border: 0; box-shadow: none; }
.vm.vm-img .vm-body img { width: 34px; height: 34px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.vm.vm-img .vm-ring { inset: auto -3px -3px auto; width: 13px; height: 13px; border: 2px solid #fff; background: var(--s); z-index: 3; }
.vm.vm-img.sel .vm-body img { filter: drop-shadow(0 0 3px #1e6fd9) drop-shadow(0 0 3px #1e6fd9); }
.vm.vm-img .vm-arrow::before { top: -30px; }
.vm-t-rot .vm-body { transition: transform .5s; }
.vm-t-arrow .vm-nav { position: absolute; inset: 0; width: 36px; height: 36px; overflow: visible; transition: transform .5s; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)); }
.vm-t-arrow .vm-nav path { fill: var(--s); stroke: #fff; stroke-width: 2.2; stroke-linejoin: round; }
.vm-t-arrow.sel .vm-nav path { stroke: #1e6fd9; stroke-width: 3; }
.vm-t-arrow.alarm .vm-nav { animation: vmblink 1s infinite; }
@keyframes vmblink { 50% { opacity: .35; } }
.oicon .dev-img, .dp-head .oicon .dev-img { width: 100%; height: 100%; object-fit: contain; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.6); } 100% { box-shadow: 0 0 0 16px rgba(220,38,38,0); } }
.pin {
  width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--c); border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35); display: grid; place-items: center;
}
.pin .ti { transform: rotate(45deg); color: #fff; font-size: 15px; }
.hmark {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 12px;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.hmark .ti { font-size: 14px; }
.leaflet-popup-content { margin: 10px 12px; font-size: 13px; line-height: 1.45; }
.leaflet-popup-content .pt { font-weight: 700; margin-bottom: 4px; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-tooltip.gf-label { background: rgba(255,255,255,.85); border: 0; box-shadow: none; font-weight: 600; font-size: 11px; padding: 0 4px; }
.leaflet-tooltip.gf-label::before { display: none; }

/* ---------- painel do veículo (inferior) ---------- */
#devpanel {
  position: absolute; left: 10px; right: 58px; bottom: 10px; z-index: 820; background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg);
  max-height: 46%; display: flex; flex-direction: column; overflow: hidden;
}
.dp-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
.dp-head .oicon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.dp-title { font-weight: 700; font-size: 15px; }
.dp-body { padding: 10px 12px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 14px; }
.kv { display: flex; flex-direction: column; min-width: 0; }
.kv .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; display: flex; align-items: center; gap: 4px; }
.kv .k .ti { font-size: 13px; }
.kv .v { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.kv.wide { grid-column: span 2; }
.dp-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px; border-top: 1px solid var(--line-2); background: #fafbfc; }

/* ---------- histórico ---------- */
#histbar {
  position: absolute; left: 10px; right: 58px; bottom: 10px; z-index: 830; background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); padding: 8px 12px 10px;
}
.hb-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hb-info { display: flex; gap: 14px; font-size: 12.5px; flex-wrap: wrap; }
.hb-info b { font-variant-numeric: tabular-nums; }
/* celular: os dados da reprodução vão para uma linha inteira, lado a lado (antes ficavam espremidos numa coluna) */
@media (max-width: 600px) { .hb-info { flex-basis: 100%; order: 5; gap: 4px 14px; } }
.hb-chart { width: 100%; height: 64px; margin-top: 6px; cursor: crosshair; display: block; }
input[type=range].slider { width: 100%; accent-color: var(--brand); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: #f6f8fb; border-radius: 8px; padding: 8px 10px; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.seg { display: flex; gap: 9px; padding: 8px 10px; border-bottom: 1px solid var(--line-2); cursor: pointer; font-size: 12.5px; }
.seg:hover { background: #f7f9fc; }
.seg .seg-ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex-shrink: 0; font-weight: 800; font-size: 12px; }
.seg .seg-ic .ti { font-size: 14px; }

/* ---------- modais ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 2000; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal {
  background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; display: flex; flex-direction: column;
  max-height: calc(100vh - 80px); animation: pop .14s ease-out;
}
@keyframes pop { from { transform: translateY(8px); } to { transform: none; } }
.modal.sm { max-width: 420px; } .modal.lg { max-width: 860px; } .modal.xl { max-width: 1200px; } .modal.full { max-width: none; height: calc(100vh - 80px); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-head h3 .ti { color: var(--brand); font-size: 20px; }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-shrink: 0; background: #fafbfc; border-radius: 0 0 12px 12px; }
.modal-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 18px; flex-shrink: 0; overflow-x: auto; }
.modal-tab { padding: 10px 12px; border: 0; background: none; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: 13px; }
.modal-tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ---------- tabelas ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; font-weight: 600; color: #4b5563; background: #f6f8fb; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #f8fafc; }
.tbl tr.click { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tfoot td { font-weight: 700; background: #f6f8fb; border-top: 1px solid var(--line); }
.tbl .actions { white-space: nowrap; text-align: right; }

/* ---------- cards / dashboard ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.card h4 { margin: 0 0 10px; font-size: 13px; color: #374151; display: flex; align-items: center; gap: 6px; }
.kpi .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: calc(var(--topbar) + 10px); right: 12px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 24px)); }
.toast {
  background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); padding: 10px 12px; display: flex; gap: 10px; border-left: 4px solid var(--info);
  animation: slidein .2s ease-out; cursor: default; font-size: 13px;
}
.toast.click { cursor: pointer; }
.toast.success { border-left-color: var(--ok); } .toast.error { border-left-color: var(--err); } .toast.warn { border-left-color: var(--warn); }
.toast .t-title { font-weight: 700; margin-bottom: 2px; }
.toast .t-close { margin-left: auto; cursor: pointer; color: var(--muted); align-self: flex-start; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.spinner { width: 22px; height: 22px; border: 3px solid #dbe3ee; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 30px; color: var(--muted); }

.icon-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icon-pick button { height: 44px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.icon-pick button.active { border-color: var(--brand); background: var(--brand-l); color: var(--brand); }
.icon-pick .ti { font-size: 22px; }

.code-box { background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 10px 12px; font-family: Consolas, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.note { background: #f0f7ff; border: 1px solid #cfe2fb; color: #1e3a5f; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; }
.note.warn { background: #fffbeb; border-color: #fde68a; color: #78350f; }

/* ---------- impressão (relatórios) ---------- */
@media print {
  body { overflow: visible; }
  #topbar, #main, #toasts { display: none !important; }
  .modal-back { position: static; background: none; padding: 0; display: block; }
  .modal { box-shadow: none; max-height: none; max-width: none !important; height: auto !important; }
  .modal-head .btn, .modal-foot, .no-print { display: none !important; }
  .modal-body { overflow: visible; }
  .table-wrap { overflow: visible; border: 0; }
  .tbl th { position: static; }
}

/* ---------- responsivo ---------- */
@media (max-width: 1180px) { #topnav .topbtn .lbl { display: none; } }
@media (max-width: 900px) {
  :root { --sidebar: min(88vw, 360px); }
  #btn-menu { display: flex; }
  #topnav { display: none; }
  .mobile-only { display: flex !important; }
  #topbar .brand { font-size: 15px; }
  .map-search { width: calc(100% - 66px); }
  .topbtn .lbl { display: none; }
  #clock { display: none; }
  #sidebar { position: absolute; top: 0; bottom: 0; left: 0; box-shadow: var(--shadow-lg); }
  body:not(.sb-open) #sidebar { margin-left: calc(-1 * var(--sidebar) - 10px); }
  body.sb-collapsed #sidebar { margin-left: calc(-1 * var(--sidebar) - 10px); }
  .sb-toggle { display: none; }
  #devpanel, #histbar { left: 6px; right: 6px; bottom: 6px; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-back { padding: 0; }
  .modal, .modal.full { max-height: 100vh; height: 100%; border-radius: 0; max-width: none; }
  /* confirmações e janelas pequenas continuam como cartão no meio da tela (não ocupam o celular inteiro) */
  .modal-back:has(> .modal.sm) { padding: 16px; align-items: center; }
  .modal.sm { height: auto; max-height: calc(100vh - 32px); border-radius: 16px; max-width: 420px; }
  .kv.wide { grid-column: auto; }
  .dp-body { grid-template-columns: 1fr 1fr; }
}
