/* ===== Gestión de Flota · estética Cruz Roja ===== */
:root {
  --rojo: #E1001A;
  --rojo-osc: #B00014;
  --rojo-claro: #FDECEE;
  --tinta: #1D1D1F;
  --gris-9: #2E3134;
  --gris-7: #5B6168;
  --gris-5: #8C929A;
  --gris-3: #D5D9DE;
  --gris-2: #E9ECEF;
  --gris-1: #F5F6F8;
  --blanco: #fff;
  --verde: #1E8E4E;
  --verde-claro: #E5F5EC;
  --ambar: #C77700;
  --ambar-claro: #FFF3DC;
  --azul: #1F5FA8;
  --azul-claro: #E7F0FA;
  --radio: 10px;
  --sombra: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --sombra-2: 0 10px 30px rgba(16, 24, 40, .16);
  --sidebar: 248px;
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--tinta);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--gris-1); font-size: 14px; }
a { color: var(--rojo); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
.muted { color: var(--gris-7); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- Barra superior ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: 60px; z-index: 30;
  background: var(--rojo); color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 18px;
  box-shadow: 0 2px 0 var(--rojo-osc);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { width: 36px; height: 36px; border-radius: 8px; flex: none; }
.brand b { display: block; font-size: 16px; line-height: 1.1; }
.brand span { display: block; font-size: 11.5px; opacity: .88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.userchip {
  display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 12px; border-radius: 30px;
  background: rgba(255, 255, 255, .14); cursor: pointer; border: 0; color: #fff;
}
.userchip:hover { background: rgba(255, 255, 255, .22); }
.userchip .av { width: 30px; height: 30px; border-radius: 50%; background: #fff; color: var(--rojo); display: grid; place-items: center; font-weight: 700; }
.userchip .who { text-align: right; line-height: 1.15; }
.userchip .who small { display: block; opacity: .85; font-size: 11px; }
.hamb { display: none; background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; }
.demo-pill { background: #fff; color: var(--rojo); font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: .04em; }

.usermenu {
  position: fixed; top: 64px; right: 14px; z-index: 40; background: #fff; border-radius: var(--radio); box-shadow: var(--sombra-2);
  min-width: 230px; padding: 6px; border: 1px solid var(--gris-2);
}
.usermenu button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 10px 12px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; }
.usermenu button:hover { background: var(--gris-1); }
.usermenu .head { padding: 10px 12px; border-bottom: 1px solid var(--gris-2); margin-bottom: 4px; }

/* ---------- Menú lateral ---------- */
.sidebar {
  position: fixed; top: 60px; bottom: 0; left: 0; width: var(--sidebar); background: #fff; border-right: 1px solid var(--gris-2);
  padding: 16px 12px; overflow-y: auto; z-index: 20;
}
.nav-sec { font-size: 10.5px; font-weight: 700; color: var(--gris-5); text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--gris-9); font-weight: 600;
  position: relative; margin-bottom: 2px;
}
.nav a svg { width: 20px; height: 20px; color: var(--gris-5); flex: none; }
.nav a:hover { background: var(--gris-1); }
.nav a.on { background: var(--rojo-claro); color: var(--rojo-osc); }
.nav a.on svg { color: var(--rojo); }
.nav a.on::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--rojo); }
.nav .count { margin-left: auto; background: var(--rojo); color: #fff; font-size: 11px; border-radius: 10px; padding: 1px 7px; font-weight: 700; }
.nav .count.w { background: var(--ambar); }

/* ---------- Contenido ---------- */
.main { margin-left: var(--sidebar); padding: 84px 28px 40px; min-height: 100vh; }
.pagehead { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.pagehead h1 { font-size: 24px; }
.pagehead p { margin: 4px 0 0; color: var(--gris-7); }
.pagehead .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 12.5px; color: var(--gris-7); margin-bottom: 6px; }
.crumb a { color: var(--gris-7); }
.crumb a:hover { color: var(--rojo); }

.card { background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); border: 1px solid var(--gris-2); }
.card-pad { padding: 18px 20px; }
.card h3 { font-size: 15px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--gris-2); }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mt { margin-top: 16px; }
.mt2 { margin-top: 24px; }

/* KPIs */
.kpi { padding: 16px 18px; display: flex; gap: 14px; align-items: center; cursor: pointer; transition: transform .12s; }
.kpi:hover { transform: translateY(-1px); }
.kpi .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.kpi .ic svg { width: 22px; height: 22px; }
.kpi b { font-size: 26px; display: block; line-height: 1; }
.kpi span { color: var(--gris-7); font-size: 12.5px; }
.ic.r { background: var(--rojo-claro); color: var(--rojo); }
.ic.g { background: var(--verde-claro); color: var(--verde); }
.ic.a { background: var(--ambar-claro); color: var(--ambar); }
.ic.b { background: var(--azul-claro); color: var(--azul); }

/* Tarjetas de vehículo */
.vcard { overflow: hidden; cursor: pointer; transition: box-shadow .15s, transform .15s; display: flex; flex-direction: column; }
.vcard:hover { box-shadow: var(--sombra-2); transform: translateY(-2px); }
.vcard .top { display: flex; gap: 14px; padding: 18px; align-items: center; border-bottom: 1px solid var(--gris-2); }
.vcard .vic { width: 58px; height: 58px; border-radius: 14px; background: var(--rojo); color: #fff; display: grid; place-items: center; flex: none; }
.vcard .vic svg { width: 32px; height: 32px; }
.vcard h3 { font-size: 16px; }
.plate { display: inline-block; margin-top: 5px; font-family: ui-monospace, Menlo, monospace; font-weight: 700; background: var(--gris-1); border: 1px solid var(--gris-3); border-radius: 5px; padding: 1px 7px; font-size: 12.5px; }
.vcard .rows { padding: 12px 18px 16px; display: grid; gap: 8px; }
.vcard .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.vcard .row > span:first-child { color: var(--gris-7); }

.bar { height: 7px; background: var(--gris-2); border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--verde); border-radius: 6px; }
.bar.w > i { background: var(--ambar); }
.bar.d > i { background: var(--rojo); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--verde-claro); color: var(--verde); }
.badge.w { background: var(--ambar-claro); color: var(--ambar); }
.badge.d { background: var(--rojo-claro); color: var(--rojo-osc); }
.badge.i { background: var(--azul-claro); color: var(--azul); }
.badge.n { background: var(--gris-2); color: var(--gris-7); }
.badge.plain::before { display: none; }
.tag { display: inline-block; font-size: 11px; color: var(--gris-7); background: var(--gris-1); border: 1px solid var(--gris-2); border-radius: 5px; padding: 1px 6px; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 8px;
  padding: 9px 14px; font-weight: 700; cursor: pointer; background: var(--rojo); color: #fff; font-size: 13px; white-space: nowrap;
}
.btn:hover { background: var(--rojo-osc); }
.btn svg { width: 16px; height: 16px; }
.btn.sec { background: #fff; color: var(--gris-9); border-color: var(--gris-3); }
.btn.sec:hover { background: var(--gris-1); }
.btn.ghost { background: none; color: var(--gris-7); padding: 6px 8px; }
.btn.ghost:hover { background: var(--gris-1); color: var(--tinta); }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.green { background: var(--verde); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.iconbtn { border: 0; background: none; padding: 6px; border-radius: 6px; cursor: pointer; color: var(--gris-5); display: inline-grid; place-items: center; }
.iconbtn:hover { background: var(--gris-2); color: var(--tinta); }
.iconbtn.del:hover { background: var(--rojo-claro); color: var(--rojo); }
.iconbtn svg { width: 16px; height: 16px; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--gris-3); border-radius: 8px; overflow: hidden; background: #fff; }
.stepper button { border: 0; background: none; width: 28px; height: 28px; cursor: pointer; font-size: 16px; font-weight: 700; color: var(--gris-7); }
.stepper button:hover { background: var(--rojo-claro); color: var(--rojo); }
.stepper b { min-width: 34px; text-align: center; font-size: 13.5px; }

/* Pestañas */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--gris-3); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 11px 16px; color: var(--gris-7); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--tinta); }
.tabs a.on { color: var(--rojo); border-color: var(--rojo); }
.tabs a .count { font-size: 11px; background: var(--gris-2); color: var(--gris-7); border-radius: 10px; padding: 1px 7px; margin-left: 4px; }
.tabs a .count.d { background: var(--rojo); color: #fff; }

/* Tablas */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--gris-7); font-weight: 700; padding: 10px 12px; background: var(--gris-1); border-bottom: 1px solid var(--gris-2); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--gris-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #FCFCFD; }
tr.low td:first-child { box-shadow: inset 3px 0 0 var(--ambar); }
tr.out td:first-child { box-shadow: inset 3px 0 0 var(--rojo); }
td .name { font-weight: 600; }
td.num { text-align: center; font-variant-numeric: tabular-nums; }

/* Inventario agrupado */
details.group { border-top: 1px solid var(--gris-2); }
details.group:first-of-type { border-top: 0; }
details.group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 13px 18px; font-weight: 700; background: #fff;
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary .chev { transition: transform .15s; color: var(--gris-5); }
details.group[open] > summary .chev { transform: rotate(90deg); }
details.group > summary .meta { margin-left: auto; display: flex; gap: 8px; align-items: center; font-weight: 500; }
.zone { padding: 8px 18px 4px; font-size: 11.5px; font-weight: 700; color: var(--rojo-osc); text-transform: uppercase; letter-spacing: .05em; background: var(--rojo-claro); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--gris-2); }
.toolbar .grow { flex: 1; min-width: 200px; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--gris-5); }
.search input { padding-left: 34px !important; }
.seg { display: inline-flex; background: var(--gris-1); border: 1px solid var(--gris-2); border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 6px; font-weight: 600; color: var(--gris-7); cursor: pointer; font-size: 12.5px; white-space: nowrap; }
.seg button.on { background: #fff; color: var(--rojo); box-shadow: var(--sombra); }

/* Formularios */
.input, input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; border: 1px solid var(--gris-3); border-radius: 8px; padding: 9px 11px; background: #fff; outline: none; transition: border .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--rojo); box-shadow: 0 0 0 3px rgba(225, 0, 26, .12); }
textarea { min-height: 80px; resize: vertical; }
label.f { display: block; }
label.f > span { display: block; font-size: 12px; font-weight: 700; color: var(--gris-9); margin-bottom: 5px; }
label.f > small { display: block; color: var(--gris-5); margin-top: 4px; font-size: 11.5px; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form .full { grid-column: 1 / -1; }
.form h4 { grid-column: 1 / -1; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--rojo); margin-top: 6px; border-bottom: 1px solid var(--gris-2); padding-bottom: 6px; }
input.qty { width: 74px; text-align: center; padding: 6px; }

/* Modal */
.overlay { position: fixed; inset: 0; background: rgba(20, 20, 24, .45); z-index: 60; display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.modal { background: #fff; border-radius: 14px; width: min(640px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--sombra-2); animation: pop .18s; }
.modal.wide { width: min(860px, 100%); }
.modal header { padding: 18px 22px; border-bottom: 1px solid var(--gris-2); display: flex; align-items: center; gap: 10px; }
.modal header h3 { font-size: 17px; }
.modal header .x { margin-left: auto; }
.modal .body { padding: 20px 22px; overflow-y: auto; }
.modal footer { padding: 14px 22px; border-top: 1px solid var(--gris-2); display: flex; justify-content: flex-end; gap: 10px; background: var(--gris-1); border-radius: 0 0 14px 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* Avisos */
.alerts { display: grid; }
.alert { display: flex; gap: 12px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--gris-2); cursor: pointer; }
.alert:last-child { border-bottom: 0; }
.alert:hover { background: var(--gris-1); }
.alert .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.alert .dot.d { background: var(--rojo); }
.alert .dot.w { background: var(--ambar); }
.alert .txt { flex: 1; min-width: 0; }
.alert .txt b { font-weight: 600; }
.empty { padding: 34px 20px; text-align: center; color: var(--gris-7); }
.empty svg { width: 36px; height: 36px; color: var(--verde); display: block; margin: 0 auto 8px; }

.dl { display: grid; grid-template-columns: 170px 1fr; gap: 0; }
.dl > div { padding: 10px 0; border-bottom: 1px solid var(--gris-2); }
.dl > div:nth-child(odd) { color: var(--gris-7); }
.dl > div:nth-last-child(-n+2) { border-bottom: 0; }

.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; }
.toast { background: var(--gris-9); color: #fff; padding: 11px 18px; border-radius: 10px; box-shadow: var(--sombra-2); font-weight: 600; animation: pop .2s; display: flex; gap: 10px; align-items: center; }
.toast.err { background: var(--rojo-osc); }
.toast.ok::before { content: '✓'; color: #7BE3A6; }

.loading-bar { position: fixed; top: 60px; left: 0; right: 0; height: 3px; z-index: 50; overflow: hidden; }
.loading-bar::after { content: ''; position: absolute; height: 100%; width: 30%; background: #fff; box-shadow: 0 0 0 1px var(--rojo-osc); animation: load 1s infinite ease-in-out; background: var(--rojo-osc); }
@keyframes load { from { left: -30%; } to { left: 100%; } }

.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--radio); background: var(--azul-claro); color: var(--azul); margin-bottom: 18px; font-weight: 500; }
.banner.w { background: var(--ambar-claro); color: #7A4A00; }
.banner svg { width: 20px; height: 20px; flex: none; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .hero { background: var(--rojo); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login .hero::after { content: ''; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; background:
  linear-gradient(rgba(255,255,255,.08), rgba(255,255,255,.08)) center/34% 100% no-repeat,
  linear-gradient(rgba(255,255,255,.08), rgba(255,255,255,.08)) center/100% 34% no-repeat; }
.login .hero img { width: 64px; height: 64px; border-radius: 14px; }
.login .hero h1 { font-size: 38px; line-height: 1.1; margin: 22px 0 12px; }
.login .hero p { font-size: 16px; opacity: .92; max-width: 440px; line-height: 1.5; }
.login .hero ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; }
.login .hero li { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.login .hero li::before { content: '+'; width: 22px; height: 22px; border-radius: 6px; background: #fff; color: var(--rojo); display: grid; place-items: center; font-weight: 800; }
.login .panel { display: grid; place-items: center; padding: 40px 24px; background: #fff; }
.login form { width: min(380px, 100%); display: grid; gap: 16px; }
.login form h2 { font-size: 24px; }
.login .btn { padding: 12px; font-size: 14px; }
.login .err { background: var(--rojo-claro); color: var(--rojo-osc); padding: 10px 12px; border-radius: 8px; font-weight: 600; }
.demo-box { border: 1px dashed var(--gris-3); border-radius: 10px; padding: 12px 14px; font-size: 12.5px; color: var(--gris-7); }
.demo-box button { display: flex; width: 100%; justify-content: space-between; border: 0; background: none; padding: 6px 4px; cursor: pointer; border-radius: 6px; }
.demo-box button:hover { background: var(--gris-1); color: var(--rojo); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .hamb { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--sombra-2); }
  body.nav-open .sidebar { transform: none; }
  .main { margin-left: 0; padding: 80px 14px 40px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .userchip .who { display: none; }
  .login { grid-template-columns: 1fr; }
  .login .hero { padding: 28px; }
  .login .hero h1 { font-size: 28px; }
  .login .hero ul { display: none; }
  .login .hero::after { display: none; }
  .form { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; }
  .dl > div:nth-child(odd) { border-bottom: 0; padding-bottom: 0; font-size: 12px; }
  .brand span { display: none; }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr 1fr; } .kpi b { font-size: 22px; } .hide-sm { display: none; } }
@media print { .topbar, .sidebar, .actions, .toolbar, .iconbtn, .stepper button { display: none !important; } .main { margin: 0; padding: 0; } details.group { break-inside: avoid; } }

.vhead-ic { width: 44px; height: 44px; border-radius: 11px; background: var(--rojo); color: #fff; display: inline-grid; place-items: center; }
.vhead-ic svg { width: 26px; height: 26px; }
.hamb svg { width: 24px; height: 24px; display: block; }
@media (max-width: 520px) {
  td, th { padding: 8px 7px; }
  td .name { font-size: 13px; }
  .stepper button { width: 24px; }
  .stepper b { min-width: 26px; }
  .toolbar { padding: 12px; }
}
