:root {
  --bg: #0b1120; --surface: #1a2332; --surface2: #253548;
  --text: #e2e8f0; --muted: #8b9bb4; --accent: #38bdf8;
  --ok: #22c55e; --warn: #f59e0b; --danger: #ef4444; --purple: #a78bfa;
}
* { box-sizing: border-box; margin: 0; }
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh; }

/* ─── Navbar ─────────────────────────────────────────────────────────────── */
.navbar { display: flex; align-items: center; background: var(--surface);
  border-bottom: 1px solid var(--surface2); padding: 0 24px; position: sticky; top: 0; z-index: 10; }
.navbar .brand { font-size: 16px; font-weight: 700; color: var(--accent);
  margin-right: 32px; padding: 14px 0; letter-spacing: .3px; white-space: nowrap; }
.navbar .tabs { display: flex; gap: 4px; flex: 1; }
.navbar .tab { padding: 14px 20px; font-size: 13px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; transition: all .15s; background: none;
  border-top: none; border-left: none; border-right: none; }
.navbar .tab:hover { color: var(--text); }
.navbar .tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.navbar .status { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.pill { font-size: 11px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface2); cursor: pointer; white-space: nowrap; }
.pill.on { background: rgba(245,158,11,.2); color: var(--warn); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:.6 } }
.btn-ghost { font-size: 12px; background: none; border: 1px solid var(--surface2);
  color: var(--muted); padding: 6px 12px; border-radius: 6px; cursor: pointer; }

/* ─── Layout base ────────────────────────────────────────────────────────── */
.tab-content { display: none; padding: 24px; max-width: 1280px; margin: 0 auto; }
.tab-content.active { display: block; }
.card { background: var(--surface); border: 1px solid var(--surface2); border-radius: 10px;
  padding: 16px; margin-bottom: 12px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px; margin: 20px 0 10px; }
.muted { color: var(--muted); font-size: 12px; }
.small { font-size: 11px; }
.hidden { display: none !important; }
hr { border-color: var(--surface2); margin: 16px 0; }
.subtitle { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.login { max-width: 360px; margin: 80px auto; }
.login input { width: 100%; margin-bottom: 12px; }

/* ─── Context bar / banners ──────────────────────────────────────────────── */
.context-bar { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.context-actions { display: flex; align-items: center; gap: 10px; }
.banner { border-radius: 8px; padding: 10px 14px; font-size: 12.5px; margin-bottom: 14px; }
.banner.warn { background: rgba(245,158,11,.12); color: var(--warn); border: 1px solid rgba(245,158,11,.35); }
.banner.ok { background: rgba(34,197,94,.12); color: var(--ok); border: 1px solid rgba(34,197,94,.35); }
.banner.danger { background: rgba(239,68,68,.12); color: var(--danger); border: 1px solid rgba(239,68,68,.35); }
.banner.neutral { background: var(--surface2); color: var(--muted); border: 1px solid var(--surface2); }

/* ─── KPIs ───────────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--surface2); border-radius: 10px; padding: 16px; }
.kpi .value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .5px; margin-top: 4px; }
.kpi.accent .value { color: var(--accent); }
.kpi.ok .value { color: var(--ok); }
.kpi.warn .value { color: var(--warn); }
.kpi.danger .value { color: var(--danger); }
.kpi.purple .value { color: var(--purple); }

/* ─── Gráficos ───────────────────────────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.chart-card { margin-bottom: 0; }
.chart-wide { grid-column: 1 / -1; }
.chart-wrap { position: relative; height: 260px; }
.chart-wide .chart-wrap { height: 220px; }

/* ─── Tabelas ────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--surface2); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: .4px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
tr:hover > td { background: rgba(255,255,255,.02); }
.bar-cell { position: relative; }
.bar { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(56,189,248,.12);
  border-radius: 0 4px 4px 0; transition: width .3s ease; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Frota / drill-down ─────────────────────────────────────────────────── */
.fleet-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.fleet-toolbar input { flex: 1; min-width: 220px; }
.fleet-scroll { max-height: 560px; overflow: auto; }
tr.company-row { cursor: pointer; }
tr.company-row > td:first-child { width: 26px; color: var(--muted); }
tr.company-row.open > td { background: rgba(56,189,248,.05); }
td.detail-cell { padding: 0 0 0 26px; background: rgba(0,0,0,.15); }
.veh-table { margin: 0; }
.veh-table th { position: static; background: transparent; font-size: 10.5px; }
tr.veh-row { cursor: pointer; }
tr.veh-row.open > td { background: rgba(56,189,248,.05); }
td.veh-detail-cell { padding: 4px 10px 12px 26px; background: rgba(0,0,0,.2); }
.debit-mini { width: auto; min-width: 70%; }
.debit-mini td, .debit-mini th { padding: 5px 8px; font-size: 11.5px; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 14px;
  padding: 2px 6px; border-radius: 6px; color: var(--muted); }
.btn-icon:hover { background: var(--surface2); color: var(--text); }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge { display: inline-block; font-size: 10px; padding: 2px 7px; border-radius: 999px;
  margin-right: 4px; white-space: nowrap; }
.badge.ok { background: rgba(34,197,94,.15); color: var(--ok); }
.badge.warn { background: rgba(245,158,11,.15); color: var(--warn); }
.badge.danger { background: rgba(239,68,68,.15); color: var(--danger); }
.badge.purple { background: rgba(167,139,250,.15); color: var(--purple); }
.badge.neutral { background: var(--surface2); color: var(--muted); }

/* ─── Botões / inputs ────────────────────────────────────────────────────── */
.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; align-items: flex-end; }
button { background: var(--surface2); color: var(--text); border: none; border-radius: 8px;
  padding: 10px 16px; font-size: 13px; cursor: pointer; transition: all .15s; }
button:hover { background: #3a4f64; }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: #06263a; font-weight: 600; }
button.danger { background: var(--danger); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select { background: var(--bg); border: 1px solid var(--surface2); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font-size: 13px; }
label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }

/* ─── Log (aba Ações) ────────────────────────────────────────────────────── */
#log { background: #060b18; border: 1px solid var(--surface2); border-radius: 10px;
  padding: 12px; height: 380px; overflow: auto; font-family: ui-monospace, Menlo, monospace;
  font-size: 12px; line-height: 1.5; white-space: pre-wrap; margin-top: 12px; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; }
.modal-box { background: var(--surface); border: 1px solid var(--surface2); border-radius: 12px;
  max-width: 900px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--surface2); }
.modal-head #modalTitle { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 16px;
  cursor: pointer; padding: 4px 8px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-body .section-title { margin: 18px 0 8px; }
.modal-body .section-title:first-child { margin-top: 0; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 16px; }
.kv-grid .kv { font-size: 12.5px; }
.kv-grid .kv .k { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; }
.copy-btn { font-size: 10px; padding: 2px 8px; margin-left: 6px; border-radius: 6px; }

/* ─── Responsivo ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .navbar { flex-wrap: wrap; padding: 8px 12px; }
  .navbar .tabs { order: 3; width: 100%; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .tab-content { padding: 12px; }
}
