:root {
  --bg: #f5f7fb; --surface: #fff; --text: #1b2330; --muted: #6a7587; --line: #e1e6ef;
  --primary: #1f6feb; --primary-ink: #fff; --ok: #e6f4e6; --off: #eceff4; --off-ink: #8a93a3;
  --fest: #f8c9c9; --warn: #fff1d6; --warn-ink: #8a5a00; --neg: #d0342c; --sel: #1f6feb22;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c; --surface: #1a212c; --text: #e8ecf3; --muted: #93a0b4; --line: #2a3342;
    --primary: #4c8dff; --primary-ink: #0b1220; --ok: #1f3a27; --off: #232b38; --off-ink: #7b8799;
    --fest: #5a2a2a; --warn: #3d3014; --warn-ink: #f2c46b; --neg: #ff6b61; --sel: #4c8dff33;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.15rem; margin: 0; } h2 { font-size: 1.05rem; margin: 0; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .err { color: var(--neg); }
header { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--surface); border-bottom: 1px solid var(--line); }
.year { display: flex; align-items: center; gap: 6px; }
.year button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 1.1rem; }
main { max-width: 760px; margin: 0 auto; padding: 14px 14px 24px; }
nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--surface);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
nav button { flex: 1; padding: 10px 4px 8px; border: 0; background: none; color: var(--muted); font-size: .78rem; }
nav button b { display: block; font-size: 1.25rem; font-weight: 400; }
nav button.on { color: var(--primary); font-weight: 600; }
button { font: inherit; cursor: pointer; }
button.primary { background: var(--primary); color: var(--primary-ink); border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 600; }
button.ghost { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 9px 14px; }
button.danger { background: none; border: 1px solid var(--neg); color: var(--neg); border-radius: 10px; padding: 9px 14px; }
button.mini { padding: 4px 9px; font-size: .8rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.bar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin: 6px 0 12px; }
.bar select { flex: 1; min-width: 0; }
input, select { font: inherit; width: 100%; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); }
input[type=checkbox] { width: auto; }
label { display: block; margin: 10px 0 0; font-size: .85rem; color: var(--muted); }
label.chk { display: flex; gap: 8px; align-items: center; color: var(--text); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 0 0 10px; cursor: pointer; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.saldo { font-size: 1.7rem; font-weight: 700; text-align: right; line-height: 1; }
.saldo small { display: block; font-size: .7rem; font-weight: 400; color: var(--muted); }
.saldo.neg, .neg-t { color: var(--neg); }
.meter { height: 7px; border-radius: 4px; background: var(--off); margin: 10px 0 8px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--primary); }
.meter span.neg { background: var(--neg); }
.stats { display: flex; gap: 12px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.stats b { color: var(--text); }
.tag { display: inline-block; margin: 8px 6px 0 0; padding: 2px 9px; border-radius: 99px; font-size: .75rem;
  background: var(--off); color: var(--muted); }
.tag.warn { background: var(--warn); color: var(--warn-ink); }
.tag.ok { background: var(--ok); color: var(--text); }
.tag.pen { background: var(--warn); color: var(--warn-ink); }
.tag.rej { background: var(--fest); color: var(--text); }
/* calendario */
.dow, .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.dow { text-align: center; font-size: .72rem; color: var(--muted); margin-bottom: 4px; }
.day { position: relative; aspect-ratio: 1 / 1.05; border-radius: 8px; padding: 4px; font-size: .85rem;
  border: 0; text-align: left; color: var(--text); background: var(--ok); }
.day.fin_de_semana { background: var(--off); color: var(--off-ink); }
.day.festivo { background: var(--fest); font-weight: 700; }
.day.hoy { outline: 2px solid var(--primary); }
.day .n { position: absolute; right: 4px; bottom: 3px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--primary); color: var(--primary-ink); font-size: .7rem; line-height: 18px; text-align: center; font-weight: 700; }
.leyenda { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; font-size: .75rem; }
.leyenda span { padding: 2px 8px; border-radius: 6px; }
ul.lista { list-style: none; padding: 0; margin: 8px 0; }
ul.lista li { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
/* diálogo */
dialog { border: 0; border-radius: 16px; padding: 18px; width: min(94vw, 460px); max-height: 88vh; overflow: auto;
  background: var(--surface); color: var(--text); box-shadow: 0 10px 40px #0006; }
dialog::backdrop { background: #0008; }
.btns { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.btns .primary { flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; margin: 10px 0; }
th, td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
tfoot td { font-weight: 700; }
.login { max-width: 340px; margin: 18vh auto 0; padding: 0 20px; text-align: center; }
.login img { border-radius: 16px; } .login form { display: grid; gap: 10px; margin-top: 18px; }
#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #1b2330; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: .2s; max-width: 90vw; z-index: 20; font-size: .9rem; }
#toast.show { opacity: 1; transform: translate(-50%, 0); } #toast.err { background: var(--neg); }

/* horarios */
.seg { display: flex; gap: 4px; background: var(--off); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 4px; border-radius: 8px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; }
.scroll { overflow-x: auto; }
table.sem { table-layout: fixed; min-width: 520px; font-size: .8rem; }
table.sem th, table.sem td { text-align: center; padding: 6px 3px; border: 1px solid var(--line); vertical-align: middle; }
table.sem tbody th { text-align: left; width: 22%; font-size: .78rem; }
table.sem small, .hoja small { display: block; font-weight: 400; font-size: .66rem; color: var(--muted); }
td[data-a=cell] { cursor: pointer; }
.c-off { background: var(--off); color: var(--off-ink); font-size: .7rem; }
.c-cubre { background: var(--sel); font-weight: 600; }
.c-manual { background: var(--warn); }
.c-vacio { background: var(--fest); font-weight: 700; }
.leyenda .c-cubre, .leyenda .c-manual, .leyenda .c-vacio { padding: 2px 8px; border-radius: 6px; }
.avisos { background: var(--warn); color: var(--warn-ink); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-size: .85rem; }
.card.plain { cursor: default; }
.sem2 { margin-top: 6px; } .sem2 label { flex: 1; margin: 0; }
.hoja { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.hoja-h { display: flex; justify-content: space-between; align-items: baseline; }
.hoja-sub { margin: 2px 0 8px; color: var(--muted); }
table.hoja-t { font-size: .8rem; margin: 6px 0; }
.hoja-t th, .hoja-t td { text-align: left; padding: 3px 6px; border: 1px solid var(--line); }
.hoja-t td:first-child { white-space: nowrap; width: 1%; }
.hoja-t .h-lib td { background: var(--off); } .hoja-t .h-dom td { background: var(--off); color: var(--off-ink); }
.hoja-t .h-fes td { background: var(--fest); } .hoja-t .h-aus td { background: var(--warn); }
.hoja-t .h-cubre td { background: var(--sel); }
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --line: #999; --off: #e6e6e6; --off-ink: #555;
    --fest: #f3c4c4; --warn: #fbe7b5; --warn-ink: #000; --sel: #cfe0ff; }
  @page { size: A4; margin: 12mm; }
  header, nav, #toast, .noprint { display: none !important; }
  body { padding: 0; } main { max-width: none; padding: 0; }
  .hoja { border: 0; padding: 0; margin: 0; break-after: page; page-break-after: always; }
  .hoja:last-child { break-after: auto; page-break-after: auto; }
  table.hoja-t { font-size: 10pt; } .hoja-t th, .hoja-t td { padding: 2px 6px; }
}
