:root {
  --bg: #f3f1ec;
  --bg2: #e8e5dd;
  --card: #ffffff;
  --ink: #1b1d21;
  --ink2: #5d6168;
  --line: #d6d2c8;
  --accent: #2f7fc1;
  --sun: #e9a400;
  --ok: #2e9e5b;
  --part: #d9a21b;
  --no: #c8453b;
  --unk: #8b8f96;
  --tile-ink: #fff;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171b;
    --bg2: #1d2026;
    --card: #22262d;
    --ink: #eceae4;
    --ink2: #9aa0a8;
    --line: #333841;
    --accent: #74acdf;
    --sun: #f6b40e;
    --ok: #2f9e5e;
    --part: #c9971a;
    --no: #b9443b;
    --unk: #50555d;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  --bg: #15171b; --bg2: #1d2026; --card: #22262d; --ink: #eceae4; --ink2: #9aa0a8;
  --line: #333841; --accent: #74acdf; --sun: #f6b40e; --ok: #2f9e5e; --part: #c9971a;
  --no: #b9443b; --unk: #50555d;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Barlow, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* header */
.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px; max-width: 1180px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 {
  margin: 0; font: 800 30px/1 "Barlow Condensed", sans-serif; letter-spacing: .5px; text-transform: uppercase;
}
.plate {
  font: 700 13px/1 "Barlow Condensed", sans-serif; letter-spacing: 1px;
  background: #fff; color: #111; border: 2px solid #111; border-top: 6px solid #1b4f9c;
  border-radius: 4px; padding: 3px 6px;
}
.tabs { display: flex; gap: 4px; background: var(--bg2); padding: 4px; border-radius: 10px; }
.tabs button {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 7px; cursor: pointer;
  font: 700 16px/1 "Barlow Condensed", sans-serif; letter-spacing: .4px; text-transform: uppercase; color: var(--ink2);
}
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

main { max-width: 1180px; margin: 0 auto; padding: 0 16px 48px; }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 6px 0 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 6px 12px; cursor: pointer; color: var(--ink2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: var(--bg); }
select { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.sub { color: var(--ink2); font-size: 14px; }
.help { color: var(--ink2); margin: 0 0 12px; font-size: 14px; }
.k { display: inline-block; padding: 0 6px; border-radius: 4px; color: #fff; font-size: 12px; font-weight: 600; }
.k.ok { background: var(--ok); } .k.part { background: var(--part); } .k.no { background: var(--no); }
.fine { color: var(--ink2); font-size: 12px; }
.ghost {
  background: transparent; border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px;
  cursor: pointer; color: var(--ink2);
}
.ghost:hover { border-color: var(--ink2); color: var(--ink); }
.btn {
  background: var(--ink); color: var(--bg); border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer;
  font-weight: 600;
}

/* picker */
.picker { position: relative; max-width: 560px; }
.picker input {
  width: 100%; padding: 12px 14px; font-size: 17px; background: var(--card);
  border: 2px solid var(--line); border-radius: 10px; outline: none;
}
.picker input:focus { border-color: var(--accent); }
.picker input:disabled { opacity: .5; }
/* desplegable: el buscador va debajo de los intentos, así la lista abre hacia el espacio libre */
.sug {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px;
  list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 340px; overflow-y: auto; max-width: 560px;
}
.sug:empty { display: none; }
.sug li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.sug li.act, .sug li:hover { background: var(--bg2); }
.sug .th { width: 48px; height: 32px; border-radius: 4px; object-fit: cover; flex: none; }
.sug span.th { visibility: hidden; }
.sug .nm { font-weight: 600; }
.sug .yr { color: var(--ink2); font-size: 13px; margin-left: auto; white-space: nowrap; }
.spacer { height: 360px; } /* lugar para que el desplegable abra sin cortar la página */
#tab-autodle .picker { margin-top: 14px; }
.giveup { margin-top: 8px; font-size: 14px; }

/* autodle grid */
.grid-wrap { overflow-x: auto; margin-top: 14px; padding-bottom: 6px; }
.grid { display: grid; grid-template-columns: 150px repeat(12, 76px); gap: 6px; width: max-content; }
.grid .h {
  font: 700 13px/1.1 "Barlow Condensed", sans-serif; text-transform: uppercase; letter-spacing: .4px;
  color: var(--ink2); text-align: center; padding: 4px 2px; border-bottom: 2px solid var(--line);
  display: flex; align-items: end; justify-content: center;
}
.grid .h:first-child { justify-content: start; }
.tile {
  height: 82px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; font-size: 12.5px; line-height: 1.15; padding: 4px; color: var(--tile-ink); font-weight: 600;
  animation: flip .45s both; position: relative; overflow: hidden; word-break: break-word;
}
.tile .ar { font-size: 20px; line-height: 1; margin-top: 2px; }
.tile.ok { background: var(--ok); } .tile.part, .tile.near { background: var(--part); }
.tile.no { background: var(--no); } .tile.unk { background: var(--unk); }
.tile.name {
  background: var(--card); color: var(--ink); border: 1px solid var(--line); align-items: start; text-align: left;
  padding: 6px 8px; font-size: 13px;
}
.tile.name .yr { color: var(--ink2); font-weight: 500; font-size: 12px; margin-top: 2px; }
.tile.name.win { border: 2px solid var(--ok); }
@keyframes flip { from { transform: rotateX(90deg); opacity: 0; } to { transform: none; opacity: 1; } }

.hints { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: flex-start; }
.hint {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font-size: 14px;
}
.hint.locked { color: var(--ink2); border-style: dashed; }
.hint.spoiler { cursor: pointer; border-color: var(--accent); }
.hint.spoiler:hover { box-shadow: 0 0 0 1px var(--accent); }
.hint.spoiler .val { filter: blur(7px); pointer-events: none; user-select: none; display: inline-block; }
.hint.spoiler .val:has(.ph-img) { filter: none; }
.ph-img {
  display: grid; place-items: center; width: 120px; height: 80px; border-radius: 6px; margin-top: 6px;
  background: var(--bg2); font-size: 26px; opacity: .7;
}
.hint.spoiler .tap { color: var(--accent); font-weight: 600; margin-left: 4px; }
.hint img { display: block; max-width: 240px; border-radius: 6px; margin-top: 6px; }

.result:empty { display: none; }
.result {
  margin-top: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  box-shadow: var(--shadow); display: flex; flex-wrap: wrap; gap: 14px; align-items: center; max-width: 760px;
}
.result img { width: 220px; max-width: 100%; border-radius: 8px; }
.result h2 { margin: 0 0 4px; font: 800 26px/1 "Barlow Condensed", sans-serif; text-transform: uppercase; }
.result .meta { color: var(--ink2); font-size: 14px; }
.result .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* foto */
.foto-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 820px) { .foto-layout { grid-template-columns: 1fr; } }
.frame { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; box-shadow: var(--shadow); }
.frame canvas { width: 100%; height: auto; display: block; border-radius: 8px; background: var(--bg2); cursor: crosshair; }
.frame canvas[data-full] { cursor: zoom-in; }
.steps { display: flex; gap: 6px; margin-top: 10px; justify-content: center; }
.steps span {
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--line); display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: var(--ink2); cursor: default;
}
.steps span.seen { cursor: pointer; }
.steps span.cur { border: 2px solid var(--accent); color: var(--ink); }
.steps span.no { background: var(--no); color: #fff; border-color: transparent; }
.steps span.part { background: var(--part); color: #fff; border-color: transparent; }
.steps span.ok { background: var(--ok); color: #fff; border-color: transparent; }
.foto-side { display: flex; flex-direction: column; gap: 10px; }
.clues, .tries { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.clues li { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 14px; }
.clues li b { color: var(--ink2); font-weight: 600; margin-right: 4px; }
.clues li.spoiler { cursor: pointer; border-color: var(--accent); }
.clues li.spoiler:hover { box-shadow: 0 0 0 1px var(--accent); }
.clues li.spoiler .val { filter: blur(7px); pointer-events: none; user-select: none; display: inline-block; }
.clues li.spoiler .tap { color: var(--accent); font-weight: 600; margin-left: 4px; }
.tries li { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 8px; color: #fff; font-weight: 600; font-size: 14px; }
.tries li.no { background: var(--no); } .tries li.part { background: var(--part); } .tries li.ok { background: var(--ok); }
.tries li.skip { background: var(--unk); }
.tries li small { margin-left: auto; font-weight: 500; opacity: .9; }

/* mas o menos */
.hl { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: stretch; margin-top: 6px; }
@media (max-width: 720px) { .hl { grid-template-columns: 1fr; } .hl .vs { justify-self: center; } }
.car {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.car .pic { aspect-ratio: 16/9; background-size: cover; background-position: center; display: grid; place-items: center; }
.car .pic.ph {
  font: 800 34px/1 "Barlow Condensed", sans-serif; color: rgba(255,255,255,.92); text-transform: uppercase;
  text-align: center; padding: 10px; letter-spacing: 1px;
}
.car .pic.ph small { display: block; font-size: 15px; font-weight: 600; letter-spacing: .5px; opacity: .85; margin-top: 6px; }
.car .body { padding: 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.car .nm { font: 800 24px/1.05 "Barlow Condensed", sans-serif; text-transform: uppercase; }
.car .yr { color: var(--ink2); font-size: 14px; }
.car .val { font: 800 38px/1 "Barlow Condensed", sans-serif; margin-top: 8px; color: var(--accent); font-variant-numeric: tabular-nums; }
.car .lbl { color: var(--ink2); font-size: 13px; }
.car .ver { font-weight: 600; font-size: 15px; margin-top: 2px; }
.car .qa { display: flex; gap: 8px; margin-top: 10px; }
.car .qa button { flex: 1; padding: 12px; font-size: 17px; font-weight: 700; border-radius: 10px; border: 0; cursor: pointer; color: #fff; }
.car .qa .up { background: var(--ok); } .car .qa .down { background: var(--no); }
.car.good { outline: 3px solid var(--ok); } .car.bad { outline: 3px solid var(--no); }
.vs {
  align-self: center; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--bg); font: 800 20px/1 "Barlow Condensed", sans-serif;
}
.over { grid-column: 1 / -1; }

/* catálogo */
:root { --bar: #2f7fc1; --bar-mute: #cfd8e2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bar: #4f93dc; --bar-mute: #3a414c; } }
:root[data-theme="dark"] { --bar: #4f93dc; --bar-mute: #3a414c; }

.cat { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .cat { grid-template-columns: 1fr; } }
.cat-side {
  position: sticky; top: 10px; display: flex; flex-direction: column; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px;
}
@media (max-width: 860px) { .cat-side { position: static; } }
.cat-side input[type=search] {
  width: 100%; padding: 9px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.cat-side input[type=search]:focus { border-color: var(--accent); }
.cat-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cat-filters select { flex: 1 1 130px; min-width: 0; padding: 5px 6px; font-size: 14px; }
.cat-sort { display: flex; gap: 6px; flex: 1 1 100%; }
.cat-sort select { flex: 1; }
.cat-sort button { padding: 4px 10px; font-size: 15px; line-height: 1; }
.cat-list .val { font-variant-numeric: tabular-nums; }
.chk { font-size: 14px; display: flex; gap: 6px; align-items: center; color: var(--ink2); cursor: pointer; }
.cat-list { max-height: calc(100vh - 210px); overflow-y: auto; margin: 0 -4px; }
@media (max-width: 860px) { .cat-list { max-height: 42vh; } }
.cat-list .grp {
  position: sticky; top: 0; background: var(--card); z-index: 1;
  font: 700 13px/1 "Barlow Condensed", sans-serif; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ink2); padding: 8px 8px 5px; border-bottom: 1px solid var(--line);
}
.cat-list button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0;
  padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.cat-list button:hover { background: var(--bg2); }
.cat-list button.on { background: var(--ink); color: var(--bg); }
.cat-list button.on .yr { color: inherit; opacity: .75; }
.cat-list .th { width: 36px; height: 24px; border-radius: 3px; object-fit: cover; flex: none; background: var(--bg2); }
.cat-list .yr { color: var(--ink2); font-size: 12.5px; margin-left: auto; white-space: nowrap; }

.cat-detail { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.ficha-head h2 { margin: 0; font: 800 34px/1 "Barlow Condensed", sans-serif; text-transform: uppercase; }
.ficha-head .meta { color: var(--ink2); margin-top: 4px; }
.ficha-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .ficha-top { grid-template-columns: 1fr; } }
.gal .main {
  width: 100%; aspect-ratio: 3/2; object-fit: cover; border-radius: 10px; display: block; background: var(--bg2);
}
.gal .none {
  aspect-ratio: 3/2; border-radius: 10px; display: grid; place-items: center; color: var(--ink2);
  background: var(--bg2); border: 1px dashed var(--line);
}
.gal .thumbs { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.gal .thumbs button { padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; cursor: pointer; }
.gal .thumbs button.on { border-color: var(--accent); }
.gal .thumbs img { width: 72px; height: 48px; object-fit: cover; border-radius: 4px; display: block; }
.gal .cap { color: var(--ink2); font-size: 13px; margin-top: 4px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat .k { display: block; color: var(--ink2); font-size: 12.5px; padding: 0; background: none; font-weight: 500; }
.stat .v { font: 700 24px/1.1 "Barlow Condensed", sans-serif; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 14px; margin-top: 10px; }
.facts dt { color: var(--ink2); }
.facts dd { margin: 0; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.box h3 { margin: 0 0 10px; font: 700 18px/1 "Barlow Condensed", sans-serif; text-transform: uppercase; letter-spacing: .4px; }
.box h3 small { font: 400 13px Barlow, sans-serif; text-transform: none; color: var(--ink2); letter-spacing: 0; margin-left: 6px; }

/* barras de ventas por año: una serie, tono único; fuera de la generación en gris */
.bars { position: relative; display: flex; align-items: flex-end; height: 160px; gap: 2px; border-bottom: 1px solid var(--line); }
.bars .col { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.bars .b { width: 100%; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b.out { background: var(--bar-mute); }
.bars .col:hover .b { filter: brightness(1.15); }
.bars .peak { position: absolute; font-size: 12px; font-weight: 600; color: var(--ink); transform: translate(-50%, -100%); white-space: nowrap; padding-bottom: 2px; }
.bars-x { display: flex; gap: 2px; font-size: 11.5px; color: var(--ink2); margin-top: 3px; }
.bars-x span { flex: 1; text-align: center; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--ink2); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }
.tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 13px; padding: 5px 8px;
  border-radius: 6px; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px)); z-index: 5;
}

.vt-wrap { overflow-x: auto; }
.vt { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.vt th {
  text-align: left; font: 700 12.5px/1.1 "Barlow Condensed", sans-serif; text-transform: uppercase; letter-spacing: .4px;
  color: var(--ink2); padding: 6px 8px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
.vt td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
.vt td:nth-child(2) { white-space: normal; min-width: 180px; }
.vt tr.nota td { white-space: pre-wrap; }
.vt td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vt th.n { text-align: right; }
.vt tr.row { cursor: pointer; }
.vt tr.row:hover td { background: var(--bg2); }
.vt tr.row.open td { background: var(--bg2); }
.vt .tag { font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: var(--sun); color: #222; margin-left: 4px; }
.vt .cam { margin-left: 4px; cursor: pointer; }
.vt tr.nota td { background: var(--bg); font-size: 13px; color: var(--ink2); white-space: pre-wrap; }
.vt tr.nota a { color: var(--accent); word-break: break-all; }
.btn-ficha { margin-left: 0; }

[data-full] { cursor: zoom-in; }
.lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(10, 11, 13, .92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px;
}
.lb-scroll { max-width: 100%; max-height: calc(100vh - 70px); overflow: auto; display: flex; }
.lb-scroll img { max-width: calc(100vw - 32px); max-height: calc(100vh - 70px); margin: auto; display: block; cursor: zoom-in; }
.lightbox.real .lb-scroll img { max-width: none; max-height: none; cursor: zoom-out; }
.lightbox.fits .lb-scroll img { cursor: default; }
.lb-cap { color: #ddd; font-size: 14px; margin-top: 10px; text-align: center; }
.lb-close {
  position: absolute; top: 12px; right: 14px; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.6); color: #fff; font-size: 18px; cursor: pointer; z-index: 2;
  box-shadow: 0 0 0 1px rgba(255,255,255,.35);
}
.lb-close:hover { background: rgba(0,0,0,.85); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; transition: .25s; pointer-events: none;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
