/* ==========================================================
   R07 — Registro R07
   Rediseño cosmético · Editorial vibrante
   Serif (Fraunces) para títulos + Sans (DM Sans) para cuerpo
   ========================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Acento neutral: grafito (mismo tono que el botón principal) + cálido secundario */
  --accent: rgb(54, 54, 54);
  --accent-2: rgba(54, 54, 54, 0.06);
  --accent-strong: rgb(34, 34, 34);
  --warm: rgb(199, 118, 59);

  /* Base claro */
  --bg: rgb(252, 251, 247);
  --surface: #ffffff;
  --surface-2: rgb(246, 245, 241);
  --surface-3: rgb(237, 236, 230);
  --ink: rgb(54, 54, 54);
  --ink-soft: rgb(101, 101, 101);
  --ink-muted: rgb(141, 141, 141);
  --line: rgb(205, 205, 205);
  --line-soft: rgb(222, 222, 222);

  --good: rgb(79, 159, 101);
  --bad: rgb(190, 68, 62);

  /* Helper variables for alpha colors (replacing oklch relative syntax) */
  --warm-soft: rgba(199, 118, 59, 0.12);
  --accent-alpha-4: rgba(54, 54, 54, 0.4);
  --accent-alpha-5: rgba(54, 54, 54, 0.5);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-sm: 0 1px 2px rgba(15, 18, 30, 0.04), 0 1px 1px rgba(15, 18, 30, 0.03);
  --shadow: 0 4px 14px -4px rgba(15, 18, 30, 0.08), 0 2px 4px rgba(15, 18, 30, 0.04);
  --shadow-lg: 0 18px 40px -12px rgba(15, 18, 30, 0.18), 0 4px 10px rgba(15, 18, 30, 0.06);

  --font-serif: 'Fraunces', 'Iowan Old Style', 'Apple Garamond', Georgia, serif;
  --font-sans: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Compatibilidad con CSS antiguo de impresión */
  --blue: rgb(48, 86, 153);
  --blue-light: rgb(245, 248, 255);
  --green: rgb(79, 159, 101);
  --red: rgb(190, 68, 62);
  --border: rgb(226, 226, 226);
  --white: #ffffff;
}

html[data-theme="dark"] {
  --bg: rgb(39, 39, 39);
  --surface: rgb(50, 50, 50);
  --surface-2: rgb(58, 58, 58);
  --surface-3: rgb(67, 67, 67);
  --ink: rgb(245, 245, 245);
  --ink-soft: rgb(194, 194, 194);
  --ink-muted: rgb(141, 141, 141);
  --line: rgb(98, 98, 98);
  --line-soft: rgb(78, 78, 78);

  --accent: rgb(235, 235, 235);
  --accent-2: rgba(235, 235, 235, 0.12);
  --accent-strong: rgb(250, 250, 250);
  --warm: rgb(240, 158, 99);

  /* Helper variables for alpha colors (replacing oklch relative syntax) */
  --warm-soft: rgba(240, 158, 99, 0.12);
  --accent-alpha-4: rgba(235, 235, 235, 0.4);
  --accent-alpha-5: rgba(235, 235, 235, 0.5);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 50px -16px rgba(0, 0, 0, 0.7);
}

/* ---------- Base ---------- */

html,
body {
  height: 100%;
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  background:
    radial-gradient(1200px 600px at 100% -10%, var(--accent-2), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, var(--accent-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}

/* ---------- Header ---------- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-nav h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-variation-settings: "opsz" 96, "SOFT" 50;
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.1;
  white-space: nowrap;
  display: flex;
  align-items: baseline;
  gap: 0.4em;
}

.header-nav h1 .title-year {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.6em;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  font-feature-settings: "tnum";
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Botones ---------- */

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.18s ease;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-2);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: translateY(0);
}

#theme-toggle .icon-moon {
  display: none;
}

html[data-theme="dark"] #theme-toggle .icon-sun {
  display: none;
}

html[data-theme="dark"] #theme-toggle .icon-moon {
  display: inline;
}

.btn-print-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: -0.005em;
  transition: all 0.18s ease;
}

.btn-print-main:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  padding: 10px 18px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 4px 12px -4px var(--accent);
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--bg);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -6px var(--accent);
}

/* ---------- Calendario ---------- */

.calendar-wrapper {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.calendar-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.calendar-head span {
  text-align: center;
  padding: 14px 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface);
  gap: 0;
}

.day-cell {
  background: var(--surface);
  min-height: 132px;
  padding: 10px 11px 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: background 0.18s ease, transform 0.18s ease;
}

/* Quitar bordes externos: última columna y última fila */
.day-cell:nth-child(7n) {
  border-right: none;
}

.day-cell:hover {
  background: var(--surface-2);
}

.day-cell:hover .day-num {
  color: var(--accent);
}

.day-cell.empty {
  cursor: default;
  background: transparent;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.day-cell.empty:nth-child(7n) {
  border-right: none;
}

.day-cell.weekend,
.day-cell.holiday {
  background: linear-gradient(180deg, var(--accent-2), transparent 70%), var(--surface);
}

.day-cell.has-data::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 11px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-2);
}

.day-num {
  font-family: var(--font-serif);
  font-variation-settings: "opsz" 60;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 6px;
  margin-left: 14px;
  letter-spacing: -0.02em;
  transition: color 0.18s ease;
}

.day-data {
  font-size: 11px;
  line-height: 1.45;
  color: var(--ink-muted);
  font-family: var(--font-sans);
}

.day-data b {
  color: var(--ink);
  font-weight: 600;
}

.day-line {
  line-height: 1.4;
  color: rgba(141, 141, 141, 0.5);
  margin-bottom: 2px;
}

.has-data .day-line {
  color: var(--ink-soft);
}

.has-data .day-line b {
  color: var(--ink);
  font-weight: 700;
}

.festivo-tag {
  font-family: var(--font-sans);
  font-size: 8.5px;
  font-weight: 600;
  color: var(--warm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-left: 6px;
  vertical-align: middle;
  padding: 2px 6px;
  background: var(--warm-soft);
  border-radius: 999px;
}

.blank {
  display: inline-block;
  min-width: 18px;
  border-bottom: 1px dashed var(--line);
  vertical-align: bottom;
  margin: 0 1px;
  height: 1em;
}

.blank.wide {
  min-width: 50px;
}

.radio-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  align-items: center;
}

.radio-opt {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9.5px;
  color: rgba(141, 141, 141, 0.5);
  white-space: nowrap;
}

.radio-opt.sel {
  color: var(--accent);
  font-weight: 700;
}

.rdot {
  font-size: 9px;
  line-height: 1;
}

/* ---------- Móvil ---------- */

@media (max-width: 768px) {
  .app {
    padding: 0 14px 14px 14px;
  }

  header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }

  .header-nav h1 {
    font-size: 1.3rem;
  }

  .btn-print-main span {
    display: none;
  }

  .btn-print-main {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
    border-radius: 999px;
  }

  .no-mobile-head {
    display: none;
  }

  .calendar-wrapper {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    background: transparent;
  }

  .day-cell {
    min-height: auto;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    flex-direction: row;
    gap: 10px;
    padding: 14px 16px;
    align-items: flex-start;
    box-shadow: var(--shadow-sm);
    position: relative;
  }

  .day-cell.has-data {
    border-color: var(--ink);
  }

  .day-cell.has-data::before {
    display: none;
  }

  .day-cell.weekend,
  .day-cell.holiday {
    background: linear-gradient(180deg, var(--accent-2), transparent 70%), var(--surface);
  }

  .day-num {
    background: transparent;
    color: var(--ink);
    width: 32px;
    height: auto;
    border-radius: 0;
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    flex-shrink: 0;
    margin: 0;
    padding-top: 2px;
    font-family: var(--font-serif);
    font-variation-settings: "opsz" 60;
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: -0.02em;
  }

  .day-cell.has-data .day-num {
    background: transparent;
    color: var(--accent);
  }

  .festivo-tag {
    display: none;
  }

  /* Texto de resumen como marca de agua (igual a desktop) en móvil */
  .day-data {
    font-size: 13.5px;
    flex: 1;
    color: var(--ink-muted);
  }

  .day-line {
    color: rgba(141, 141, 141, 0.5);
    margin-bottom: 4px;
  }

  .has-data .day-line {
    color: var(--ink-soft);
  }

  .has-data .day-line b {
    color: var(--ink);
    font-weight: 700;
  }

  .blank {
    border-bottom: 1px dashed var(--line);
    min-width: 28px;
  }

  .blank.wide {
    min-width: 70px;
  }

  .radio-opt {
    font-size: 11px;
    color: rgba(141, 141, 141, 0.5);
  }

  .radio-opt.sel {
    color: var(--accent);
    font-weight: 700;
  }

  /* Modal en móvil */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    display: flex;
    flex-direction: column;
  }

  .modal-header {
    padding: 14px 16px 10px;
    flex-shrink: 0;
  }

  .modal-header h2 {
    font-size: 1rem;
  }

  .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    font-size: 13px;
  }

  .modal-footer {
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    flex-shrink: 0;
  }

  .save-indicator {
    display: none;
  }

  .btn-primary {
    padding: 10px 18px;
    font-size: 13px;
  }

  /* Radios más compactos en móvil */
  .radio-group {
    gap: 6px;
  }

  .radio-label {
    padding: 9px 12px;
    font-size: 13px;
  }

  .field-label {
    font-size: 11px;
    margin-bottom: 6px;
  }

  input[type="text"],
  input[type="number"] {
    padding: 9px 12px;
    font-size: 14px;
  }

  .form-group {
    margin-bottom: 12px;
  }
}

/* ---------- Modal ---------- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(39, 39, 39, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: overlayIn 0.18s ease;
}

.modal-overlay.open {
  display: flex;
}

@keyframes overlayIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 540px;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 20px 24px 16px;
  background: var(--surface);
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-header h2 {
  font-family: var(--font-serif);
  font-variation-settings: "opsz" 90;
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.modal-body {
  padding: 22px 24px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  position: relative;
}

.save-side {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-clear-day {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-muted);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
}

.btn-clear-day:hover {
  color: var(--bad);
  border-color: rgba(190, 68, 62, 0.4);
  background: rgba(190, 68, 62, 0.08);
}

#modal-close {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
}

#modal-close:hover {
  color: var(--bad);
  border-color: rgba(190, 68, 62, 0.4);
  background: rgba(190, 68, 62, 0.08);
}

/* ---------- Formulario ---------- */

.form-group {
  margin-bottom: 18px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.field-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--surface);
  transition: all 0.18s ease;
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

input[type="text"]:hover,
input[type="number"]:hover,
textarea:hover {
  border-color: var(--accent-alpha-4);
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-2);
}

input::placeholder {
  color: var(--ink-soft);
  font-style: normal;
  font-size: 14px;
  opacity: 0.85;
}

.radio-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.radio-label {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 12px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-sans);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  transition: all 0.18s ease;
}

.radio-label:hover {
  border-color: var(--accent-alpha-5);
  color: var(--ink);
  background: var(--accent-2);
}

.radio-label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-2);
  color: var(--ink);
  box-shadow: 0 0 0 3px var(--accent-2);
}

.radio-label input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  margin: 0;
  display: inline-block;
  position: relative;
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.radio-label input[type="radio"]:checked {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--surface);
}

.time-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-selector select {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 15px;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.18s ease;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
}

.time-selector .time-hour {
  width: 64px;
}

.time-selector .time-min {
  width: 64px;
}

.time-selector .time-period {
  width: 68px;
}

.time-selector select:hover {
  border-color: var(--accent-alpha-4);
}

.time-selector select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-2);
}

.time-sep {
  font-size: 18px;
  color: var(--ink-muted);
  font-weight: 600;
  line-height: 1;
  user-select: none;
}

.save-indicator {
  position: absolute;
  left: 20px;
  color: var(--good);
  font-weight: 600;
  font-size: 13px;
  font-family: var(--font-sans);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.save-indicator.show {
  opacity: 1;
  transform: translateX(0);
}

/* ---------- Scrollbar (modal) ---------- */

.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--ink-muted);
}

/* ---------- Print header (oculto en pantalla) ---------- */

.print-header {
  display: none;
}

.print-header h2 {
  font-family: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  font-variation-settings: "opsz" 96, "SOFT" 50;
  font-size: 1.6rem;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: -0.02em;
  line-height: 1.1;
  display: inline-flex;
  align-items: baseline;
  gap: 0.4em;
}

.print-year {
  font-family: 'DM Sans', 'Inter', -apple-system, sans-serif;
  font-variation-settings: normal;
  font-size: 0.6em;
  font-weight: 500;
  color: #8a8a8a;
  letter-spacing: 0.02em;
  line-height: 1;
}

/* ==========================================================
   IMPRESIÓN — Estética editorial (Fraunces + DM Sans + índigo)
   A4 horizontal, mantiene la maquetación original
   ========================================================== */
@media print {
  @page {
    size: A4 landscape;
    margin: 4mm 5mm;
  }

  html,
  body {
    height: 100% !important;
  }

  .day-cell {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    box-sizing: border-box !important;
  }

  /* Forzar tema claro al imprimir, sin importar el toggle */
  html[data-theme="dark"],
  html {
    --print-accent: #1a1a1a;
    --print-accent-soft: #ececec;
    --print-warm: #b86a3a;
    --print-warm-soft: #f7e8dc;
    --print-ink: #1a1a1a;
    --print-ink-soft: #555;
    --print-ink-muted: #8a8a8a;
    --print-line: #9a9a9a;
    --print-line-soft: #b8b8b8;
  }

  .no-print {
    display: none !important;
  }

  body {
    background: white !important;
    font-family: 'DM Sans', 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif !important;
    margin: 0 !important;
    padding: 0 !important;
    color: var(--print-ink) !important;
  }

  .app {
    padding: 0 !important;
    max-width: none !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Contenedor del calendario — redondeado como en pantalla */
  .calendar-wrapper {
    background: white !important;
    border: 0.6pt solid var(--print-line) !important;
    box-shadow: none !important;
    border-radius: 3mm !important;
    overflow: hidden !important;
    flex: 1 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* ── Título (centrado, R07 + Mes + Año mismo tamaño) ── */
  .print-header {
    display: block !important;
    text-align: center !important;
    padding: 0 0 3.5mm !important;
    line-height: 1 !important;
  }

  .print-header h2 {
    font-family: 'Fraunces', 'Iowan Old Style', Georgia, serif !important;
    font-variation-settings: "opsz" 96, "SOFT" 50 !important;
    font-size: 15pt !important;
    font-weight: 600 !important;
    color: var(--print-ink) !important;
    letter-spacing: -0.02em !important;
    line-height: 1.1 !important;
    display: inline-flex !important;
    align-items: baseline !important;
    gap: 0.4em !important;
  }

  .print-year {
    font-family: 'DM Sans', 'Inter', -apple-system, sans-serif !important;
    font-variation-settings: normal !important;
    font-size: 0.6em !important;
    font-weight: 500 !important;
    color: var(--print-ink-muted, #888) !important;
    letter-spacing: 0.02em !important;
    line-height: 1 !important;
  }

  /* ── Cabecera de días (gris suave, mayúsculas, igual que pantalla) ── */
  .calendar-head {
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 0 !important;
    background: var(--print-accent-soft) !important;
    margin-bottom: 0 !important;
    border-bottom: 0.6pt solid var(--print-line) !important;
    padding: 0 !important;
    border-radius: 0 !important;
  }

  .calendar-head span {
    background: transparent !important;
    color: var(--print-ink-soft) !important;
    font-family: 'DM Sans', sans-serif !important;
    font-size: 7pt !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    text-align: center !important;
    padding: 1.8mm 1mm !important;
    letter-spacing: 0.16em !important;
    border-radius: 0 !important;
    border: none !important;
  }

  /* ── Grilla (bordes en celdas, sin fondo gris) ── */
  .calendar-grid {
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    grid-auto-rows: minmax(0, 1fr) !important;
    gap: 0 !important;
    background: white !important;
    border: none !important;
    flex: 1 !important;
    min-height: 0 !important;
  }

  /* ── Celdas con borde individual ── */
  .day-cell {
    border: none !important;
    border-right: 0.5pt solid var(--print-line) !important;
    border-bottom: 0.5pt solid var(--print-line) !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0.8mm 1.5mm !important;
    display: flex !important;
    flex-direction: column !important;
    background: #ffffff !important;
    position: relative !important;
    overflow: hidden !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
  }

  /* Quitar bordes externos */
  .day-cell:nth-child(7n) {
    border-right: none !important;
  }

  /* Celdas vacías: invisibles, sin fondo gris */
  .day-cell.empty {
    background: transparent !important;
    border-right: 0.5pt solid var(--print-line) !important;
    border-bottom: 0.5pt solid var(--print-line) !important;
  }

  .day-cell.empty:nth-child(7n) {
    border-right: none !important;
  }

  /* Weekend/Holiday — degradado sutil neutro, igual a pantalla */
  .day-cell.weekend,
  .day-cell.holiday {
    background: linear-gradient(180deg, var(--print-accent-soft), #ffffff 70%) !important;
  }

  /* Punto grafito con halo para días con datos */
  .day-cell.has-data::before {
    content: '' !important;
    position: absolute !important;
    top: 2mm !important;
    left: 2mm !important;
    width: 1.4mm !important;
    height: 1.4mm !important;
    border-radius: 50% !important;
    background: var(--print-accent) !important;
    box-shadow: 0 0 0 0.7mm var(--print-accent-soft) !important;
  }

  /* ── Número del día (serif editorial, alineado a la izquierda como en pantalla) ── */
  .day-num {
    position: static !important;
    font-family: 'Fraunces', 'Iowan Old Style', Georgia, serif !important;
    font-variation-settings: "opsz" 60 !important;
    font-size: 11pt !important;
    font-weight: 600 !important;
    color: var(--print-ink) !important;
    line-height: 1 !important;
    width: auto !important;
    height: auto !important;
    background: transparent !important;
    border-radius: 0 !important;
    border-bottom: none !important;
    margin: 0 0 0.5mm 3mm !important;
    display: inline-flex !important;
    align-items: baseline !important;
    letter-spacing: -0.02em !important;
  }

  /* Festivo pill cálido como en pantalla */
  .festivo-tag {
    font-family: 'DM Sans', sans-serif !important;
    font-size: 5pt !important;
    color: var(--print-warm) !important;
    background: var(--print-warm-soft) !important;
    padding: 0.5mm 1.2mm !important;
    border-radius: 999px !important;
    font-weight: 600 !important;
    letter-spacing: 0.08em !important;
    margin-left: 1.5mm !important;
    vertical-align: middle !important;
    text-transform: uppercase !important;
    display: inline-block !important;
  }

  .blank {
    display: inline-block !important;
    min-width: 10px !important;
    border-bottom: 0.4pt dashed var(--print-ink-muted) !important;
    vertical-align: bottom !important;
    margin: 0 1px !important;
    height: auto !important;
  }

  .blank.wide {
    min-width: 30px !important;
  }

  .day-line {
    color: var(--print-ink-muted) !important;
    font-family: 'DM Sans', sans-serif !important;
  }

  .has-data .day-line {
    color: var(--print-ink) !important;
  }

  .has-data .day-line b {
    color: #000 !important;
    font-weight: 700 !important;
  }

  .radio-row {
    display: inline-flex !important;
    flex-wrap: wrap !important;
    gap: 0px 3px !important;
    align-items: center !important;
  }

  .radio-opt {
    display: inline-flex !important;
    align-items: center !important;
    gap: 2px !important;
    font-size: 6pt !important;
    color: var(--print-ink-muted) !important;
    white-space: nowrap !important;
    font-family: 'DM Sans', sans-serif !important;
  }

  .radio-opt.sel {
    color: var(--print-accent) !important;
    font-weight: 700 !important;
  }

  .rdot {
    font-size: 6pt !important;
    line-height: 1 !important;
  }

  /* ── Texto distribuido ── */
  .day-data {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    gap: 0.4mm !important;
    padding-top: 0.2mm !important;
    font-family: 'DM Sans', sans-serif !important;
    font-size: 6.5pt !important;
    line-height: 1.2 !important;
    color: var(--print-ink) !important;
    overflow: visible !important;
  }

  .day-line {
    display: block !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
  }

  .day-data b {
    font-weight: 700 !important;
    color: #000 !important;
  }
}

/* ==========================================================
   AUTH — Pantalla de bienvenida / login
   ========================================================== */

#auth-screen,
#main-app {
  display: none;
}

#auth-screen {
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

/* ---------- Auth card — entrada animada ---------- */

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  position: relative;
  z-index: 2;
  opacity: 0;
  transform: translateY(14px);
  animation: card-in 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) 0.05s forwards;
}

@keyframes card-in {
  to { opacity: 1; transform: translateY(0); }
}

.auth-card > * {
  opacity: 0;
  transform: translateY(8px);
  animation: stagger-in 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

@keyframes stagger-in {
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  font-family: var(--font-serif);
  font-weight: 800;
  font-variation-settings: "opsz" 96, "SOFT" 80;
  font-size: 3.6rem;
  letter-spacing: -0.04em;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 4px;
  position: relative;
  animation: logo-in 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.30s forwards;
}

@keyframes logo-in {
  0%   { opacity: 0; transform: translateY(10px) scale(0.94); letter-spacing: 0.02em; }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: translateY(0) scale(1); letter-spacing: -0.04em; }
}

.auth-logo::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 0;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transform: translateX(-50%);
  animation: logo-rule 0.7s cubic-bezier(0.4, 0.1, 0.2, 1) 0.85s forwards;
}

@keyframes logo-rule {
  to { width: 56px; }
}

.auth-title  { animation-delay: 0.45s; }
.auth-desc   { animation-delay: 0.60s; }
.auth-features { animation-delay: 0.75s; }
.btn-google  { animation-delay: 1.30s; }

.auth-title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 24px;
}

.auth-desc {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.6;
  margin-bottom: 20px;
}

.auth-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 32px;
  width: 100%;
  text-align: left;
}

.auth-features li {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink-soft);
  padding-left: 20px;
  position: relative;
  opacity: 0;
  transform: translateX(-6px);
  animation: feat-in 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

.auth-features li:nth-child(1) { animation-delay: 0.90s; }
.auth-features li:nth-child(2) { animation-delay: 1.03s; }
.auth-features li:nth-child(3) { animation-delay: 1.16s; }

@keyframes feat-in {
  to { opacity: 1; transform: translateX(0); }
}

.auth-features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--good);
  font-weight: 700;
  display: inline-block;
  transform: scale(0);
  animation: feat-check 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.3) forwards;
}

.auth-features li:nth-child(1)::before { animation-delay: 1.05s; }
.auth-features li:nth-child(2)::before { animation-delay: 1.18s; }
.auth-features li:nth-child(3)::before { animation-delay: 1.31s; }

@keyframes feat-check {
  to { transform: scale(1); }
}

.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 13px 20px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.btn-google::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 38%, rgba(255,255,255,0.6) 50%, transparent 62%);
  transform: translateX(-130%);
  animation: btn-shimmer 1.1s ease-out 1.7s forwards;
  pointer-events: none;
}

html[data-theme="dark"] .btn-google::after {
  background: linear-gradient(105deg, transparent 38%, rgba(255,255,255,0.18) 50%, transparent 62%);
}

@keyframes btn-shimmer {
  to { transform: translateX(130%); }
}

.btn-google:hover {
  border-color: var(--accent-alpha-4);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.btn-google:active {
  transform: translateY(0);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .auth-card, .auth-card > *,
  .auth-features li, .btn-google::after, .auth-logo::after {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .auth-logo::after { width: 56px !important; }
}

/* ==========================================================
   USER BAR — Header (usuario logueado)
   ========================================================== */

/* ---------- Botón volver arriba ---------- */

.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 200;
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--accent-strong);
  transform: translateY(-2px);
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 4px;
  border-left: 1px solid var(--line-soft);
  margin-left: 4px;
}

.user-avatar-img {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  object-fit: cover;
  border: 1.5px solid var(--line);
  display: none;
}

.user-name-text {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Botón compartir — variante secundaria (borde en lugar de fondo sólido) */
.btn-print-main.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.btn-print-main.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--accent-alpha-5);
  color: var(--ink);
}

@media (max-width: 640px) {
  .auth-card {
    padding: 36px 24px 32px;
  }

  .user-name-text {
    max-width: 80px;
    font-size: 12px;
  }

  .btn-print-main span {
    display: none;
  }
}

/* Overrides for PDF generation — jsPDF can't parse CSS gradients */
.generating-pdf .day-cell.weekend,
.generating-pdf .day-cell.holiday {
  background: var(--accent-2) !important;
}

/*
 * Single-page PDF layout
 * Empirically determined: without windowWidth, scale=2, A4 landscape,
 * the threshold for a single page is ~732px. We use 730px for a safe margin.
 */
.generating-pdf .app {
  height: 730px !important;
  max-height: 730px !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 0 !important;
}

.generating-pdf .print-header {
  flex-shrink: 0 !important;
  padding-bottom: 6px !important;
}

.generating-pdf .calendar-wrapper {
  flex: 1 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}

.generating-pdf .calendar-head {
  flex-shrink: 0 !important;
}

.generating-pdf .calendar-grid {
  flex: 1 !important;
  min-height: 0 !important;
  grid-auto-rows: 1fr !important;
}

.generating-pdf .day-cell {
  min-height: 0 !important;
  overflow: hidden !important;
}

.generating-pdf .day-num {
  font-size: 1rem !important;
  margin-bottom: 3px !important;
}

.generating-pdf .day-data {
  font-size: 8px !important;
  line-height: 1.25 !important;
}

.generating-pdf .day-line {
  line-height: 1.25 !important;
  margin-bottom: 0 !important;
}

.generating-pdf .blank {
  min-width: 10px !important;
}

.generating-pdf .blank.wide {
  min-width: 28px !important;
}

.generating-pdf .radio-opt {
  font-size: 7px !important;
}
