:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --accent: #f5c518;
  --accent-dim: #c9a012;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.45;
  padding-bottom: calc(72px + var(--safe-bottom));
}
.hidden { display: none !important; }

/* Login */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: radial-gradient(ellipse at top, #1e3a5f 0%, var(--bg) 55%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: 0 20px 50px rgba(0,0,0,.4);
}
.login-card h1 { font-size: 1.35rem; margin-bottom: .25rem; }
.login-card .sub { color: var(--muted); font-size: .85rem; margin-bottom: 1.5rem; }
.logo { font-size: 2rem; margin-bottom: .5rem; }

/* Forms */
label { display: block; font-size: .8rem; color: var(--muted); margin: .75rem 0 .35rem; }
input, select, textarea {
  width: 100%;
  padding: .75rem .9rem;
  border: 1px solid var(--surface2);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .75rem 1rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  transition: transform .1s, opacity .15s;
  touch-action: manipulation;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #111; width: 100%; margin-top: 1rem; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: var(--surface2); color: var(--text); }
.btn-sm { padding: .45rem .7rem; font-size: .8rem; }
.btn-danger { background: var(--danger); color: #fff; }

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--surface2);
  padding: .85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.topbar h1 { font-size: 1rem; font-weight: 700; }
.topbar .user { font-size: .75rem; color: var(--muted); }
.live-badge {
  font-size: .7rem;
  color: var(--ok);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.live-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse-live 2s ease-in-out infinite;
}
.live-badge.paused { color: var(--muted); }
.live-badge.paused::before { background: var(--muted); animation: none; }
@keyframes pulse-live {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(.85); }
}
.card .val.flash { animation: flash-val .6s ease; }
@keyframes flash-val {
  0% { color: var(--accent); transform: scale(1.08); }
  100% { color: var(--accent); transform: scale(1); }
}

/* Nav bottom mobile */
.nav-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--surface2);
  padding-bottom: var(--safe-bottom);
}
.nav-bottom button {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  padding: .65rem .25rem;
  font-size: .65rem;
  cursor: pointer;
}
.nav-bottom button.active { color: var(--accent); }
.nav-bottom button span { display: block; font-size: 1.2rem; margin-bottom: 2px; }

/* Content */
.main { padding: 1rem; max-width: 900px; margin: 0 auto; }
.section-title { font-size: 1.1rem; margin-bottom: 1rem; }

.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1.25rem; }
@media (min-width: 600px) { .cards { grid-template-columns: repeat(4, 1fr); } }
.card {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 1rem;
}
.card .val { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.card .lbl { font-size: .7rem; color: var(--muted); text-transform: uppercase; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: .65rem;
  border: 1px solid var(--surface2);
}
.switch {
  width: 48px; height: 26px;
  background: var(--surface2);
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}
.switch.on { background: var(--ok); }
.switch::after {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  background: #fff;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: left .2s;
}
.switch.on::after { left: 24px; }

/* Chofer list */
.search { margin-bottom: 1rem; }
.chofer-item {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  margin-bottom: .6rem;
  cursor: pointer;
}
.chofer-item:active { background: var(--surface2); }
.badge-tier {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  border: 2px solid;
}
.chofer-meta { flex: 1; min-width: 0; }
.chofer-meta h3 { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chofer-meta p { font-size: .78rem; color: var(--muted); }
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}
.status-dot.libre { background: var(--ok); }
.status-dot.ocupado { background: var(--accent); }
.status-dot.off { background: var(--muted); }

/* Modal */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
@media (min-width: 600px) {
  .modal-bg { align-items: center; padding: 1rem; }
}
.modal {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.25rem;
}
@media (min-width: 600px) {
  .modal { border-radius: var(--radius); }
}
.modal h2 { margin-bottom: 1rem; font-size: 1.1rem; }
.modal-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.form-section {
  font-size: .75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 1rem 0 .5rem;
  padding-top: .5rem;
  border-top: 1px solid var(--surface2);
}
.form-section:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
@media (max-width: 400px) { .form-row-2 { grid-template-columns: 1fr; } }
.check-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 0;
  font-size: .9rem;
}
.check-row input { width: auto; }
.chofer-item .btn-edit-card {
  flex-shrink: 0;
  align-self: center;
  min-width: 44px;
  min-height: 44px;
  position: relative;
  z-index: 2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chofer-item { position: relative; }
.expediente-meta {
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.page-hint {
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 1rem;
}
.rec-preview {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
}
.rec-preview strong { display: block; font-size: 1rem; margin-bottom: .35rem; }
.rec-preview .saldo { font-size: 1.25rem; color: var(--accent); font-weight: 700; }
.rec-quick {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .65rem;
}
.rec-quick button {
  flex: 1;
  min-width: 4.5rem;
  padding: .55rem .75rem;
  border: 1px solid var(--surface2);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
.nav-bottom button.nav-only-role {
  flex: 1;
  max-width: 100%;
}
.rec-comprobante {
  margin-top: 1rem;
  padding: 1.1rem;
  background: linear-gradient(145deg, #1a2a1a 0%, var(--surface) 100%);
  border: 2px solid var(--ok);
  border-radius: var(--radius);
}
.rec-comprobante h3 {
  font-size: .95rem;
  color: var(--ok);
  margin-bottom: .75rem;
}
.rec-comprobante dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .35rem .75rem;
  font-size: .88rem;
}
.rec-comprobante dt { color: var(--muted); }
.rec-comprobante dd { font-weight: 600; margin: 0; }
.rec-comprobante .folio-val {
  font-size: 1.05rem;
  color: var(--accent);
  word-break: break-all;
}
.recarga-item {
  padding: .75rem .85rem;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  margin-bottom: .5rem;
  font-size: .82rem;
}
.recarga-item .folio-line {
  font-weight: 700;
  color: var(--accent);
  font-size: .88rem;
}
.recarga-item .meta-line { color: var(--muted); margin-top: .25rem; }

.alert {
  padding: .75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: .85rem;
}
.alert-error { background: rgba(239,68,68,.15); color: #fca5a5; }
.alert-ok { background: rgba(34,197,94,.15); color: #86efac; }

.promo-card {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: .65rem;
}
.promo-card code { color: var(--accent); font-weight: 700; }

.tabs { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button {
  padding: .5rem .85rem;
  border-radius: 20px;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--muted);
  font-size: .8rem;
  cursor: pointer;
}
.tabs button.active { background: var(--accent); color: #111; border-color: var(--accent); }

.reservas-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  margin-bottom: 1rem;
}
.reserva-stat {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  padding: .65rem;
  text-align: center;
}
.reserva-stat .n { font-size: 1.25rem; font-weight: 700; color: var(--accent); }
.reserva-stat .l { font-size: .65rem; color: var(--muted); text-transform: uppercase; }
.reserva-card {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: .65rem;
  cursor: pointer;
}
.reserva-card:active { background: var(--surface2); }
.reserva-card .res-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .5rem;
  margin-bottom: .5rem;
}
.reserva-card h3 { font-size: .95rem; }
.badge-estado {
  font-size: .65rem;
  font-weight: 700;
  padding: .2rem .5rem;
  border-radius: 6px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.badge-pendiente { background: rgba(251, 191, 36, .2); color: #fbbf24; }
.badge-asignada { background: rgba(34, 197, 94, .2); color: #22c55e; }
.badge-cancelada { background: rgba(239, 68, 68, .2); color: #ef4444; }
.badge-completada { background: rgba(148, 163, 184, .2); color: #94a3b8; }
.reserva-card .res-fecha { color: var(--accent); font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.reserva-card p { font-size: .8rem; color: var(--muted); margin: .2rem 0; }
.nav-bottom button { font-size: .6rem; }
