/* Layout: oficina de carrera — barra fija con fecha activa y pestañas de trabajo; hojas de manga como tarjetas en grilla */
:root {
  --bg: #EEF1EE; --surface: #FFFFFF; --surface-2: #F6F8F6; --ink: #142019; --muted: #5A6860; --line: #D4DBD6;
  --accent: #0B7A4B; --accent-ink: #FFFFFF; --accent-soft: #DCEFE5;
  --warn: #9A5200; --warn-soft: #FBEBD6; --bad: #B42318; --bad-soft: #FBE3E0; --signal: #F2C200;
  --f-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0E1411; --surface: #151D19; --surface-2: #1A2420; --ink: #E4EBE7; --muted: #92A39A; --line: #29362F;
  --accent: #3BC487; --accent-ink: #04140C; --accent-soft: #163327; --warn: #F0A24A; --warn-soft: #3A2A14; --bad: #F27B70; --bad-soft: #3D1C19; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0E1411; --surface: #151D19; --surface-2: #1A2420; --ink: #E4EBE7; --muted: #92A39A; --line: #29362F;
  --accent: #3BC487; --accent-ink: #04140C; --accent-soft: #163327; --warn: #F0A24A; --warn-soft: #3A2A14; --bad: #F27B70; --bad-soft: #3D1C19; color-scheme: dark }
html, body { background: var(--bg); color: var(--ink); }
body { font-family: var(--f-body); font-size: 14px; line-height: 1.45; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
* { box-sizing: border-box; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1280px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding-block: 10px 6px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 700; font-size: 24px; letter-spacing: .02em; text-transform: uppercase; }
.lights { display: inline-flex; gap: 3px; padding: 4px 5px; background: #111; border-radius: 4px; }
.lights i { width: 7px; height: 7px; border-radius: 50%; display: block; }
.lights i:nth-child(1) { background: #E5342B; } .lights i:nth-child(2), .lights i:nth-child(3) { background: #F2C200; } .lights i:nth-child(4) { background: #2BC46F; }
.fecha-pick { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; }
.fecha-pick label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.fecha-pick select { max-width: 60vw; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 9px 12px 10px; font-family: var(--f-display); font-size: 17px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab:hover { color: var(--ink); }

main { max-width: 1280px; margin: 0 auto; padding-block: 20px 60px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 18px; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; letter-spacing: .02em; margin: 0; text-wrap: balance; }
h1 { font-size: 30px; text-transform: uppercase; }
h2 { font-size: 22px; text-transform: uppercase; }
h3 { font-size: 18px; }
p { margin: 0; }
.sub { color: var(--muted); }
.small { font-size: 12.5px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; justify-content: space-between; }
.head > div { min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grow { flex: 1 1 200px; min-width: 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.panel.flat { background: var(--surface-2); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); display: grid; gap: 8px; justify-items: center; }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: var(--r); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.pri:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.ghost { border-color: transparent; background: none; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 9px; width: 100%; min-width: 0; }
textarea { min-height: 110px; font-family: var(--f-mono); font-size: 12.5px; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.check { display: flex; gap: 6px; align-items: center; }

.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.mono { font-family: var(--f-mono); }
.nowrap { white-space: nowrap; }

.plate { display: inline-block; min-width: 2.7em; text-align: center; font-family: var(--f-mono); font-weight: 600; font-size: 13px; padding: 2px 6px 3px; border-radius: 3px 3px 9px 9px; border: 1px solid rgba(0,0,0,.28); line-height: 1.2; }
.pl-b { background: #F4CB16; color: #111; } .pl-g { background: #1F5BC4; color: #fff; } .pl-cru { background: #C7291F; color: #fff; }
.pl-el { background: #FFFFFF; color: #111; } .pl-u23 { background: #8C9490; color: #fff; } .pl-jr { background: #141414; color: #fff; border-color: #555; }
.lane { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 4px; background: var(--ink); color: var(--bg); font-family: var(--f-mono); font-weight: 600; font-size: 13px; }
.lane.empty { background: none; color: var(--muted); border: 1px dashed var(--line); }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.ok { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.irm { font-family: var(--f-mono); font-weight: 600; font-size: 12px; color: var(--bad); }

.layout-race { display: grid; grid-template-columns: 270px 1fr; gap: 16px; align-items: start; }
.racelist { display: grid; gap: 4px; max-height: calc(100vh - 160px); overflow-y: auto; position: sticky; top: 110px; }
.raceitem { text-align: left; border: 1px solid transparent; background: none; border-radius: var(--r); padding: 8px 10px; cursor: pointer; display: grid; gap: 3px; }
.raceitem:hover { background: var(--surface); }
.raceitem[aria-current="true"] { background: var(--surface); border-color: var(--line); box-shadow: inset 3px 0 0 var(--accent); }
.raceitem b { font-weight: 600; }
.racesel { display: none; }
@media (max-width: 860px) { .layout-race { grid-template-columns: 1fr; } .racelist { display: none; } .racesel { display: block; } }

.rounds { display: flex; gap: 6px; flex-wrap: wrap; }
.rbtn { border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 99px; cursor: pointer; font-family: var(--f-display); font-weight: 600; font-size: 16px; letter-spacing: .03em; text-transform: uppercase; display: inline-flex; gap: 6px; align-items: center; }
.rbtn[aria-current="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.rbtn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.rbtn .dot.done { background: var(--accent); }

.heats { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
@media (max-width: 420px) { .heats { grid-template-columns: 1fr; } }
.heat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); display: grid; min-width: 0; }
.heat-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.heat-h h3 { font-size: 19px; text-transform: uppercase; }
.heat table td { padding: 6px 10px; }
.heat .who { min-width: 0; }
.heat .who small { display: block; color: var(--muted); font-size: 12px; }
.entry { padding: 10px 12px; display: grid; gap: 8px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r) var(--r); }
.pickrow { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 4px 6px; cursor: pointer; display: inline-flex; gap: 5px; align-items: center; }
.pick:hover { border-color: var(--accent); }
.placed { display: flex; flex-wrap: wrap; gap: 6px; min-height: 32px; align-items: center; }
.placed .pos { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.place-n { font-family: var(--f-display); font-weight: 700; font-size: 18px; }
.transfer { color: var(--accent); font-weight: 600; }
.pts { font-family: var(--f-mono); font-weight: 600; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.stat { display: grid; gap: 2px; }
.stat b { font-family: var(--f-display); font-size: 30px; line-height: 1; }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stats { display: flex; flex-wrap: wrap; gap: 28px; }
.note { border-left: 3px solid var(--warn); background: var(--warn-soft); padding: 8px 12px; border-radius: 0 var(--r) var(--r) 0; }
.note.info { border-color: var(--accent); background: var(--accent-soft); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r); z-index: 20; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--bad); color: #fff; }
.catgroup { display: grid; gap: 6px; }
.catgroup-h { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
details > summary { cursor: pointer; font-weight: 600; }
@media (prefers-reduced-motion: no-preference) { .btn, .tab, .pick { transition: border-color .12s, background-color .12s, color .12s; } }
/* ----- Planillas imprimibles: la hoja es siempre papel blanco, también en modo oscuro ----- */
:root { --paper: #FFFFFF; --paper-ink: #111111; --paper-line: #8E9692; --paper-soft: #ECEFEC; }
.sheet-wrap { overflow-x: auto; }
.sheet { background: var(--paper); color: var(--paper-ink); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 14px; min-width: 640px; font-size: 12px; align-content: start; }
.sheet.land { min-width: 980px; }
.sheet table { width: 100%; border-collapse: collapse; }
.sheet th, .sheet td { padding: 2px 5px; border: 1px solid var(--paper-line); color: var(--paper-ink); font-size: 11px; line-height: 1.3; }
.sheet th { background: var(--paper-soft); font-weight: 600; letter-spacing: 0; text-transform: none; }
.sheet tr:last-child td { border-bottom: 1px solid var(--paper-line); }
.sheet tbody + tbody tr:first-child td { border-top: 1.5px dashed var(--paper-ink); }
.sheet td.ln { text-align: center; font-family: var(--f-mono); width: 30px; white-space: nowrap; }
.sheet td.pl { text-align: right; font-family: var(--f-mono); font-weight: 600; width: 42px; }
.sheet td small { font-size: 9.5px; }
.p-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px; border-bottom: 2px solid var(--paper-ink); padding-bottom: 6px; }
.p-head > div { display: grid; font-size: 11px; }
.p-head > div b { font-size: 13px; }
.p-head h2 { font-size: 20px; text-align: center; }
.p-ts { justify-self: end; font-size: 10px; }
.p-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; }
.p-box, .p-sec { break-inside: avoid; display: grid; gap: 3px; min-width: 0; }
.p-bh, .p-sh { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.p-bh b { font-family: var(--f-display); font-size: 15px; text-transform: uppercase; }
.p-bh i, .p-sh i { font-size: 10.5px; }
.p-sh h3 { font-size: 16px; text-transform: uppercase; }
.p-sh h3 span:not(.p-num) { font-size: 12px; text-transform: none; }
.p-num { font-family: var(--f-mono); font-weight: 600; font-size: 12px; }
.p-prov { font-size: 10px; text-transform: uppercase; border: 1px solid var(--paper-ink); padding: 0 4px; }
.p-vacio { color: var(--paper-ink); padding: 12px 0; }
.p-foot { font-size: 10px; border-top: 1px solid var(--paper-line); padding-top: 4px; }
@media print {
  html, body { background: #fff; }
  .top, .no-print, #toast, body::before { display: none !important; }
  main { padding: 0; max-width: none; display: block; }
  .sheet-wrap { overflow: visible; }
  .sheet { border: 0; border-radius: 0; padding: 0; min-width: 0; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
[hidden]{display:none!important}
body{margin:0}
.login{max-width:420px}
