:root {
  --bg: #12151a;
  --panel: #1b1f27;
  --panel-2: #22262f;
  --line: #2b303b;
  --text: #ecebe6;
  --muted: #9198a3;
  --amber: #e8a33d;
  --amber-dim: #4a3a1f;
  --teal: #4fb8a4;
  --teal-dim: #1c3a35;
  --red: #e0605a;
  --red-dim: #4a2323;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.od { font-family: 'Space Mono', monospace; font-variant-numeric: tabular-nums; letter-spacing: .03em; }
.heading { font-family: 'Oswald', sans-serif; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 36px 30px; width: 100%; max-width: 360px; text-align: center;
}
.login-mark { margin: 0 auto 16px; }
.login-box h1 { font-size: 22px; font-weight: 600; }
.login-sub { font-size: 12px; color: var(--muted); letter-spacing: .08em; margin-bottom: 22px; }
.login-box input {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 12px; color: var(--text); font-size: 14px; font-family: inherit; outline: none; margin-bottom: 12px;
}
.login-box input:focus { border-color: var(--amber); }
.login-error { color: var(--red); font-size: 12.5px; margin-top: 10px; min-height: 16px; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px 13px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(232,163,61,.06), transparent);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px; background: var(--panel-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--amber); border: 1px solid var(--line);
  font-family: 'Oswald', sans-serif; font-weight: 700; font-size: 15px; letter-spacing: .05em;
}
.brand-title { font-size: 19px; font-weight: 600; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .08em; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab-btn {
  padding: 12px 15px; font-size: 13px; font-weight: 500; font-family: inherit;
  color: var(--muted); background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab-btn.active { color: var(--amber); border-bottom-color: var(--amber); }
.tab-btn:hover:not(.active) { color: var(--text); }

.content { padding: 20px 22px 40px; max-width: 1400px; margin: 0 auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13px; font-weight: 500; font-family: inherit;
  padding: 9px 14px; border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--amber); color: #1a1305; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--amber); }
.btn-danger { background: var(--red-dim); color: #f3c9c6; }
.btn-danger:hover { filter: brightness(1.15); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; }
.icon-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 5px 7px; border-radius: 6px; font-size: 15px; line-height: 1;
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); }

/* ---------- Sections ---------- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 15px; flex-wrap: wrap; gap: 10px;
}
.section-title { font-size: 16px; font-weight: 600; }

.panel-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.panel-box h4 {
  font-size: 11.5px; font-weight: 600; margin-bottom: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 15px; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 3px; }
.tone-amber .stat-value { color: var(--amber); }
.tone-red .stat-value { color: var(--red); }
.tone-teal .stat-value { color: var(--teal); }

.grid-2 { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Alert rows ---------- */
.alert-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.alert-row:last-child { border-bottom: none; }
.alert-row .grow { flex: 1; }
.txt-red { color: var(--red); }
.txt-amber { color: var(--amber); }
.txt-muted { color: var(--muted); }

/* ---------- Vehicle cards ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.v-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; display: flex; flex-direction: column; gap: 11px;
}
.v-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.v-name { font-size: 15px; font-weight: 600; }
.v-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.v-actions { display: flex; gap: 2px; flex-shrink: 0; }

.odo-panel {
  background: #0d0f13; border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.odo-label { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.odo-value { font-size: 20px; color: var(--amber); margin-top: 2px; }
.v-footer { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }

/* ---------- Chips ---------- */
.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.chip-ok { background: var(--teal-dim); color: var(--teal); }
.chip-amber { background: var(--amber-dim); color: var(--amber); }
.chip-danger { background: var(--red-dim); color: var(--red); }

/* ---------- Search ---------- */
.search-box {
  display: flex; align-items: center; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; min-width: 210px;
}
.search-box input { background: none; border: none; outline: none; color: var(--text); font-size: 13px; width: 100%; font-family: inherit; }
.search-box input::placeholder { color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
.cell-actions { display: flex; gap: 6px; }

/* ---------- Services ---------- */
.service-vehicle { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.service-head { margin-bottom: 13px; }
.service-types { display: grid; grid-template-columns: repeat(auto-fit, minmax(225px, 1fr)); gap: 10px; }
.service-item { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 12px; }
.service-item-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 7px; }
.service-item-name { font-size: 12.5px; font-weight: 500; }
.progress-track { height: 6px; background: #0d0f13; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .3s; }
.service-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); gap: 8px; }
.interval-input {
  width: 62px; background: #0d0f13; border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); font-size: 11px; padding: 3px 5px; font-family: 'Space Mono', monospace;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel); z-index: 2;
}
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 13px; }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.field-label { color: var(--muted); }
.field input, .field select, .field textarea {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 11px; color: var(--text); font-size: 13.5px; font-family: inherit; outline: none; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--amber); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.info-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 12px; font-size: 12.5px; line-height: 1.7; }

/* ---------- Empty ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 44px 16px; color: var(--muted); gap: 7px;
}
.empty-title { font-size: 14px; font-weight: 500; color: var(--text); }
.empty-sub { font-size: 12.5px; max-width: 290px; line-height: 1.6; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 11px 18px; font-size: 13px; z-index: 100; box-shadow: 0 6px 22px rgba(0,0,0,.45);
}
.toast.error { border-color: var(--red); color: #f3c9c6; }
.toast.ok { border-color: var(--teal); }

/* ---------- Cobros ---------- */
.cobro-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 15px; display: flex; flex-direction: column; gap: 11px;
}
.cobro-card.vencido { border-color: var(--red); }
.cobro-card.proximo { border-color: var(--amber); }
.cobro-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.cobro-cliente { font-size: 15px; font-weight: 600; }
.cobro-vehiculo { font-size: 12px; color: var(--muted); margin-top: 2px; }
.saldo-panel {
  background: #0d0f13; border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.saldo-label { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.saldo-value { font-size: 20px; margin-top: 2px; }
.saldo-value.deuda { color: var(--red); }
.saldo-value.ok { color: var(--teal); }
.cobro-detalle { font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.pagos-mini { font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.pago-linea { display: flex; justify-content: space-between; padding: 3px 0; }

/* ---------- Banner de cobros ---------- */
.banner-cobros {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(90deg, rgba(232,163,61,.14), rgba(232,163,61,.04));
  border: 1px solid var(--amber); border-radius: 11px;
  padding: 13px 15px; margin-bottom: 18px; flex-wrap: wrap;
}
.banner-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.txt-teal { color: var(--teal); }
