/* ═══════════════════════════════════════════════
   RallyNote Pro by Murciadrones — app.css  (White theme)
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;500;600;700;800;900&family=Barlow:wght@300;400;500;600;700&family=Share+Tech+Mono&display=swap');

/* ── TOKENS ── */
:root {
  /* White base palette */
  --bg:        #f7f8fa;
  --surface:   #ffffff;
  --surface2:  #f0f2f5;
  --surface3:  #e4e7ec;
  --border:    #d1d5db;
  --border2:   #e5e7eb;

  /* Brand */
  --red:       #e8341a;
  --red-light: #fef2f0;
  --red-mid:   #fcd5cc;
  --orange:    #f5a623;
  --orange-lt: #fef7ea;
  --green:     #16a34a;
  --green-lt:  #f0fdf4;
  --blue:      #2563eb;
  --blue-lt:   #eff6ff;
  --gray:      #6b7280;
  --gray-lt:   #f9fafb;

  /* Type badges */
  --c-curva:   #2563eb;
  --c-peligro: #e8341a;
  --c-nota:    #f5a623;
  --c-wp:      #16a34a;
  --c-flat:    #6b7280;

  /* Text */
  --text:      #111827;
  --text-2:    #374151;
  --text-3:    #6b7280;
  --text-4:    #9ca3af;

  /* Race mode — NIGHT (default): pure black bg, bright text */
  --race-bg:   #000000;
  --race-s1:   #0e1014;
  --race-acc:  #ffb43a;
  --race-red:  #ff5640;
  --race-text: #ffffff;
  /* Pacenote token colors (night) */
  --race-dir:      #6db3ff;   /* dirección izq/der */
  --race-dir-bg:   #16263b;
  --race-num:      #ffffff;   /* números de curva */
  --race-danger:   #ff6b5a;   /* peligro / ! */
  --race-danger-bg:#3a1410;
  --race-terrain:  #ffc06b;   /* terreno */
  --race-terrain-bg:#3a2a12;
  --race-conj:     #b9c0cc;   /* conjunciones (y, en) */
  --race-dist:     #5fe39f;   /* distancias */
  --race-mod:      #d4dae3;   /* modificadores */
  /* Superficies y grises de la interfaz de carrera (noche) */
  --race-s2:       #191c23;   /* cajas y botones */
  --race-s3:       #1f2530;   /* botón secundario */
  --race-border:   #2a2f3a;
  --race-muted:    #8b93a3;   /* etiquetas secundarias */
  --race-muted2:   #7a8090;
  --race-teal:     #4ecdc4;   /* posición / distancias */

  --font-cond: 'Barlow Condensed', sans-serif;
  --font-body: 'Barlow', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;

  --topbar-h:  52px;
  --sat: env(safe-area-inset-top,0px);
  --sab: env(safe-area-inset-bottom,0px);
  --sal: env(safe-area-inset-left,0px);
  --sar: env(safe-area-inset-right,0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; font-size: 18px; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  background: var(--bg); color: var(--text);
  height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column;
  -webkit-tap-highlight-color: transparent;
  -webkit-overflow-scrolling: touch;
  padding-top: var(--sat);
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── VIEWS ── */
.view { display: none !important; }
.view.active { display: flex !important; flex: 1; overflow: hidden; flex-direction: column; }

/* Hide app chrome by default, only show when in 'view-app' */
#topbar, #sidebar, #sidebar-ov { display: none; }
body.in-app #topbar { display: flex; }
body.in-app #sidebar { display: flex; }
body.in-app.sidebar-open #sidebar-ov { display: block; }
/* In race-only mode (from picker), hide app's topbar and sidebar */
body.in-race #topbar, body.in-race #sidebar, body.in-race #sidebar-ov { display: none !important; }
body.in-race #view-app { background: var(--race-bg); }

/* Race DAY mode — light theme overrides (toggled by 🌙/☀ button) */
body.in-race.race-day {
  --race-bg:   #ffffff;
  --race-s1:   #ffffff;
  --race-acc:  #c2410c;
  --race-red:  #dc2626;
  --race-text: #0c0c0c;
  /* Pacenote token colors (day) — dark, high contrast on white */
  --race-dir:      #1d4ed8;
  --race-dir-bg:   #e6efff;
  --race-num:      #0c0c0c;
  --race-danger:   #c81e1e;
  --race-danger-bg:#fde2e2;
  --race-terrain:  #9a4a06;
  --race-terrain-bg:#fbedd6;
  --race-conj:     #555c66;
  --race-dist:     #0f7a45;
  --race-mod:      #3a4049;
  /* Superficies y grises (día) */
  --race-s2:       #e9ecf1;
  --race-s3:       #dfe3ea;
  --race-border:   #c8cdd6;
  --race-muted:    #5c6470;
  --race-muted2:   #6b7280;
  --race-teal:     #0f7a6e;
}
body.in-race.race-day .race-zoom-btn { background: #e9ecf1; border-color: #c8cdd6; color: #333; }
body.in-race.race-day .race-zoom-btn:hover { color: var(--race-acc); border-color: var(--race-acc); }
/* Day-mode chrome bars: white surfaces, dark text */
body.in-race.race-day .race-topbar { background: #ffffff; border-bottom-color: #e0e3e8; }
body.in-race.race-day .race-stagebar { background: #f3f5f8; border-bottom-color: #e0e3e8; }
body.in-race.race-day .race-ink-bar { background: #f3f5f8; border-bottom-color: #e0e3e8; }
body.in-race.race-day .rsb-btn { background: #e9ecf1; border-color: #c8cdd6; color: #14171c; }
body.in-race.race-day .race-timer-btn { background: #e9ecf1; border-color: #c8cdd6; color: #14171c; }
body.in-race.race-day .race-posbar { background: #eef2f6; border-top-color: #0f9b8e; }
body.in-race.race-day .rpos-lbl { color: #667; }
body.in-race.race-day .rpos-note { color: #14171c; }
body.in-race.race-day .race-timer { color: #14171c; }
body.in-race.race-day .race-back { color: #555; border-color: #c8cdd6; }
body.in-race.race-day .race-topbar .nb-trip-lbl { color: #888; }
/* Day-mode: bottom ODO-trim footer buttons (were black-on-black) */
body.in-race.race-day .race-footer { background: #f3f5f8; border-top-color: #e0e3e8; }
body.in-race.race-day .rf-btn { background: #e9ecf1; border-color: #c8cdd6; color: #14171c; }
body.in-race.race-day .rf-btn:hover, body.in-race.race-day .rf-btn:active { border-color: #0f9b8e; color: #0f7a45; }
body.in-race.race-day .rf-btn.pos { color: #0f7a45; }
body.in-race.race-day .rf-split { background: var(--race-acc); color: #fff; }
/* Day-mode: zoom level label + ink size slider track */
body.in-race.race-day .race-zoom-lvl { background: #e9ecf1; border-color: #c8cdd6; color: var(--race-acc); }
body.in-race.race-day .race-ink-bar .pen-color { box-shadow: 0 0 0 1px #c8cdd6; }
/* Day-mode: semantic stagebar buttons keep meaning but readable on light */
body.in-race.race-day .rsb-countdown { background: #e9ecf1; color: #14171c; }
body.in-race.race-day .rsb-go { background: #dff3e2; border-color: #2e9e54; color: #1a7a38; }
body.in-race.race-day .rsb-locate { background: #e3eefb; border-color: #4a90d0; color: #1d5fa5; }
body.in-race.race-day .rsb-autoscroll { color: #555c66; }
body.in-race.race-day .race-odo-lbl { color: #888; }
body.in-race.race-day .rpos-now .rpos-note { color: #667; }
body.in-race #view-app.active { display: flex !important; }

/* ══════════════ MODALES (base) ══════════════
   Ventana flotante centrada sobre fondo oscuro, con scroll interno y los botones
   siempre visibles en el pie (aunque el contenido crezca, p.ej. al aparecer el mapa). */
.modal-ov { display: none; }
.modal-ov.open {
  display: flex !important;
  position: fixed; inset: 0; z-index: 900;
  background: rgba(10, 12, 16, .55);
  align-items: center; justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface, #fff); color: var(--text, #111);
  border-radius: 16px; box-shadow: 0 18px 50px rgba(0,0,0,.35);
  width: min(94vw, 720px); max-height: min(92vh, 100dvh - 24px);
  display: flex; flex-direction: column;
  padding: 18px 22px 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.modal > .modal-title, .modal > h3 { flex-shrink: 0; margin: 0 0 12px; }
.modal-btns, .modal-actions {
  position: sticky; bottom: 0; flex-shrink: 0;
  display: flex; gap: 10px; justify-content: flex-end; align-items: center;
  margin: 16px -22px 0; padding: 12px 22px;
  background: var(--surface, #fff); border-top: 1px solid var(--border, #e5e7eb);
  border-radius: 0 0 16px 16px;
}
.modal-btns .btn-secondary, .modal-actions .btn-secondary, .modal-btns .btn-sec, .modal-actions .btn-sec { margin-right: auto; }
@media (max-width: 720px) {
  .modal { width: 100%; max-height: calc(100dvh - 16px); border-radius: 14px; padding: 14px 16px 0; }
  .modal-btns, .modal-actions { margin: 14px -16px 0; padding: 10px 16px; }
}

/* Bottom of body class scoping — every top-level view has its own */


/* ══════════════ LOGIN ══════════════ */
/* Override .view.active to allow centering */
#view-login.view.active {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  background: #f4f5f7;
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.lg-container {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lg-card {
  width: 100%;
  background: #ffffff;
  border-radius: 14px;
  padding: 36px 32px 28px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 8px 32px rgba(15, 23, 42, 0.08);
  border: 1px solid #e5e7eb;
}

.lg-brand {
  text-align: center;
  margin-bottom: 24px;
}
.lg-logo {
  font-family: var(--font-cond);
  font-weight: 800;
  font-size: 36px;
  letter-spacing: 0.5px;
  line-height: 1;
  color: #111827;
  margin-bottom: 8px;
}
.lg-logo em {
  color: var(--red);
  font-style: normal;
}
.lg-tagline {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
  line-height: 1.4;
}

.lg-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 0 -32px 24px;
}

.lg-form {
  width: 100%;
}

.lg-field {
  margin-bottom: 16px;
}
.lg-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}
.lg-input {
  display: block;
  width: 100%;
  padding: 11px 14px;
  font-size: 15px !important;
  font-family: inherit;
  color: #111827;
  background: #ffffff;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
  line-height: 1.4;
}
.lg-input::placeholder { color: #9ca3af; }
.lg-input:hover:not(:focus) { border-color: #9ca3af; }
.lg-input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(232, 52, 26, 0.12);
}

.lg-pw { position: relative; }
.lg-pw .lg-input { padding-right: 44px; }
.lg-pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color .12s, background .12s;
  padding: 0;
}
.lg-pw-toggle:hover { color: #111827; background: #f3f4f6; }
.lg-pw-toggle.active { color: var(--red); }

.lg-err {
  min-height: 20px;
  margin: -4px 0 12px;
  font-size: 13px;
  color: var(--red);
  font-weight: 500;
  line-height: 1.3;
}

.lg-submit {
  display: block;
  width: 100%;
  padding: 12px 20px;
  font-size: 15px !important;
  font-weight: 600 !important;
  font-family: inherit;
  color: #ffffff;
  background: #111827;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s, transform .08s;
  letter-spacing: 0.2px;
  margin-top: 4px;
}
.lg-submit:hover { background: #000000; }
.lg-submit:active { transform: scale(0.99); }
.lg-submit:disabled { opacity: 0.55; cursor: wait; }
.lg-submit.loading .lg-submit-text::after {
  content: '';
  display: inline-block;
  margin-left: 4px;
  animation: lgDots 1.2s steps(4, end) infinite;
}
@keyframes lgDots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

.lg-hint {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
  color: #6b7280;
  text-align: center;
  line-height: 1.5;
}
.lg-hint code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 1px 6px;
  border-radius: 4px;
  color: #374151;
}

.lg-foot {
  margin-top: 20px;
  font-size: 12px;
  color: #9ca3af;
  display: flex;
  align-items: center;
  gap: 8px;
}
.lg-foot-sep { color: #d1d5db; }
.lg-link {
  color: #6b7280;
  text-decoration: none;
  transition: color .12s;
}
.lg-link:hover { color: var(--red); text-decoration: underline; }

@media (max-width: 480px) {
  .lg-card { padding: 28px 22px 24px; }
  .lg-divider { margin: 0 -22px 22px; }
  .lg-logo { font-size: 32px; }
}


#view-hub { background: linear-gradient(180deg, #f7f8fa 0%, #eef1f6 100%); }

.hub-topbar {
  display: flex; align-items: center;
  height: var(--topbar-h); padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0; gap: 10px;
}
.hub-logo {
  font-family: var(--font-cond); font-weight: 900; font-size: 22px;
  letter-spacing: 1.5px; color: var(--text); flex: 1;
}
.hub-logo span { color: var(--red); }
.hub-right { display: flex; align-items: center; gap: 10px; }
#hub-clock, #rp-clock {
  font-family: var(--font-mono); font-size: 14px; color: var(--text-3);
}
.hub-back {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-2); padding: 6px 12px; border-radius: 6px;
  font-family: var(--font-cond); font-weight: 600; font-size: 13px;
  letter-spacing: .5px; transition: all .12s;
}
.hub-back:hover { background: var(--surface3); }

.hub-wrap {
  flex: 1; overflow-y: auto; padding: 32px 20px 80px;
  display: flex; flex-direction: column; align-items: center;
  -webkit-overflow-scrolling: touch;
}
.hub-welcome { text-align: center; margin-bottom: 36px; max-width: 720px; }
.hub-welcome-label { font-size: 13px; color: var(--text-3); letter-spacing: 2px; text-transform: uppercase; margin-bottom: 6px; }
.hub-welcome-name { font-family: var(--font-cond); font-weight: 800; font-size: 36px; color: var(--text); letter-spacing: .5px; line-height: 1; }

.hub-cards {
  display: grid; grid-template-columns: 1fr; gap: 18px;
  width: 100%; max-width: 760px;
}
@media (min-width: 720px) { .hub-cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1080px) { .hub-cards { grid-template-columns: 1fr 1fr 1fr; max-width: 1140px; } }

.hub-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px 24px;
  cursor: pointer; transition: all .18s;
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  text-align: left; box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  position: relative; overflow: hidden;
}
.hub-card::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: var(--red); transform: scaleX(0); transform-origin: left;
  transition: transform .25s ease;
}
.hub-card:hover { transform: translateY(-3px); box-shadow: 0 6px 12px rgba(0,0,0,.06), 0 16px 32px rgba(0,0,0,.08); border-color: var(--red); }
.hub-card:hover::after { transform: scaleX(1); }
.hub-card-notes::after { background: var(--blue); }
.hub-card-race::after  { background: var(--red); }
.hub-card-results::after { background: var(--green); }

.hc-icon {
  width: 64px; height: 64px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-lt); color: var(--blue);
}
.hub-card-race .hc-icon { background: var(--red-light); color: var(--red); }
.hub-card-results .hc-icon { background: rgba(22,163,74,0.12); color: var(--green); }
.hc-title {
  font-family: var(--font-cond); font-weight: 800; font-size: 26px;
  letter-spacing: .5px; color: var(--text); line-height: 1.1;
}
.hc-desc { font-size: 14px; color: var(--text-3); line-height: 1.5; }
.hc-cta {
  margin-top: auto; padding-top: 6px;
  font-family: var(--font-cond); font-weight: 700; font-size: 15px;
  color: var(--blue); letter-spacing: .5px;
}
.hub-card-race .hc-cta { color: var(--red); }
.hub-card-results .hc-cta { color: var(--green); }

.hub-footer {
  margin-top: 40px; font-size: 11px; color: var(--text-4);
  letter-spacing: 2px; text-transform: uppercase;
}

.hub-user-menu { top: calc(var(--topbar-h) + 4px); right: 12px; }

/* ══════════════ RESULTS / HISTORY ══════════════ */
.res-wrap { flex: 1; overflow-y: auto; padding: 20px; -webkit-overflow-scrolling: touch; }
.res-toolbar { max-width: 820px; margin: 0 auto 20px; }
.res-rally-sel {
  width: 100%; max-width: 420px; padding: 11px 14px;
  font-size: 15px; font-family: inherit;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
.res-content { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.res-timing-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: var(--surface); border: 1.5px solid var(--red);
  border-radius: 12px; text-decoration: none;
  transition: background .12s;
}
.res-timing-banner:hover { background: var(--red-light); }
.rtb-icon { font-size: 24px; }
.rtb-text { display: flex; flex-direction: column; flex: 1; }
.rtb-text strong { font-size: 15px; color: var(--text); }
.rtb-sub { font-size: 12px; color: var(--text-3); }
.rtb-arrow { font-size: 20px; color: var(--red); font-weight: 700; }
.res-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; color: var(--text-3); text-align: center; gap: 10px;
}
.res-empty .eh-icon { font-size: 44px; }

/* Stage result card */
.res-stage {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
}
.res-stage-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.res-stage-name {
  font-family: var(--font-cond); font-weight: 800; font-size: 18px;
  color: var(--text); flex: 1;
}
.res-stage-best {
  font-family: var(--font-mono); font-size: 16px; color: var(--green);
  font-weight: 700;
}
.res-stage-best-lbl {
  font-size: 10px; color: var(--text-4); letter-spacing: 1px;
  text-transform: uppercase; display: block; text-align: right;
}
.res-runs { display: flex; flex-direction: column; }
.res-run {
  display: grid; grid-template-columns: 28px 1fr auto auto 36px;
  align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.res-run:last-child { border-bottom: none; }
.res-run.is-best { background: rgba(22,163,74,0.05); }
.res-run-pos {
  font-family: var(--font-cond); font-weight: 800; font-size: 15px;
  color: var(--text-4); text-align: center;
}
.res-run.is-best .res-run-pos { color: var(--green); }
.res-run-time {
  font-family: var(--font-mono); font-weight: 700; font-size: 16px; color: var(--text);
}
.res-run-meta { font-size: 12px; color: var(--text-3); }
.res-run-delta {
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  text-align: right;
}
.res-run-delta.pos { color: var(--red); }
.res-run-delta.best { color: var(--green); }
.res-run-info {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.res-run-pilot { font-weight: 600; color: var(--text-2); font-size: 13px; }
.res-run-date { font-size: 11px; color: var(--text-4); }
.res-run-method {
  font-size: 11px; padding: 2px 6px; border-radius: 3px;
  background: var(--surface3); color: var(--text-3);
  display: inline-block; width: fit-content;
}
.res-run-del {
  background: none; border: none; color: var(--text-4); cursor: pointer;
  font-size: 16px; padding: 4px; border-radius: 4px; line-height: 1;
}
.res-run-del:hover { color: var(--red); background: var(--red-light); }
.res-stage-empty {
  padding: 18px 16px; color: var(--text-4); font-size: 13px; font-style: italic;
}

/* ══════════════ STAGE GPS / COORDS ══════════════ */
.fl-opt { font-weight: 400; color: var(--text-4); font-size: 11px; }
.fl-sm { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.ms-gps-block {
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.ms-method-tabs { display: flex; gap: 6px; margin: 8px 0 12px; }
.ms-method-tab {
  flex: 1; padding: 8px 6px; font-size: 12px; font-weight: 600;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 7px; cursor: pointer; color: var(--text-3);
  font-family: inherit; transition: all .12s;
}
.ms-method-tab.active { background: var(--blue-lt); border-color: var(--blue); color: var(--blue); }
.ms-method-panel { margin-bottom: 8px; }
.ms-gps-status {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--surface2); border-radius: 7px;
  font-size: 13px; margin-bottom: 10px;
}
.ms-gps-dot { width: 9px; height: 9px; border-radius: 50%; background: #999; flex-shrink: 0; }
.ms-gps-status.active .ms-gps-dot { background: #2ecc71; box-shadow: 0 0 6px rgba(46,204,113,.6); }
.ms-gps-status.searching .ms-gps-dot { background: var(--orange); animation: pulse 1s infinite; }
.ms-gps-acc { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }
.ms-gps-mark-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ms-mark-btn {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; font-size: 14px; font-weight: 600;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 8px; cursor: pointer; color: var(--text); font-family: inherit;
  transition: all .12s;
}
.ms-mark-btn:hover { border-color: var(--blue); }
.ms-mark-num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--blue);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; flex-shrink: 0;
}
.ms-mark-state { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); min-width: 70px; }
.ms-mark-state.set { color: #16a34a; font-weight: 700; }
.ms-coord-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.ms-use-gps-btn { width: 100%; font-size: 13px; }
.ms-radius-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.ms-radius-control { display: flex; align-items: center; gap: 6px; }

/* ══════════════ CREW (PILOTOS Y COPILOTOS) ══════════════ */
.crew-wrap { flex: 1; overflow-y: auto; padding: 20px; -webkit-overflow-scrolling: touch; max-width: 920px; margin: 0 auto; width: 100%; align-self: center; }
.crew-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.crew-tab {
  padding: 8px 16px; font-size: 14px; font-weight: 600;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 8px; cursor: pointer; color: var(--text-3); font-family: inherit;
}
.crew-tab.active { background: #fef3f2; border-color: #ea580c; color: #c2410c; }
.crew-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.crew-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 8px; transition: all .15s;
}
.crew-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); border-color: #ea580c; }
.crew-card-photo {
  width: 80px; height: 80px; border-radius: 50%; overflow: hidden;
  background: var(--surface3); display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: var(--text-4);
}
.crew-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.crew-card-name { font-weight: 700; font-size: 16px; color: var(--text); line-height: 1.2; }
.crew-card-type { font-size: 12px; padding: 2px 10px; border-radius: 20px; font-weight: 600; }
.crew-card-type.pilot { background: #fef3f2; color: #c2410c; }
.crew-card-type.codriver { background: var(--blue-lt); color: var(--blue); }
.crew-card-sub { font-size: 12px; color: var(--text-4); }
.crew-card-badges { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; margin-top: 2px; }
.crew-badge { font-size: 10px; padding: 2px 7px; border-radius: 4px; font-weight: 600; }
.crew-badge.ok { background: #dcfce7; color: #15803d; }
.crew-badge.warn { background: #fef9c3; color: #a16207; }
.crew-badge.exp { background: var(--red-light); color: var(--red); }
.crew-empty { grid-column: 1/-1; text-align: center; padding: 60px 20px; color: var(--text-3); }
.crew-empty .eh-icon { font-size: 48px; margin-bottom: 12px; }

/* Crew detail */
.crew-detail { flex: 1; overflow-y: auto; padding: 20px; max-width: 820px; margin: 0 auto; width: 100%; align-self: center; -webkit-overflow-scrolling: touch; }
.crew-detail-back { background: none; border: none; color: var(--text-3); font-size: 14px; cursor: pointer; padding: 4px 0; margin-bottom: 12px; }
.crew-detail-head { display: flex; gap: 18px; align-items: center; margin-bottom: 20px; }
.crew-detail-photo {
  width: 110px; height: 110px; border-radius: 14px; overflow: hidden; flex-shrink: 0;
  background: var(--surface3); display: flex; align-items: center; justify-content: center;
  font-size: 44px; color: var(--text-4);
}
.crew-detail-photo img { width: 100%; height: 100%; object-fit: cover; }
.crew-detail-name { font-family: var(--font-cond); font-weight: 800; font-size: 26px; color: var(--text); line-height: 1.1; }
.crew-detail-type { font-size: 14px; color: var(--text-3); margin: 4px 0 12px; }
.crew-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crew-detail-data {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; margin-bottom: 24px;
}
.crew-data-item { background: var(--surface); padding: 12px 14px; }
.crew-data-label { font-size: 11px; color: var(--text-4); text-transform: uppercase; letter-spacing: .5px; }
.crew-data-value { font-size: 15px; color: var(--text); font-weight: 500; margin-top: 2px; }

/* Documents */
.crew-docs-section { margin-top: 10px; }
.crew-docs-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.crew-docs-head h3 { font-family: var(--font-cond); font-weight: 800; font-size: 18px; color: var(--text); }
.crew-docs-list { display: flex; flex-direction: column; gap: 10px; }
.doc-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px;
}
.doc-icon { font-size: 26px; flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; }
.doc-title { font-weight: 700; font-size: 15px; color: var(--text); }
.doc-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.doc-expiry { font-size: 12px; font-weight: 600; margin-top: 3px; }
.doc-expiry.ok { color: #15803d; }
.doc-expiry.warn { color: #a16207; }
.doc-expiry.exp { color: var(--red); }
.doc-actions { display: flex; gap: 6px; flex-shrink: 0; }
.doc-btn { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.doc-btn:hover { background: var(--surface3); }
.doc-btn.del:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }
.crew-docs-empty { padding: 24px; text-align: center; color: var(--text-4); font-size: 13px; background: var(--surface2); border-radius: 10px; }

/* Crew modal */
.modal-crew, .modal-doc { max-width: 560px; }
.crew-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.crew-photo-edit { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.crew-photo-preview {
  width: 90px; height: 90px; border-radius: 12px; overflow: hidden; flex-shrink: 0;
  background: var(--surface3); display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: var(--text-4);
}
.crew-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.crew-photo-actions { display: flex; flex-direction: column; gap: 8px; }
.crew-photo-btn { cursor: pointer; display: inline-block; text-align: center; }
.crew-license-block, .crew-block-title { margin-top: 4px; }
.crew-block-title { font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 1px; margin: 12px 0 8px; }
.doc-file-edit { display: flex; align-items: center; gap: 12px; }
.doc-file-btn { cursor: pointer; }
.doc-file-name { font-size: 13px; color: var(--text-3); }

@media (max-width: 560px) {
  .crew-form-grid { grid-template-columns: 1fr; }
  .crew-detail-data { grid-template-columns: 1fr; }
}

/* ══════════════ CONFIGURACIÓN ══════════════ */
.cfg-wrap {
  flex: 1; overflow-y: auto; padding: 20px;
  -webkit-overflow-scrolling: touch;
  max-width: 720px; margin: 0 auto; width: 100%; align-self: center;
  display: flex; flex-direction: column; gap: 18px;
}
.cfg-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 20px;
}
.cfg-section-title {
  font-family: var(--font-cond); font-weight: 800; font-size: 18px;
  color: var(--text); margin-bottom: 14px;
}
.cfg-section-desc { font-size: 13px; color: var(--text-3); margin-bottom: 14px; line-height: 1.5; }
.cfg-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-top: 1px solid var(--border);
}
.cfg-row:first-of-type { border-top: none; }
.cfg-label { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.cfg-name { font-size: 15px; font-weight: 600; color: var(--text); }
.cfg-help { font-size: 12px; color: var(--text-4); line-height: 1.4; }
.cfg-control { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cfg-input { width: 90px; text-align: center; }
.cfg-unit { font-size: 13px; color: var(--text-3); }
.cfg-info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--border); font-size: 14px;
  color: var(--text-3);
}
.cfg-info-row:first-of-type { border-top: none; }
.cfg-info-row strong { color: var(--text); font-weight: 600; }
.cfg-link { color: var(--red); text-decoration: none; }
.cfg-link:hover { text-decoration: underline; }
.cfg-logout { margin-top: 16px; width: 100%; }
.cfg-sym-btn { margin-top: 12px; width: 100%; }
#cfg-sym-list { max-height: none; }

/* Scale preview */
.scale-preview {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.scale-pv-item {
  display: flex; flex-direction: column; align-items: center;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; min-width: 52px;
}
.scale-pv-num {
  font-family: var(--font-cond); font-weight: 800; font-size: 20px;
  color: var(--text);
}
.scale-pv-deg { font-size: 10px; color: var(--text-4); font-family: var(--font-mono); }

/* ══════════════ RACE PICKER ══════════════ */
.rp-wrap { flex: 1; overflow-y: auto; padding: 24px 20px 80px; -webkit-overflow-scrolling: touch; }
.rp-title { font-family: var(--font-cond); font-weight: 700; font-size: 22px; color: var(--text); text-align: center; margin-bottom: 24px; }
.rp-rally-list { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.rp-rally {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 18px;
  border-left: 4px solid var(--red);
}
.rp-rally-name { font-family: var(--font-cond); font-weight: 800; font-size: 18px; margin-bottom: 8px; }
.rp-stages-list { display: flex; flex-direction: column; gap: 6px; }
.rp-stage {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 8px; cursor: pointer; transition: all .12s;
}
.rp-stage:hover { background: var(--red-light); border-color: var(--red); }
.rp-stage-name { flex: 1; font-family: var(--font-cond); font-weight: 600; font-size: 15px; }
.rp-stage-meta { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }
.rp-stage-go { color: var(--red); font-weight: 700; font-size: 16px; }
.rp-no-notes { font-size: 11px; color: var(--text-4); padding: 8px 12px; font-style: italic; }
.rp-empty { text-align: center; padding: 60px 20px; color: var(--text-3); }
.rp-empty .eh-icon { font-size: 48px; margin-bottom: 12px; opacity: .4; }
.rp-empty p { font-family: var(--font-cond); font-size: 14px; letter-spacing: 1px; text-transform: uppercase; }

.admin-wrap { flex: 1; overflow-y: auto; padding: 20px; -webkit-overflow-scrolling: touch; max-width: 1000px; margin: 0 auto; width: 100%; }

/* ══════════════ HUB CARDS — Pilot variant ══════════════ */
.hub-card-pilot .hc-icon {
  background: #f0fdf4;
  color: #15803d;
}
.hub-card-pilot::after { background: #16a34a !important; }
.hub-card-pilot:hover { border-color: #16a34a !important; }
.hub-card-pilot .hc-cta { color: #16a34a !important; }

.hub-card-config .hc-icon { background: #f1f5f9; color: #475569; }
.hub-card-config::after { background: #64748b !important; }
.hub-card-config:hover { border-color: #64748b !important; }
.hub-card-config .hc-cta { color: #64748b !important; }

.hub-card-crew .hc-icon { background: #fef3f2; color: #c2410c; }
.hub-card-crew::after { background: #ea580c !important; }
.hub-card-crew:hover { border-color: #ea580c !important; }
.hub-card-crew .hc-cta { color: #ea580c !important; }

.hub-card-rallies .hc-icon { background: #eff6ff; color: #1d4ed8; }
.hub-card-rallies::after { background: #2563eb !important; }
.hub-card-rallies:hover { border-color: #2563eb !important; }
.hub-card-rallies .hc-cta { color: #2563eb !important; }

.hub-card-tools .hc-icon { background: #f5f3ff; color: #7c3aed; }
.hub-card-tools::after { background: #7c3aed !important; }
.hub-card-tools:hover { border-color: #7c3aed !important; }
.hub-card-tools .hc-cta { color: #7c3aed !important; }

/* ══════════════ HERRAMIENTAS DE COPILOTO ══════════════ */
.tools-wrap { flex: 1; overflow-y: auto; padding: 20px; -webkit-overflow-scrolling: touch; max-width: 720px; margin: 0 auto; width: 100%; align-self: center; }
.tools-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tools-tab {
  flex: 1; padding: 10px 16px; font-size: 14px; font-weight: 600;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 8px; cursor: pointer; color: var(--text-3); font-family: inherit;
}
.tools-tab.active { background: #f5f3ff; border-color: #7c3aed; color: #6d28d9; }
.tools-help { font-size: 13px; color: var(--text-3); margin-bottom: 16px; line-height: 1.5; }

/* Schedule */
.sched-now { text-align: center; margin-bottom: 14px; }
.sched-now-lbl { font-size: 11px; letter-spacing: 1.5px; color: var(--text-4); text-transform: uppercase; }
.sched-now-clock { font-family: var(--font-mono); font-size: 28px; font-weight: 700; color: var(--text); }
.sched-next {
  text-align: center; background: linear-gradient(135deg, #6d28d9, #4f46e5);
  color: #fff; border-radius: 14px; padding: 18px; margin-bottom: 20px;
}
.sched-next-lbl { font-size: 12px; letter-spacing: 1px; opacity: .9; text-transform: uppercase; }
.sched-next-time { font-family: var(--font-cond); font-size: 22px; font-weight: 700; margin-top: 2px; }
.sched-countdown { font-family: var(--font-mono); font-size: 44px; font-weight: 800; line-height: 1.1; margin-top: 6px; }
.sched-countdown.imminent { color: #fde047; animation: pulse 1s infinite; }
.sched-countdown-lbl { font-size: 11px; opacity: .85; text-transform: uppercase; letter-spacing: 1px; }
.sched-list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sched-list-head h3 { font-family: var(--font-cond); font-weight: 800; font-size: 16px; }
.sched-list { display: flex; flex-direction: column; gap: 8px; }
.sched-row { display: flex; gap: 8px; align-items: center; }
.sched-name { flex: 1; }
.sched-time { width: 130px; flex-shrink: 0; }
.sched-del { width: 36px; height: 38px; flex-shrink: 0; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; color: var(--text-3); }
.sched-del:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }
.sched-empty { padding: 24px; text-align: center; color: var(--text-4); font-size: 13px; background: var(--surface2); border-radius: 10px; }
.sched-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.sched-saved-note { font-size: 12px; color: var(--text-4); }

/* Fuel */
.fuel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.fuel-section { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.fuel-section-title { font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.fuel-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.fuel-result { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.fuel-result-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; color: var(--text-2); border-bottom: 1px solid var(--border2); }
.fuel-result-row b { color: var(--text); font-family: var(--font-mono); }
.fuel-result-row.total { font-size: 16px; font-weight: 700; border-bottom: none; }
.fuel-result-row.total b { color: #7c3aed; font-size: 18px; }
.fuel-result-row.need { background: #f5f3ff; margin: 6px -16px -16px; padding: 12px 16px; border-radius: 0 0 12px 12px; }
.fuel-result-row.need b { color: #6d28d9; font-size: 18px; }
@media (max-width: 560px) {
  .fuel-grid, .fuel-extra { grid-template-columns: 1fr; }
}

/* ══════════════ RALLY & STAGE MANAGER ══════════════ */
.rmgr-wrap, .rmgr-detail {
  flex: 1; overflow-y: auto; padding: 20px;
  -webkit-overflow-scrolling: touch;
  max-width: 820px; margin: 0 auto; width: 100%; align-self: center;
}
.rmgr-rally-list { display: flex; flex-direction: column; gap: 12px; }
.rmgr-rally-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px; cursor: pointer;
  display: flex; align-items: center; gap: 14px; transition: all .15s;
}
.rmgr-rally-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); border-color: #2563eb; }
.rmgr-rc-flag { font-size: 26px; flex-shrink: 0; }
.rmgr-rc-info { flex: 1; min-width: 0; }
.rmgr-rc-name { font-weight: 700; font-size: 17px; color: var(--text); }
.rmgr-rc-meta { font-size: 13px; color: var(--text-3); margin-top: 2px; display: flex; gap: 12px; flex-wrap: wrap; }
.rmgr-rc-count {
  font-family: var(--font-cond); font-weight: 800; font-size: 14px;
  color: #2563eb; background: #eff6ff; padding: 4px 12px; border-radius: 20px;
  flex-shrink: 0;
}
.rmgr-empty { text-align: center; padding: 60px 20px; color: var(--text-3); }
.rmgr-empty .eh-icon { font-size: 48px; margin-bottom: 12px; }

.rmgr-detail-back { background: none; border: none; color: var(--text-3); font-size: 14px; cursor: pointer; padding: 4px 0; margin-bottom: 12px; }
.rmgr-detail-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 14px; margin-bottom: 22px; flex-wrap: wrap;
}
.rmgr-detail-name { font-family: var(--font-cond); font-weight: 800; font-size: 26px; color: var(--text); line-height: 1.1; }
.rmgr-detail-meta { font-size: 14px; color: var(--text-3); margin-top: 4px; }
.rmgr-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rmgr-stages-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.rmgr-stages-head h3 { font-family: var(--font-cond); font-weight: 800; font-size: 18px; color: var(--text); }
.rmgr-stages-tools { display: flex; align-items: center; gap: 10px; }
.rmgr-view-toggle { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.rmgr-vt-btn { width: 36px; height: 36px; background: var(--surface2); border: none; cursor: pointer; font-size: 15px; color: var(--text-3); }
.rmgr-vt-btn.active { background: #2563eb; color: #fff; }
.rmgr-stage-list { display: flex; flex-direction: column; gap: 10px; }
.rmgr-stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.rmgr-grid-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; cursor: pointer; transition: all .15s; position: relative;
  display: flex; flex-direction: column; gap: 6px;
}
.rmgr-grid-card:hover { border-color: #2563eb; box-shadow: 0 4px 14px rgba(0,0,0,.08); transform: translateY(-2px); }
.rmgr-grid-num {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px;
  background: #2563eb; color: #fff; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-cond); font-weight: 800; font-size: 12px;
}
.rmgr-grid-preview {
  height: 70px; overflow: hidden; font-size: 11px; line-height: 1.4;
  color: var(--text-2); background: var(--surface2); border-radius: 6px;
  padding: 8px; font-family: var(--font-mono);
}
.rmgr-grid-preview.empty { color: var(--text-4); font-style: italic; display: flex; align-items: center; justify-content: center; font-family: inherit; }
.rmgr-grid-imgtag { font-size: 10px; color: #7c3aed; margin-top: 4px; }
.rmgr-grid-imgtag.ink { color: var(--red); }
.rmgr-grid-name { font-weight: 700; font-size: 13px; color: var(--text); line-height: 1.2; }
.rmgr-grid-meta { font-size: 11px; color: var(--text-4); }
.rmgr-grid-actions { display: flex; gap: 3px; margin-top: 2px; }
.rmgr-grid-actions .rmgr-st-btn { width: 26px; height: 26px; font-size: 11px; }
.rmgr-stage-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
}
.rmgr-st-num {
  width: 30px; height: 30px; flex-shrink: 0;
  background: var(--surface3); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-cond); font-weight: 800; font-size: 14px; color: var(--text-2);
}
.rmgr-st-info { flex: 1; min-width: 0; }
.rmgr-st-name { font-weight: 700; font-size: 15px; color: var(--text); }
.rmgr-st-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.rmgr-st-gps { color: #16a34a; }
.rmgr-st-nogps { color: var(--text-4); }
.rmgr-st-actions { display: flex; gap: 4px; flex-shrink: 0; }
.rmgr-st-btn {
  width: 30px; height: 30px; padding: 0;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.rmgr-st-btn:hover { background: var(--surface3); color: var(--text); }
.rmgr-st-btn:disabled { opacity: .3; cursor: default; }
.rmgr-st-btn.del:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }
.rmgr-stage-empty { padding: 30px; text-align: center; color: var(--text-4); font-size: 13px; background: var(--surface2); border-radius: 10px; }
@media (max-width: 560px) {
  .rmgr-st-meta { display: none; }
}

/* ══════════════ PILOT PICKER ══════════════ */
.pp-help {
  max-width: 720px; margin: 0 auto 20px; padding: 12px 16px;
  background: var(--blue-lt); border: 1px solid var(--blue);
  border-radius: 8px; color: var(--text-2);
  font-size: 13px; line-height: 1.5;
  display: flex; gap: 10px; align-items: flex-start;
}
.pp-help-icon { color: var(--blue); font-weight: bold; flex-shrink: 0; }

/* ══════════════ PILOT HUD ══════════════ */
#view-pilot {
  background: #0e1117;
  color: #e8eaf0;
  flex-direction: column !important;
  overflow: hidden !important;
}

/* If we can't lock to landscape and the user is in portrait, show overlay */
.pilot-rotate-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  background: #0e1117;
  color: #fff;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; text-align: center; padding: 40px;
}
.pilot-rotate-icon {
  width: 64px; height: 100px;
  border: 3px solid #fff; border-radius: 10px;
  position: relative;
  animation: rotPhone 2s ease-in-out infinite;
}
.pilot-rotate-icon::before {
  content: ''; position: absolute;
  top: 8px; left: 50%; transform: translateX(-50%);
  width: 30px; height: 4px;
  background: rgba(255,255,255,0.4); border-radius: 2px;
}
@keyframes rotPhone {
  0%, 50% { transform: rotate(0deg); }
  75%, 100% { transform: rotate(-90deg); }
}
.pilot-rotate-msg {
  font-family: var(--font-cond);
  font-size: 18px; letter-spacing: 1.5px;
  text-transform: uppercase;
}
.pilot-rotate-sub {
  font-size: 13px; color: #8a909c; max-width: 320px; line-height: 1.5;
}
.pilot-rotate-force {
  margin-top: 8px;
  background: #16a34a; color: #fff; border: none;
  padding: 14px 24px; border-radius: 10px;
  font-family: var(--font-cond); font-weight: 800; font-size: 16px;
  letter-spacing: 1px; cursor: pointer;
}
.pilot-rotate-force:hover { background: #15803d; }
.pilot-rotate-tip {
  font-size: 12px; color: #6b7280; max-width: 340px; line-height: 1.5;
  margin-top: 4px;
}
.pilot-rotate-tip strong { color: #aab; }

/* Show overlay only when in pilot view AND portrait AND not already forced landscape */
@media (orientation: portrait) {
  body.in-pilot:not(.pilot-force-landscape) .pilot-rotate-overlay { display: flex; }
}
/* In the native app the OS locks orientation, so never show the manual rotate overlay */
body.is-native .pilot-rotate-overlay { display: none !important; }

/* ── FORCE LANDSCAPE (iOS fallback) ──────────────────────────────
   When the device can't auto-rotate (iOS rotation lock on), rotate the
   whole recce view 90° so it fills the portrait viewport in landscape.
   We swap width/height (use dynamic viewport units so the browser address
   bar doesn't leave a gap) and pin to the corner. */
body.pilot-force-landscape { overflow: hidden; }
body.pilot-force-landscape #view-pilot,
body.pilot-force-landscape #view-autorecce {
  position: fixed;
  top: 0; left: 0;
  /* width / height / margin-left are set in JS to the exact visible pixels
     (via visualViewport) so the browser toolbar never leaves a gap. */
  width: 100dvh;   /* fallback before JS measures */
  height: 100dvw;
  margin-left: 100dvw;
  transform: rotate(90deg);
  transform-origin: top left;
  background: #0e1117;
  z-index: 9998;
  overflow: hidden;
}
/* Solid backdrop behind the rotated view so nothing (header/other views)
   ever shows through the browser-chrome gap. */
body.pilot-force-landscape::before {
  content: '';
  position: fixed; inset: 0;
  background: #0e1117;
  z-index: 9997;
}
/* Hide the rotate overlay once forced */
body.pilot-force-landscape .pilot-rotate-overlay { display: none !important; }
/* Inside forced landscape, size the compass against the rotated viewport
   (width is 100dvh, height is 100dvw because the container is rotated). */
body.pilot-force-landscape .compass {
  width: min(58dvw, 100%, 420px);
  max-height: calc(100dvw - 160px);
}

.pilot-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: #15191f;
  border-bottom: 1px solid #2a2f3a;
  flex-shrink: 0;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
.pilot-back {
  background: transparent; border: 1px solid #2a2f3a;
  color: #aab; padding: 7px 14px; border-radius: 6px;
  font-family: var(--font-cond); font-weight: 700; font-size: 13px;
  letter-spacing: .5px; cursor: pointer;
}
.pilot-back:hover { color: #fff; border-color: #16a34a; }
.pilot-stage-info { flex: 1; min-width: 0; }
.pilot-rally-name {
  font-size: 10px; color: #6b7280;
  letter-spacing: 1.5px; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pilot-stage-name {
  font-family: var(--font-cond); font-weight: 800; font-size: 18px;
  color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pilot-status { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.pilot-status-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-family: var(--font-mono);
  color: #6b7280; text-transform: uppercase;
}
.ps-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: #6b7280;
}
.pilot-status-item.ok .ps-dot { background: #16a34a; box-shadow: 0 0 6px #16a34a; }
.pilot-status-item.warn .ps-dot { background: #f5a623; }
.pilot-status-item.err .ps-dot { background: #e8341a; }
.pilot-status-item.ok { color: #16a34a; }
.pilot-status-item.warn { color: #f5a623; }
.pilot-status-item.err { color: #e8341a; }
.pilot-settings-btn {
  width: 34px; height: 34px;
  background: #1f2530; border: 1px solid #2a2f3a;
  color: #aab; border-radius: 6px;
  font-size: 16px; cursor: pointer;
}
.pilot-settings-btn:hover { color: #fff; border-color: #16a34a; }
.pilot-recal-top {
  background: #1f2530; border: 1px solid #f5a623; color: #f5a623;
  padding: 7px 12px; border-radius: 6px;
  font-family: var(--font-cond); font-weight: 800; font-size: 13px;
  letter-spacing: .5px; cursor: pointer; white-space: nowrap;
}
.pilot-recal-top:hover { background: #f5a623; color: #0e1117; }
.pilot-finish-top {
  background: #16a34a; border: 1px solid #16a34a; color: #fff;
  padding: 7px 14px; border-radius: 6px;
  font-family: var(--font-cond); font-weight: 800; font-size: 13px;
  letter-spacing: .5px; cursor: pointer; white-space: nowrap;
}
.pilot-finish-top:hover { background: #15803d; }
.pilot-voice-btn {
  width: 34px; height: 34px;
  background: #1f2530; border: 1px solid #2a2f3a;
  color: #aab; border-radius: 6px;
  font-size: 16px; cursor: pointer;
}
.pilot-voice-btn:hover { color: #fff; border-color: #6cc9ff; }
.pilot-voice-btn.active {
  background: #6cc9ff; color: #0e1117; border-color: #6cc9ff;
  animation: voicePulse 1.4s ease-in-out infinite;
}
@keyframes voicePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(108,201,255,.5); }
  50%     { box-shadow: 0 0 0 8px rgba(108,201,255,0); }
}
.pilot-voice-status {
  display: flex; align-items: center; gap: 8px;
  background: #15191f; border: 1px solid #2a3a4a;
  border-radius: 8px; padding: 6px 12px;
  font-size: 13px; color: #6cc9ff;
}
.pvs-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #6cc9ff; box-shadow: 0 0 6px #6cc9ff;
  animation: voicePulse 1.4s ease-in-out infinite;
}
.pvs-text { font-family: var(--font-cond); font-weight: 600; letter-spacing: .5px; }
.pilot-voice-status.heard { border-color: #16a34a; color: #6ee89a; }
.pilot-voice-status.heard .pvs-dot { background: #16a34a; box-shadow: 0 0 6px #16a34a; }

/* MAIN HUD layout: 3 columns */
.pilot-hud {
  flex: 1;
  display: grid;
  grid-template-columns: 140px 1fr 160px;
  gap: 12px;
  padding: 14px;
  overflow: hidden;
  min-height: 0;
}

/* LEFT column */
.pilot-left, .pilot-right {
  display: flex; flex-direction: column;
  gap: 10px;
}
.pilot-info-block {
  background: #15191f;
  border: 1px solid #2a2f3a;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
}
.pii-label {
  font-size: 10px; font-family: var(--font-mono);
  letter-spacing: 1.5px; text-transform: uppercase;
  color: #6b7280;
}
.pii-value {
  font-family: var(--font-cond); font-weight: 800;
  font-size: 26px; color: #fff; line-height: 1.1;
  margin-top: 4px;
}
.pii-value.pii-large { font-size: 44px; }

/* Alerta de exceso de velocidad en recce */
.pilot-info-block.speed-over {
  background: #3a1410;
  border-color: var(--red);
  animation: speed-over-pulse .6s ease-in-out infinite;
}
.pilot-info-block.speed-over .pii-value,
.pilot-info-block.speed-over .pii-label,
.pilot-info-block.speed-over .pii-sub { color: #ff6b5a; }
@keyframes speed-over-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,52,26,.6); }
  50% { box-shadow: 0 0 0 6px rgba(232,52,26,0); }
}
.pii-sub {
  font-size: 11px; color: #6b7280;
  font-family: var(--font-mono); letter-spacing: 1px;
}
.pilot-info-recalibrate { padding: 6px; }
.pilot-recal-btn {
  width: 100%;
  background: #1f2530; border: 1px solid #2a2f3a;
  color: #f5a623;
  padding: 9px 6px; border-radius: 6px;
  font-family: var(--font-cond); font-weight: 700; font-size: 12px;
  letter-spacing: 1px; cursor: pointer;
}
.pilot-recal-btn:hover { border-color: #f5a623; }

/* CENTER: compass + action buttons */
.pilot-center {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  min-height: 0;
}

.compass {
  position: relative;
  width: min(58vh, 100%, 420px);
  aspect-ratio: 1;
  max-height: calc(100vh - 230px);
  border-radius: 50%;
  background: radial-gradient(circle at center, #1c2128 0%, #0e1117 90%);
  border: 2px solid #2a2f3a;
  flex-shrink: 0;
  user-select: none; -webkit-user-select: none;
}

/* Outer ring with degree marks — rotates */
.compass-face {
  position: absolute; inset: 8px;
  border-radius: 50%;
  transition: transform 0.05s linear; /* smooth but responsive */
}
.compass-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1px solid #2a2f3a;
  background:
    radial-gradient(circle at center, transparent 70%, #1a1f27 70%, #1a1f27 73%, transparent 73%);
}
.compass-marks {
  position: absolute; inset: 0;
  /* the marks are drawn via inline SVG by JS */
}
.compass-marks svg { width: 100%; height: 100%; display: block; }

/* Fixed pointer at top — does NOT rotate */
.compass-pointer {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 24px solid #16a34a;
  filter: drop-shadow(0 2px 4px rgba(22,163,74,.6));
  z-index: 3;
}

/* Center content of compass — direction letter + note number + delta */
.compass-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 2;
}
.compass-dir {
  font-family: var(--font-cond); font-weight: 900;
  font-size: clamp(28px, 8vh, 56px);
  color: #6b7280;
  line-height: 1; letter-spacing: 2px;
  transition: color .15s;
}
.compass-dir.left  { color: #6cc9ff; }
.compass-dir.right { color: #f5a623; }
.compass-note {
  font-family: var(--font-cond); font-weight: 900;
  font-size: clamp(54px, 16vh, 130px);
  color: #fff; line-height: 1;
  margin: 4px 0;
  font-feature-settings: 'tnum';
  letter-spacing: -2px;
}
/* When showing 10 (straight) use a softer color */
.compass-note.detecting {
  color: #f5a623;
  text-shadow: 0 0 20px rgba(245,166,35,.6);
}
.compass-delta {
  font-family: var(--font-mono);
  font-size: clamp(11px, 2vh, 16px);
  color: #6b7280; letter-spacing: 1px;
}

/* Action buttons under the compass */
.pilot-actions {
  display: flex; gap: 10px;
  flex-wrap: wrap; justify-content: center;
}
.pilot-action-btn {
  padding: 12px 22px;
  border: 2px solid;
  border-radius: 8px;
  font-family: var(--font-cond); font-weight: 800;
  font-size: 14px; letter-spacing: 1px;
  cursor: pointer; transition: all .15s;
  text-transform: uppercase;
  background: transparent;
}
.pilot-mark-start {
  border-color: #f5a623; color: #f5a623;
}
.pilot-mark-start:hover, .pilot-mark-start.recording {
  background: #f5a623; color: #0e1117;
}
.pilot-mark-start.recording {
  animation: recordPulse 1.2s ease-in-out infinite;
}
@keyframes recordPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(245,166,35,.5); }
  50%     { box-shadow: 0 0 0 12px rgba(245,166,35,0); }
}
.pilot-mark-confirm {
  border-color: #16a34a; color: #16a34a;
}
.pilot-mark-confirm:hover:not(:disabled) {
  background: #16a34a; color: #0e1117;
}
.pilot-mark-confirm:disabled {
  opacity: 0.4; cursor: not-allowed;
}

/* RIGHT column: trip blocks */
.trip-block {
  background: #15191f;
  border: 1px solid #2a2f3a;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
  position: relative;
}
.trip-block.trip-curve {
  border-color: #e8341a; background: #1d1110;
}
.trip-label {
  font-size: 10px; font-family: var(--font-mono);
  letter-spacing: 1.5px; text-transform: uppercase;
  color: #6b7280;
}
.trip-curve .trip-label { color: #e8341a; }
.trip-value {
  font-family: var(--font-mono); font-weight: 700;
  font-size: 26px; color: #fff; line-height: 1.1;
  margin-top: 4px;
}
.trip-curve .trip-value { color: #ff5e3e; font-size: 30px; }
.trip-unit { font-size: 11px; color: #6b7280; font-family: var(--font-mono); }
.trip-reset {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px;
  background: transparent; border: none;
  color: #6b7280; cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
}
.trip-reset:hover { color: #fff; background: #2a2f3a; }

/* BOTTOM timeline */
.pilot-timeline {
  flex-shrink: 0;
  background: #15191f;
  border-top: 1px solid #2a2f3a;
  padding: 6px 14px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 12px;
}
.pilot-timeline-label {
  font-size: 10px; font-family: var(--font-mono);
  letter-spacing: 1.5px; text-transform: uppercase;
  color: #6b7280; flex-shrink: 0;
}
.pilot-timeline-list {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 2px 0; flex: 1;
  -webkit-overflow-scrolling: touch;
  min-height: 34px; align-items: center;
}
.pilot-timeline-list::-webkit-scrollbar { height: 4px; }
.ptl-item {
  flex-shrink: 0;
  padding: 6px 10px;
  background: #1f2530;
  border: 1px solid #2a2f3a;
  border-left: 3px solid #6b7280;
  border-radius: 6px;
  font-family: var(--font-cond); font-weight: 700;
  font-size: 13px;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.ptl-item.left { border-left-color: #6cc9ff; }
.ptl-item.right { border-left-color: #f5a623; }
.ptl-item .ptl-dist {
  font-family: var(--font-mono); font-size: 10px;
  color: #6b7280;
}
.ptl-item .ptl-del {
  margin-left: 4px; color: #e8341a;
  font-size: 12px; padding: 0 2px;
}
.ptl-item .ptl-del:hover { color: #ff5e3e; }
.ptl-empty {
  color: #6b7280; font-size: 12px;
  font-style: italic; padding: 10px;
}

.pilot-finish-btn {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  background: #16a34a; color: #fff;
  border: none; border-radius: 8px;
  font-family: var(--font-cond); font-weight: 800;
  font-size: 14px; letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
}
.pilot-finish-btn:hover { background: #15803d; }
.pilot-finish-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* First-use calibration overlay */
.pilot-calib-overlay {
  position: absolute; inset: 0; z-index: 60;
  background: rgba(14,17,23,0.96);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.pilot-calib-box {
  max-width: 460px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.pilot-calib-icon {
  font-size: 54px; color: #f5a623; line-height: 1;
}
.pilot-calib-title {
  font-family: var(--font-cond); font-weight: 800; font-size: 24px;
  color: #fff; letter-spacing: 1px;
}
.pilot-calib-text {
  font-size: 14px; color: #aab; line-height: 1.6;
}
.pilot-calib-text strong { color: #fff; }
.pilot-calib-btn {
  background: #f5a623; color: #0e1117; border: none;
  padding: 14px 24px; border-radius: 10px;
  font-family: var(--font-cond); font-weight: 800; font-size: 16px;
  letter-spacing: 1px; cursor: pointer; margin-top: 6px;
}
.pilot-calib-btn:hover { background: #ffb83a; }
.pilot-calib-skip {
  background: transparent; border: none; color: #6b7280;
  font-size: 13px; cursor: pointer; text-decoration: underline;
}
.pilot-calib-skip:hover { color: #aab; }

/* Landscape optimizations: keep everything visible without scrolling */
@media (orientation: landscape) and (max-height: 520px) {
  .pilot-topbar { padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top, 0px)); }
  .pilot-stage-name { font-size: 15px; }
  .pilot-hud { padding: 8px 12px; gap: 8px; grid-template-columns: 120px 1fr 130px; }
  .compass { max-height: calc(100vh - 170px); }
  .pii-value.pii-large { font-size: 34px; }
  .pii-value { font-size: 20px; }
  .trip-value { font-size: 20px; }
  .trip-curve .trip-value { font-size: 22px; }
  .pilot-info-block, .trip-block { padding: 7px 10px; }
  .pilot-actions { gap: 8px; }
  .pilot-action-btn { padding: 9px 16px; font-size: 13px; }
  .pilot-timeline { padding: 4px 12px; }
  .pilot-timeline-list { min-height: 30px; }
}

/* Form helper text */
.fl-help {
  font-size: 11px; color: var(--text-3);
  margin-top: 4px; margin-bottom: 8px;
  line-height: 1.4;
}

/* Mobile responsive */
@media (max-width: 700px) {
  .pilot-hud {
    grid-template-columns: 80px 1fr 100px;
    gap: 6px;
    padding: 8px;
  }
  .pilot-info-block { padding: 6px 4px; }
  .pii-value { font-size: 18px; }
  .pii-value.pii-large { font-size: 28px; }
  .trip-block { padding: 6px; }
  .trip-value { font-size: 18px; }
  .trip-curve .trip-value { font-size: 22px; }
  .pilot-action-btn { padding: 10px 14px; font-size: 12px; }
  .compass { max-height: calc(100vh - 240px); }
}

/* Landscape orientation hint */
@media (max-height: 500px) and (orientation: landscape) {
  .compass { max-height: calc(100vh - 180px); }
  .pilot-timeline { padding: 4px 12px; }
  .pilot-finish-btn { padding: 8px; font-size: 12px; }
}

/* ══════════════ TOP BAR ══════════════ */
#topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 2px solid var(--red);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; flex-shrink: 0; z-index: 50; position: relative;
}
.tb-menu {
  display: flex; flex-direction: column; justify-content: center; gap: 5px;
  width: 36px; height: 36px; padding: 7px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  flex-shrink: 0; transition: all .15s;
}
.tb-menu span { display: block; height: 2px; background: var(--text-2); border-radius: 2px; transition: all .15s; }
.tb-menu:hover { background: var(--surface3); }
.tb-breadcrumb { display: flex; align-items: center; gap: 6px; overflow: hidden; flex: 1; }
.tb-logo { font-family: var(--font-cond); font-weight: 900; font-size: 20px; color: var(--text); white-space: nowrap; }
.tb-logo em { font-style: normal; color: var(--red); }
.tb-sep { color: var(--text-4); font-size: 16px; }
.tb-crumb { font-family: var(--font-cond); font-size: 15px; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.tb-odo {
  font-family: var(--font-mono); font-size: 13px;
  background: var(--surface2); border: 1px solid var(--border);
  padding: 4px 9px; border-radius: 4px; color: var(--blue); cursor: pointer;
  white-space: nowrap; transition: border-color .15s;
}
.tb-odo:hover { border-color: var(--blue); }
#tb-clock { font-family: var(--font-mono); font-size: 15px; color: var(--text-2); white-space: nowrap; }
.tb-user-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--red); color: white;
  font-family: var(--font-cond); font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity .15s;
}
.tb-user-btn:hover { opacity: .85; }

/* ── USER MENU ── */
.user-menu {
  position: absolute; top: calc(var(--topbar-h) + 4px); right: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; min-width: 180px; padding: 10px 0;
  box-shadow: 0 4px 20px rgba(0,0,0,.12); z-index: 200;
  display: none;
}
.user-menu.open { display: block; }
.um-name { padding: 2px 14px; font-weight: 600; font-size: 14px; }
.um-role { padding: 0 14px 8px; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 1px; }
.um-sep { border: none; border-top: 1px solid var(--border2); margin: 4px 0; }
.um-item { display: block; width: 100%; text-align: left; padding: 8px 14px; font-size: 14px; color: var(--text-2); transition: background .1s; }
.um-item:hover { background: var(--surface2); }

/* ══════════════ SIDEBAR ══════════════ */
#sidebar-ov { display: none; position: fixed; inset: 0; z-index: 58; background: rgba(0,0,0,.3); }
#sidebar-ov.open { display: block; }
#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 59;
  transform: translateX(-100%); transition: transform .25s ease;
  padding-top: calc(var(--topbar-h) + var(--sat));
  padding-bottom: var(--sab);
}
#sidebar.open { transform: translateX(0); }
.sb-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border2);
}
.sb-logo { font-family: var(--font-cond); font-weight: 900; font-size: 20px; }
.sb-logo span { color: var(--red); }
.sb-close { color: var(--text-3); font-size: 18px; padding: 4px 6px; }
.sb-section-label { padding: 10px 14px 4px; font-family: var(--font-cond); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-4); }
.sb-rally-list, .sb-stage-list { overflow-y: auto; }
.sb-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; cursor: pointer; transition: background .1s;
  border-left: 3px solid transparent;
}
.sb-item:hover { background: var(--surface2); }
.sb-item.active { background: #fef2f0; border-left-color: var(--red); }
.sb-item .sb-item-name { font-size: 14px; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-item.active .sb-item-name { color: var(--red); font-weight: 600; }
.sb-item .sb-item-meta { font-size: 11px; color: var(--text-4); white-space: nowrap; }
.sb-item .sb-item-name { cursor: pointer; }
.sb-item-actions {
  display: none; align-items: center; gap: 2px; flex-shrink: 0;
}
.sb-item:hover .sb-item-actions { display: flex; }
.sb-mini {
  width: 24px; height: 24px; padding: 0;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 5px; cursor: pointer; font-size: 11px; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
}
.sb-mini:hover { background: var(--surface3); color: var(--text); }
.sb-mini:disabled { opacity: .3; cursor: default; }
.sb-mini.del:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }
/* On touch devices, actions are always visible (no hover) */
@media (hover: none) {
  .sb-item-actions { display: flex; }
}
.sb-add-btn {
  margin: 6px 10px; padding: 7px 12px;
  background: transparent; border: 1px dashed var(--border);
  border-radius: 6px; color: var(--text-3); font-size: 13px;
  font-family: var(--font-cond); letter-spacing: .5px; text-transform: uppercase;
  transition: all .12s; text-align: center;
}
.sb-add-btn:hover { border-color: var(--red); color: var(--red); background: var(--red-light); }
.sb-footer { margin-top: auto; padding: 10px; }
.sb-footer-btn {
  width: 100%; padding: 11px; border-radius: 6px;
  background: var(--text); color: white;
  font-family: var(--font-cond); font-weight: 700; font-size: 14px;
  letter-spacing: 2px; text-transform: uppercase; transition: all .15s;
}
.sb-footer-btn:hover { background: var(--red); }

/* ══════════════ CONTENT AREA ══════════════ */
#view-app.active { display: flex; flex-direction: column; overflow: hidden; }
#content-area { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.panel { display: none; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; flex-direction: column; }
.panel.active { display: flex; }

/* ── PANEL HEAD ── */
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; flex-wrap: wrap; gap: 10px; flex-shrink: 0;
  border-bottom: 1px solid var(--border2);
}
.ph-sup { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 2px; }
.ph-title { font-family: var(--font-cond); font-weight: 800; font-size: 24px; letter-spacing: .5px; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ph-sub { padding: 0 16px 8px; font-size: 13px; color: var(--text-3); max-width: 720px; }
.rc-pick { font-size: 13px; font-weight: 700; color: var(--red); }

/* ══════════════ HOME / RALLY GRID ══════════════ */
#panel-home { padding: 0; }
.rally-grid { padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.rally-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px;
  cursor: pointer; transition: all .15s;
  border-top: 4px solid var(--red);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.rally-card:hover { border-color: var(--red); box-shadow: 0 4px 16px rgba(0,0,0,.1); transform: translateY(-1px); }
.rc-name { font-family: var(--font-cond); font-weight: 800; font-size: 18px; margin-bottom: 4px; }
.rc-meta { font-size: 12px; color: var(--text-3); display: flex; flex-wrap: wrap; gap: 8px; }
.rc-meta span { display: flex; align-items: center; gap: 3px; }
.rc-timing-link {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 10px;
  font-size: 13px; font-weight: 600; color: var(--red);
  text-decoration: none;
  background: var(--red-light);
  padding: 6px 10px; border-radius: 6px;
  width: fit-content;
  transition: background .12s;
}
.rc-timing-link:hover { background: rgba(232,52,26,0.16); text-decoration: underline; }
.rc-footer { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border2); display: flex; justify-content: space-between; align-items: center; }
.rc-stages { font-size: 12px; color: var(--text-3); }
.rc-actions { display: flex; gap: 6px; }
.empty-home { grid-column: 1/-1; text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-home .eh-icon { font-size: 48px; margin-bottom: 12px; }
.empty-home p { font-family: var(--font-cond); font-size: 14px; letter-spacing: 1px; text-transform: uppercase; }

/* ══════════════ FOCUS MODE — hide chrome for max writing space ══════════════ */

/* ── BIGGER UI FONTS (+2pt baseline) ── */
.nb-rally-name        { font-size: 12px !important; }
.nb-stage-name        { font-size: 20px !important; }
.tb-logo              { font-size: 22px !important; }
.tb-crumb             { font-size: 17px !important; }
.tb-sep               { font-size: 18px !important; }
.sb-logo              { font-size: 22px !important; }
.sb-section-label     { font-size: 12px !important; }
.sb-item-name         { font-size: 16px !important; }
.sb-item-meta         { font-size: 13px !important; }
.hub-welcome-label    { font-size: 15px !important; }
.hub-welcome-name     { font-size: 40px !important; }
.hc-title             { font-size: 28px !important; }
.hc-desc              { font-size: 16px !important; }
.hc-cta               { font-size: 17px !important; }
.login-sub            { font-size: 14px !important; }
.login-logo           { font-size: 44px !important; }
.lc-title             { font-size: 18px !important; }
.fl                   { font-size: 14px !important; }
.fi                   { font-size: 16px !important; }
.btn-primary, .btn-sec, .btn-danger { font-size: 15px !important; }
.icon-btn             { font-size: 16px !important; }
.qb                   { font-size: 15px !important; }
.qb.dir               { font-size: 19px !important; }
.qb-lbl               { font-size: 12px !important; }
.save-status, .nb-counter { font-size: 13px !important; }
.modal-title          { font-size: 20px !important; }
.users-table          { font-size: 16px !important; }
.users-table th       { font-size: 13px !important; }
.role-badge           { font-size: 13px !important; }
.um-name              { font-size: 16px !important; }
.um-role              { font-size: 13px !important; }
.um-item              { font-size: 16px !important; }
.rp-rally-name        { font-size: 20px !important; }
.rp-stage-name        { font-size: 17px !important; }
.rp-stage-meta        { font-size: 14px !important; }
.rc-km                { font-size: 30px !important; }
.empty-home p, .rp-empty p { font-size: 15px !important; }

/* Floating "exit focus" button — only visible when in focus mode */
.focus-exit-btn {
  display: none;
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 10px;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 16px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  opacity: 0.5;
  transition: opacity .15s, background .15s;
}
.focus-exit-btn:hover { opacity: 1; background: var(--red-light); color: var(--red); }

/* When in focus mode: hide topbar of view-app, the notebook header, and the statusbar */
body.in-app.focus-mode #topbar { display: none; }
/* En modo enfoque mantenemos la barra de configuración del cuaderno (modo, trips, herramientas) */
body.in-app.focus-mode .nb-statusbar { display: none; }
body.in-app.focus-mode #sidebar,
body.in-app.focus-mode #sidebar-ov { display: none !important; }
/* La barra del cuaderno ya tiene su propio botón de enfoque, así que ocultamos el flotante */
body.in-app.focus-mode .focus-exit-btn { display: none; }

/* The focus button in the header itself shows toggled-on state */
.focus-btn.active {
  background: var(--red) !important;
  color: white !important;
  border-color: var(--red) !important;
}




/* ══════════════ NOTEBOOK MODE TOOLBAR ══════════════ */
.nb-mode-group {
  display: flex; gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.nb-mode {
  background: var(--surface);
  border: none;
  color: var(--text-3);
  width: 36px; height: 36px;
  font-size: 17px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--border);
  transition: all .12s;
  padding: 0;
}
.nb-mode:last-child { border-right: none; }
.nb-mode:hover { background: var(--surface2); color: var(--text); }
.nb-mode.active {
  background: var(--text);
  color: #fff;
}
.nb-mode.active.mode-draw-btn   { background: #2563eb; }
.nb-mode.active.mode-erase-btn  { background: var(--red); }

/* Pen color swatches — only visible in draw mode */
.nb-pen-colors {
  display: none; gap: 4px; align-items: center;
  padding: 0 4px;
  border-left: 1px solid var(--border);
  margin-left: 2px;
}
body.nb-mode-draw .nb-pen-colors, body.nb-mode-marker .nb-pen-colors { display: flex; }
.pen-color {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 0 0 1px var(--border);
  transition: transform .12s, box-shadow .12s;
}
.pen-color:hover { transform: scale(1.1); }
.pen-color.sel { box-shadow: 0 0 0 2px var(--text); }

/* Pen size slider — only visible in draw mode */
.nb-pen-size {
  display: none; align-items: center; gap: 4px;
  padding: 0 6px;
}
body.nb-mode-draw .nb-pen-size, body.nb-mode-marker .nb-pen-size, body.nb-mode-corrector .nb-pen-size, body.nb-mode-erasepx .nb-pen-size { display: flex; }
#pen-size { width: 70px; }

/* Pen action buttons (undo, clear) — visible in draw/erase mode */
.nb-pen-action { display: none; }
body.nb-mode-draw .nb-pen-action, body.nb-mode-marker .nb-pen-action, body.nb-mode-corrector .nb-pen-action,
body.nb-mode-erase .nb-pen-action, body.nb-mode-erasepx .nb-pen-action, body.nb-mode-lasso .nb-pen-action { display: flex; }



/* Compact header bar */
.nb-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border2);
}
.nb-header-info { flex: 1; min-width: 0; }
.nb-rally-name { font-size: 10px; color: var(--text-3); letter-spacing: 1.5px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-stage-name { font-family: var(--font-cond); font-weight: 800; font-size: 18px; color: var(--text); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Rally Codriver-style MODE badge (N green = notas, R red = carrera) ── */
.nb-mode-badge {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #2ecc40; color: #fff; border-radius: 10px;
  padding: 4px 14px; min-width: 64px; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(46,204,64,.4);
}
.nb-mode-badge.race { background: var(--red); box-shadow: 0 2px 6px rgba(232,52,26,.4); }
.nb-mode-badge-lbl { font-size: 9px; font-weight: 700; letter-spacing: 1px; opacity: .9; }
.nb-mode-badge-letter { font-family: var(--font-cond); font-weight: 800; font-size: 30px; line-height: 1; }

/* ── Rally Codriver-style TRIP counters ── */
.nb-trips { display: flex; gap: 16px; flex-shrink: 0; padding: 0 4px; }
.nb-trip { display: flex; flex-direction: column; align-items: flex-end; }
.nb-trip-lbl { font-size: 9px; font-weight: 700; letter-spacing: 1px; color: var(--text-3); text-transform: uppercase; }
.nb-trip-val { font-family: var(--font-mono); font-weight: 700; font-size: 26px; line-height: 1; color: var(--red); font-variant-numeric: tabular-nums; }
.nb-trip-val[id="nb-trip-partial"] { cursor: pointer; }
@media (max-width: 720px) {
  .nb-trips { gap: 10px; }
  .nb-trip-val { font-size: 20px; }
  .nb-mode-badge { min-width: 52px; padding: 3px 10px; }
  .nb-mode-badge-letter { font-size: 24px; }
}

.nb-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.nb-header-actions .icon-btn { width: 42px; height: 42px; font-size: 19px; }
.nb-header-actions .icon-btn.active { background: var(--red); color: white; border-color: var(--red); }
.nb-header-actions .icon-btn.recording {
  background: var(--red-light); color: var(--red); border-color: var(--red);
  animation: micPulse 1.4s ease-in-out infinite;
}
@keyframes micPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(232,52,26,.3); }
  50%      { box-shadow: 0 0 0 8px rgba(232,52,26,0); }
}

/* Voice strip — visible only when recording */
.voice-strip {
  display: none; align-items: center; gap: 10px;
  padding: 8px 14px; flex-shrink: 0;
  background: var(--red-light); border-bottom: 1px solid var(--red);
}
.voice-strip.active { display: flex; }
.vs-left { display: flex; align-items: center; gap: 8px; }
.vs-pulse {
  width: 10px; height: 10px; border-radius: 50%; background: var(--red);
  animation: vsPulse .8s ease-in-out infinite;
}
@keyframes vsPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.4); opacity: .5; } }
.vs-label { font-family: var(--font-cond); font-weight: 700; font-size: 12px; color: var(--red); letter-spacing: 1.5px; text-transform: uppercase; }
.voice-waves { display: flex; align-items: center; gap: 2px; height: 16px; }
.voice-waves span { display: block; width: 3px; border-radius: 2px; background: var(--red); height: 4px; }
.voice-waves.active span { animation: waveBounce .8s ease-in-out infinite; }
.voice-waves.active span:nth-child(1){ animation-delay: 0s;   animation-duration: .9s; }
.voice-waves.active span:nth-child(2){ animation-delay: .15s; animation-duration: .7s; }
.voice-waves.active span:nth-child(3){ animation-delay: .05s; animation-duration: 1s;  }
.voice-waves.active span:nth-child(4){ animation-delay: .2s;  animation-duration: .8s; }
.voice-waves.active span:nth-child(5){ animation-delay: .1s;  animation-duration: .75s;}
@keyframes waveBounce { 0%,100%{height:3px} 50%{height:14px} }
.voice-interim {
  flex: 1; min-width: 0; font-style: italic; font-size: 13px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vs-stop {
  background: var(--red); color: white; border: none;
  padding: 5px 12px; border-radius: 4px;
  font-family: var(--font-cond); font-weight: 700; font-size: 12px;
  letter-spacing: 1px; cursor: pointer;
}

/* THE NOTEBOOK — takes the most screen space, scrollable */
.notebook {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  background: #fafbfc;
  position: relative;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
/* Red margin line moved into editor as a border (grows with content) */
.notebook-margin {
  display: none;  /* deprecated - replaced by editor's red border */
}

/* INK CANVAS — drawing overlay that sits on top of the editor */
.ink-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  /* height set by JS to match scroll height */
  pointer-events: none;   /* off by default — text mode */
  z-index: 2;
  background: transparent;
}
body.nb-mode-draw .ink-canvas {
  pointer-events: auto;
  touch-action: none;
  cursor: crosshair;
}
body.nb-mode-erase .ink-canvas {
  pointer-events: auto;
  touch-action: none;
  cursor: cell;
}

/* Editor is below the canvas */
.pacenote-editor {
  position: relative;
  z-index: 1;
}
/* In draw/erase mode, editor stops receiving input (canvas catches it) */
body.nb-mode-draw .pacenote-editor,
body.nb-mode-erase .pacenote-editor {
  user-select: none;
  -webkit-user-select: none;
}


/* The big editable pacenote text area */
.pacenote-editor {
  /* min-height is set dynamically by inkResize() to support infinite scroll */
  min-height: 100%;
  padding: 18px 14px 18px 76px;
  font-family: 'Barlow', 'Barlow Condensed', sans-serif;
  font-size: var(--editor-fs, 28px);
  line-height: 1.7;
  color: var(--text);
  outline: none;
  word-break: break-word;
  white-space: pre-wrap;
  font-weight: 600;
  /* Notebook lines + red margin line at 60px from left */
  background-image:
    linear-gradient(to right, transparent 59px, rgba(232,52,26,0.35) 59px, rgba(232,52,26,0.35) 60px, transparent 60px),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(var(--line-h, 50px) - 1px),
      var(--nb-line, #e3e7ec) calc(var(--line-h, 50px) - 1px),
      var(--nb-line, #e3e7ec) var(--line-h, 50px)
    );
  background-size: 100% 100%, 100% var(--line-h, 50px);
  background-position: 0 0, 0 calc(var(--line-h, 50px) - 6px);
  background-repeat: no-repeat, repeat;
  letter-spacing: .3px;
  -webkit-user-select: text;
  user-select: text;
}
.pacenote-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-4);
  font-style: italic;
  font-size: 18px;
  font-weight: 400;
}

/* Scanned notes image inserted into the notebook */
.pacenote-editor img.pn-scan {
  display: block; max-width: 100%; height: auto;
  border-radius: 8px; margin: 10px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

/* ── Notebook appearance themes (set via Configuración) — solo en modo notas, no carrera ── */
body.nb-bg-cream #panel-stage .pacenote-editor { background-color: #f7f1e3; }
body.nb-bg-cream #panel-stage { background-color: #f7f1e3; }

body.nb-bg-dark #panel-stage,
body.nb-bg-dark #panel-stage .pacenote-editor { background-color: #14171c; color: #f0f3f7; }
body.nb-bg-dark .pacenote-editor { color: #f0f3f7; }
body.nb-bg-dark .pacenote-editor .pn-dist { color: #9aa3af; }

body.nb-bg-yellow #panel-stage,
body.nb-bg-yellow #panel-stage .pacenote-editor { background-color: #fde047; color: #111; }
body.nb-bg-yellow .pacenote-editor { color: #111; }

/* Line spacing */
body.nb-space-compact .pacenote-editor { line-height: 1.4; }
body.nb-space-wide .pacenote-editor { line-height: 2.2; }

/* Hide line counter */
body.nb-hide-counter .nb-counter { display: none !important; }

/* Page mode: snap scrolling per screenful */
body.nb-page-mode #pacenote-viewer,
body.nb-page-mode .notebook-scroll { scroll-snap-type: y mandatory; }

/* Highlighting of pacenote elements */
.pacenote-editor .pn-dir {
  font-weight: 900;
  color: var(--blue);
  background: var(--blue-lt);
  padding: 0 2px;
  border-radius: 2px;
  font-size: 1.05em;
}
.pacenote-editor .pn-num {
  font-weight: 800;
  color: var(--text);
}
.pacenote-editor .pn-conj {
  color: var(--text-3);
  font-style: italic;
  font-weight: 500;
  font-size: 0.92em;
}
.pacenote-editor .pn-danger {
  font-weight: 900;
  color: var(--red);
  background: var(--red-light);
  padding: 0 4px;
  border-radius: 3px;
  text-decoration: underline;
}
.pacenote-editor .pn-terrain {
  font-weight: 700;
  color: #b45309;
  background: var(--orange-lt);
  padding: 0 3px;
  border-radius: 2px;
}
.pacenote-editor .pn-mod {
  color: var(--text-2);
  font-style: italic;
  font-weight: 600;
}
.pacenote-editor .pn-dist {
  color: var(--green);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* Rally symbols — distinct boxed look so they stand out as graphic shorthand */
.pn-sym {
  font-family: var(--font-mono);
  font-weight: 900;
  display: inline-block;
  padding: 0 5px;
  border-radius: 4px;
  border: 1.5px solid currentColor;
  line-height: 1.25;
}
.pn-sym-terrain { color: #b45309; background: var(--orange-lt); }
.pn-sym-danger  { color: var(--red); background: var(--red-light); }
.pn-sym-conj    { color: var(--text-2); background: var(--surface3); }
.pn-sym-dir     { color: var(--blue); background: var(--blue-lt); }
.pn-sym-mod     { color: #7c3aed; background: #f3e8ff; }
.race-content .pn-sym { border-width: 2px; }

/* Symbol editor modal */
.modal-sym-editor { max-width: 540px; }
.se-head {
  display: grid; grid-template-columns: 70px 1fr 110px 34px;
  gap: 8px; padding: 0 4px 6px; font-size: 11px; color: var(--text-4);
  text-transform: uppercase; letter-spacing: 1px; font-weight: 700;
}
.sym-editor-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 42vh; overflow-y: auto; margin-bottom: 10px;
}
.se-row {
  display: grid; grid-template-columns: 70px 1fr 110px 34px;
  gap: 8px; align-items: center;
}
.se-sym {
  font-family: var(--font-mono); font-weight: 900; font-size: 16px;
  text-align: center; padding: 8px 4px;
  border: 1.5px solid var(--border); border-radius: 6px;
  background: var(--surface2);
}
.se-name {
  padding: 8px 10px; font-size: 14px;
  border: 1.5px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
}
.se-cat {
  padding: 8px 4px; font-size: 12px;
  border: 1.5px solid var(--border); border-radius: 6px;
  background: var(--surface);
}
.se-del {
  width: 34px; height: 34px; border: 1.5px solid var(--border);
  border-radius: 6px; background: var(--surface2); color: var(--text-4);
  cursor: pointer; font-size: 14px;
}
.se-del:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }
.se-empty { padding: 20px; text-align: center; color: var(--text-4); font-size: 13px; }
.se-add {
  margin-top: 8px; padding: 12px; background: var(--surface2);
  border-radius: 8px; border: 1px dashed var(--border);
}
.se-add-title {
  font-size: 12px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px;
}
.se-add-row {
  display: grid; grid-template-columns: 70px 1fr 110px 40px;
  gap: 8px; align-items: center;
}
.se-add-btn {
  width: 40px; height: 38px; border: none; border-radius: 6px;
  background: var(--blue); color: #fff; font-size: 20px; font-weight: 700;
  cursor: pointer;
}
.se-add-btn:hover { background: var(--blue); filter: brightness(1.1); }

@media (max-width: 540px) {
  .se-head, .se-row { grid-template-columns: 56px 1fr 86px 30px; gap: 5px; }
  .se-add-row { grid-template-columns: 56px 1fr 86px 36px; gap: 5px; }
  .se-name, .se-cat { font-size: 12px; padding: 7px 6px; }
}

/* Symbol guide modal */
.modal-symbols { max-width: 460px; }
.sym-guide-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 50vh; overflow-y: auto; margin: 8px 0 4px;
}
.sym-guide-row {
  display: grid; grid-template-columns: 56px 1fr auto;
  align-items: center; gap: 12px;
  padding: 8px 6px; border-bottom: 1px solid var(--border);
}
.sym-guide-row:last-child { border-bottom: none; }
.sym-guide-sym {
  font-family: var(--font-mono); font-weight: 900; font-size: 18px;
  text-align: center; padding: 4px 0; border-radius: 5px;
  border: 1.5px solid currentColor;
}
.sym-guide-name { font-size: 15px; color: var(--text); font-weight: 600; }
.sym-guide-cat {
  font-size: 11px; color: var(--text-4); text-transform: uppercase;
  letter-spacing: 1px;
}

/* Editor zoom levels — el estándar (92px) es el nivel 2: 1 por debajo, 4 por encima. */
.pacenote-editor.zoom-1 { --editor-fs: 74px;  --line-h: 116px; }
.pacenote-editor.zoom-2 { --editor-fs: 92px;  --line-h: 142px; }
.pacenote-editor.zoom-3 { --editor-fs: 116px; --line-h: 176px; }
.pacenote-editor.zoom-4 { --editor-fs: 144px; --line-h: 214px; }
.pacenote-editor.zoom-5 { --editor-fs: 176px; --line-h: 258px; }
.pacenote-editor.zoom-6 { --editor-fs: 212px; --line-h: 308px; }

/* Quickbar — collapsible, sticks above status bar */
.quickbar {
  display: none;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  flex-shrink: 0;
  max-height: 38vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.quickbar.open { display: flex; flex-direction: column; gap: 6px; }
.qb-section { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 2px 0; }
.qb-lbl {
  font-family: var(--font-cond); font-size: 10px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-4);
  width: 60px; flex-shrink: 0; font-weight: 700;
}
.qb {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-2);
  padding: 7px 11px;
  border-radius: 6px;
  font-family: var(--font-cond); font-weight: 700;
  font-size: 13px; letter-spacing: .5px;
  transition: all .1s;
  min-width: 38px; text-align: center;
  user-select: none; -webkit-user-select: none;
}
.qb:hover, .qb:active { transform: scale(0.96); }
.qb.dir { background: var(--blue-lt); color: var(--blue); border-color: var(--blue); font-size: 16px; font-weight: 900; min-width: 44px; }
.qb.dir:hover, .qb.dir:active { background: var(--blue); color: white; }
.qb.num { background: var(--surface); font-family: var(--font-mono); font-weight: 800; }
.qb.num:hover { background: var(--blue-lt); color: var(--blue); border-color: var(--blue); }
.qb.conj { background: var(--surface); color: var(--text-3); font-style: italic; }
.qb.conj:hover { background: var(--surface3); color: var(--text); }
.qb.mod { background: var(--surface); color: var(--text-2); font-style: italic; }
.qb.mod:hover { background: var(--surface3); }
.qb.terr { background: var(--orange-lt); color: #b45309; border-color: #f5a623; }
.qb.terr:hover { background: #f5a623; color: white; }
.qb.danger { background: var(--red-light); color: var(--red); border-color: var(--red); font-weight: 900; }
.qb.danger:hover { background: var(--red); color: white; }
.qb.dist { background: var(--green-lt); color: var(--green); border-color: var(--green); font-family: var(--font-mono); }
.qb.dist:hover { background: var(--green); color: white; }
.qb.sym {
  background: var(--surface2); color: var(--text);
  font-family: var(--font-mono); font-weight: 800; font-size: 17px;
  display: inline-flex; flex-direction: column; align-items: center; gap: 0;
  line-height: 1.05; min-width: 46px; padding: 5px 8px;
}
.qb.sym small {
  font-family: var(--font-body); font-size: 8px; font-weight: 600;
  letter-spacing: .3px; color: var(--text-4); text-transform: uppercase;
}
.qb.sym:hover { background: #2a2f3a; color: #fff; }
.qb.sym:hover small { color: rgba(255,255,255,.7); }
.qb.sym-help { background: var(--blue-lt); color: var(--blue); }
.qb.act { background: var(--surface2); color: var(--text-2); }
.qb.act.del { background: var(--surface2); color: var(--red); }

/* Status bar at very bottom */
.nb-statusbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 14px; flex-shrink: 0;
  background: var(--surface); border-top: 1px solid var(--border2);
  font-size: 11px; color: var(--text-4);
  font-family: var(--font-cond); letter-spacing: 1px;
  padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
}
.save-status.saved { color: var(--green); }
.save-status.saving { color: var(--orange-lt); color: #b45309; }
.save-status.dirty { color: var(--orange-lt); color: #b45309; }

/* ══════════════ RACE MODE — CONTINUOUS PACENOTE READER ══════════════ */

.panel-race {
  background: var(--race-bg) !important;
  color: var(--race-text);
  overflow: hidden !important;
  padding: 0;
}

.race-topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--race-s1);
  border-bottom: 2px solid var(--race-acc);
  flex-shrink: 0;
  flex-wrap: wrap;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
}
.race-back {
  background: transparent; border: 1px solid var(--race-border);
  color: var(--race-muted); padding: 6px 12px; border-radius: 4px;
  font-family: var(--font-cond); font-weight: 700; font-size: 13px;
  letter-spacing: .5px; cursor: pointer; transition: all .12s;
  flex-shrink: 0;
}
.race-back:hover { color: var(--race-text); border-color: var(--race-acc); }
.race-stage-name {
  font-family: var(--font-cond); font-weight: 800;
  font-size: 16px; color: var(--race-acc);
  flex: 0 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: 1px;
}
/* Trip counters in race mode: spacer pushes controls to the right; labels readable on dark */
.race-topbar .nb-trips { flex: 1 1 auto; }
.race-topbar .nb-trip-lbl { color: var(--race-muted); }
.race-topbar .nb-trip-val { color: var(--race-acc); }
.race-controls-top { display: flex; align-items: center; gap: 6px; }
.race-zoom-btn {
  background: var(--race-s2); border: 1px solid var(--race-border); color: var(--race-muted);
  width: 38px; height: 38px; border-radius: 4px;
  font-family: var(--font-cond); font-weight: 700; font-size: 14px;
  cursor: pointer; transition: all .12s;
}
.race-zoom-btn:hover { color: var(--race-acc); border-color: var(--race-acc); }
.race-zoom-lvl {
  background: var(--race-s2); border: 1px solid var(--race-border); color: var(--race-acc);
  font-family: var(--font-mono); font-size: 11px;
  padding: 0 6px; min-width: 32px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  user-select: none;
}
.race-odo-wrap {
  display: flex; align-items: baseline; gap: 4px;
  background: var(--race-s2); border: 1px solid var(--race-border);
  padding: 4px 10px; border-radius: 4px;
}
.race-odo-lbl { font-size: 9px; color: var(--race-muted2); text-transform: uppercase; letter-spacing: 1.5px; }
.race-odo-val { font-family: var(--font-mono); font-size: 18px; color: var(--race-teal); }
.race-timer {
  font-family: var(--font-mono); font-size: 18px; color: var(--race-acc);
  background: var(--race-s2); border: 1px solid var(--race-border);
  padding: 4px 10px; border-radius: 4px;
  min-width: 90px; text-align: center;
}
.race-timer-btn {
  background: #2ecc71; color: #000; border: none;
  width: 36px; height: 36px; border-radius: 4px;
  font-size: 15px; font-weight: 800; cursor: pointer;
  flex-shrink: 0;
}
.race-timer-btn.running { background: var(--race-red); color: white; }

/* The big race viewer */
.race-viewer {
  flex: 1; overflow-y: auto;
  background: var(--race-bg);
  background-image:
    linear-gradient(to right, transparent 59px, rgba(232,52,26,0.25) 59px, rgba(232,52,26,0.25) 60px, transparent 60px);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  position: relative;
}
.race-ink-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 2;
  /* Strokes shown in their original colors — no inversion */
}

/* ── Splits (parciales) overlay panel ── */
.race-splits {
  position: absolute; top: 10px; right: 10px; z-index: 5;
  display: flex; flex-direction: column; gap: 2px;
  background: rgba(0,0,0,.72); backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.12); border-radius: 8px;
  padding: 8px 10px; min-width: 200px; max-height: 60%; overflow-y: auto;
  font-family: var(--font-mono); pointer-events: auto;
}
body.in-race.race-day .race-splits { background: rgba(255,255,255,.92); border-color: #d0d4da; }
.rsplit-title { font-size: 10px; letter-spacing: 2px; color: var(--race-acc); font-weight: 700; margin-bottom: 4px; }
.rsplit-row { display: flex; align-items: baseline; gap: 8px; font-size: 14px; color: var(--race-text); padding: 2px 0; border-top: 1px solid rgba(255,255,255,.08); }
body.in-race.race-day .rsplit-row { border-top-color: #e0e3e8; }
.rsplit-n { width: 18px; color: var(--race-acc); font-weight: 700; }
.rsplit-t { font-weight: 700; min-width: 56px; }
.rsplit-d { color: #5fe39f; font-size: 12px; min-width: 56px; }
body.in-race.race-day .rsplit-d { color: #0f7a45; }
.rsplit-km { margin-left: auto; color: var(--race-muted); font-size: 12px; }
.rf-split.split-flash { background: #2ecc71 !important; color: #000 !important; transition: none; }
/* When editing by hand during the race, the canvas captures touch/pen */
body.race-inking .race-ink-canvas { pointer-events: auto; touch-action: none; cursor: crosshair; }
body.race-inking .race-viewer { touch-action: none; }

/* Handwriting toolbar in race mode */
.race-ink-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 14px; flex-shrink: 0;
  background: var(--race-s1); border-bottom: 1px solid #2a2f3a;
}
.race-ink-colors { display: flex; gap: 6px; }
.race-ink-bar .pen-color {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0;
}
.race-ink-bar .pen-color.sel { border-color: var(--race-acc); transform: scale(1.12); }
.race-ink-size { width: 110px; }
.race-ink-btn-active { background: var(--race-acc) !important; color: #111 !important; }
.race-content {
  position: relative;
  z-index: 1;
  padding: 24px 18px 80px 76px;
  font-family: 'Barlow', 'Barlow Condensed', sans-serif;
  font-size: var(--race-fs, 54px);
  line-height: 1.45;
  color: var(--race-text);
  white-space: pre-wrap;
  word-break: break-word;
  letter-spacing: .3px;
  -webkit-user-select: text;
  user-select: text;
  font-weight: 600;
  background: var(--race-bg);
}

/* Race text highlighting — day/night aware, always readable */
.race-content .pn-dir {
  font-weight: 900;
  color: var(--race-dir);
  background: var(--race-dir-bg);
  padding: 0 6px;
  border-radius: 4px;
  font-size: 1.05em;
}
.race-content .pn-num { font-weight: 900; color: var(--race-num); }
.race-content .pn-conj {
  color: var(--race-conj);
  font-style: italic;
  font-weight: 500;
  font-size: 0.92em;
}
.race-content .pn-danger {
  font-weight: 900;
  color: var(--race-danger);
  background: var(--race-danger-bg);
  padding: 0 8px;
  border-radius: 4px;
  text-decoration: underline;
}
.race-content .pn-terrain {
  font-weight: 700;
  color: var(--race-terrain);
  background: var(--race-terrain-bg);
  padding: 0 6px;
  border-radius: 4px;
}
.race-content .pn-mod {
  color: var(--race-mod);
  font-style: italic;
  font-weight: 600;
}
.race-content .pn-dist {
  color: var(--race-dist);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* Race zoom levels */
.race-content.zoom-1 { --race-fs: 28px; }
.race-content.zoom-2 { --race-fs: 36px; }
.race-content.zoom-3 { --race-fs: 44px; }
.race-content.zoom-4 { --race-fs: 54px; }
.race-content.zoom-5 { --race-fs: 66px; }
.race-content.zoom-6 { --race-fs: 80px; }
.race-content.zoom-7 { --race-fs: 96px; }
.race-content.zoom-8 { --race-fs: 116px; }

.race-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 80px 20px;
  color: var(--text-3); text-align: center;
}
.race-empty p { font-family: var(--font-cond); font-size: 14px; letter-spacing: 1.5px; text-transform: uppercase; }

/* Race footer */
.race-footer {
  display: flex; gap: 5px; padding: 8px 12px;
  background: var(--race-s1); border-top: 1px solid #21252f;
  flex-shrink: 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

/* ── Position indicator (which note to follow) ── */
.race-posbar {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 16px; flex-shrink: 0;
  background: linear-gradient(90deg, #10141b, #161b24);
  border-top: 2px solid #4ecdc4;
}
.rpos-now, .rpos-next { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rpos-next { flex: 1; }
.rpos-lbl {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px;
  color: var(--race-muted2); text-transform: uppercase; white-space: nowrap;
}
.rpos-lbl span { color: var(--race-teal); font-weight: 700; }
.rpos-note {
  font-family: var(--font-cond); font-weight: 900; line-height: 1;
  color: var(--race-text);
}
.rpos-now .rpos-note { font-size: 26px; color: var(--race-muted); }
.rpos-next .rpos-note { font-size: 38px; color: var(--race-teal); }
.rpos-arrow { font-size: 28px; color: var(--race-teal); flex-shrink: 0; }
@media (max-height: 520px) and (orientation: landscape) {
  .rpos-now .rpos-note { font-size: 22px; }
  .rpos-next .rpos-note { font-size: 30px; }
  .race-posbar { padding: 5px 16px; }
}

.rf-btn {
  flex: 1; min-width: 42px; padding: 9px 4px;
  background: var(--race-s2); border: 1px solid var(--race-border);
  color: var(--race-text); border-radius: 4px;
  font-family: var(--font-cond); font-weight: 700; font-size: 13px;
  text-align: center; cursor: pointer; transition: all .1s;
}
.rf-btn:hover, .rf-btn:active { border-color: var(--race-teal); color: var(--race-teal); }
.rf-btn.pos { color: var(--race-teal); }
.rf-split {
  background: var(--race-acc); color: #000; border: none;
  padding: 9px 14px; border-radius: 4px;
  font-family: var(--font-cond); font-weight: 900;
  font-size: 14px; cursor: pointer; flex-shrink: 0;
  min-width: 50px;
}

/* ── GPS badge in topbar ── */
.race-gps-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: #191c23; border: 1px solid #2a2f3a;
  padding: 4px 9px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 11px; color: #7a8090;
}
.rgb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--race-muted); }
.race-gps-badge.active .rgb-dot { background: #2ecc71; box-shadow: 0 0 6px rgba(46,204,113,.7); }
.race-gps-badge.active { color: #2ecc71; }
.race-gps-badge.searching .rgb-dot { background: var(--race-acc); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ── Stage GPS map ── */
.modal-map { max-width: 640px; width: 92vw; }
.stage-map-canvas {
  width: 100%; height: 56vh; max-height: 460px; min-height: 280px;
  border-radius: 10px; overflow: hidden;
  background: var(--surface3); border: 1px solid var(--border);
}
.stage-map-canvas .leaflet-container { width: 100%; height: 100%; background: #aad3df; }
.stage-map-info {
  margin-top: 10px; font-size: 13px; color: var(--text-3);
  display: flex; gap: 16px; flex-wrap: wrap;
}
.stage-map-info b { color: var(--text); }
.stage-map-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--text-4); text-align: center; padding: 20px; gap: 8px;
}
.smap-pin {
  border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
/* Small inline preview map inside the stage create modal */
.stage-coord-map {
  width: 100%; height: 200px; margin-top: 10px;
  border-radius: 8px; overflow: hidden; display: none;
  border: 1px solid var(--border); background: var(--surface3);
}
.stage-coord-map .leaflet-container { width: 100%; height: 100%; background: #aad3df; }

/* ── Stage timer bar ── */
.race-stagebar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px;
  background: #15191f;
  border-bottom: 1px solid #21252f;
  flex-shrink: 0;
}
.rsb-btn {
  background: var(--race-s2); border: 1px solid var(--race-border); color: var(--race-text);
  padding: 8px 14px; border-radius: 5px; cursor: pointer;
  font-family: var(--font-cond); font-weight: 700; font-size: 13px;
  letter-spacing: .5px; transition: all .12s;
}
.rsb-btn:hover { border-color: var(--race-acc); }
.rsb-countdown { background: var(--race-s3); }
.rsb-go { background: #1a3a1f; border-color: #2ecc71; color: #6ee89a; }
.rsb-go:hover { background: #225026; }
.rsb-finish { background: var(--race-red); border-color: var(--race-red); color: var(--race-text); }
.rsb-locate { background: #1a2a3a; border-color: #4a90d0; color: #8cc0f0; margin-left: auto; }
.rsb-live { display: flex; align-items: center; gap: 10px; }
.rsb-dist, .rsb-speed { font-family: var(--font-mono); font-size: 14px; color: var(--race-acc); }
.rsb-autoscroll {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font-cond); font-size: 12px; color: var(--race-muted2);
  cursor: pointer; user-select: none;
}
.rsb-autoscroll input { width: 16px; height: 16px; accent-color: var(--race-acc); }

/* ── Geo-anchor highlight on the current note in race mode ── */
.geo-marker { display: inline; }
.race-content .geo-current {
  background: rgba(245,166,35,0.22);
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(245,166,35,0.5);
  scroll-margin: 40vh;
}

/* ── Countdown overlay ── */
.race-countdown-ov {
  display: none;
  position: absolute; inset: 0; z-index: 50;
  background: rgba(10,11,13,0.97);
  flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px; text-align: center;
}
.race-countdown-ov.show { display: flex; }
.rcd-stage { font-family: var(--font-cond); font-weight: 800; font-size: 22px; color: #fff; letter-spacing: 1px; }
.rcd-mark { font-family: var(--font-mono); font-size: 13px; color: var(--race-acc); letter-spacing: 2px; }
.rcd-display {
  font-family: var(--font-mono); font-size: 84px; line-height: 1;
  color: var(--race-acc); font-weight: 700;
}
.rcd-display.yellow { color: #f5d623; }
.rcd-display.red    { color: #ff5e3e; }
.rcd-display.green  { color: #2ecc71; text-shadow: 0 0 40px rgba(46,204,113,.5); }
.rcd-lights { display: flex; gap: 12px; }
.rcd-circle {
  width: 26px; height: 26px; border-radius: 50%;
  background: #21252f; border: 2px solid #2a2f3a; transition: all .15s;
}
.rcd-circle.lit { background: var(--race-red); border-color: var(--race-red); box-shadow: 0 0 16px rgba(232,52,26,.7); }
.rcd-sub { font-family: var(--font-cond); font-size: 16px; color: #fff; letter-spacing: 2px; min-height: 20px; }
.rcd-abort {
  margin-top: 8px; background: transparent; border: 1px solid #2a2f3a;
  color: #7a8090; padding: 8px 18px; border-radius: 5px; cursor: pointer;
  font-family: var(--font-cond); font-weight: 700; font-size: 13px;
}

/* ══════════════ RESPONSIVE ══════════════ */
@media (max-width: 599px) {
  .nb-stage-name { font-size: 16px; }
  .nb-header-actions .icon-btn { width: 32px; height: 32px; }
  .pacenote-editor { padding-left: 60px; }
  .notebook-margin { left: 44px; }
  .race-stage-name { font-size: 14px; }
  .race-timer { font-size: 16px; min-width: 78px; }
  .qb-lbl { width: 50px; font-size: 9px; }
  .qb { padding: 8px 10px; font-size: 13px; }
}

@media (min-width: 900px) {
  #sidebar { position: relative; transform: none !important; border-right: 1px solid var(--border); padding-top: 0; flex-shrink: 0; }
  #sidebar-ov { display: none !important; }
  .tb-menu { display: none; }
  #view-app { flex-direction: column; }
  #content-area { flex-direction: row; }
  #sidebar { width: 260px; }
  .pacenote-editor { padding-left: 90px; }
  .notebook-margin { left: 72px; }
}

@media (min-width: 1100px) {
  .rally-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

/* ══════════════ IMPORTAR NOTAS DESDE PDF ══════════════ */
.pdfimp-modal { max-width: 860px; width: 94vw; }
.pdfimp-status { font-size: 13px; color: var(--text-2); background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin: 6px 0 12px; min-height: 34px; }
.pdfimp-body { display: flex; flex-direction: column; gap: 14px; max-height: 62vh; overflow-y: auto; padding-right: 4px; }
.pdfimp-pages-hdr { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.pdfimp-links a { color: var(--red); text-decoration: none; }
.pdfimp-pages { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.pdfimp-page { position: relative; flex: 0 0 auto; width: 110px; border: 2px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; background: #fff; opacity: .55; transition: all .12s; }
.pdfimp-page img { display: block; width: 100%; height: auto; }
.pdfimp-page.sel { opacity: 1; border-color: var(--red); box-shadow: 0 2px 8px rgba(232,52,26,.25); }
.pdfimp-page-n { position: absolute; left: 4px; bottom: 4px; font-size: 11px; font-weight: 700; background: rgba(0,0,0,.65); color: #fff; padding: 1px 6px; border-radius: 4px; }
.pdfimp-page-chk { position: absolute; right: 4px; top: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--red); color: #fff; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.pdfimp-page:not(.sel) .pdfimp-page-chk { background: transparent; }
.pdfimp-method-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.pdfimp-mbtn { flex: 1 1 160px; padding: 12px 10px; font-size: 14px; font-weight: 700; background: var(--surface2); border: 2px solid var(--border); border-radius: 10px; cursor: pointer; color: var(--text); font-family: inherit; }
.pdfimp-mbtn.active { border-color: var(--red); background: var(--red-light); color: var(--red); }
.pdfimp-mbtn:disabled { opacity: .4; cursor: not-allowed; }
.pdfimp-run { width: 100%; margin-top: 6px; padding: 12px; font-size: 15px; }
.pdfimp-result { width: 100%; font-family: var(--font-mono); font-size: 16px; line-height: 1.5; resize: vertical; min-height: 160px; }
@media (max-width: 720px) { .pdfimp-page { width: 84px; } .pdfimp-mbtn { flex-basis: 45%; font-size: 13px; padding: 10px 6px; } }

/* ══════════════ GPS EN EL CUADERNO — anclas de notas ══════════════ */
.nb-gps-btn.searching { border-color: var(--race-acc, #f5a623); color: #b45309; animation: nbgps-pulse 1.2s infinite; }
.nb-gps-btn.active    { background: #2ecc40; border-color: #2ecc40; color: #fff; }
.nb-gps-btn.weak      { background: #f5a623; border-color: #f5a623; color: #111; }
.nb-gps-btn.error     { background: var(--red); border-color: var(--red); color: #fff; }
.nb-mark-btn          { font-size: 22px; }
.nb-mark-btn.armed    { background: var(--red); border-color: var(--red); color: #fff; animation: nbgps-pulse .8s infinite; }
@keyframes nbgps-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(232,52,26,.45); } 50% { box-shadow: 0 0 0 6px rgba(232,52,26,0); } }
.nb-anchor-layer { position: absolute; top: 0; left: 0; width: 60px; height: 100%; pointer-events: none; z-index: 3; }
.nb-anchor-mark {
  position: absolute; left: 22px; width: 14px; height: 14px; margin-top: -7px;
  border-radius: 50%; background: #2ecc40; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.nb-anchor-mark::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: #fff; }

/* Marcas de notas manuscritas en el Modo Carrera */
.geo-ink-marker {
  position: absolute; left: 0; width: 60px; height: 4px; margin-top: -2px;
  background: transparent; pointer-events: none; z-index: 4;
}
.geo-ink-marker::before { content: ''; position: absolute; left: 22px; top: -5px; width: 14px; height: 14px; border-radius: 50%; background: var(--race-teal); opacity: .55; }
.geo-ink-marker.geo-current { height: 6px; }
.geo-ink-marker.geo-current::before { background: var(--race-acc); opacity: 1; width: 22px; height: 22px; top: -9px; left: 18px; box-shadow: 0 0 0 6px rgba(255,180,58,.25); }
.geo-ink-marker.geo-current::after {
  content: '▶'; position: absolute; left: 44px; top: -12px; color: var(--race-acc);
  font-size: 18px; font-weight: 900;
}

/* ══════════════ PROGRESO EN CARRERA (no perder el sitio) ══════════════ */
/* Texto */
.race-content .geo-passed { opacity: .32; filter: saturate(.4); }
.race-content .geo-cur-seg { box-shadow: 0 0 0 4px var(--race-cur-band, rgba(255,180,58,.16)); background-color: var(--race-cur-band, rgba(255,180,58,.16)); border-radius: 4px; }
.race-content .geo-next { outline: 3px dashed var(--race-acc); outline-offset: 3px; border-radius: 4px; }
.race-content .geo-current { box-shadow: 0 0 0 6px var(--race-acc) !important; background: var(--race-acc) !important; color: #111 !important; border-radius: 6px; }
body.in-race.race-day { --race-cur-band: rgba(194,65,12,.13); }
/* Cursor manuscrito */
.race-ink-cursor {
  position: absolute; left: 0; right: 0; height: 0; z-index: 6; pointer-events: none;
  border-top: 3px solid var(--race-acc); box-shadow: 0 0 10px rgba(255,180,58,.6);
  transition: top .6s linear;
}
.race-ink-cursor .ric-arrow {
  position: absolute; left: 6px; top: -15px; color: var(--race-acc); font-size: 22px; font-weight: 900;
  text-shadow: 0 0 6px rgba(0,0,0,.5);
}
body.in-race.race-day .race-ink-cursor { box-shadow: 0 0 8px rgba(194,65,12,.4); }
body.in-race.race-day .race-ink-cursor .ric-arrow { text-shadow: none; }

/* Adelanto de lectura */
.race-lead-btn { font-family: var(--font-mono); font-size: 12px !important; width: auto !important; padding: 0 8px; }
.race-lead-btn.active { color: var(--race-acc); border-color: var(--race-acc); }
.rpos-lead { color: var(--race-acc); font-weight: 800; margin-left: 4px; }

/* ══════════════ RECCE AUTOMÁTICO ══════════════ */
.pilot-auto-btn { border-color: #6b7280; color: #cbd5e1; background: #1a1f29; }
.pilot-auto-btn.active { background: #2ecc40; border-color: #2ecc40; color: #04210a; animation: nbgps-pulse 1.6s infinite; }
.pilot-action-btn:disabled { opacity: .35; cursor: not-allowed; }
.pilot-auto-status {
  display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 8px 12px;
  background: #0f2a15; border: 1px solid #2ecc40; border-radius: 8px;
  font-family: var(--font-mono); font-size: 13px; color: #b9f5c3; letter-spacing: .5px;
}
.pas-dot { width: 10px; height: 10px; border-radius: 50%; background: #2ecc40; box-shadow: 0 0 8px #2ecc40; animation: nbgps-pulse 1.2s infinite; flex-shrink: 0; }
.pas-last { margin-left: auto; color: #fff; font-weight: 700; }

/* ══════════════ RECCE AUTOMÁTICO — pantalla mínima ══════════════ */
.hub-card-auto .hc-icon { background: #ecfeff; color: #0e7490; }
.hub-card-auto::after { background: #0891b2 !important; }
.hub-card-auto:hover { border-color: #0891b2 !important; }

#view-autorecce { background: #0e1117; color: #e8eaf0; flex-direction: column !important; overflow: hidden !important; }
#view-autorecce.ar-running { background: #06110a; }
.ar-body { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr auto auto; gap: 14px; padding: 16px 22px 20px; min-height: 0; }
.ar-center { grid-row: 1; grid-column: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.ar-arrow-wrap { width: 150px; height: 150px; border-radius: 50%; border: 3px solid #2a2f3a; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle, #151a23 0%, #0e1117 70%); position: relative; }
.ar-arrow-wrap::before { content: ''; position: absolute; top: -6px; left: 50%; width: 4px; height: 18px; margin-left: -2px; background: #2ecc40; border-radius: 2px; }
.ar-arrow { font-size: 72px; line-height: 1; color: #fff; transition: transform .12s linear; }
.ar-running .ar-arrow { color: #2ecc40; }
.ar-offset { font-family: var(--font-mono); font-size: 22px; color: #cbd5e1; }
.ar-center-btn { padding: 14px 28px; border-radius: 10px; border: 2px solid #6b7280; background: #1a1f29; color: #fff; font-family: var(--font-cond); font-weight: 800; font-size: 18px; letter-spacing: 2px; cursor: pointer; }
.ar-center-btn:active { background: #2ecc40; color: #04210a; border-color: #2ecc40; }
.ar-hint { font-size: 12px; color: #6b7280; text-align: center; }
.ar-data { grid-row: 1; grid-column: 2; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.ar-datum { background: #15191f; border: 1px solid #2a2f3a; border-radius: 12px; padding: 12px 18px; display: flex; align-items: baseline; gap: 12px; }
.ar-lbl { font-family: var(--font-mono); font-size: 11px; letter-spacing: 2px; color: #6b7280; width: 110px; }
.ar-val { font-family: var(--font-cond); font-weight: 800; font-size: 54px; line-height: 1; color: #fff; margin-left: auto; }
.ar-running .ar-datum:nth-child(3) .ar-val { color: #2ecc40; }
.ar-unit { font-size: 13px; color: #6b7280; width: 56px; }
.ar-state { grid-row: 2; grid-column: 1 / -1; text-align: center; font-family: var(--font-mono); font-size: 15px; letter-spacing: .5px; color: #cbd5e1; background: #15191f; border: 1px solid #2a2f3a; border-radius: 10px; padding: 12px; }
.ar-running .ar-state { border-color: #2ecc40; color: #b9f5c3; background: #0f2a15; animation: nbgps-pulse 1.6s infinite; }
.ar-actions { grid-row: 3; grid-column: 1 / -1; display: flex; gap: 14px; }
.ar-btn { flex: 1; padding: 26px 10px; border-radius: 14px; border: none; font-family: var(--font-cond); font-weight: 900; font-size: 30px; letter-spacing: 2px; cursor: pointer; transition: transform .08s; }
.ar-btn:active { transform: scale(.98); }
.ar-btn:disabled { opacity: .3; cursor: not-allowed; }
.ar-start { background: #2ecc40; color: #04210a; }
.ar-finish { background: var(--red); color: #fff; }
@media (max-width: 720px) {
  .ar-body { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto; padding: 12px; }
  .ar-center { grid-row: 1; grid-column: 1; } .ar-data { grid-row: 2; grid-column: 1; }
  .ar-state { grid-row: 3; } .ar-actions { grid-row: 4; }
  .ar-arrow-wrap { width: 110px; height: 110px; } .ar-arrow { font-size: 52px; }
  .ar-val { font-size: 40px; } .ar-btn { font-size: 22px; padding: 18px 8px; }
}
.tts-btn { opacity: .55; }
.tts-btn.active { opacity: 1; border-color: #2ecc40 !important; color: #2ecc40 !important; }

/* Recce Automático: funciona en cualquier orientación (móvil en el volante) — sin aviso de girar */
body.in-autorecce .pilot-rotate-overlay { display: none !important; }

/* Pegar coordenadas GMS en el formulario de tramo */
.ms-dms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-bottom: 8px; }
.ms-dms-ok { font-family: var(--font-mono); font-size: 11px; color: #15803d; min-height: 14px; margin-top: 3px; }
@media (max-width: 720px) { .ms-dms-grid { grid-template-columns: 1fr; } }

/* Distancia a salida/meta y estado "armado" en la barra de tramo */
.rsb-gpsline { font-family: var(--font-mono); font-size: 12px; color: #4ecdc4; letter-spacing: .5px; padding: 6px 10px; border: 1px dashed #2a4a48; border-radius: 5px; }
body.in-race.race-day .rsb-gpsline { color: #0f7a6e; border-color: #9fd6d0; }

/* Trazado por carretera en el formulario de tramo */
.ms-route-row { display: flex; align-items: center; gap: 12px; margin: 8px 0 4px; flex-wrap: wrap; }
.ms-route-info { font-family: var(--font-mono); font-size: 12px; color: #15803d; }

/* Auditoría de contraste: flecha de posición y GPS en día */
.rpos-arrow { color: var(--race-teal); }
body.in-race.race-day .race-gps-badge.active { color: #157a3b; background: #dff3e2; }
body.in-race.race-day .race-gps-badge.active .rgb-dot { background: #157a3b; box-shadow: 0 0 6px rgba(21,122,59,.5); }
body.in-race.race-day .race-gps-badge { background: var(--race-s2); color: var(--race-muted); }

/* ══════════════ HERRAMIENTAS DE ESCRITURA (resaltador, corrector, goma píxel, lazo) ══════════════ */
body.nb-mode-marker .ink-canvas, body.nb-mode-corrector .ink-canvas,
body.nb-mode-erasepx .ink-canvas, body.nb-mode-lasso .ink-canvas { pointer-events: auto; touch-action: none; }
body.nb-mode-marker .ink-canvas { cursor: crosshair; }
body.nb-mode-corrector .ink-canvas { cursor: cell; }
body.nb-mode-erasepx .ink-canvas { cursor: crosshair; }
body.nb-mode-lasso .ink-canvas { cursor: crosshair; }
.nb-mode#mode-marker.active { background: #fde047; color: #111; }
.nb-mode#mode-corrector.active { background: #e5e7eb; color: #111; }
.nb-mode#mode-erasepx.active { background: #fb923c; color: #111; }
.nb-mode#mode-lasso.active { background: #2563eb; color: #fff; }
.lasso-actions { display: none; gap: 4px; align-items: center; }
.lasso-actions.show { display: flex; }
.lasso-actions .icon-btn { width: 36px; height: 36px; font-size: 16px; border-color: #2563eb; color: #2563eb; }

/* Posición de los contadores TRIP (izquierda/derecha) */
body.trips-left .nb-header .nb-mode-badge, body.trips-left .nb-header .nb-trips { order: -1; }
body.trips-left .race-topbar .nb-mode-badge, body.trips-left .race-topbar .nb-trips { order: -1; }
.nb-trip-remaining .nb-trip-val { color: var(--race-teal, #0f7a6e); }
/* Formulario de rally: año + campeonato */
.mr-two { display: grid; grid-template-columns: 120px 1fr; gap: 10px 14px; }
/* Cabeceras de archivo Año › Campeonato en el gestor */
.rmgr-group-hdr { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }
.rmgr-group-hdr .yr { font-family: var(--font-cond); font-weight: 800; font-size: 22px; color: var(--text); }
.rmgr-group-hdr .ch { font-size: 13px; color: var(--text-3); text-transform: uppercase; letter-spacing: 1.5px; }

/* ══════════════ VISOR DE DOCUMENTOS ══════════════ */
.docv-modal { max-width: 1400px; width: 96vw; max-height: 96vh; padding: 0 !important; }
.docv-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.docv-bar .modal-title { margin: 0 !important; font-size: 16px !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docv-tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.docv-zoom { font-family: var(--font-mono); font-size: 12px; min-width: 44px; text-align: center; }
.docv-body { background: #3a3f47; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; overflow: auto; min-height: 50vh; }
.docv-page { background: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.4); max-width: none; }
.docv-pagenum { font-size: 11px; color: #cbd5e1; margin-bottom: 10px; }
.docv-img { display: block; width: 100%; height: auto; background: #fff; }
.docv-loading { color: #fff; padding: 40px; }
/* Salto de página en el cuaderno */
.pn-pagebreak { display: flex; align-items: center; gap: 10px; margin: 18px 0; font-size: 12px; color: var(--text-3); letter-spacing: 1px; user-select: none; page-break-after: always; break-after: page; }
.pn-pagebreak::before, .pn-pagebreak::after { content: ''; flex: 1; border-top: 2px dashed var(--border); }
body.nb-page-mode .pn-pagebreak { scroll-snap-align: start; }
@media print { .pn-pagebreak { visibility: hidden; height: 0; margin: 0; } }

/* ═══════════════════════════════════════════════════════════════════
   TEMA "RALLY CODRIVER" (body.theme-rc) — capa visual sobre el resto.
   Blanco, botones planos con texto en mayúsculas, etiquetas pequeñas
   en gris, línea de color bajo las cabeceras, píldoras en ajustes.
   ═══════════════════════════════════════════════════════════════════ */
body.theme-rc {
  --font-cond: 'Montserrat', 'Barlow Condensed', system-ui, sans-serif;
  --font-body: 'Montserrat', 'Barlow', system-ui, sans-serif;
  --border: #e6e8ec; --border2: #eef0f3; --surface2: #ffffff; --surface3: #f4f5f7;
  --text-3: #8b93a3; --text-4: #b4bac5;
  --rc-dark: #3d434d;
  font-family: var(--font-body);
}
body.theme-rc *:not(.nb-trip-val):not(.race-timer):not(.rsplit-row):not(.rsplit-title):not(.pii-label):not(code):not(pre) { font-family: inherit; }
body.theme-rc .nb-trip-val, body.theme-rc .race-timer, body.theme-rc .rsplit-row { font-family: var(--font-mono) !important; }

/* Cabeceras: blancas con línea de color debajo */
body.theme-rc .hub-topbar, body.theme-rc #topbar, body.theme-rc .rmgr-topbar, body.theme-rc .cfg-topbar, body.theme-rc .tools-topbar {
  background: #fff !important; border-bottom: 3px solid var(--red) !important; box-shadow: none !important;
}
body.theme-rc .hub-logo { font-family: var(--font-cond); font-weight: 800; font-style: italic; font-size: 26px; letter-spacing: -.5px; display: flex; align-items: baseline; gap: 6px; }
body.theme-rc .hl-rn { color: var(--red); }
body.theme-rc .hl-pro { color: #111; text-transform: uppercase; }
body.theme-rc .hl-by { font-style: normal; font-weight: 500; font-size: 11px; color: var(--text-3); letter-spacing: 1px; text-transform: uppercase; margin-left: 4px; }
.hl-by { display: none; } body.theme-rc .hl-by { display: inline; }

/* Botones */
body.theme-rc .btn-primary {
  background: var(--red) !important; color: #fff !important; border: none !important; border-radius: 6px !important;
  text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700 !important; font-size: 13px !important; padding: 13px 22px !important;
  box-shadow: none !important;
}
body.theme-rc .btn-primary:hover { filter: brightness(.94); }
body.theme-rc .btn-secondary, body.theme-rc .btn-sec {
  background: #fff !important; color: var(--rc-dark) !important; border: 1.5px solid #d3d7de !important; border-radius: 6px !important;
  text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700 !important; font-size: 12px !important; padding: 12px 18px !important;
}
body.theme-rc .btn-danger { border-radius: 6px !important; text-transform: uppercase; letter-spacing: 1px; font-weight: 700 !important; font-size: 12px !important; }
body.theme-rc .icon-btn { border-radius: 8px; border-color: var(--border); background: #fff; }
body.theme-rc .icon-btn.active, body.theme-rc .nb-mode.active { background: var(--red) !important; color: #fff !important; border-color: var(--red) !important; }

/* Etiquetas y campos */
body.theme-rc .fl, body.theme-rc .fl-sm, body.theme-rc .cfg-name, body.theme-rc .rp-title, body.theme-rc .cfg-section-title, body.theme-rc .modal-title, body.theme-rc .rmgr-section-title, body.theme-rc .sb-section-label {
  text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600 !important;
}
body.theme-rc .fl, body.theme-rc .fl-sm { font-size: 11px !important; color: var(--text-3) !important; margin-bottom: 6px; }
body.theme-rc .cfg-name { font-size: 12px; color: var(--rc-dark); }
body.theme-rc .cfg-section-title { font-size: 12px !important; color: var(--red); margin-bottom: 4px; }
body.theme-rc .modal-title { font-size: 14px !important; color: var(--red); }
body.theme-rc .cfg-help, body.theme-rc .fl-help { font-size: 12px; color: var(--text-3); }
body.theme-rc .fi {
  border: 1.5px solid var(--border) !important; border-radius: 6px !important; background: #fff !important;
  min-height: 44px; padding: 10px 12px !important; font-size: 15px !important; color: #111;
}
body.theme-rc .fi:focus { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgba(232,52,26,.12) !important; outline: none; }
/* Píldoras en ajustes (como KMS / PORTRAIT / FULL PAGE) */
body.theme-rc .cfg-control select.fi {
  background: var(--red) !important; color: #fff !important; border: none !important; border-radius: 6px !important;
  text-transform: uppercase; font-weight: 700 !important; font-size: 12px !important; letter-spacing: 1px; padding: 10px 34px 10px 14px !important;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='white' stroke-width='2'/></svg>") !important;
  background-repeat: no-repeat !important; background-position: right 12px center !important;
}
body.theme-rc .cfg-control input.fi { text-align: center; font-weight: 700; }
body.theme-rc .cfg-row { padding: 14px 0; border-top: 1px solid var(--border2); }
body.theme-rc .cfg-section { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }

/* Inicio: tarjetas limpias */
body.theme-rc #view-hub { background: #fff; }
body.theme-rc .hub-card { border-radius: 10px !important; box-shadow: none !important; border: 1px solid var(--border) !important; padding: 22px 20px !important; }
body.theme-rc .hub-card::after { display: none !important; }
body.theme-rc .hub-card:hover { border-color: var(--red) !important; }
body.theme-rc .hc-icon { border-radius: 10px; }
body.theme-rc .hc-title { text-transform: uppercase; letter-spacing: 1px; font-size: 14px !important; font-weight: 800; }
body.theme-rc .hc-cta { color: var(--red); text-transform: uppercase; letter-spacing: 1px; font-size: 11px; font-weight: 700; }
body.theme-rc .hub-welcome-label { text-transform: uppercase; letter-spacing: 1.5px; font-size: 11px; color: var(--text-3); }

/* Pestañas inferiores del inicio */
.rc-tabbar { display: none; }
body.theme-rc.in-hub .rc-tabbar {
  display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: #fff; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
body.theme-rc.in-hub #view-hub { padding-bottom: 72px; }
.rc-tab { flex: 1; border: none; background: #fff; padding: 10px 6px 8px; font-family: inherit; font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: var(--text-3); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.rc-tab .rc-tab-ico { font-size: 22px; line-height: 1; }
.rc-tab.active { background: var(--red); color: #fff; }
.rc-tab:not(.active):hover { color: var(--red); }

/* Gestor de rallys: tarjetas y tabla de tramos con cabecera oscura */
body.theme-rc .rmgr-rally-card { border-radius: 8px !important; box-shadow: none !important; border: 1px solid var(--border) !important; }
body.theme-rc .rmgr-rally-card:hover { border-color: var(--red) !important; }
body.theme-rc .rmgr-rc-name { text-transform: uppercase; letter-spacing: .5px; font-weight: 800; }
body.theme-rc .rmgr-group-hdr .yr { color: var(--red); }
body.theme-rc .rmgr-stage-list::before {
  content: 'Nº   ·   TRAMO   ·   KM   ·   GPS'; display: block; background: var(--rc-dark); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: 2px; padding: 8px 14px; border-radius: 6px; margin-bottom: 4px;
}
body.theme-rc .rmgr-stage-card { border-radius: 6px !important; border: 1px solid var(--border) !important; }
body.theme-rc .rmgr-st-num { background: var(--red) !important; color: #fff !important; border-radius: 6px !important; font-weight: 800; }
body.theme-rc .rmgr-st-name { text-transform: uppercase; letter-spacing: .5px; }
body.theme-rc .rmgr-st-btn { border-radius: 6px; }

/* Cuaderno: cabecera blanca con línea, modo/trips ya al estilo */
body.theme-rc .nb-header { background: #fff; border-bottom: 3px solid var(--red); }
body.theme-rc .nb-mode-badge { border-radius: 8px; }
body.theme-rc .nb-trip-lbl { letter-spacing: 2px; }
body.theme-rc .nb-mode { border-radius: 0; }

/* Modales y pestañas de herramientas */
body.theme-rc .modal { border-radius: 10px; }
body.theme-rc .tools-tab, body.theme-rc .rmgr-tab { border-radius: 6px !important; text-transform: uppercase; letter-spacing: 1px; font-size: 12px !important; font-weight: 700 !important; }
body.theme-rc .tools-tab.active, body.theme-rc .rmgr-tab.active { background: var(--red) !important; color: #fff !important; border-color: var(--red) !important; }
body.theme-rc .login-box { border-radius: 10px; }
body.theme-rc .login-title, body.theme-rc .login-box h1 { font-family: var(--font-cond); font-weight: 800; font-style: italic; }
@media (max-width: 720px) { body.theme-rc .hub-logo { font-size: 22px; } body.theme-rc .hl-by { display: none; } }
