/* ═══════════════════════════════════════════════
   Historial de Vehículos — Hoja de estilos global
   Diseño: Utilitario / Taller Mecánico
═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

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

:root {
  --bg:        #f0eeea;
  --white:     #ffffff;
  --surface:   #faf9f7;
  --border:    #e0ddd8;
  --border2:   #ccc8c2;
  --text:      #1c1917;
  --muted:     #78716c;
  --light:     #a8a29e;
  --primary:   #1c1917;
  --accent:    #c8460a;

  --cat-mant:  #1d4ed8;
  --cat-comp:  #15803d;
  --cat-acei:  #b45309;
  --cat-llant: #be123c;

  --r:  8px;
  --r2: 12px;
  --sh: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --sh2: 0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── TOPBAR ─────────────────────────────────── */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 200;
  box-shadow: var(--sh);
}
.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.3px;
}
.topbar-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  padding: 6px 0;
  transition: color .15s;
}
.topbar-back:hover { color: var(--text); }
.topbar-back svg { width: 16px; height: 16px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ── CONTAINER ──────────────────────────────── */
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

/* ── BUTTONS ────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--r);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  line-height: 1;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #333; }
.btn-ghost     { background: transparent; color: var(--text); border: 1px solid var(--border2); }
.btn-ghost:hover { background: var(--bg); border-color: #aaa; }
.btn-danger    { background: transparent; color: var(--cat-llant); border: 1px solid #fecdd3; }
.btn-danger:hover { background: #fff1f2; }
.btn-export    { background: #1d4ed8; color: #fff; }
.btn-export:hover { background: #1e40af; }
.btn-sm        { padding: 6px 12px; font-size: 12.5px; }
.btn-icon      { padding: 6px; border-radius: 6px; background: transparent;
                 color: var(--muted); border: 1px solid transparent; }
.btn-icon:hover { background: var(--bg); border-color: var(--border); color: var(--text); }
.btn-icon svg  { width: 14px; height: 14px; }

/* ── PAGE TOP ───────────────────────────────── */
.page-top {
  padding: 28px 0 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-heading { font-size: 24px; font-weight: 700; letter-spacing: -.5px; }
.page-sub     { font-size: 13.5px; color: var(--muted); margin-top: 3px; }

/* ── VEHICLE GRID ───────────────────────────── */
.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
  margin-top: 4px;
}
.v-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 20px;
  cursor: pointer;
  transition: all .18s;
  display: block;
  box-shadow: var(--sh);
  position: relative;
  overflow: hidden;
}
.v-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
  opacity: 0;
  transition: opacity .18s;
}
.v-card:hover {
  border-color: var(--border2);
  box-shadow: var(--sh2);
  transform: translateY(-2px);
}
.v-card:hover::before { opacity: 1; }

.v-plate {
  font-family: 'DM Mono', monospace;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 3px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  margin-bottom: 14px;
}
.v-name  { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.v-meta  { font-size: 13px; color: var(--muted); }
.v-stats {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex; gap: 16px;
}
.v-stat-item { font-size: 12px; }
.v-stat-val  { font-weight: 700; font-size: 14px; color: var(--text); display: block; }
.v-stat-lbl  { color: var(--muted); }

/* ── VEHICLE HEADER ─────────────────────────── */
.vh-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 22px 26px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  box-shadow: var(--sh);
  margin-top: 24px;
}
.vh-plate {
  font-family: 'DM Mono', monospace;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 4px;
  background: var(--bg);
  border: 1.5px solid var(--border2);
  border-radius: 8px;
  padding: 8px 18px;
  flex-shrink: 0;
}
.vh-info { flex: 1; min-width: 160px; }
.vh-name { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.vh-meta { font-size: 13px; color: var(--muted); margin-top: 3px; }
.vh-actions { display: flex; gap: 8px; }

/* ── STATS ROW ──────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin: 18px 0 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 16px 18px;
  box-shadow: var(--sh);
}
.stat-val {
  font-size: 22px; font-weight: 700;
  letter-spacing: -.5px;
  line-height: 1.2;
  font-family: 'DM Mono', monospace;
}
.stat-lbl {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 600;
}

/* ── FILTER TABS ────────────────────────────── */
.filter-bar {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.f-tab {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--muted);
  font-family: inherit;
  transition: all .15s;
}
.f-tab:hover { color: var(--text); border-color: var(--border2); }
.f-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── TABLE ──────────────────────────────────── */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  box-shadow: var(--sh);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11.5px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th:first-child { border-radius: var(--r2) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--r2) 0 0; }
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td      { background: #faf9f7; }
.td-date  { white-space: nowrap; font-family: 'DM Mono', monospace; font-size: 12.5px; }
.td-km    { font-family: 'DM Mono', monospace; font-size: 12.5px; white-space: nowrap; }
.td-cost  { font-family: 'DM Mono', monospace; font-size: 13px; font-weight: 600; white-space: nowrap; }
.td-desc-main  { font-weight: 600; margin-bottom: 2px; }
.td-desc-sub   { font-size: 12.5px; color: var(--muted); }
.td-actions    { white-space: nowrap; }

/* ── BADGES ─────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}
.badge-mant  { background: #eff6ff; color: var(--cat-mant); }
.badge-comp  { background: #f0fdf4; color: var(--cat-comp); }
.badge-acei  { background: #fffbeb; color: var(--cat-acei); }
.badge-llant { background: #fff1f2; color: var(--cat-llant); }

/* ── EMPTY STATE ────────────────────────────── */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-icon { font-size: 40px; margin-bottom: 14px; }
.empty h3   { font-size: 15px; color: var(--text); margin-bottom: 5px; }
.empty p    { font-size: 13.5px; }

/* ── MODAL ──────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.overlay.on { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: 14px;
  padding: 28px 28px 24px;
  width: 100%; max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px) scale(.98);
  transition: transform .2s;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.overlay.on .modal { transform: translateY(0) scale(1); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.modal-title { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  background: var(--bg);
  border: none; font-size: 18px;
  color: var(--muted); font-family: inherit;
  transition: all .15s;
}
.modal-close:hover { background: var(--border); color: var(--text); }

/* ── FORM ───────────────────────────────────── */
.fg { margin-bottom: 15px; }
.fg label {
  display: block;
  font-size: 12.5px; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 6px;
}
.fg input, .fg select, .fg textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  font-size: 14px; font-family: inherit;
  background: var(--white); color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.fg input:focus, .fg select:focus, .fg textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(28,25,23,.06);
}
.fg textarea { resize: vertical; min-height: 80px; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ── TOAST ──────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--primary); color: #fff;
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 13.5px; font-weight: 500;
  z-index: 999;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 4px 20px rgba(0,0,0,.22);
  max-width: 320px; text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err  { background: #be123c; }

/* ── SECTION LABEL ──────────────────────────── */
.section-label {
  font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ── PRINT / EXPORT ─────────────────────────── */
@media print {
  .topbar, .btn, .filter-bar, .td-actions,
  .vh-actions, .page-top .btn-group, .no-print { display: none !important; }
  body { background: white; font-size: 12px; }
  .container { padding: 0; max-width: 100%; }
  .table-wrap, .stat-card, .vh-card { box-shadow: none !important; }
  table { font-size: 11px; }
  .vh-card { margin-top: 0; border: 1.5px solid #333; }
}

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 640px) {
  .container    { padding: 0 16px 40px; }
  .topbar-inner { padding: 0 16px; }
  .form-row, .form-row3 { grid-template-columns: 1fr; }
  .stats-row    { grid-template-columns: 1fr 1fr; }
  .vh-card      { padding: 16px 18px; gap: 14px; }
  .page-top     { flex-direction: column; align-items: flex-start; gap: 12px; }
  .vh-actions   { flex-wrap: wrap; }
  thead th:nth-child(3),
  tbody td:nth-child(3) { display: none; } /* ocultar hora en mobile */
}
