/* ── Reset & base ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --border:    #334155;
  --text:      #e2e8f0;
  --muted:     #94a3b8;
  --accent:    #3b82f6;
  --danger:    #ef4444;
  --success:   #22c55e;
  --money:     #f59e0b;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,.35);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}
.brand-sub {
  display: block;
  font-size: .8rem;
  color: var(--muted);
  margin-top: 2px;
}
.last-update {
  text-align: right;
}
.last-update .label {
  display: block;
  font-size: .75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
#last-update-value {
  font-size: .95rem;
  font-weight: 500;
}

/* ── Main ───────────────────────────────────────── */
main {
  flex: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

/* ── Cards ──────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
}
.card-icon { font-size: 2rem; line-height: 1; }
.card-value {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
}
.card-label {
  display: block;
  font-size: .8rem;
  color: var(--muted);
  margin-top: 2px;
}
.card-value.danger  { color: var(--danger); }
.card-value.success { color: var(--success); }
.card-value.money   { color: var(--money); }

/* ── Content layout ─────────────────────────────── */
.content {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) {
  .content { grid-template-columns: 1fr; }
}

/* ── Chart box ──────────────────────────────────── */
.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.chart-box h2, .table-box h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
}
.chart-wrap {
  position: relative;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 0;
}

/* ── Table box ──────────────────────────────────── */
.table-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.table-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.table-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.filter-btns {
  display: flex;
  gap: .35rem;
}
.filter-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: .8rem;
  padding: .35rem .75rem;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
#search {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .45rem .85rem;
  font-size: .875rem;
  outline: none;
  width: 200px;
  transition: border-color .2s;
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border);
}
td {
  padding: .75rem;
  font-size: .9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background .15s; }
tbody tr:hover { background: rgba(59,130,246,.08); }

.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge.danger  { background: rgba(239,68,68,.15);  color: var(--danger); }
.badge.success { background: rgba(34,197,94,.15);  color: var(--success); }

.placa-cell { font-family: monospace; font-size: 1rem; font-weight: 600; letter-spacing: .05em; }
.valor-cell { font-weight: 600; }
.valor-cell.danger { color: var(--danger); }

.loading, .no-results {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

/* ── Modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: .25rem;
  border-radius: 4px;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.5rem; overflow-x: auto; }
.modal-total {
  margin-top: 1.25rem;
  text-align: right;
  font-size: 1rem;
  color: var(--muted);
}
.modal-total strong { color: var(--money); font-size: 1.1rem; }

/* ── Footer ─────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.25rem;
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
