/* Luxx Plataforma — estilos (tema claro e escuro) */
:root {
  --bg: #F3F5F9; --surface: #FFFFFF; --surface2: #F7F9FC; --text: #0E1A2B; --muted: #556479;
  --border: #DFE5EE; --primary: #1D4F86; --primary-ink: #FFFFFF; --primary-soft: #E6EEF8;
  --ok: #137A3E; --ok-soft: #E3F4EA; --warn: #9A5800; --warn-soft: #FCEFD9;
  --danger: #C62828; --danger-soft: #FBE7E7; --hero: #173F6C; --side: #143A63; --side-ink: #FFFFFF;
  --side-on: rgba(255,255,255,.14); --side-line: rgba(255,255,255,.16);
  --shadow: 0 1px 2px rgba(15,27,45,.06), 0 6px 20px rgba(15,27,45,.08);
  --radius: 12px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0A111E; --surface: #111A2B; --surface2: #162236; --text: #E7EEF8; --muted: #9AABC2;
  --border: #22314A; --primary: #6AA8F0; --primary-ink: #06101F; --primary-soft: #16294A;
  --ok: #4ADE80; --ok-soft: #0F2E1D; --warn: #F5B44A; --warn-soft: #33260E;
  --danger: #F87171; --danger-soft: #3A1717; --hero: #0F2747; --side: #0D1626; --side-ink: #E7EEF8;
  --side-on: rgba(106,168,240,.16); --side-line: rgba(255,255,255,.12);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
h1, h2, h3 { margin: 0; }
.display { font-family: "Space Grotesk", Inter, sans-serif; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* Botões e campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer; text-decoration: none; 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: var(--primary-ink); font-weight: 600; }
.btn-danger { color: var(--danger); font-weight: 600; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn-ok { color: var(--ok); font-weight: 600; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 44px; padding: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.input { height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); font-weight: 400; font-size: 14px; min-width: 0; width: 100%; }
.input:focus, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; }
.chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.pill { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.info { background: var(--primary-soft); color: var(--primary); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.off { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.stat { padding: 10px 12px; border-radius: 10px; background: var(--bg); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat span { font-size: 11px; color: var(--muted); }
.stat strong { font-size: 14px; overflow-wrap: anywhere; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.table-wrap { overflow-x: auto; }
#posTable { max-height: 420px; overflow-y: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 16px; background: var(--surface2); white-space: nowrap; }
.tbl td { padding: 10px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Login */
.login { min-height: 100%; display: flex; flex-wrap: wrap; }
.login-hero { flex: 1 1 380px; background: var(--hero); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.login-hero h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.08; font-weight: 600; max-width: 480px; }
.login-hero p { color: #D5E3F5; line-height: 1.6; max-width: 460px; margin: 16px 0 0; }
.login-main { flex: 999 1 420px; display: flex; flex-direction: column; padding: 24px; }
.login-form { width: 100%; max-width: 400px; margin: auto; display: flex; flex-direction: column; gap: 18px; }
.login-form h2 { font-size: 30px; font-weight: 600; }
.alert-box { padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.alert-box.danger { background: var(--danger-soft); color: var(--danger); }
.alert-box.ok { background: var(--ok-soft); color: var(--ok); }
.alert-box.warn { background: var(--warn-soft); color: var(--warn); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text b { font-family: "Space Grotesk", sans-serif; font-size: 20px; letter-spacing: .5px; }
.brand-text small { font-size: 9px; font-weight: 600; letter-spacing: 2.4px; opacity: .8; }

/* Topo */
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--ok-soft); color: var(--ok); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.live.off { background: var(--warn-soft); color: var(--warn); }
.seg { display: flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); }
.seg button { min-height: 36px; padding: 0 14px; border-radius: 8px; border: 0; background: transparent; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.user-chip { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px 0 6px; border-radius: 10px; border: 1px solid var(--border); font-size: 14px; max-width: 220px; }
.user-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }

/* Tela do mapa: no celular o mapa vem primeiro */
.track { display: flex; flex-wrap: wrap-reverse; align-items: stretch; min-height: calc(100% - 61px); }
.side { flex: 1 1 340px; min-width: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.side-head { padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 10px; }
.search { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); }
.vlist { display: flex; flex-direction: column; padding: 0 8px 8px; max-height: 360px; overflow-y: auto; }
.vrow { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px 10px; border-radius: 12px; border: 1px solid transparent; background: transparent; cursor: pointer; text-align: left; }
.vrow:hover { background: var(--surface2); }
.vrow.on { border-color: var(--primary); background: var(--primary-soft); }
.vrow-ico { width: 38px; height: 38px; flex: none; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.vrow-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vrow-txt b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vrow-txt small { font-size: 12px; color: var(--muted); }
.vrow-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--muted); }
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg); margin: 12px 12px 0; }
.tabs button { min-height: 40px; border-radius: 9px; border: 0; background: transparent; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 4px; }
.tabs button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.badge { display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; align-items: center; justify-content: center; }
.panel { padding: 16px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--border); margin-top: 12px; }
.cmd-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cmd-grid .btn { min-height: 52px; justify-content: flex-start; white-space: normal; text-align: left; line-height: 1.2; }
.confirm { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 12px; background: var(--danger-soft); border: 1px solid var(--danger); }
.alert-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; border: 1px solid var(--border); }
.dot { width: 10px; height: 10px; flex: none; border-radius: 50%; }

.main { flex: 999 1 600px; min-width: 0; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.map-box { position: relative; height: min(62vh, 620px); min-height: 380px; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); background: var(--surface2); }
#map { position: absolute; inset: 0; }
.map-card { position: absolute; left: 12px; top: 12px; width: 300px; max-width: calc(100% - 80px); padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; z-index: 2; }
.map-tools { position: absolute; right: 12px; top: 12px; z-index: 2; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.legend { position: absolute; left: 12px; bottom: 28px; z-index: 2; display: flex; flex-wrap: wrap; gap: 10px; padding: 6px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font-size: 11px; max-width: calc(100% - 24px); }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 16px; height: 4px; border-radius: 2px; }
.marker { width: 32px; height: 32px; border-radius: 50%; border: 3px solid #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,.35); cursor: pointer; padding: 0; }
.marker.sel { width: 40px; height: 40px; box-shadow: 0 0 0 8px rgba(29,79,134,.25), 0 4px 12px rgba(0,0,0,.35); }
.marker svg { width: 15px; height: 15px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; max-width: calc(100% - 24px); display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-size: 14px; }

/* Administrativo */
.admin { display: flex; flex-wrap: wrap; min-height: calc(100% - 61px); }
.admin-nav { flex: 1 1 220px; background: var(--side); color: var(--side-ink); padding: 16px 12px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px; }
.admin-nav button { flex: 1 1 190px; display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; border-radius: 10px; border: 0; background: transparent; color: var(--side-ink); font-weight: 500; cursor: pointer; text-align: left; }
.admin-nav button.on { background: var(--side-on); font-weight: 600; box-shadow: inset 3px 0 0 #E04545; }
.admin-main { flex: 999 1 640px; min-width: 0; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.admin-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.admin-head h1 { font-size: 28px; font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.kpi strong { font-family: "Space Grotesk", sans-serif; font-size: 34px; font-weight: 600; line-height: 1; }
.bar { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.bar i { display: block; height: 100%; }
.sec-head { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.sec-head h2 { font-size: 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }

dialog { border: 1px solid var(--border); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); width: min(560px, calc(100% - 24px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(5,10,20,.55); }
.dlg { display: flex; flex-direction: column; gap: 14px; padding: 20px; max-height: 85vh; overflow-y: auto; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--primary); }

.blocked { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.blocked .card { max-width: 440px; padding: 28px; display: flex; flex-direction: column; gap: 14px; text-align: center; }

@media (max-width: 700px) {
  .login-hero { padding: 28px; }
  .main, .admin-main { padding: 12px; }
  .map-card { width: auto; right: 12px; max-width: none; padding: 10px; gap: 8px; }
  .map-card .grid2 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .map-card .stat { padding: 6px; }
  .map-tools { top: auto; bottom: 110px; }
  .map-card .stat strong { font-size: 12px; }
  .map-box { height: 72vh; }
  #posTable { max-height: 300px; }
  .vlist { max-height: none; }
  .user-chip span:last-child { display: none; }
  .user-chip { padding: 0 6px; }
  .topbar { gap: 6px; padding: 8px 10px; }
}
