/* ───────── Tokens ───────── */
:root {
  --paper: #e9e5db;
  --card: #f6f3ec;
  --card-2: #efebe1;
  --ink: #16181c;
  --ink-2: #4a4c50;
  --ink-3: #7a7a76;
  --rule: #cbc5b7;
  --rule-strong: #16181c;
  --red: #c4311d;

  --m: #f5c518;  --m-ink: #1d1a0c;  --m-soft: #f8e7a3;
  --t: #b45f1f;  --t-ink: #fff7ee;  --t-soft: #e8c5a5;
  --n: #1c2d63;  --n-ink: #eef2ff;  --n-soft: #b9c3e2;
  --v: #0f9a85;  --v-ink: #f0fffb;  --v-soft: #a9ded4;
  --l: transparent;

  --brand: #f5c518;
  --shadow: 0 1px 0 rgba(22,24,28,.06), 0 10px 30px -12px rgba(22,24,28,.28);
  --ease: cubic-bezier(.16,1,.3,1);
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, sans-serif;
  --r: 6px;
  --head-h: 76px;
  color-scheme: light;
}
:root[data-theme="noche"] {
  --paper: #0f1114;
  --card: #181b20;
  --card-2: #1e2228;
  --ink: #ece7dc;
  --ink-2: #b4b0a6;
  --ink-3: #807d76;
  --rule: #2c3038;
  --rule-strong: #ece7dc;
  --red: #ff6a52;
  --n: #2b4596; --n-soft: #2a3558;
  --m-soft: #4b3f12; --t-soft: #4a2f1b; --v-soft: #13443d;
  --shadow: 0 1px 0 rgba(0,0,0,.4), 0 14px 34px -14px rgba(0,0,0,.8);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="claro"]):not([data-theme="noche"]) {
    --paper: #0f1114; --card: #181b20; --card-2: #1e2228;
    --ink: #ece7dc; --ink-2: #b4b0a6; --ink-3: #807d76;
    --rule: #2c3038; --rule-strong: #ece7dc; --red: #ff6a52;
    --n: #2b4596; --n-soft: #2a3558;
    --m-soft: #4b3f12; --t-soft: #4a2f1b; --v-soft: #13443d;
    --shadow: 0 1px 0 rgba(0,0,0,.4), 0 14px 34px -14px rgba(0,0,0,.8);
    color-scheme: dark;
  }
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-width: none; touch-action: pan-x pan-y; overflow-x: hidden; }
body { overflow-x: hidden; touch-action: pan-y; }
.ph-m { display: none; font-style: normal; }
html::-webkit-scrollbar, *::-webkit-scrollbar { display: none; width: 0; height: 0; }
* { scrollbar-width: none; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 500 15px/1.4 var(--body);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
::selection { background: var(--brand); color: #16181c; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 3px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.lbl {
  font: 600 11px/1 var(--cond); letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3);
}
.cond { font-family: var(--cond); }

/* ───────── Cabecera tipo task card ───────── */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.head {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: auto 1fr auto; align-items: stretch;
  background: var(--card); border-bottom: 2px solid var(--rule-strong);
  padding-top: env(safe-area-inset-top);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 18px; border-right: 1px solid var(--rule); }
.brand-mark {
  background: #16181c; color: #fff; padding: 7px 10px 6px;
  font: 800 23px/1 var(--cond); letter-spacing: .02em;
  border-radius: 3px; box-shadow: inset 0 -3px 0 var(--brand);
}
:root[data-theme="noche"] .brand-mark { background: var(--brand); color: #16181c; box-shadow: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="claro"]) .brand-mark { background: var(--brand); color: #16181c; box-shadow: none; } }
.brand-sub { font: 600 11px/1.05 var(--cond); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); }

.head-fields { display: flex; margin: 0; min-width: 0; overflow-x: auto; }
.head-fields > div { padding: 12px 18px; border-right: 1px solid var(--rule); display: flex; flex-direction: column; justify-content: center; gap: 5px; min-width: max-content; }
.head-fields dt { font: 600 10.5px/1 var(--cond); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.head-fields dd { margin: 0; font: 700 19px/1 var(--cond); letter-spacing: .01em; }
.head-fields .prov { color: var(--red); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }

.tabs { display: flex; }
.tabs button {
  display: flex; align-items: center; gap: 8px; padding: 0 20px; height: 100%;
  font: 700 14px/1 var(--cond); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2);
  border-left: 1px solid var(--rule); position: relative; transition: color .2s, background .2s;
}
.tabs button:hover { color: var(--ink); background: var(--card-2); }
.tabs button[aria-current="page"] { color: var(--ink); background: var(--paper); }
.tabs button[aria-current="page"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 4px; background: var(--brand); }

main { flex: 1; min-height: 0; }
.view { animation: viewIn .5s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }

/* ───────── Vista MES ───────── */
.mes {
  display: grid; grid-template-columns: minmax(290px, 340px) minmax(0, 1fr) minmax(320px, 380px);
  height: calc(100dvh - var(--head-h)); min-height: 520px;
}
:root { --tabs-h: 0px; }
.ed { padding: 16px 20px 20px; }
.ed-head h2 { font-size: 38px; }
.ed-sec { margin-top: 14px; padding-top: 12px; }
.sw-row { padding: 7px 0; }
.col { min-height: 0; overflow-y: auto; }
.col-l { border-right: 1px solid var(--rule); display: flex; flex-direction: column; }
.col-r { border-left: 1px solid var(--rule); background: var(--card); }

/* Bloque HOY */
.hoy { padding: 20px 22px 22px; border-bottom: 1px solid var(--rule); position: relative; overflow: hidden; }
.hoy-fecha { display: flex; justify-content: space-between; align-items: baseline; }
.hoy-fecha strong { font: 700 15px/1 var(--cond); letter-spacing: .08em; text-transform: uppercase; }
.hoy-turno {
  margin-top: 14px; padding: 16px 16px 14px; border-radius: var(--r);
  background: var(--shift-bg, var(--card-2)); color: var(--shift-ink, var(--ink));
  position: relative; overflow: hidden;
}
.hoy-turno .big { font: 800 64px/.86 var(--cond); letter-spacing: -.02em; text-transform: uppercase; display: block; }
.hoy-turno .hrs { font: 600 18px/1 var(--cond); letter-spacing: .04em; margin-top: 10px; display: block; }
.hoy-turno .bloque { position: absolute; right: 14px; top: 14px; font: 700 12px/1 var(--cond); letter-spacing: .1em; text-transform: uppercase; opacity: .8; }
.hoy-turno .pips { display: flex; gap: 4px; margin-top: 12px; }
.hoy-turno .pips i { flex: 1; height: 5px; border-radius: 2px; background: currentColor; opacity: .22; }
.hoy-turno .pips i.on { opacity: 1; }
.hoy-turno .pips i.now { opacity: 1; animation: pip 1.6s ease-in-out infinite; }
@keyframes pip { 50% { opacity: .45; } }

.prox { margin-top: 16px; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center; }
.prox .chip { grid-row: span 2; }
.prox b { font: 700 19px/1.05 var(--cond); text-transform: uppercase; letter-spacing: .02em; }
.prox span { color: var(--ink-2); font-size: 13.5px; }
.cuenta { margin-top: 16px; display: flex; gap: 6px; }
.flap {
  background: #16181c; color: #f5c518; border-radius: 4px; min-width: 52px; padding: 8px 6px 6px; text-align: center;
  font: 700 28px/1 var(--cond); position: relative; box-shadow: inset 0 -1px 0 rgba(255,255,255,.08);
}
.flap::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(0,0,0,.6); }
.flap small { display: block; font: 600 10px/1 var(--cond); letter-spacing: .1em; color: #a39c86; margin-top: 4px; }
.flap.tick { animation: flap .45s var(--ease); }
@keyframes flap { 0% { transform: rotateX(70deg); filter: brightness(.6); } 100% { transform: none; } }

.leyenda { padding: 18px 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; border-bottom: 1px solid var(--rule); }
.leyenda div { display: flex; align-items: center; gap: 8px; font: 600 14px/1 var(--cond); letter-spacing: .05em; text-transform: uppercase; }
.sw { width: 18px; height: 18px; border-radius: 3px; flex: none; background: var(--c); }
.sw.fest { background: var(--card); border: 1px solid var(--rule); position: relative; overflow: hidden; }
.sw.fest::after { content: ""; position: absolute; right: 0; top: 0; border: 7px solid transparent; border-top-color: var(--red); border-right-color: var(--red); }
.sw.hoyc { background: none; border: 2.5px solid var(--ink); border-radius: 50%; }
.sw.mod { background: none; display: grid; place-items: center; }
.sw.mod::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

.mini-stats { padding: 18px 22px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px 14px; }
.mini-stats .v { font: 700 30px/1 var(--cond); letter-spacing: -.01em; display: block; margin-top: 6px; }
.mini-stats .v small { font-size: 15px; color: var(--ink-3); font-weight: 600; margin-left: 2px; }
.barra { grid-column: 1 / -1; }
.barra .track { height: 10px; background: var(--card-2); border: 1px solid var(--rule); border-radius: 2px; margin-top: 8px; overflow: hidden; display: flex; }
.barra .track i { display: block; height: 100%; transform-origin: left; animation: grow 1s var(--ease) both .15s; }
@keyframes grow { from { transform: scaleX(0); } }
.barra .meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12.5px; color: var(--ink-2); }

/* Rejilla del mes */
.col-c { display: flex; flex-direction: column; padding: 18px 22px 22px; overflow: hidden; }
.mes-nav { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 14px; }
.mes-nav h1 { margin: 0; font: 800 clamp(40px, 4.4vw, 68px)/.85 var(--cond); letter-spacing: -.02em; text-transform: uppercase; }
.mes-nav h1 span { color: var(--ink-3); font-weight: 600; }
.guias { font: 600 12px/1.2 var(--cond); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.mes-nav .sp { flex: 1; }
.btn-ic {
  width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--card); transition: background .2s, transform .15s, border-color .2s;
}
.btn-ic:hover { border-color: var(--ink); }
.btn-ic:active { transform: scale(.94); }
.btn {
  height: 42px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--rule); background: var(--card);
  font: 700 14px/1 var(--cond); letter-spacing: .08em; text-transform: uppercase; display: inline-flex; align-items: center; gap: 8px;
  transition: border-color .2s, background .2s, transform .15s;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: scale(.97); }
.btn.solid { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.yellow { background: var(--brand); color: #16181c; border-color: #16181c; }

.dow { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--rule-strong); border-bottom: 0; background: var(--ink); color: var(--paper); border-radius: var(--r) var(--r) 0 0; }
.dow span { padding: 8px 10px; font: 700 12px/1 var(--cond); letter-spacing: .14em; text-transform: uppercase; }
.dow span:nth-child(7) { color: var(--brand); }
.grid-wrap { flex: 1; min-height: 0; position: relative; perspective: 1400px; }
.grid {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr);
  gap: 1px; background: var(--rule); border: 1px solid var(--rule-strong); border-top: 0; border-radius: 0 0 var(--r) var(--r); overflow: hidden;
}
.grid.in-next { animation: pageNext .55s var(--ease) both; }
.grid.in-prev { animation: pagePrev .55s var(--ease) both; }
@keyframes pageNext { from { opacity: 0; transform: translateX(40px) rotateY(-6deg); transform-origin: left; } }
@keyframes pagePrev { from { opacity: 0; transform: translateX(-40px) rotateY(6deg); transform-origin: right; } }

.d {
  position: relative; background: var(--card); color: var(--ink); text-align: left;
  padding: 8px 9px; display: flex; flex-direction: column; justify-content: space-between; min-height: 0; overflow: hidden;
  transition: filter .2s, box-shadow .2s;
  animation: cellIn .45s var(--ease) both; animation-delay: calc(var(--i) * 9ms);
}
@keyframes cellIn { from { opacity: 0; transform: translateY(6px); } }
.d:hover { filter: brightness(1.04); }
.d.out { background: var(--card-2); }
.d.out > * { opacity: .38; }
.d .num { font: 700 22px/1 var(--cond); width: 34px; height: 34px; display: grid; place-items: center; margin: -5px 0 0 -6px; border-radius: 50%; position: relative; }
.d .lab { font: 700 13px/1 var(--cond); letter-spacing: .07em; text-transform: uppercase; }
.d .hr { font: 600 12px/1.1 var(--cond); letter-spacing: .03em; opacity: .8; margin-top: 3px; }
.d .letra { position: absolute; right: 6px; bottom: -10px; font: 800 64px/1 var(--cond); opacity: .13; pointer-events: none; }
.d.M { background: var(--m); color: var(--m-ink); }
.d.T { background: var(--t); color: var(--t-ink); }
.d.N { background: var(--n); color: var(--n-ink); }
.d.V { background: var(--v); color: var(--v-ink); }
.d.L .lab { color: var(--ink-3); font-weight: 600; }
.d.sel { box-shadow: inset 0 0 0 3px var(--ink); z-index: 2; }
.d.N.sel, .d.T.sel, .d.V.sel { box-shadow: inset 0 0 0 3px var(--ink), inset 0 0 0 5px var(--card); }
.d.hoy .num::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2.5px solid currentColor; animation: ring 2.4s var(--ease) both .3s; }
@keyframes ring { 0% { transform: scale(1.8); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; } }
.d.fest::after { content: ""; position: absolute; top: 0; right: 0; border: 11px solid transparent; border-top-color: var(--red); border-right-color: var(--red); }
.d .tags { position: absolute; top: 7px; right: 8px; display: flex; gap: 4px; align-items: center; }
.d.fest .tags { right: 24px; }
.tag-x { font: 700 11px/1 var(--cond); letter-spacing: .04em; padding: 3px 5px 2px; border-radius: 3px; background: var(--ink); color: var(--paper); }
.d.M .tag-x, .d.V .tag-x { background: #16181c; color: #fff; }
.d.N .tag-x, .d.T .tag-x { background: #fff; color: #16181c; }
.dot-mod { width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--card); }
.d.M .dot-mod, .d.T .dot-mod, .d.N .dot-mod, .d.V .dot-mod { box-shadow: 0 0 0 2px rgba(255,255,255,.85); }
.d .festn { font: 600 10.5px/1.1 var(--cond); letter-spacing: .05em; text-transform: uppercase; color: var(--red); margin-top: 2px; }
.d.M .festn, .d.T .festn, .d.N .festn, .d.V .festn { color: inherit; opacity: .9; }

/* ───────── Editor del día (panel / hoja) ───────── */
.ed { padding: 20px 22px 28px; }
.ed-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.ed-head h2 { margin: 6px 0 0; font: 800 44px/.88 var(--cond); text-transform: uppercase; letter-spacing: -.01em; }
.ed-head h2 small { display: block; font-size: 17px; font-weight: 600; color: var(--ink-3); letter-spacing: .06em; margin-top: 6px; }
.ed-sec { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--rule); position: relative; }
.ed-sec > .lbl { display: flex; justify-content: space-between; margin-bottom: 10px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--ink); border-radius: var(--r); overflow: hidden; }
.seg button { padding: 11px 0 10px; font: 700 14px/1 var(--cond); letter-spacing: .06em; text-transform: uppercase; border-left: 1px solid var(--ink); transition: background .2s, color .2s; }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"][data-t="M"] { background: var(--m); color: var(--m-ink); }
.seg button[aria-pressed="true"][data-t="T"] { background: var(--t); color: var(--t-ink); }
.seg button[aria-pressed="true"][data-t="N"] { background: var(--n); color: var(--n-ink); }
.seg button[aria-pressed="true"][data-t="L"], .seg button[aria-pressed="true"][data-tema] { background: var(--ink); color: var(--paper); }
.nota-plan { font-size: 13px; color: var(--ink-2); margin-top: 8px; }

.sw-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; gap: 12px; }
.sw-row + .sw-row { border-top: 1px solid var(--rule); }
.sw-row b { font: 700 17px/1 var(--cond); letter-spacing: .04em; text-transform: uppercase; display: block; }
.sw-row span { font-size: 13px; color: var(--ink-2); }
.toggle { width: 52px; height: 30px; border-radius: 15px; background: var(--card-2); border: 1px solid var(--rule); position: relative; transition: background .25s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink-3); transition: transform .35s var(--ease), background .25s; }
.toggle[aria-checked="true"] { background: var(--tc, var(--ink)); border-color: var(--tc, var(--ink)); }
.toggle[aria-checked="true"]::after { transform: translateX(22px); background: #fff; }

.extra { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; animation: viewIn .35s var(--ease) both; }
.extra span { color: var(--ink-3); font: 600 13px/1 var(--cond); }
.inp {
  height: 42px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--paper); padding: 0 10px;
  font: 600 17px/1 var(--cond); letter-spacing: .03em; width: 100%; min-width: 0;
}
.inp:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 45%, transparent); }
textarea.inp { height: 70px; padding: 10px; resize: none; font: 500 14px/1.4 var(--body); }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.presets .btn { height: 34px; padding: 0 11px; font-size: 13px; }

.calc { margin-top: 20px; border: 1px solid var(--ink); border-radius: var(--r); overflow: hidden; }
.calc-row { display: flex; justify-content: space-between; padding: 9px 12px; font-size: 14px; border-top: 1px solid var(--rule); }
.calc-row:first-child { border-top: 0; }
.calc-row b { font: 700 16px/1 var(--cond); letter-spacing: .02em; }
.calc-row.tot { background: var(--ink); color: var(--paper); }
.calc-row.tot b { font-size: 20px; }

/* Sello */
.stamp {
  position: absolute; right: 4px; top: 6px; pointer-events: none;
  font: 800 22px/1 var(--cond); letter-spacing: .12em; text-transform: uppercase;
  color: var(--sc, var(--v)); border: 3px solid currentColor; border-radius: 6px; padding: 6px 10px 4px;
  transform: rotate(-9deg); opacity: .92; mix-blend-mode: multiply;
}
:root[data-theme="noche"] .stamp { mix-blend-mode: screen; }
.stamp.drop { animation: stamp .5s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes stamp { 0% { transform: rotate(-20deg) scale(2.2); opacity: 0; } 60% { opacity: 1; } 100% { transform: rotate(-9deg) scale(1); } }

/* ───────── Vista AÑO ───────── */
.ano {
  height: calc(100dvh - var(--head-h) - var(--tabs-h)); min-height: 520px;
  padding: 14px 22px 18px; display: flex; flex-direction: column; gap: 14px; overflow: hidden;
}
.ano-top { display: flex; align-items: stretch; gap: 18px; flex: none; }
.ano-top > div:first-child { display: flex; flex-direction: column; justify-content: flex-end; }
.ano-top h1 { margin: 0; font: 800 clamp(48px, 4.6vw, 80px)/.82 var(--cond); letter-spacing: -.02em; }
.ano-nav { display: flex; gap: 8px; align-items: flex-end; }
.ano-stats { flex: 1; display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); border: 1px solid var(--rule-strong); border-radius: var(--r); background: var(--card); overflow: hidden; }
.ano-stats > div { padding: 10px 14px; border-left: 1px solid var(--rule); }
.ano-stats > div:first-child { border-left: 0; }
.ano-stats .v { font: 700 28px/1 var(--cond); display: block; margin-top: 5px; }
.ano-stats .v small { font-size: 14px; color: var(--ink-3); }
.ano-stats .wide { grid-column: span 2; }
.ano-stats .track { margin-top: 6px; }
.meses { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mm {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); padding: 10px 10px 8px; text-align: left;
  transition: border-color .2s, transform .25s var(--ease), box-shadow .25s;
  animation: viewIn .5s var(--ease) both; animation-delay: calc(var(--i) * 35ms);
}
.mm:hover { border-color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow); }
.mm.actual { border: 2px solid var(--ink); padding: 9px 9px 7px; }
.mm-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; flex: none; }
.mm-h b { font: 800 22px/1 var(--cond); text-transform: uppercase; letter-spacing: .01em; }
.mm-h span { font: 600 12px/1 var(--cond); color: var(--ink-3); letter-spacing: .06em; }
.mm-g { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: auto repeat(6, minmax(0, 1fr)); gap: 2px; }
.mm-g i { min-height: 0; display: grid; place-items: center; font: 600 clamp(9px, 1.5vh, 13px)/1 var(--cond); font-style: normal; border-radius: 2px; position: relative; color: var(--ink-2); }
.mm-g i.M { background: var(--m); color: var(--m-ink); }
.mm-g i.T { background: var(--t); color: var(--t-ink); }
.mm-g i.N { background: var(--n); color: var(--n-ink); }
.mm-g i.V { background: var(--v); color: var(--v-ink); }
.mm-g i.f::after { content: ""; position: absolute; top: 0; right: 0; border: 4px solid transparent; border-top-color: var(--red); border-right-color: var(--red); }
.mm-g i.h { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink); z-index: 1; }
.mm-g i.dw { font-size: 10px; color: var(--ink-3); padding-bottom: 2px; }
.mm-f { flex: none; display: flex; gap: 10px; margin-top: 7px; font: 600 12px/1 var(--cond); letter-spacing: .05em; color: var(--ink-2); }
.mm-f em { font-style: normal; display: inline-flex; align-items: center; gap: 4px; }
.mm-f em::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c); }

/* ───────── Vista NÓMINA ───────── */
.nom { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 0; height: calc(100dvh - var(--head-h)); }
.nom-l { padding: 16px 26px 18px; border-right: 1px solid var(--rule); overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.nom-r { padding: 16px 26px 18px; background: var(--card); overflow-y: auto; }
.nom-top { display: flex; align-items: center; gap: 8px; }
.nom-y { font: 800 34px/1 var(--cond); letter-spacing: -.01em; padding: 0 2px; }
.nom-top .mes-chips { margin: 0 0 0 10px; flex: 1; padding: 0; }
.mes-chips { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 4px; margin: 0 -2px 18px; }
.mes-chips button { flex: 1 0 auto; padding: 10px 9px 9px; border: 1px solid var(--rule); border-radius: var(--r); font: 700 14px/1 var(--cond); letter-spacing: .07em; text-transform: uppercase; background: var(--card); transition: all .2s; }
.mes-chips button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.liq { border: 2px solid var(--rule-strong); border-radius: var(--r); background: var(--card); overflow: hidden; }
.liq-h { display: grid; grid-template-columns: 1fr auto; padding: 14px 20px; border-bottom: 1px solid var(--rule); gap: 8px; }
.liq-h h1 { margin: 2px 0 0; font: 800 40px/.9 var(--cond); text-transform: uppercase; letter-spacing: -.01em; }
.liq-h p { margin: 6px 0 0; color: var(--ink-2); font-size: 13.5px; }
.liq-h .cat { text-align: right; }
.liq-h .cat b { display: block; font: 700 20px/1 var(--cond); margin-top: 6px; }
.liq table { width: 100%; border-collapse: collapse; }
.liq th { text-align: left; font: 600 11px/1 var(--cond); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding: 10px 20px 8px; border-bottom: 1px solid var(--rule); }
.liq th:not(:first-child), .liq td:not(:first-child) { text-align: right; }
.liq td { padding: 8px 20px; border-bottom: 1px solid var(--rule); font-size: 14.5px; }
.liq td:first-child b { font: 700 17px/1.1 var(--cond); letter-spacing: .03em; text-transform: uppercase; display: block; }
.liq td:first-child span { font-size: 12.5px; color: var(--ink-3); }
.liq td.imp { font: 700 19px/1 var(--cond); letter-spacing: .01em; white-space: nowrap; }
.liq tr.sub td { background: var(--card-2); }
.liq td.hh { font: 600 16px/1 var(--cond); letter-spacing: .02em; white-space: nowrap; color: var(--ink-2); }
.liq tr.cero td { opacity: .45; }
@media (max-width: 760px) {
  .liq th, .liq td { padding-left: 8px; padding-right: 8px; }
  .liq td.hh { font-size: 14px; }
  .liq td:first-child span { display: block; }
}
.liq tr.neg td.imp { color: var(--red); }
.liq .irpf-inp { width: 64px; height: 32px; text-align: right; font-size: 16px; display: inline-block; }
.neto { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: var(--brand); color: #16181c; gap: 12px; }
.neto b { font: 800 clamp(40px, 4vw, 56px)/.9 var(--cond); letter-spacing: -.02em; }
.neto .lbl { color: #16181c; opacity: .75; font-size: 13px; }
.aviso { margin-top: 14px; font-size: 13px; color: var(--ink-2); line-height: 1.5; max-width: 70ch; }
.reg { width: 100%; border-collapse: collapse; margin-top: 6px; }
.reg th { text-align: right; font: 600 11px/1 var(--cond); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding: 8px 6px; border-bottom: 2px solid var(--rule-strong); }
.reg th:first-child, .reg td:first-child { text-align: left; }
.reg td { text-align: right; padding: clamp(5px, .9vh, 9px) 6px; border-bottom: 1px solid var(--rule); font: 600 15.5px/1 var(--cond); letter-spacing: .02em; }
.reg td:first-child { text-transform: uppercase; letter-spacing: .06em; }
.reg tr { cursor: pointer; transition: background .15s; }
.reg tbody tr:hover { background: var(--card-2); }
.reg tr.on td { background: var(--paper); font-weight: 800; }
.reg tr.on td:first-child { box-shadow: inset 4px 0 0 var(--brand); }
.reg tfoot td { border-top: 2px solid var(--rule-strong); border-bottom: 0; font-weight: 800; font-size: 17px; }
.barras { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin: 10px 0 22px; }
.barras div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; height: 100%; cursor: pointer; }
.barras i { display: block; border-radius: 2px 2px 0 0; transform-origin: bottom; animation: growY .7s var(--ease) both; animation-delay: calc(var(--i) * 40ms); }
.barras i.b { background: var(--ink); opacity: .85; }
.barras i.x { background: var(--brand); }
.barras span { font: 600 10.5px/1 var(--cond); text-align: center; color: var(--ink-3); letter-spacing: .05em; margin-top: 4px; }
.barras div.on span { color: var(--ink); font-weight: 800; }
@keyframes growY { from { transform: scaleY(0); } }

/* ───────── Vista AJUSTES ───────── */
.aj {
  padding: 16px 26px 18px; display: grid; gap: 14px; align-items: start;
  grid-template-columns: repeat(3, minmax(0,1fr));
  grid-template-areas: "ficha fest nom" "ficha fest tema" "ficha fest copia" "ficha fest roster";
}
.aj > :nth-child(1) { grid-area: ficha; } .aj > :nth-child(2) { grid-area: fest; } .aj > :nth-child(3) { grid-area: nom; }
.aj > :nth-child(4) { grid-area: tema; } .aj > :nth-child(5) { grid-area: copia; } .aj > :nth-child(6) { grid-area: roster; }
.aj .box h2 { font-size: 24px; margin-bottom: 10px; }
.aj .box { padding: 14px 18px 16px; }
.box { background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); padding: 18px 20px 20px; }
.box h2 { margin: 0 0 14px; font: 800 28px/1 var(--cond); text-transform: uppercase; letter-spacing: .01em; }
.box p { margin: 0 0 12px; font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }
.teams { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.teams button { height: 52px; border: 1px solid var(--rule); border-radius: var(--r); font: 800 20px/1 var(--cond); background: var(--paper); transition: all .2s var(--ease); }
.teams button:hover { border-color: var(--ink); }
.teams button[aria-pressed="true"] { background: var(--brand); border-color: #16181c; color: #16181c; transform: translateY(-2px); box-shadow: 0 3px 0 #16181c; }
.cats { display: grid; gap: 6px; }
.cats button { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r); text-align: left; background: var(--paper); transition: all .2s; }
.cats button:hover { border-color: var(--ink); }
.cats button b { font: 700 17px/1 var(--cond); text-transform: uppercase; letter-spacing: .04em; }
.cats button span { font: 600 15px/1 var(--cond); color: var(--ink-2); }
.cats button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.cats button[aria-pressed="true"] span { color: var(--paper); opacity: .8; }
.fest-list { display: grid; gap: 4px; margin-top: 12px; max-height: 320px; overflow-y: auto; }
.fest-list div { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
.fest-list b { font: 700 15px/1 var(--cond); letter-spacing: .03em; }
.fest-add { display: grid; grid-template-columns: 150px 1fr auto; gap: 6px; }
.vacio { color: var(--ink-3); font-size: 13.5px; padding: 10px 0; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ───────── Hoja móvil, primer uso, aviso ───────── */
.sheet-back { position: fixed; inset: 0; background: rgba(10,11,13,.45); z-index: 40; animation: fade .3s both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow-y: auto;
  background: var(--card); border-radius: 16px 16px 0 0; border-top: 2px solid var(--rule-strong);
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -20px 50px -20px rgba(0,0,0,.4);
  animation: sheetIn .5s var(--ease) both;
}
.sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--rule); margin: 10px auto 0; }
.sheet.closing { animation: sheetOut .3s ease-in both; }
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }
.sheet.center { left: 50%; top: 50%; bottom: auto; right: auto; width: min(560px, calc(100vw - 32px)); transform: translate(-50%, -50%); border-radius: 14px; border: 2px solid var(--rule-strong); animation: popIn .5s var(--ease) both; max-height: 92dvh; }
.sheet.center::before { display: none; }
@keyframes popIn { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } }
.onb { padding: 24px 24px 26px; }
.onb h2 { margin: 0; font: 800 46px/.9 var(--cond); text-transform: uppercase; letter-spacing: -.01em; }
.onb > p { color: var(--ink-2); margin: 10px 0 18px; }
.onb .step { margin-top: 18px; }
.onb .step > .lbl { display: block; margin-bottom: 8px; }
.onb .go { margin-top: 22px; width: 100%; height: 52px; justify-content: center; font-size: 17px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); z-index: 60;
  background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: var(--r);
  font: 700 15px/1 var(--cond); letter-spacing: .05em; text-transform: uppercase; pointer-events: none;
  opacity: 0; visibility: hidden; transition: transform .45s var(--ease), opacity .3s, visibility 0s .45s;
}
.toast.on { transform: translate(-50%, 0); opacity: 1; visibility: visible; transition: transform .45s var(--ease), opacity .2s, visibility 0s; }

/* ───────── Adaptación ───────── */
@media (max-width: 1280px) {
  .mes { grid-template-columns: 300px minmax(0, 1fr) 330px; }
  .head-fields > div:nth-child(n+4) { display: none; }
  .aj { grid-template-columns: 1fr 1fr; grid-template-areas: "ficha fest" "ficha nom" "ficha tema" "copia roster"; }
  .ano-stats .v { font-size: 24px; }
  .mm-h b { font-size: 18px; }
  .mm-f { display: none; }
}
@media (max-width: 1080px) {
  :root { --head-h: 64px; }
  .mes { grid-template-columns: 300px minmax(0, 1fr); }
  .col-r { display: none; }
  .meses { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
  .ano-stats > div:not(.wide) { display: none; }
  .ano-stats { grid-template-columns: 1fr; }
  .nom { grid-template-columns: 1fr; height: auto; }
  .nom-l, .nom-r { overflow: visible; }
  .nom-l { border-right: 0; }
}
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .head { grid-template-columns: auto 1fr; }
  .brand { padding: 10px 14px; border-right: 0; }
  .brand-mark { font-size: 20px; }
  .head-fields { justify-content: flex-end; }
  .head-fields > div { padding: 8px 12px; border-right: 0; border-left: 1px solid var(--rule); }
  .head-fields > div:nth-child(n+3) { display: none; }
  .head-fields dd { font-size: 17px; }
  .tabs {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; background: var(--card);
    border-top: 2px solid var(--rule-strong); padding-bottom: env(safe-area-inset-bottom);
    display: grid; grid-template-columns: repeat(4, 1fr);
  }
  .tabs button { flex-direction: column; gap: 4px; height: 60px; padding: 0; justify-content: center; font-size: 12px; border-left: 0; }
  .tabs button svg { width: 21px; height: 21px; }
  .tabs button[aria-current="page"]::after { top: -2px; bottom: auto; }
  main { padding-bottom: var(--tabs-h); }
  input, select, textarea, .inp { font-size: 16px !important; } /* evita el zoom automático del iPhone */

  .nom-top { flex-wrap: wrap; gap: 6px; }
  .nom-top .mes-chips { flex-basis: 100%; margin: 4px 0 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; overflow: visible; }
  .mes-chips button { padding: 9px 0 8px; font-size: 13px; text-align: center; }
  .liq table { table-layout: fixed; }
  .liq th:nth-child(3), .liq td:nth-child(3) { display: none; }
  .liq th:nth-child(2), .liq td:nth-child(2) { width: 52px; }
  .liq th:nth-child(4), .liq td:nth-child(4) { width: 96px; }
  .liq td:first-child { overflow-wrap: anywhere; }
  .liq td.hh { font-size: 14px; }
  .ph-m { display: inline; }
  .liq-h h1 { font-size: 34px; }
  .liq-h .cat b { font-size: 16px; }
  .reg { table-layout: fixed; }
  .reg td, .reg th { font-size: 14px; }

  .mes { display: block; height: auto; min-height: 0; }
  .col { overflow: visible; }
  .col-l { border-right: 0; display: contents; }
  .hoy { order: 0; padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: start; }
  .hoy-fecha { grid-column: 1 / -1; }
  .hoy-turno { margin-top: 12px; padding: 12px; }
  .hoy-turno .big { font-size: 40px; }
  .hoy-turno .hrs { font-size: 15px; margin-top: 6px; }
  .hoy-turno .bloque { font-size: 10.5px; top: 10px; right: 10px; }
  .prox { margin-top: 12px; grid-template-columns: 1fr; }
  .prox .chip { display: none; }
  .prox b { font-size: 17px; }
  .cuenta { margin-top: 10px; gap: 4px; }
  .flap { min-width: 0; flex: 1; font-size: 22px; padding: 6px 2px 5px; }
  .col-c { padding: 16px 10px 10px; overflow: visible; }
  .mes-nav { margin-bottom: 10px; gap: 8px; padding: 0 4px; }
  .mes-nav h1 { font-size: 44px; }
  .mes-nav .btn { display: none; }
  .btn-ic { width: 40px; height: 40px; }
  .grid-wrap { flex: none; }
  .grid { position: relative; grid-auto-rows: minmax(64px, auto); }
  .d { padding: 5px 5px 6px; }
  .d .num { font-size: 17px; width: 26px; height: 26px; margin: -2px 0 0 -3px; }
  .d .lab { font-size: 10.5px; letter-spacing: .04em; }
  .d .hr { display: none; }
  .d .letra { font-size: 40px; bottom: -6px; right: 3px; }
  .d .tags { top: 5px; right: 4px; }
  .d.fest .tags { right: 14px; }
  .d.fest::after { border-width: 7px; }
  .tag-x { font-size: 9.5px; padding: 2px 3px 1px; }
  .d .festn { display: none; }
  .dow span { padding: 7px 5px; font-size: 11px; letter-spacing: .08em; }
  .leyenda { order: 3; padding: 14px 16px; grid-template-columns: 1fr 1fr 1fr; gap: 9px 8px; border-top: 1px solid var(--rule); }
  .leyenda div { font-size: 12px; gap: 6px; }
  .sw { width: 14px; height: 14px; }
  .mini-stats { order: 4; padding: 14px 16px 22px; }

  .ano { padding: 10px 8px 8px; gap: 8px; min-height: 0; }
  .ano-top { gap: 8px; }
  .ano-top .guias { display: none; }
  .ano-top h1 { font-size: 40px; }
  .ano-stats > div { padding: 6px 10px; }
  .ano-stats .lbl { font-size: 9.5px; }
  .ano-stats .v { font-size: 17px; margin-top: 3px; }
  .ano-stats .v small { font-size: 11px; }
  .ano-stats .track { height: 6px; margin-top: 4px; }
  .ano-nav { gap: 4px; align-items: center; }
  .ano-nav .btn-ic { width: 34px; height: 34px; }
  .meses { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .mm { padding: 5px 4px 4px; border-radius: 4px; }
  .mm.actual { padding: 4px 3px 3px; }
  .mm-h { margin-bottom: 3px; }
  .mm-h b { font-size: 13px; }
  .mm-h span { display: none; }
  .mm-g { gap: 1px; }
  .mm-g i { font-size: 8.5px; border-radius: 1.5px; }
  .mm-g i.dw { font-size: 7.5px; padding-bottom: 0; }
  .mm-g i.f::after { border-width: 3px; }
  .mm-g i.h { box-shadow: 0 0 0 1.5px var(--card), 0 0 0 3px var(--ink); }

  .nom-l, .nom-r { padding: 16px 12px 30px; }
  .liq-h { padding: 14px; }
  .liq-h h1 { font-size: 36px; }
  .liq th, .liq td { padding-left: 12px; padding-right: 12px; }
  .liq td.imp { font-size: 17px; }
  .neto { padding: 14px; }

  .aj { grid-template-columns: 1fr; grid-template-areas: none; padding: 16px 12px 40px; gap: 12px; }
  .aj > * { grid-area: auto !important; }
  .box { padding: 16px; }
  .fest-add { grid-template-columns: 1fr 1fr; }
  .fest-add .btn { grid-column: 1 / -1; justify-content: center; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
