@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f7f9fa;
  --surface: #ffffff;
  --field: #f2f6f8;
  --ink: #22303c;
  --muted: #5c6b78;
  --line: #edf1f4;
  --accent: #1f5f8b;
  --accent-soft: #dcebf6;
  --switch-on: #bfdcef;
  --switch-off: #e3e8ec;
  --danger: #973652;
  --vac: #2b5797;
  --vac-soft: #e6eefb;
  --baja: #973652;
  --baja-soft: #f9e8ec;
  --libre: #4e5c68;
  --libre-soft: #eef1f3;
  --fest: #8a5a0a;
  --fest-soft: #fdf1dc;
  --radius: 20px;
  --gutter: 20px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.print-only { display: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Estructura */
.layout { min-height: 100dvh; }
.main {
  max-width: 900px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 28px) var(--gutter) calc(env(safe-area-inset-bottom) + 100px);
}
.nav {
  position: fixed;
  z-index: 5;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--surface);
  padding: 6px 8px env(safe-area-inset-bottom);
}
.nav button {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  background: none;
  border: 0;
  padding: 6px 0;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}
.nav button[aria-current="page"] { color: var(--accent); font-weight: 600; }
.nav svg { width: 22px; height: 22px; }
.nav .brand { display: none; }

@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); }
  .nav {
    position: sticky;
    top: 0;
    height: 100dvh;
    flex-direction: column;
    gap: 4px;
    padding: 32px 14px;
  }
  .nav .brand { display: block; font-size: 16px; font-weight: 600; padding: 0 12px 20px; }
  .nav button {
    flex: 0 0 auto;
    min-height: 44px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 0 12px;
    font-size: 15px;
    border-radius: 10px;
  }
  .nav button:hover { background: var(--bg); }
  .nav button[aria-current="page"] { background: var(--accent-soft); font-weight: 500; }
  .nav svg { width: 18px; height: 18px; }
  .main { padding-top: 48px; padding-bottom: 48px; padding-inline: 32px; width: 100%; }
  .page-title { font-size: 30px !important; }
  .hoy-top { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
  .hoy-top > .section { margin-top: 0; }
  .stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 899px) {
  .only-wide { display: none; }
}

/* Cabeceras */
.page-title { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.section { margin-top: 28px; }
.section-title { font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 10px; }
.month-nav { display: flex; align-items: center; }
.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; background: none; border-radius: 10px;
  color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--line); }
.icon-btn svg { width: 18px; height: 18px; }

/* Tarjetas y filas */
.card { background: var(--surface); border-radius: var(--radius); }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 20px;
  min-height: 52px;
  border-top: 1px solid var(--line);
}
.card > .row:first-child { border-top: 0; }
.row.total { font-weight: 600; }
button.row {
  width: 100%;
  text-align: left;
  background: none;
  border-left: 0; border-right: 0; border-bottom: 0;
  cursor: pointer;
}
.card > button.row:first-child { border-top: 0; border-radius: var(--radius) var(--radius) 0 0; }
.row-main { min-width: 0; flex: 1; }
.row-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row-actions { display: flex; flex-shrink: 0; margin-right: -12px; }

/* Botones */
.btn {
  border: 0;
  background: var(--libre-soft);
  border-radius: 14px;
  padding: 10px 16px;
  min-height: 48px;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { filter: brightness(0.98); }
.btn.primary { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); background: var(--baja-soft); }
.btn.full { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row .btn { flex: 1 1 0; min-width: 96px; }
.link { background: none; border: 0; padding: 8px 0; color: var(--accent); cursor: pointer; }

/* Cifras */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 12px; }
.stat { min-width: 0; }
.stat-value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.hero-value { font-size: 44px; font-weight: 500; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-side { text-align: right; }

/* Formularios */
.field { display: block; min-width: 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--field);
  font-size: 16px; /* 16 px evita el zoom automático en iPhone */
}
input[type="time"], input[type="date"] { -webkit-appearance: none; appearance: none; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; min-height: 76px; display: block; }
textarea.note-line { background: none; padding: 16px 20px; min-height: 52px; border-radius: 0 0 var(--radius) var(--radius); border-top: 1px solid var(--line); }
.time-big {
  height: 72px;
  font-size: 30px;
  font-weight: 500;
  text-align: center;
  border-radius: 14px;
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
}
.time-big::-webkit-date-and-time-value { text-align: center; }
.time-big::-webkit-calendar-picker-indicator { display: none; }
input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  min-height: 0;
  padding: 3px;
  border-radius: 13px;
  background: var(--switch-off);
  display: flex;
  cursor: pointer;
  transition: background 0.15s;
}
input[type="checkbox"]::before {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
input[type="checkbox"]:checked { background: var(--switch-on); }
input[type="checkbox"]:checked::before { transform: translateX(18px); }
.fields { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.pad { padding: 20px; }
.stack > * + * { margin-top: 14px; }
.input-inline { width: 120px; text-align: right; flex-shrink: 0; min-height: 40px; padding: 6px 10px; }
.hint { font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 0;
  background: var(--libre-soft);
  border-radius: 22px;
  padding: 6px 16px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }
.chip.day { width: 44px; padding: 6px 0; text-align: center; }

.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.tag.vacaciones { background: var(--vac-soft); color: var(--vac); }
.tag.baja { background: var(--baja-soft); color: var(--baja); }
.tag.libre { background: var(--libre-soft); color: var(--libre); }
.tag.festivo { background: var(--fest-soft); color: var(--fest); }
.tag.extra { background: var(--accent-soft); color: var(--accent); }

/* Calendario */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 4px; padding: 14px 8px 12px; }
.cal-head { padding-bottom: 8px; text-align: center; font-size: 12px; color: var(--muted); }
.cal-day {
  position: relative;
  min-height: 62px;
  min-width: 0;
  margin: 0 2px;
  padding: 6px 1px 4px;
  background: none;
  border: 0;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  overflow: hidden;
}
.cal-day:hover { background: var(--bg); }
.cal-day.out { visibility: hidden; }
.cal-n { font-size: 14px; font-variant-numeric: tabular-nums; }
.cal-h { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-h.open { color: var(--accent); }
.cal-t { font-size: 11px; line-height: 15px; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-t.plan { color: var(--muted); }
.cal-day.fest { background: var(--fest-soft); color: var(--fest); }
.cal-day.fest .cal-n { font-weight: 600; }
.cal-day.vacaciones { background: var(--vac-soft); color: var(--vac); }
.cal-day.baja { background: var(--baja-soft); color: var(--baja); }
.cal-day.libre { background: var(--libre-soft); color: var(--libre); }
.cal-day.today { background: var(--accent-soft); color: var(--accent); }
.cal-day.today .cal-n { font-weight: 600; }
.cal-note { position: absolute; top: 6px; right: 6px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.45; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; align-items: center; }
@media (min-width: 900px) {
  .cal-day { min-height: 84px; }
}

/* Hojas modales */
dialog { color: inherit; }
dialog::backdrop { background: rgba(34, 48, 60, 0.18); }
.sheet {
  width: 100%;
  max-width: 100%;
  max-height: 90dvh;
  margin: auto 0 0;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 8px 8px 20px;
  background: var(--bg);
}
.sheet-head h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.sheet-body { padding: 8px var(--gutter) calc(env(safe-area-inset-bottom) + 28px); }
.sheet-body .section { margin-top: 20px; }
.sheet-body .section:first-child { margin-top: 0; }
@media (min-width: 640px) {
  .sheet { max-width: 500px; margin: auto; border-radius: 24px; max-height: 86dvh; }
}
.confirm {
  width: calc(100% - 48px);
  max-width: 340px;
  padding: 20px;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
}
.confirm p { margin-bottom: 16px; }
.confirm .btn-row { justify-content: flex-end; }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 84px);
  transform: translate(-50%, 8px);
  max-width: calc(100% - 32px);
  width: max-content;
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Resumen impreso */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .layout, .sheet, .confirm, .toast { display: none !important; }
  .print-only { display: block; }
  .print-only h1 { font-size: 18pt; font-weight: 600; margin-bottom: 2pt; }
  .print-only h2 { font-size: 11pt; margin: 14pt 0 4pt; }
  .print-only table { width: 100%; border-collapse: collapse; font-size: 9.5pt; font-variant-numeric: tabular-nums; }
  .print-only th, .print-only td { text-align: left; padding: 3pt 5pt; border-bottom: 0.5pt solid #bbb; vertical-align: top; }
  .print-only th { font-weight: 600; border-bottom: 1pt solid #000; }
  .print-only .r { text-align: right; }
  .print-only tr { break-inside: avoid; }
  .print-only .tot td { font-weight: 600; border-top: 1pt solid #000; }
  .print-only .note { font-size: 9pt; color: #444; margin-top: 8pt; }
}
