:root {
  --azul: #1f3864;
  --azul2: #2e5090;
  --azul-soft: #e7edf9;
  --gris: #eef1f6;
  --linea: #e2e8f2;
  --linea-soft: #eef2f8;
  --ok: #1e7d34;
  --alerta: #b3261e;
  --warn: #9a6a00;
  --texto: #182231;
  --muted: #5a6678;
  --faint: #8b96a8;
  --sidebar-w: 224px;
  --sombra: 0 1px 2px rgba(20,35,60,.05), 0 8px 24px -18px rgba(20,35,60,.25);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
  color: var(--texto); background: var(--gris); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { letter-spacing: -.01em; }

/* ===================== BARRA LATERAL (panel admin) ===================== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--azul); color: #cdd8ef; padding: 16px 12px;
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto; z-index: 30;
}
.side-brand {
  display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none;
  font-weight: 700; letter-spacing: .02em; margin: 2px 8px 14px; font-size: 15px;
}
.side-group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: #8fa4cd; font-weight: 700; margin: 14px 10px 5px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px; color: #cdd8ef; text-decoration: none;
  padding: 8px 10px; border-radius: 9px; font-size: 13.5px;
}
.nav-link svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.nav-link:hover { background: rgba(255,255,255,.08); }
.nav-link.on { background: rgba(255,255,255,.15); color: #fff; font-weight: 600; }
.side-foot { margin-top: auto; padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.side-foot .user-chip { margin: 0 8px; }

body.admin .content { margin-left: var(--sidebar-w); }
.content { min-width: 0; }

.container { max-width: 1040px; margin: 0 auto; padding: 20px; }
.movil { max-width: 560px; }

/* ===================== TIPOGRAFÍA / TEXTO ===================== */
h1 { font-size: 22px; margin: 6px 0 4px; }
h2 { font-size: 17px; margin: 20px 0 8px; color: var(--azul); }
.muted { color: var(--muted); font-size: 14px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 700; color: var(--faint); }
.tnum { font-variant-numeric: tabular-nums; }

/* Encabezado de página con acciones a la derecha */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.page-head .sp { margin-left: auto; }

/* ===================== TARJETAS ===================== */
.card { background: #fff; border: 1px solid var(--linea); border-radius: 14px;
  padding: 16px; margin-bottom: 14px; box-shadow: var(--sombra); }
.card h1 { margin-top: 0; }

/* ===================== KPIs ===================== */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--linea); border-radius: 12px; padding: 13px 15px; box-shadow: var(--sombra); }
.kpi small { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.kpi .num { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1; margin-top: 6px; }
.kpi .num.use { color: var(--azul2); } .kpi .num.warn { color: var(--warn); } .kpi .num.bad { color: var(--alerta); }
/* KPI clickeable: lleva al detalle */
a.kpi { color: inherit; text-decoration: none; display: block;
  transition: box-shadow .12s ease, transform .12s ease; }
a.kpi:hover { box-shadow: 0 4px 12px rgba(31,56,100,.18); transform: translateY(-1px);
  border-color: var(--azul2); }
a.kpi .cta { display: block; margin-top: 6px; font-size: 11px; font-weight: 700;
  color: var(--azul2); text-transform: uppercase; letter-spacing: .04em; }
/* Leyenda del donut / barras clickeables */
.legend a { display: flex; align-items: center; gap: 8px; color: inherit;
  text-decoration: none; border-radius: 6px; padding: 1px 3px; margin: -1px -3px; }
.legend a:hover { background: #f6f8fc; }
a.bar { color: inherit; text-decoration: none; border-radius: 6px;
  padding: 2px 3px; margin: -2px -3px; }
a.bar:hover { background: #f6f8fc; }
/* Vista de detalle (solo lectura) */
ul.detalle { list-style: none; margin: 0; padding: 0; display: grid;
  grid-template-columns: 1fr 1fr; gap: 6px 22px; }
ul.detalle li { display: flex; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--linea); padding: 6px 0; }
ul.detalle li span { color: var(--faint); }
ul.detalle li b { text-align: right; }
@media (max-width: 700px) { ul.detalle { grid-template-columns: 1fr; } }
.fotos-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.fotos-grid figure { margin: 0; }
.fotos-grid img { max-width: 220px; max-height: 220px; border-radius: 8px;
  border: 1px solid var(--linea); display: block; }
/* Editor de turnos en el ABM de vehículos */
.turnos-box { border: 1px dashed var(--linea); border-radius: 10px;
  padding: 10px 12px; margin-top: 12px; background: #fafbfe; }
.turnos-box .row { gap: 10px; }
.turno-row { padding: 8px 0; border-top: 1px solid var(--linea); }
.turno-row:first-of-type { border-top: 0; }
.turno-dias { display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 6px; font-size: 13px; }
.turno-dias label { display: inline-flex; align-items: center; gap: 4px;
  margin: 0; font-weight: 600; }
.turno-dias input { width: auto; }
/* Turnos en la ficha del vehículo (landing del QR) */
.turnos-ficha { border: 1px solid var(--linea); border-radius: 10px;
  padding: 8px 12px; margin: 4px 0 12px; background: #f6f8fc; }
.turnos-ficha .th { font-size: 12px; font-weight: 700; color: var(--faint);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.turnos-ficha .tr { display: flex; align-items: baseline; gap: 10px;
  padding: 4px 0; border-top: 1px solid var(--linea); }
.turnos-ficha .tr:first-of-type { border-top: 0; }
.turnos-ficha .nom { font-weight: 700; flex: 0 0 auto; }
.turnos-ficha .hs { color: var(--muted); font-variant-numeric: tabular-nums;
  flex: 0 0 auto; }
.turnos-ficha .resp { margin-left: auto; font-weight: 600; }

/* ===================== GRÁFICOS (CSS puro) ===================== */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.chart-card { background: #fff; border: 1px solid var(--linea); border-radius: 14px; padding: 16px; box-shadow: var(--sombra); }
.chart-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.chart-h h3 { font-size: 14px; margin: 0; }
.donut-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.donut { width: 128px; height: 128px; border-radius: 50%; flex: none; position: relative;
  -webkit-mask: radial-gradient(circle 40px at 50% 50%, transparent 98%, #000 100%);
          mask: radial-gradient(circle 40px at 50% 50%, transparent 98%, #000 100%); }
.donut .mid { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.donut .mid .n { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.donut .mid .l { font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.legend { display: flex; flex-direction: column; gap: 7px; min-width: 150px; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar { display: grid; grid-template-columns: 56px 1fr 26px; align-items: center; gap: 10px; font-size: 13px; }
.bar .lab { font-weight: 600; }
.bar .track { height: 9px; background: var(--gris); border-radius: 6px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 6px; background: var(--alerta); }
.bar .v { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ===================== BOTONES ===================== */
.btn { display: inline-block; border: 1px solid var(--linea); background: #fff;
  color: var(--texto); padding: 10px 14px; border-radius: 8px; text-decoration: none;
  cursor: pointer; font-size: 15px; text-align: center; font-family: inherit; }
.btn:hover { background: #f6f8fc; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-primary { background: var(--azul); color: #fff; border-color: var(--azul); }
.btn-primary:hover { background: var(--azul2); }
.btn-lg { display: block; width: 100%; padding: 16px; font-size: 17px; margin-bottom: 10px; }
.btn-alerta { background: var(--alerta); color: #fff; border-color: var(--alerta); }

/* Filtro segmentado (estado) */
.seg { display: inline-flex; background: var(--gris); border: 1px solid var(--linea); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; color: var(--muted); font: inherit; font-size: 13px;
  font-weight: 600; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: #fff; color: var(--texto); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* ===================== FORMULARIOS ===================== */
label { display: block; margin: 12px 0 4px; font-weight: bold; font-size: 14px; }
input[type=text], input[type=number], input[type=password], input[type=date],
input[type=time], input[type=email], input[type=file], select, textarea {
  width: 100%; padding: 11px; border: 1px solid var(--linea); border-radius: 8px;
  font-size: 16px; font-family: inherit; background: #fff; color: var(--texto);
}
textarea { min-height: 70px; }
.pin-input { letter-spacing: 8px; text-align: center; font-size: 22px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }

/* ===================== TABLAS ===================== */
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--linea-soft); text-align: left; }
th { background: #eef2f8; color: var(--azul); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }

/* Panel con encabezado (tabla dentro de tarjeta) */
.panel { background: #fff; border: 1px solid var(--linea); border-radius: 14px; overflow: hidden; margin-bottom: 14px; box-shadow: var(--sombra); }
.panel > .panel-h { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--linea); flex-wrap: wrap; }
.panel-h h2, .panel-h h3 { margin: 0; font-size: 15px; color: var(--texto); }
.panel-h .tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel .tbl-wrap { overflow-x: auto; }

/* ===================== PÍLDORAS / AVISOS ===================== */
.pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: bold; white-space: nowrap; }
.pill.ok { background: #e3f4e8; color: var(--ok); }
.pill.alerta { background: #fbe4e2; color: var(--alerta); }
.pill.warn { background: #fbf1d9; color: var(--warn); }
.pill.uso { background: #e3ecfb; color: var(--azul2); }

.aviso { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.aviso.ok { background: #e3f4e8; color: var(--ok); }
.aviso.err { background: #fbe4e2; color: var(--alerta); }
.aviso.warn { background: #fbf1d9; color: var(--warn); }

.user-chip { background: rgba(255,255,255,.15); padding: 4px 10px; border-radius: 20px; font-size: 13px; color: #fff; display: inline-block; }

/* ===================== CHECKLIST / FIELDSET ===================== */
.chk-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #eef1f6; }
.chk-item .nombre { flex: 1; }
.chk-item .toggle { display: flex; gap: 6px; }
.chk-item .toggle label { margin: 0; font-weight: normal; display: flex; align-items: center; gap: 4px; }
fieldset { border: 1px solid var(--linea); border-radius: 10px; margin: 12px 0; padding: 10px 14px; }
legend { font-weight: bold; color: var(--azul); padding: 0 6px; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 820px) {
  .sidebar { position: static; width: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: 4px; padding: 10px 12px; }
  .side-brand { margin: 0 10px 0 4px; }
  .side-group { display: none; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; padding: 0; }
  body.admin .content { margin-left: 0; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
}
