:root {
  --bg: #0b0e13;
  --panel: #121823;
  --panel2: #0f141d;
  --line: #1e2733;
  --text: #d6deea;
  --muted: #7d8aa0;
  --accent: #36c2ff;
  --ok: #6fdc8c;
  --warn: #e8b339;
  --bad: #ff8a8a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 13px/1.4 "Segoe UI", system-ui, sans-serif;
}
button:focus-visible, input:focus-visible, select:focus-visible, .pickcard:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
button svg, .dropzone svg { vertical-align: -2px; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
button { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; padding: 4px 11px; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
button:hover { border-color: var(--accent); }
.rm { padding: 2px 6px; }

/* ---------- Top bar ---------- */
#topbar { display: flex; align-items: center; gap: 16px; padding: 6px 12px; background: var(--panel2); border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.brand { font-weight: 800; letter-spacing: 1px; font-size: 15px; color: #fff; }
.brand span { color: var(--accent); font-weight: 600; }
.sess #track { font-weight: 700; font-size: 14px; }
.sess #subheader { font-size: 11.5px; }
.chips { margin-left: auto; display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 2px 8px; border-radius: 11px; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 11.5px; user-select: none; }
.chip.box { font-style: italic; opacity: .6; }
.chip.on { color: #06121d; font-weight: 700; border-color: transparent; }

/* ---------- Stepper del wizard (franja propia, centrado) ---------- */
.stepper { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 12.5px; white-space: nowrap; flex: 0 0 auto; padding: 14px 12px 2px; }
.stepper .sep { color: #2a3442; margin: 0 3px; }
.stepper .st { padding: 5px 14px; border-radius: 14px; color: #5a6679; display: inline-flex; align-items: center; gap: 7px; }
.stepper .st.done { background: #12331f; color: var(--ok); cursor: pointer; }
.stepper .st.done:hover { filter: brightness(1.2); }
.stepper .st.cur { background: #0e2a3a; color: var(--accent); border: 1px solid #1c4a61; font-weight: 700; }

/* ---------- Dropzone de ficheros ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 7px; border: 1.5px dashed #2a3442; border-radius: 10px; padding: 20px 16px; color: var(--muted); cursor: pointer; margin-top: 14px; font-size: 12.5px; text-align: center; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); color: var(--text); }
.dropzone .dz-main b { color: var(--accent); font-weight: 600; }
.dropzone svg { opacity: .75; }

/* ---------- Overlay de trabajo en curso ---------- */
.busy-back { position: fixed; inset: 0; background: rgba(4, 7, 11, .72); display: flex; align-items: center; justify-content: center; z-index: 95; }
.busy { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 26px; display: flex; align-items: center; gap: 14px; min-width: 300px; }
.spinner { width: 19px; height: 19px; flex: 0 0 19px; border: 2.5px solid #1c4a61; border-top-color: var(--accent); border-radius: 50%; animation: kspin .9s linear infinite; }
@keyframes kspin { to { transform: rotate(360deg); } }
.busy .bt { font-size: 13.5px; color: var(--text); font-weight: 600; }
.busy .bs { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Navegación principal ---------- */
#mainnav { display: flex; gap: 2px; }
.navbtn { background: transparent; border: none; color: var(--muted); font-size: 12.5px; padding: 5px 11px; border-radius: 5px; }
.navbtn:hover { color: var(--text); }
.navbtn.on { background: var(--panel); color: #fff; font-weight: 600; border: 1px solid var(--line); }

/* ---------- Mantenimiento: maestro-detalle ---------- */
#view-circuits, #view-karts, #view-pilots { display: flex; flex-direction: column; overflow: hidden; }
#view-circuits.hidden, #view-karts.hidden, #view-pilots.hidden { display: none; }
.mwrap { display: flex; flex: 1; min-height: 0; height: 100%; }
.mlist { width: 280px; flex: 0 0 280px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel2); }
.msearch { padding: 10px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.msearch input, .msearch select { background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 7px 10px; font-size: 12.5px; width: 100%; box-sizing: border-box; }
.msearch input:focus, .msearch select:focus { outline: none; border-color: var(--accent); }
.mitems { flex: 1; overflow-y: auto; padding: 6px; }
.mitem { padding: 9px 11px; border-radius: 7px; cursor: pointer; margin-bottom: 3px; border: 1px solid transparent; }
.mitem:hover { background: var(--panel); }
.mitem.on { background: var(--panel); border-color: var(--line); }
.mitem .t { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mitem .t .badge { font-weight: 400; }
.mitem .s { font-size: 11px; color: var(--muted); margin-top: 2px; }
mark { background: rgba(54, 194, 255, .28); color: inherit; border-radius: 2px; padding: 0 1px; }
.mfoot { padding: 10px; border-top: 1px solid var(--line); font-size: 11px; }
.wide-btn { width: 100%; }
.mdetail { flex: 1; overflow-y: auto; padding: 22px 28px; min-width: 0; }
.mdetail .dhead { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.mdetail .dhead input.big { background: var(--panel2); border: 1px dashed var(--line); color: #fff; font-size: 21px; font-weight: 700; border-radius: 6px; padding: 4px 10px; min-width: 0; flex: 1; }
.mdetail .dhead input.big:hover { border-style: solid; border-color: var(--accent); }
.mdetail .dhead input.big:focus { outline: none; border-style: solid; border-color: var(--accent); }
.mdetail .ehint { font-size: 10.5px; color: var(--muted); margin: 2px 0 0 2px; }
.mgroup { margin: 10px 0 4px; font-size: 12px; font-weight: 700; color: var(--text); border-bottom: 1px solid var(--line); padding-bottom: 4px; display: flex; justify-content: space-between; align-items: baseline; }
.mgroup .muted { font-weight: 400; }
.mitem.ghead { cursor: default; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 8px 11px 2px; }
.mitem.ghead:hover { background: transparent; }
.modal input.confirm { width: 100%; box-sizing: border-box; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 7px 10px; font-size: 13px; margin-bottom: 14px; }
.modal input.confirm:focus { outline: none; border-color: #ff8a8a; }
.modal button:disabled { opacity: .4; cursor: not-allowed; }
.mdetail .dmeta { color: var(--muted); font-size: 12px; margin-bottom: 18px; }
.dsec { margin-top: 26px; }
.dsec > h2 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 0 0 10px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.stat .v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .v.accent { color: var(--accent); }
.stat .l { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.formgrid label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.formgrid input, .formgrid select { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 7px 9px; font-size: 13px; width: 100%; box-sizing: border-box; }
.formgrid input:focus, .formgrid select:focus { outline: none; border-color: var(--accent); }
.formgrid .fhint { font-size: 10.5px; color: var(--muted); }
.danger { color: #ff8a8a; border-color: #5a2a2a; }
.danger:hover { border-color: #ff8a8a; }
.mtable { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.mtable th { color: var(--muted); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.mtable td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.mtable tr:last-child td { border-bottom: none; }
.mtable input, .mtable select { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 5px; padding: 4px 7px; font-size: 12.5px; width: 100%; box-sizing: border-box; }
.mtable input:focus, .mtable select:focus { outline: none; border-color: var(--accent); }
.mtable .acts { text-align: right; white-space: nowrap; }
.mtable .newrow td { border-bottom: none; padding-top: 8px; }
.mtable .muted { color: var(--muted); }
.mtable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mtable .delta-up { color: #6fdc8c; }
.lapcard td.bestsec { color: #6fdc8c; font-weight: 700; }
.lapcard td.gbest { color: #c084fc; font-weight: 700; }
.mtable .delta-down { color: #ff8a8a; }
.senses .chip { margin-right: 5px; }
.senses .chip.on { background: var(--accent); color: #06121d; }
.senses .spin { font-size: 10.5px; color: var(--muted); margin-left: 4px; white-space: nowrap; }
/* Subida rápida: resultados por fichero */
.upres { margin-top: 10px; padding: 10px 14px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px; background: var(--panel); }
.upres.ok { border-left-color: #2f9e4f; }
.upres.warn { border-left-color: #cf7a2e; }
.upres.bad { border-left-color: #c43d3d; }
/* Aviso de versión nueva de la PWA */
#update-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 200;
  display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-radius: 10px;
  background: var(--panel2); border: 1px solid var(--accent); box-shadow: 0 6px 24px rgba(0,0,0,.5);
  font-size: 13px; color: var(--text); }
#update-bar button { background: var(--accent); color: #06121d; border: none; font-weight: 700; }
#update-bar a { color: var(--accent); font-size: 12px; text-decoration: underline; }
/* Modal de novedades */
.modal.news { max-width: 460px; }
.modal.news .newshead { font-weight: 700; color: var(--accent); margin: 10px 0 4px; }
.modal.news .newslist { margin: 6px 0 4px; padding-left: 20px; }
.modal.news .newslist li { margin: 5px 0; line-height: 1.45; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 10.5px; border: 1px solid var(--line); color: var(--muted); background: var(--panel2); }
.badge.acc { color: var(--accent); border-color: #1c4a61; }
.subtabs { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 2px; }
.subtab { flex: 1; background: transparent; border: none; color: var(--muted); font-size: 11.5px; padding: 5px 4px; border-radius: 5px; }
.subtab.on { background: var(--panel2); color: #fff; font-weight: 600; }
.curvewrap { margin-top: 10px; }
.curvewrap canvas { width: 100%; height: 240px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.empty-detail { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--muted); gap: 6px; }
.empty-detail .big { font-size: 15px; font-weight: 600; color: var(--text); }

/* Tarjetas de selección de circuito/trazado (pasos 1-2 del wizard) */
.pickgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 14px; }
.pickcard { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 14px 16px; cursor: pointer; }
.pickcard:hover { border-color: var(--accent); }
.pickcard .t { font-size: 14.5px; font-weight: 700; margin-bottom: 4px; }
.pickcard .s { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.pickcard.other { border-style: dashed; }
.pickcard.other .t { color: var(--muted); }

/* Modal + toast propios (window.confirm no existe en todos los webviews) */
.modal-back { position: fixed; inset: 0; background: rgba(4, 7, 11, .72); display: flex; align-items: center; justify-content: center; z-index: 90; }

/* ── Login multiusuario ── */
.auth-overlay { position: fixed; inset: 0; background: var(--bg, #0b0e13); display: flex; align-items: center; justify-content: center; z-index: 100; }
.authbox { display: flex; flex-direction: column; gap: 12px; width: 320px; padding: 28px 26px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.authbox .brand { font-size: 18px; text-align: center; margin-bottom: 4px; }
.authbox h2 { margin: 0; font-size: 16px; }
.authbox label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.authbox input { padding: 8px 10px; font-size: 14px; }
.autherr { color: #ff8a8a; font-size: 12.5px; }
.userbox { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.modal.wide { width: 560px; max-width: 92vw; }
.storedlist { max-height: 50vh; overflow-y: auto; margin: 8px 0; display: flex; flex-direction: column; gap: 4px; }
.storeditem { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.storeditem:hover { border-color: var(--accent); background: var(--panel2); }
.storeditem .t { display: flex; align-items: center; gap: 8px; }
.storeditem .fn { font-weight: 600; }
.storeditem .s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; width: 420px; max-width: 92vw; }
.modal h3 { margin: 0 0 8px; font-size: 15px; }
.modal p { margin: 0 0 16px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.modal .mrow { display: flex; justify-content: flex-end; gap: 8px; }
.modal .mrow button { padding: 6px 14px; }
#toast { position: fixed; bottom: 18px; right: 18px; background: var(--panel); border: 1px solid var(--accent); color: var(--text); border-radius: 8px; padding: 9px 16px; font-size: 12.5px; z-index: 99; opacity: 0; transition: opacity .18s; pointer-events: none; }
#toast.show { opacity: 1; }

/* ---------- Comparison table ---------- */
#cmpwrap { padding: 4px 12px; background: var(--panel2); border-bottom: 1px solid var(--line); overflow-x: auto; flex: 0 0 auto; }
#cmp { border-collapse: collapse; width: 100%; font-size: 12px; }
#cmp th, #cmp td { padding: 3px 10px; text-align: right; white-space: nowrap; }
#cmp th { color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; }
#cmp td.lap, #cmp th:first-child { text-align: left; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.best { color: #7fe3a0; font-size: 9.5px; margin-left: 6px; }
.up { color: #ff8a8a; } .down { color: #7fe3a0; }
.est { color: #c9a83a; }

/* ---------- Controls ---------- */
#controls { display: flex; align-items: center; gap: 18px; padding: 4px 12px; background: var(--panel2); border-bottom: 1px solid var(--line); flex: 0 0 auto; font-size: 12px; }
#controls .cg { display: flex; align-items: center; gap: 6px; }
#controls .cg b { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
#controls .grow { flex: 1; }
#controls .grow input[type=range] { flex: 1; accent-color: var(--accent); }
#controls label { display: flex; align-items: center; gap: 4px; color: var(--muted); }
#poslbl { min-width: 56px; text-align: center; color: var(--text); font-variant-numeric: tabular-nums; }
.seg { border-radius: 0; }
.seg:first-of-type { border-radius: 4px 0 0 4px; }
.seg:last-of-type { border-radius: 0 4px 4px 0; border-left: none; }
.seg.on { background: var(--accent); color: #06121d; font-weight: 700; border-color: var(--accent); }

/* ---------- Layout (single screen) ---------- */
#layout { display: grid; grid-template-columns: 1fr 440px; gap: 7px; padding: 7px; flex: 1 1 auto; min-height: 0; }
#charts { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; min-height: 0; }
.chartcol { display: flex; flex-direction: column; gap: 7px; min-height: 0; }
.chartcol .card { flex: 1 1 0; }
#side { display: flex; flex-direction: column; gap: 7px; min-height: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; display: flex; flex-direction: column; min-height: 0; }
.card-h { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 2px; display: flex; justify-content: space-between; flex: 0 0 auto; }
.card-h .est { text-transform: none; letter-spacing: 0; }
.chart { flex: 1 1 auto; min-height: 0; width: 100%; position: relative; }
/* Lectura de valores por vuelta, superpuesta arriba-izquierda de cada gráfica. */
.vals { position: absolute; top: 1px; left: 46px; z-index: 5; display: flex; gap: 11px; pointer-events: none; font-variant-numeric: tabular-nums; font-size: 11.5px; font-weight: 700; }
.vals span { text-shadow: 0 0 3px #000, 0 0 4px #000, 0 0 4px #000; }
.mount { position: absolute; inset: 0; }

.canvas-wrap { flex: 1 1 auto; min-height: 0; position: relative; }
canvas { display: block; width: 100%; height: 100%; border-radius: 4px; }
.map-card { flex: 1.4 1 0; }
.gg-card { flex: 0.9 1 0; }
.tabs-card { flex: 1.1 1 0; }
#map { background: #000; }

.tabs { display: flex; gap: 4px; flex: 0 0 auto; }
.tab { background: var(--panel2); color: var(--muted); border: 1px solid var(--line); border-radius: 5px 5px 0 0; padding: 3px 9px; cursor: pointer; font-size: 11.5px; }
.tab.active { color: var(--text); background: var(--panel); border-bottom-color: var(--accent); }
.tabbody { flex: 1 1 auto; min-height: 0; overflow: auto; padding-top: 4px; }
.tabpane table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.tabpane th, .tabpane td { padding: 2px 6px; text-align: right; }
.tabpane th { color: var(--muted); font-size: 10.5px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.tabpane td:first-child, .tabpane th:first-child { text-align: left; }
.finding { border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; margin-bottom: 4px; background: var(--panel2); }
.finding .tag { color: #ffaa00; font-weight: 700; margin-right: 6px; }
.finding .ttl { font-weight: 600; }
.finding .det { color: var(--muted); font-size: 10.5px; margin-top: 2px; }

.uplot { font-family: inherit; }

/* ---------- Wizard (pasos 1 y 2) ---------- */
.step { flex: 1 1 auto; min-height: 0; overflow: auto; }
#step-cockpit { display: flex; flex-direction: column; }
.wizard { max-width: 760px; margin: 28px auto; padding: 0 16px; }
.wizard.wide { max-width: 1280px; }
/* El informe aprovecha casi toda la pantalla: márgenes laterales mínimos y
   más sitio para el mapa lateral con la ortofoto. */
#step-report .wizard.wide { max-width: 1760px; padding: 0 22px; margin-top: 12px; }
.wizard h1 { font-size: 19px; margin: 0 0 6px; }
.wizard p { margin: 4px 0 14px; }
.row { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.row.right { justify-content: flex-end; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px; background: var(--accent); color: #06121d; font-weight: 700;
  border: 1px solid var(--accent); border-radius: 7px; padding: 8px 16px; cursor: pointer; font-size: 13px;
}
.btn-primary:hover { filter: brightness(1.1); border-color: var(--accent); }
.btn-primary:disabled { opacity: .35; cursor: default; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 7px 13px; border-radius: 7px; }
button.ghost:hover { color: var(--text); }
#back-to-laps { margin-left: 10px; }

/* Tarjeta por sesión/piloto */
.scard { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.scard .head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.scard .dot { width: 11px; height: 11px; }
.scard .fname { color: var(--muted); font-size: 11.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scard .rm { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; }
.scard .rm:hover { color: #ff8a8a; }
.scard .grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.scard label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
.scard input, .scard select { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 5px; padding: 5px 8px; font-size: 13px; width: 100%; box-sizing: border-box; }
.scard input:focus, .scard select:focus { outline: none; border-color: var(--accent); }
.scard .hint { font-size: 10.5px; color: var(--muted); margin-top: 6px; }
.scard .kartrow { display: flex; align-items: center; gap: 4px; }
.scard .kartrow select { flex: 1; min-width: 0; }

/* Paso 2: tablas de vueltas */
.lap-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 12px; }
/* La tabla nunca recorta columnas: si no cabe, la TARJETA hace scroll lateral. */
.lapcard { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; min-width: 0; }
.lapcard h3 { margin: 0 0 8px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.lapcard h3 .fid { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: auto; }
.lapcard table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.lapcard th, .lapcard td { padding: 3px 7px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lapcard th { color: var(--muted); font-size: 10.5px; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.lapcard td:first-child, .lapcard th:first-child { text-align: left; }
.lapcard tr.box td { opacity: .45; font-style: italic; }
.lapcard tr.sel td { background: rgba(54, 194, 255, .12); }
.lapcard tr { cursor: pointer; }
.lapcard .bestlap { color: #7fe3a0; font-size: 10px; margin-left: 6px; }

/* ---------- Informe del entrenador ---------- */
.coach h1 { font-size: 20px; margin: 6px 0 2px; }
.coach .sub { color: var(--muted); margin-bottom: 14px; }
.coach .kpis { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0 16px; }
.coach .kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; }
.coach .kpi b { display: block; font-size: 21px; font-variant-numeric: tabular-nums; }
.coach .kpi.accent b { color: var(--accent); }
.coach .titlerow { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.coach .pbadge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 12px; }
.coach .pbadge.up { background: #12331f; color: var(--ok); }
.coach .pbadge.down { background: #3a1518; color: var(--bad); }
.coach .pbadge.flat { background: var(--panel); color: var(--muted); border: 1px solid var(--line); }
/* Barras de pérdida por curva (clic → cabina) */
.lossrow { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; cursor: pointer; font-variant-numeric: tabular-nums; }
.lossrow:hover .lossbar { filter: brightness(1.25); }
.lossrow .lname { width: 34px; font-weight: 700; font-size: 12.5px; }
.lossrow .ltrack { flex: 1; background: var(--panel2); border-radius: 4px; height: 15px; overflow: hidden; }
.lossrow .lossbar { height: 100%; border-radius: 4px; }
.lossrow .lval { width: 70px; text-align: right; font-size: 12px; }
.ctabs { position: sticky; top: 46px; z-index: 5; display: flex; gap: 6px; padding: 8px 0; background: var(--bg); border-bottom: 1px solid var(--line); margin-bottom: 10px; flex-wrap: wrap; }
.ctab { background: var(--panel); border: 1px solid var(--line); color: var(--muted); border-radius: 14px; padding: 5px 14px; font-size: 12.5px; }
.ctab.on { background: #0e2a3a; color: var(--accent); border-color: #1c4a61; font-weight: 700; }
.coach-hidden { display: none; }

/* Botonera del informe: FIJA arriba, no desaparece al hacer scroll */
#report-actions { position: sticky; top: 0; z-index: 6; display: flex; justify-content: flex-end; gap: 10px; padding: 10px 0; background: var(--bg); border-bottom: 1px solid var(--line); margin-bottom: 6px; }
/* Informe a dos columnas: contenido + mapa SIEMPRE visible a la derecha */
.report-cols { display: flex; gap: 20px; align-items: flex-start; }
.report-main { flex: 1; min-width: 0; }
.report-side { flex: 0 0 clamp(360px, 32vw, 560px); position: sticky; top: 56px; }
.losswrap { display: block; }
.losswrap .lossbars { min-width: 0; }
.minimap { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 6px 6px 4px; text-align: center; }
.minimap canvas { border-radius: 6px; display: block; width: 100%; }
.minimap .muted { padding: 3px 0 2px; }
/* Leyenda de la escala de colores (la del piloto) */
.clegend { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin-top: 10px; font-size: 11.5px; }
.clegend .ci { display: flex; align-items: center; gap: 8px; margin: 3px 0; color: var(--muted); }
.clegend .dot { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 11px; }
.coach .explain { color: var(--muted); font-size: 11.5px; margin: 4px 0 10px; line-height: 1.55; }
.tlegend { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 10px 14px; margin: 4px 0 12px; }
.tlegend .ti { font-size: 11.5px; color: var(--muted); line-height: 1.55; margin: 4px 0; }
.tlegend .ti b { color: var(--text); }
.coach td.tread { max-width: 320px; }
.hw .tactic, .callout .tactic { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.hw .tactic b, .callout .tactic b { color: var(--text); margin-right: 4px; }
/* Régimen en el ápice */
.rpmrow { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 6px; padding: 9px 14px; margin-bottom: 7px; cursor: pointer; font-size: 12.5px; }
.rpmrow b { margin-right: 8px; }
.rpmrow.bad { border-left-color: var(--bad); }
.rpmrow.bad b { color: var(--bad); }
.rpmrow.warn b { color: var(--warn); }
.rpmrow.info { border-left-color: #3d7dc4; }
.rpmrow.info b { color: #3d7dc4; }
.rpmok { color: var(--ok); font-size: 12.5px; padding: 4px 0; }

/* Deber nº1 destacado */
.callout { background: #0e2a3a; border-left: 3px solid var(--accent); border-radius: 0; padding: 12px 16px; margin-bottom: 10px; font-size: 13px; cursor: pointer; }
.callout b { color: var(--accent); margin-right: 8px; }
.callout:hover { filter: brightness(1.15); }
.coach .kpi span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.coach h2 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 18px 0 8px; }
.hw { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid #ffaa00; border-radius: 6px; padding: 10px 14px; margin-bottom: 8px; cursor: pointer; }
.hw:hover { border-color: var(--accent); }
.hw b { color: #ffaa00; margin-right: 8px; }
.hw .gain { float: right; color: #7fe3a0; font-weight: 700; }
.strength { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid #7fe3a0; border-radius: 6px; padding: 8px 14px; margin-bottom: 6px; color: var(--text); }
.coach table { width: 100%; border-collapse: collapse; font-size: 12.5px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.coach th, .coach td { padding: 5px 10px; text-align: right; border-bottom: 1px solid var(--line); }
.coach th { color: var(--muted); font-size: 10.5px; text-transform: uppercase; }
.coach td:first-child, .coach th:first-child { text-align: left; }
.coach tr.warn td { color: #ffb86b; }
.coach .progress { background: var(--panel2); border: 1px dashed var(--line); border-radius: 6px; padding: 10px 14px; margin: 10px 0; }

/* ---------- Impresión del informe (para dárselo al piloto) ---------- */
@media print {
  body { display: block; height: auto; overflow: visible; background: #fff; color: #111; font-size: 12px; }
  #topbar, #stepper, .row.right, .dropzone, #chips, #report-actions, .ctabs { display: none !important; }
  .coach-hidden { display: block !important; }
  .coach { page-break-after: always; }
  .report-cols { display: block; }
  .report-side { position: static; }
  .step { overflow: visible; }
  .wizard.wide { max-width: none; margin: 0; }
  .coach { break-inside: avoid-page; }
  .coach h1 { color: #000; }
  .coach .sub, .muted { color: #555 !important; }
  .coach .kpi { border: 1px solid #bbb; background: #fff; }
  .coach .kpi b { color: #000; }
  .coach .kpi.accent b { color: #0077b6; }
  .pbadge.up { background: #e7f6ec; color: #1b7d3d; }
  .pbadge.down { background: #fdeaea; color: #b3261e; }
  .lossrow .ltrack { background: #eee; }
  .lossrow .lname, .coach table, .coach td, .coach th { color: #111; }
  .callout { background: #eaf4fb; border-left-color: #0077b6; color: #111; }
  .callout b { color: #0077b6; }
  .hw { background: #fff; border-color: #ccc; color: #111; }
  .rpmrow { background: #fff; border-color: #ccc; color: #111; }
  .minimap { border-color: #ccc; background: #fff; }
  .strength { color: #1b7d3d; }
  table tr.warn td { color: #8a5b00; }
}
