/* ============================================================
   Sistema de Pareja — CSS mobile-first
   Paleta: azul primario, verde éxito, rojo peligro
   ============================================================ */
:root {
  --primary: #2563eb;
  --success: #059669;
  --danger: #dc2626;
  --text: #111827;
  --muted: #6b7280;
  --bg: #f3f4f6;
  --card: #fff;
  --border: #e5e7eb;
}

/* ---------- Modo oscuro ---------- */
[data-tema="oscuro"] {
  --primary: #3b82f6;
  --success: #10b981;
  --danger: #f87171;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --bg: #0f172a;
  --card: #1e293b;
  --border: #334155;
  --input-bg: #0f172a;
  --navbar: #0b1220;
  --navbar-text: #e5e7eb;
}

[data-tema="oscuro"] .navbar {
  background: var(--navbar);
}

[data-tema="oscuro"] input,
[data-tema="oscuro"] select,
[data-tema="oscuro"] textarea {
  background: var(--input-bg);
  color: var(--text);
  border-color: var(--border);
}

[data-tema="oscuro"] .card--personal {
  background: #172a4a;
  border-color: #1e3a5f;
}

[data-tema="oscuro"] .card--resumen-vehiculo {
  background: #123524;
  border-color: #1e4d33;
}

[data-tema="oscuro"] .card--mantenimiento-sugerido {
  background: #3a2f0b;
  border-color: #5c4a12;
}

[data-tema="oscuro"] .btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

[data-tema="oscuro"] .tag--conjunto { background: #1e3a5f; color: #93c5fd; }
[data-tema="oscuro"] .tag--individual { background: #4a3412; color: #fcd34d; }
[data-tema="oscuro"] code { background: #1e293b; color: #93c5fd; }

[data-tema="oscuro"] .modal-box { background: var(--card); }
[data-tema="oscuro"] .tab {
  background: var(--card);
  color: var(--muted);
  border-color: var(--border);
}
[data-tema="oscuro"] .tab--active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

[data-tema="oscuro"] .barra {
  background: #0f172a;
}
[data-tema="oscuro"] .personal-fila--disponible {
  border-color: var(--border);
}
[data-tema="oscuro"] .resumen-fila--final {
  border-color: var(--border);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
}

/* ---------- Layout ---------- */
.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px;
}
.container--solo {
  max-width: 400px;
  padding-top: 8vh;
}

/* ---------- Navbar ---------- */
.navbar {
  background: var(--primary);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.navbar-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  font-size: 18px;
}
.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav-links a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
}
.nav-links a.active {
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-weight: 600;
}
.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.nav-name { color: rgba(255,255,255,0.9); }
.nav-logout {
  color: #fff;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.5);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
}

/* ---------- Tarjetas ---------- */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.card h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.grid-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.grid-cards .card { margin: 0; }
.card-label {
  font-size: 13px;
  color: var(--muted);
}
.card-valor {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
}
.card-valor.negativo { color: var(--danger); }

.card--personal {
  background: #eff6ff;
  border: 1px solid #dbeafe;
}
.personal-fila {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  padding: 6px 0;
  color: var(--text);
}
.personal-fila--disponible {
  border-top: 1px solid #dbeafe;
  margin-top: 4px;
  padding-top: 8px;
  font-weight: 700;
}
.personal-fila--disponible .negativo { color: var(--danger); }

.card--resumen-vehiculo {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}
.card--mantenimiento-sugerido {
  background: #fffbeb;
  border: 1px solid #fde68a;
}
.resumen-fila {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  padding: 6px 0;
}
.resumen-fila--final {
  border-top: 1px solid #bbf7d0;
  margin-top: 4px;
  padding-top: 8px;
  font-weight: 700;
}
.resumen-fila--final .negativo { color: var(--danger); }

/* ---------- Barras (estadísticas) ---------- */
.barra-item { margin: 12px 0; }
.barra-label {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 4px;
}
.barra {
  background: var(--bg);
  border-radius: 6px;
  height: 12px;
  overflow: hidden;
}
.barra-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.3s ease;
}
.barra--fondo { background: #8b5cf6; }
.barra--conjunto { background: var(--primary); }
.barra--pao { background: #ec4899; }
.barra--joe { background: #10b981; }

/* ---------- Formularios ---------- */
label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin: 10px 0 4px;
  color: var(--text);
}
input, select, textarea {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 0;
  border-color: var(--primary);
}
.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.row > div { flex: 1; min-width: 120px; }

/* ---------- Botones ---------- */
button, .btn {
  width: 100%;
  min-height: 44px; /* objetivo táctil */
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
button:hover, .btn:hover { filter: brightness(1.05); }
.btn--block { width: 100%; margin-top: 14px; }
.btn--danger { background: var(--danger); }
.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--mini {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
  width: auto;
}

/* ---------- Alertas y toasts ---------- */
.alert {
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  margin: 10px 0;
}
.alert--error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert--success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 92vw;
  padding: 14px 20px;
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  z-index: 999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  animation: toast-in 0.25s ease, toast-out 0.3s ease 2.7s forwards;
}
.toast--success { background: var(--success); }
.toast--error { background: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; transform: translate(-50%, 12px); }
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}
.tab {
  flex: 1;
  min-height: 44px;
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 600;
}
.tab--active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ---------- Listas ---------- */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.list-header h2 { margin: 0; }
.badge {
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 700;
}
.sub-lista {
  margin: 14px 0 4px;
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sub-lista:first-child { margin-top: 0; }
.gasto-list { margin-top: 8px; }
.gasto-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.gasto-item:last-child { border-bottom: none; }
.gasto-info { flex: 1; min-width: 0; }
.gasto-desc {
  font-weight: 600;
  font-size: 15px;
  word-break: break-word;
}
.gasto-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.gasto-monto {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  padding-top: 2px;
}
.gasto-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.inline { display: inline; }
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
}
.tag--conjunto { background: #dbeafe; color: #1d4ed8; }
.tag--individual { background: #fef3c7; color: #92400e; }

.totales {
  margin-top: 12px;
  border-top: 2px solid var(--border);
  padding-top: 10px;
}
.total-fila {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--muted);
  padding: 4px 0;
}
.total-fila--final {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--card);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 20px;
}
.modal-box h2 { margin-top: 0; }

/* ---------- Login ---------- */
.login-card { text-align: center; }
.login-title { margin: 0; font-size: 24px; }
.login-subtitle { color: var(--muted); margin: 4px 0 16px; }
.login-hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 16px;
}
code {
  background: #eef2ff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.muted { color: var(--muted); }
.form-hint { font-size: 13px; margin: 8px 0 0; }
.form-hint.sin-fondo { color: var(--danger); font-weight: 600; }

/* ---------- Escritorio ---------- */
@media (min-width: 768px) {
  .container { max-width: 960px; }
  .navbar-inner { max-width: 960px; }
  .grid-cards { grid-template-columns: repeat(4, 1fr); }
  .row { flex-wrap: nowrap; }
  .modal { align-items: center; }
  .modal-box { border-radius: 16px; }
}
