:root {
  --bg: #f5f6f8; --panel: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #0f5e9c; --accent-soft: #e7f0f8; --ok: #17803d; --ok-soft: #e6f4ea;
  --warn: #9a6200; --warn-soft: #fff4e0; --bad: #b42318; --bad-soft: #fdecea;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
header.top { background: #12263a; color: #fff; padding: 0 20px; display: flex; align-items: center; gap: 24px; height: 52px; }
header.top a { color: #dbe6f1; }
header.top .marca { font-weight: 700; color: #fff; font-size: 15px; }
header.top select { width: auto; max-width: 280px; background: #1d3a56; color: #fff; border: 1px solid #2d5277; border-radius: 6px; padding: 5px 8px; }
nav.sub { background: var(--panel); border-bottom: 1px solid var(--line); padding: 0 20px; display: flex; gap: 4px; overflow-x: auto; }
nav.sub a { padding: 12px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
nav.sub a.activo, nav.sub a:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
main { max-width: 1200px; margin: 0 auto; padding: 20px; }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 400; font-size: 14px; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #cfd4dc; border-radius: 6px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: auto; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; }
.btn.sec { background: #fff; color: var(--accent); }
.btn.peligro { background: #fff; color: var(--bad); border-color: #e6b4ae; }
.btn.chico { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .6; cursor: wait; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.items input, table.items select { padding: 5px 6px; }
.alerta { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.alerta.ok { background: var(--ok-soft); color: var(--ok); }
.alerta.error { background: var(--bad-soft); color: var(--bad); }
.alerta.aviso { background: var(--warn-soft); color: var(--warn); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eef0f3; color: var(--muted); white-space: nowrap; }
.chip.est-AUTORIZADO, .chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.est-DEVUELTA, .chip.est-NO-AUTORIZADO, .chip.est-ERROR, .chip.mal { background: var(--bad-soft); color: var(--bad); }
.chip.est-RECIBIDA, .chip.est-EN-PROCESO, .chip.est-FIRMADO, .chip.aviso { background: var(--warn-soft); color: var(--warn); }
.chip.sim { background: #efe7fb; color: #6b3fb0; }
.chip.prod { background: #12263a; color: #fff; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; }
.tarjetas { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.tarjeta { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.tarjeta h3 { margin: 0 0 2px; font-size: 15px; }
.totales { margin-left: auto; width: 320px; max-width: 100%; }
.totales td { padding: 5px 8px; }
.totales tr.final td { font-weight: 700; font-size: 16px; border-top: 2px solid var(--text); }
.buscador { position: relative; }
.sugerencias { position: absolute; z-index: 10; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.08); max-height: 260px; overflow: auto; }
.sugerencias div { padding: 7px 10px; cursor: pointer; }
.sugerencias div:hover { background: var(--accent-soft); }
.mensajes { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: #fafbfc; border: 1px solid var(--line); border-radius: 6px; padding: 10px; max-height: 320px; overflow: auto; white-space: pre-wrap; }
details summary { cursor: pointer; font-weight: 600; }
@media (max-width: 700px) { main { padding: 12px; } header.top { gap: 12px; } .ocultar-movil { display: none; } }

/* ---------- Panel de control ---------- */
.filtros { display: flex; gap: 10px; flex-wrap: wrap; margin: 0; }
.filtros label { min-width: 180px; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .titulo { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .valor { font-size: 26px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .muted { font-size: 12px; }
.kpi-aviso { border-left: 4px solid var(--warn); }
.kpi-mal { border-left: 4px solid var(--bad); }
.grafico svg { width: 100%; height: auto; display: block; }
.grafico .barra { fill: var(--accent); }
.grafico .barra.activa { fill: #0b4776; }
.grafico .zona { fill: transparent; cursor: default; }
.grafico .guia { stroke: #eceef1; stroke-width: 1; }
.grafico .base { stroke: #c9ced6; stroke-width: 1; }
.grafico .eje { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.tabla-datos { margin-top: 8px; font-size: 13px; }
.tabla-datos table { margin-top: 6px; }
.tooltip { position: fixed; z-index: 50; background: #1d2330; color: #fff; padding: 7px 10px; border-radius: 6px;
  font-size: 12px; line-height: 1.5; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.salud { display: inline-block; font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.salud-ok { background: var(--ok-soft); color: var(--ok); }
.salud-aviso { background: var(--warn-soft); color: var(--warn); }
.salud-critico { background: var(--bad-soft); color: var(--bad); }
.salud-info { background: #efe7fb; color: #6b3fb0; }

/* ---------- Vista previa del RIDE en Configuración ---------- */
.vista-ride { border: 1px solid var(--line); border-radius: 6px; padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; background: #fff; font-size: 12px; }
.vista-izq, .vista-der { display: flex; flex-direction: column; gap: 3px; }
.vista-izq img { max-width: 100%; max-height: 70px; object-fit: contain; align-self: flex-start; margin-bottom: 4px; }
.vista-der b { font-size: 16px; }
.sin-logo { border: 1px dashed #cfd4dc; color: var(--muted); padding: 18px; text-align: center; border-radius: 4px; margin-bottom: 4px; }
.vista-tabla { grid-column: 1 / -1; color: #fff; padding: 6px 8px; border-radius: 3px; font-weight: 600; }
