:root {
  /* Excel-derived palette: turquoise + magenta */
  --bg: #fafdfd;
  --bg-2: #eaf6f6;
  --bg-3: #d6ecec;
  --ink: #163838;
  --ink-2: #2f5c5c;
  --muted: #7a9999;
  --line: #c5e0e0;
  --line-2: #dbeded;
  --brand: #57BABA;            /* Turquesa medio - Excel */
  --brand-2: #9AD5D5;           /* Turquesa claro - Excel */
  --brand-dark: #2e8888;
  --accent: #E02360;            /* Magenta/fucsia - Excel (festivos) */
  --accent-soft: #fbe1ea;
  /* Semantic */
  --green: #1d8064;
  --amber: #c4831f;
  --red: #c92651;               /* alineado con accent */
  --blue: #2563eb;
  /* Profesores: tonos derivados, claramente distinguibles */
  --iniaki: #E02360;            /* magenta del Excel */
  --odei:   #2e8888;            /* turquesa oscuro */
  --shadow: 0 1px 0 rgba(22,56,56,.04), 0 2px 8px rgba(22,56,56,.06);
  --shadow-hi: 0 10px 30px rgba(22,56,56,.12);
  --r: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body::before {
  content: ''; position: fixed; inset: 0;
  background-image: radial-gradient(circle at 20% 0%, rgba(154,213,213,.18), transparent 50%),
                    radial-gradient(circle at 80% 100%, rgba(224,35,96,.05), transparent 50%);
  pointer-events: none; z-index: -1;
}
button { font-family: inherit; }
code { font-family: 'JetBrains Mono', monospace; font-size: .92em; }

/* TOPBAR */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: rgba(250,246,240,.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 100;
  flex-wrap: wrap;
}
.brand {
  font-family: 'Fraunces', serif;
  font-weight: 700; font-size: 22px;
  letter-spacing: -0.02em;
  display: flex; align-items: baseline; gap: 8px;
}
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }

.sync-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  transition: background 0.4s, box-shadow 0.4s;
  background: #d1d5db;
}
.sync-dot.synced    { background: #22c55e; box-shadow: 0 0 0 2px #bbf7d0; }
.sync-dot.pending   { background: #f59e0b; box-shadow: 0 0 0 2px #fde68a; }
.sync-dot.offline   { background: #ef4444; box-shadow: 0 0 0 2px #fecaca; }

.curso-selector {
  display: flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 4px;
}
.curso-selector select {
  border: none; background: transparent;
  font-family: 'JetBrains Mono'; font-size: 12px; font-weight: 600;
  color: var(--ink); padding: 4px 8px; cursor: pointer;
}
.curso-selector button {
  background: var(--bg-2); border: none; border-radius: 6px;
  padding: 4px 8px; font-size: 11px; cursor: pointer; color: var(--ink-2);
}
.curso-selector button:hover { background: var(--accent); color: white; }

.nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.nav button {
  background: transparent; border: 1px solid transparent;
  color: var(--ink-2); padding: 7px 13px;
  border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s;
}
.nav button:hover { background: var(--bg-2); color: var(--ink); }
.nav button.active { background: var(--brand-dark); color: white; }

/* LAYOUT */
.main { padding: 20px 20px 80px; max-width: 1480px; margin: 0 auto; }
.view-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.view-title {
  font-family: 'Fraunces', serif;
  font-weight: 600; font-size: 34px;
  letter-spacing: -0.025em;
}
.view-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.btn:hover { background: var(--bg-2); }
.btn-primary { background: var(--brand-dark); color: white; border-color: var(--brand-dark); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: white; }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* CARDS */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

/* CALENDARIO - controles superiores */
.cal-toolbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.view-switcher {
  display: flex; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 3px;
}
.view-switcher button {
  background: transparent; border: none; padding: 6px 14px;
  font-size: 12px; font-weight: 500; color: var(--ink-2); cursor: pointer;
  border-radius: 6px; transition: all .15s;
}
.view-switcher button.active { background: var(--brand-dark); color: white; }

.date-nav {
  display: flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 4px;
}
.date-nav button {
  background: transparent; border: none; width: 30px; height: 30px;
  border-radius: 6px; cursor: pointer; color: var(--ink-2);
  font-size: 16px; font-weight: 500;
}
.date-nav button:hover { background: var(--bg-2); color: var(--ink); }
.date-nav .current-label {
  font-family: 'Fraunces', serif; font-size: 16px; font-weight: 600;
  padding: 0 14px; min-width: 200px; text-align: center;
  letter-spacing: -.01em; white-space: nowrap;
}
.date-nav .today-btn {
  background: var(--bg-2); padding: 0 12px; width: auto; height: 30px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid var(--line); background: #fff;
  border-radius: 999px; font-size: 12px; font-weight: 500;
  cursor: pointer; color: var(--ink-2); transition: all .15s;
}
.chip:hover { border-color: var(--ink-2); }
.chip.active { background: var(--brand-dark); color: white; border-color: var(--brand-dark); }
.chip .swatch { width: 8px; height: 8px; border-radius: 50%; }

/* VISTA SEMANAL/DIARIA */
.cal-grid-wrapper {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 0;
  overflow: auto;
}
.cal-grid {
  display: grid;
  gap: 0;
  position: relative;
  min-width: 700px;
}
.cal-grid.week { grid-template-columns: 64px repeat(7, 1fr); }
.cal-grid.day { grid-template-columns: 64px 1fr; min-width: 320px; }

.cal-hdr {
  background: var(--bg-2);
  padding: 12px 8px;
  font-family: 'JetBrains Mono';
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-2);
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line-2);
  position: sticky; top: 0; z-index: 3;
}
.cal-hdr.today-hdr { background: var(--accent); color: white; }
.cal-hdr.holiday-hdr {
  background: var(--accent-soft);
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.cal-hdr.holiday-hdr .holiday-label {
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 2px;
  display: block;
  opacity: .9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  padding: 0 2px;
}
.cal-cell.holiday-col {
  background: repeating-linear-gradient(
    45deg,
    rgba(224,35,96,.04),
    rgba(224,35,96,.04) 6px,
    transparent 6px,
    transparent 12px
  );
}
.event.on-holiday {
  opacity: .45;
  filter: saturate(.6);
}
.event.on-holiday::after {
  content: 'FESTIVO';
  position: absolute; bottom: 2px; right: 4px;
  font-size: 8px; font-family: 'JetBrains Mono', monospace;
  font-weight: 700; color: var(--accent);
  letter-spacing: .04em;
  pointer-events: none;
}

/* ========== Week Picker dropdown ========== */
.current-label.clickable-label {
  background: transparent;
  border: none;
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 600;
  padding: 4px 14px;
  min-width: 200px;
  text-align: center;
  letter-spacing: -.01em;
  cursor: pointer;
  border-radius: 6px;
  color: var(--ink);
  transition: background .12s;
  white-space: nowrap;
}
.current-label.clickable-label:hover { background: var(--bg-2); }

.week-picker-pop {
  position: absolute;
  z-index: 250;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(22,56,56,.18);
  padding: 14px;
  width: 280px;
  animation: fadeIn .15s;
}
.wp-nav {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.wp-nav button {
  background: var(--bg); border: 1px solid var(--line);
  width: 28px; height: 28px; border-radius: 6px;
  cursor: pointer; font-size: 14px; color: var(--ink-2);
}
.wp-nav button:hover { background: var(--brand-dark); color: white; border-color: var(--brand-dark);}
.wp-selectors {
  flex: 1; display: flex; gap: 4px;
}
.wp-selectors select {
  flex: 1; padding: 4px 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  font-family: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer; outline: none;
}
.wp-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.wp-dayhdr {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--muted);
  text-align: center; padding: 4px 0;
  font-weight: 600; text-transform: uppercase;
}
.wp-day {
  text-align: center; padding: 6px 0;
  font-size: 12px; font-family: 'JetBrains Mono', monospace;
  border-radius: 6px; cursor: pointer;
  transition: all .12s;
  background: transparent;
}
.wp-day:hover:not(.empty) { background: var(--bg-2); }
.wp-day.empty { cursor: default; color: transparent; }
.wp-day.weekend { color: var(--muted); }
.wp-day.holiday { background: var(--accent-soft); color: var(--accent); font-weight: 600;}
.wp-day.selected {
  background: var(--brand-dark);
  color: white;
  font-weight: 700;
}
.wp-day.today { box-shadow: inset 0 0 0 2px var(--accent);}
.wp-day.selected.today { box-shadow: inset 0 0 0 2px white;}
.wp-actions {
  display: flex; justify-content: flex-end;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--line-2);
}
.cal-hdr .day-num { display: block; font-family: 'Fraunces',serif; font-size: 16px; margin-top: 2px;}
.cal-time {
  background: var(--bg);
  padding: 4px 6px;
  font-family: 'JetBrains Mono'; font-size: 10px;
  color: var(--muted); text-align: right;
  border-bottom: 1px dashed var(--line-2);
  border-right: 1px solid var(--line);
  position: sticky; left: 0; z-index: 2;
}
.cal-time.hour-mark { border-top: 1px solid var(--line); color: var(--ink-2); font-weight: 600; background: var(--bg-2);}
.cal-cell {
  background: #fff;
  min-height: 18px;
  position: relative;
  border-bottom: 1px dashed var(--line-2);
  border-right: 1px solid var(--line-2);
}
.cal-cell.hour-mark { border-top: 1px solid var(--line); }
.cal-cell.drop-target { background: rgba(212,165,116,.25); }
.cal-cell.today-col { background: rgba(184,69,31,.02); }

.event {
  position: absolute;
  background: var(--bg-2);
  border-left: 3px solid var(--ink);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 11px;
  cursor: grab;
  overflow: hidden;
  z-index: 4;
  transition: transform .12s, box-shadow .12s;
  user-select: none;
}
.event:active { cursor: grabbing; }
.event:hover { box-shadow: var(--shadow-hi); transform: translateY(-1px); z-index: 10; }
.event.dragging { opacity: .4; }
.event.iniaki { background: rgba(224,35,96,.14); border-left-color: var(--iniaki); }
.event.odei { background: rgba(46,136,136,.14); border-left-color: var(--odei); }
.event.guitarra { background: rgba(234,88,12,.16); border-left-color: #ea580c; }
.event .event-name { font-weight: 700; color: var(--ink); font-size: 11px; line-height: 1.2; }
.event .event-meta { font-size: 9px; color: var(--ink-2); font-family: 'JetBrains Mono'; margin-top: 2px;}

/* VISTA MES */
.month-view {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; box-shadow: var(--shadow);
}
.month-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  background: var(--line);
}
.month-day-hdr {
  background: var(--bg-2); padding: 10px;
  font-family: 'JetBrains Mono'; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-2); font-weight: 600; text-align: center;
}
.month-day {
  background: #fff; min-height: 100px; padding: 8px;
  cursor: pointer; transition: background .15s;
  position: relative; overflow: hidden;
}
.month-day:hover { background: var(--bg-2); }
.month-day.other-month { background: var(--bg); color: var(--muted); }
.month-day.today .day-number { background: var(--accent); color: white; }
.month-day.weekend { background: var(--bg); }
.month-day .day-number {
  display: inline-block; min-width: 24px; height: 24px;
  border-radius: 50%; text-align: center; line-height: 24px;
  font-family: 'Fraunces',serif; font-size: 14px; font-weight: 600;
}
.month-day .events-mini {
  margin-top: 4px; display: flex; flex-direction: column; gap: 2px;
}
.event-mini {
  font-size: 10px; padding: 2px 5px; border-radius: 3px;
  background: var(--bg-2); color: var(--ink); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  border-left: 2px solid var(--ink);
}
.event-mini.iniaki { background: rgba(224,35,96,.12); border-left-color: var(--iniaki); }
.event-mini.odei { background: rgba(46,136,136,.12); border-left-color: var(--odei); }
.event-mini-more { font-size: 9px; color: var(--muted); margin-top: 2px; font-family: 'JetBrains Mono';}

/* VISTA AÑO */
.year-view-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.year-month-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; box-shadow: var(--shadow); cursor: pointer;
  transition: all .15s;
}
.year-month-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hi); }
.year-month-name {
  font-family: 'Fraunces', serif; font-size: 16px; font-weight: 600;
  margin-bottom: 10px; letter-spacing: -0.01em;
  display: flex; justify-content: space-between; align-items: baseline;
}
.year-month-count { font-family: 'JetBrains Mono'; font-size: 11px; color: var(--accent); font-weight: 600;}
.year-mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.year-day-hdr {
  font-family: 'JetBrains Mono'; font-size: 9px; color: var(--muted);
  text-align: center; padding: 2px 0; font-weight: 600; text-transform: uppercase;
}
.year-day {
  text-align: center; padding: 4px 0; font-size: 11px;
  border-radius: 4px; font-family: 'JetBrains Mono'; cursor: pointer;
  transition: background .12s;
}
.year-day:hover { background: var(--bg-2); }
.year-day.has-classes { background: rgba(63,110,68,.15); color: var(--green); font-weight: 600; }
.year-day.holiday {
  background: var(--accent);
  color: white;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(224,35,96,.3);
}
.year-day.clickable-day { cursor: pointer; transition: all .12s; }
.year-day.clickable-day:hover { transform: scale(1.15); z-index: 2; box-shadow: 0 2px 8px rgba(0,0,0,.15); background: var(--accent-soft);}
.year-day.clickable-day.holiday:hover { background: var(--accent); }
.year-day.weekend { color: var(--muted); }
.year-day.today { box-shadow: inset 0 0 0 2px var(--brand-dark); font-weight: 700;}
.year-day.today.holiday { box-shadow: inset 0 0 0 2px white; }
.year-day.empty { color: transparent; cursor: default; }
.year-day.empty:hover { background: transparent; transform: none; box-shadow: none;}
.year-day.in-range { background: rgba(224,35,96,.18) !important; transform: none !important; box-shadow: none !important; }
.year-day.range-start { background: rgba(224,35,96,.4) !important; box-shadow: inset 0 0 0 2px #E02360 !important; }

/* List of festivos under each month */
.month-festivos-list {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.month-fest-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-2);
}
.month-fest-item .mf-day {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 4px;
  min-width: 22px;
  text-align: center;
  font-size: 10px;
}
.month-fest-item .mf-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* TABLAS */
.search-bar { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; }
.search-bar input {
  flex: 1; padding: 10px 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 13px; outline: none;
}
.search-bar input:focus { border-color: var(--ink); }

table.data-table {
  width: 100%; border-collapse: collapse;
  background: #fff; border-radius: var(--r);
  overflow: hidden; border: 1px solid var(--line);
}
.data-table th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); font-weight: 600;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.data-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--line-2);
  font-size: 13px; vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.clickable { cursor: pointer; transition: background .12s; }
.data-table tr.clickable:hover { background: var(--bg-2); }
.data-table .name-link { color: var(--accent); font-weight: 600; cursor: pointer; }
.data-table .name-link:hover { text-decoration: underline; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
.badge.iniaki { background: rgba(224,35,96,.16); color: var(--iniaki); }
.badge.odei { background: rgba(46,136,136,.18); color: var(--odei); }
.badge.dom { background: rgba(29,128,100,.16); color: var(--green); }
.badge.mano { background: rgba(196,131,31,.16); color: var(--amber); }
.badge.transf { background: rgba(224,35,96,.12); color: var(--accent); }

/* MODAL */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(29,24,21,.5);
  z-index: 200; display: none; align-items: flex-start; justify-content: center;
  padding: 20px; overflow-y: auto;
  animation: fadeIn .15s;
}
.modal-backdrop.show { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg);
  border-radius: 16px;
  max-width: 720px; width: 100%;
  margin: auto; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 30px 80px rgba(29,24,21,.3);
  animation: slideUp .2s;
}
.modal.modal-lg { max-width: 900px; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0;} to { transform: translateY(0); opacity: 1;} }
.modal-header {
  padding: 22px 28px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
}
.modal-header-left {
  display: flex; align-items: flex-start; gap: 10px; flex: 1; min-width: 0;
}
.modal-back {
  background: var(--bg-2); border: 1px solid var(--line);
  width: 32px; height: 32px; border-radius: 8px;
  cursor: pointer; color: var(--ink-2);
  font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
  transition: all .15s;
}
.modal-back:hover { background: var(--ink); color: var(--bg); border-color: var(--ink);}
.modal-header-titles { flex: 1; min-width: 0;}
.modal-title { font-family: 'Fraunces', serif; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.modal-sub { color: var(--muted); font-size: 13px; margin-top: 4px;}
.modal-close {
  background: transparent; border: none; font-size: 24px; cursor: pointer; color: var(--muted);
  padding: 4px 8px; line-height: 1; border-radius: 6px;
}
.modal-close:hover { background: var(--bg-2); color: var(--ink); }
.modal-body { padding: 22px 28px; }
.modal-footer {
  padding: 14px 28px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end;
}

.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 24px; }
.info-item .label {
  font-family: 'JetBrains Mono'; font-size: 10px;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 4px; font-weight: 600;
}
.info-item .value { font-size: 14px; color: var(--ink); }
.info-item .value.clickable { color: var(--accent); cursor: pointer; font-weight: 600; }
.info-item .value.clickable:hover { text-decoration: underline; }

.section-title {
  font-family: 'Fraunces', serif;
  font-size: 17px; font-weight: 600;
  margin: 20px 0 10px; letter-spacing: -0.01em;
}
.linked-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 14px;
  cursor: pointer; transition: all .15s;
}
.linked-card:hover { border-color: var(--ink); box-shadow: var(--shadow); }
.linked-card .lc-name { font-weight: 600; font-size: 15px; }
.linked-card .lc-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* FORMS */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 12px; }
.form-row.full { grid-template-columns: 1fr; }
.form-group label {
  display: block; font-family: 'JetBrains Mono'; font-size: 10px;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 4px; font-weight: 600;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 8px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  font-family: inherit; font-size: 13px; color: var(--ink); outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--ink); }
.form-group .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Tarifa banner in profesor month edit */
.tarifa-info-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--brand-soft), rgba(154,213,213,.3));
  border: 1px solid var(--brand);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.tarifa-info-label {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--brand-dark);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.tarifa-info-value {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

/* Inline tarifa in profesor card */
.prof-tarifa-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--brand-soft), rgba(154,213,213,.3));
  border: 1px solid var(--brand);
  border-radius: 10px;
}
.prof-tarifa-label {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--brand-dark);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.prof-tarifa-input-wrap {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.prof-tarifa-inline {
  background: #fff;
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 4px 8px;
  width: 80px;
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 700;
  text-align: right;
  color: var(--ink);
  outline: none;
}
.prof-tarifa-inline:focus {
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 3px rgba(46,136,136,.2);
}
.prof-tarifa-inline::-webkit-outer-spin-button,
.prof-tarifa-inline::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.prof-tarifa-unit {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--brand-dark);
  font-weight: 600;
}

/* Editable months table */
.prof-meses-table { font-size: 12px; }
.prof-meses-table td { padding: 5px 8px; vertical-align: middle; }
.prof-mes-input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  text-align: right;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.prof-mes-input:hover { border-color: var(--ink-2); }
.prof-mes-input:focus { border-color: var(--brand-dark); box-shadow: 0 0 0 2px rgba(46,136,136,.15);}
.prof-mes-input::-webkit-outer-spin-button,
.prof-mes-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.prof-mes-sueldo {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 12px;
  color: var(--brand-dark);
}
.prof-mes-costo {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 12px;
  color: var(--accent);
}
.view-header.compact { padding-bottom: 12px; margin-bottom: 12px;}

/* Grand total panel in header */
.pagos-grand-total {
  text-align: right;
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--brand-soft), rgba(154,213,213,.4));
  border: 1px solid var(--brand);
  border-radius: 10px;
  min-width: 200px;
}
.pgt-label {
  font-size: 11px; color: var(--brand-dark); font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  font-family: 'JetBrains Mono', monospace;
}
.pgt-value {
  font-family: 'Fraunces', serif; font-size: 30px; font-weight: 700;
  color: var(--ink); line-height: 1; margin: 2px 0 4px;
}
.pgt-breakdown {
  font-size: 11px; font-family: 'JetBrains Mono', monospace;
  display: flex; gap: 6px; justify-content: flex-end; align-items: center;
}
.pgt-dom { color: var(--brand-dark); font-weight: 600; }
.pgt-transf { color: var(--accent); font-weight: 600; }
.pgt-sep { color: var(--muted); }

/* Section blocks (Domiciliaciones / Transferencias) */
.pagos-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 14px;
  overflow: hidden;
}
.pagos-section-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.pagos-section-header.dom-hdr {
  background: rgba(46,136,136,.08);
  border-bottom-color: rgba(46,136,136,.25);
}
.pagos-section-header.transf-hdr {
  background: rgba(224,35,96,.06);
  border-bottom-color: rgba(224,35,96,.25);
}
.pagos-section-title {
  font-family: 'Fraunces', serif;
  font-size: 16px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  color: var(--ink);
}
.pagos-section-icon { font-size: 18px; }
.pagos-section-meta {
  font-size: 12px; color: var(--ink-2);
  font-family: 'JetBrains Mono', monospace;
}
.pagos-section-meta strong { color: var(--ink); }
.pagos-empty {
  padding: 16px; color: var(--muted); font-size: 13px;
  text-align: center; font-style: italic;
}
.pagos-table-wrap { overflow-x: auto; }

/* Compact pagos table */
.compact-pagos { min-width: 1080px; font-size: 12px; }
.compact-pagos thead th {
  padding: 6px 6px;
  font-size: 10px;
  background: var(--bg);
}
.compact-pagos tbody td {
  padding: 4px 6px;
  vertical-align: middle;
}
.compact-pagos tbody td strong { font-weight: 600; font-size: 12px; }
.compact-pagos .month-cell {
  text-align: center; font-family: 'JetBrains Mono'; font-size: 11px;
  padding: 4px; cursor: pointer; position: relative; min-width: 42px;
}
.compact-pagos .month-cell.paid { background: rgba(29,128,100,.1); color: var(--green); font-weight: 600;}
.compact-pagos .month-cell.partial { background: rgba(196,131,31,.12); color: var(--amber); font-weight: 600;}
.compact-pagos .month-cell.exempt { color: var(--muted); }
.compact-pagos .month-cell:hover { background: var(--bg-2);}
.compact-pagos th.month-hdr { text-align: center; font-size: 10px;}

/* Section total rows */
.compact-pagos .total-row {
  font-weight: 700;
  background: var(--bg);
}
.compact-pagos .total-row td {
  padding: 8px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-top: 2px solid var(--ink);
}
.compact-pagos .total-row.dom-total {
  background: rgba(46,136,136,.10);
  color: var(--brand-dark);
}
.compact-pagos .total-row.dom-total td { border-top-color: var(--brand-dark); }
.compact-pagos .total-row.transf-total {
  background: rgba(224,35,96,.08);
  color: var(--accent);
}
.compact-pagos .total-row.transf-total td { border-top-color: var(--accent); }
.compact-pagos .total-row .month-cell { font-weight: 700; cursor: default; font-size: 12px; }

/* GRAND TOTAL - last row */
.pagos-grand-row { margin-top: 4px; }
.grand-table { min-width: 1080px; }
.grand-table tbody td { padding: 12px 6px; }
.grand-total-row {
  background: var(--ink); color: white;
  border-radius: 12px;
}
.grand-total-row td {
  background: var(--ink); color: white;
  border: none;
}
.grand-total-row td:first-child { border-top-left-radius: 12px; border-bottom-left-radius: 12px;}
.grand-total-row td:last-child { border-top-right-radius: 12px; border-bottom-right-radius: 12px;}
.grand-label {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700; letter-spacing: .12em;
  font-size: 12px;
}
.grand-sub {
  display: block; font-size: 10px;
  font-weight: 400; opacity: .65;
  margin-top: 2px;
}
.grand-cell {
  font-family: 'JetBrains Mono', monospace;
  text-align: center; font-weight: 700; font-size: 13px;
  color: white !important;
}
.grand-final {
  background: var(--accent) !important;
  font-family: 'Fraunces', serif !important;
  font-size: 18px !important;
  font-weight: 700;
}

/* Legacy pagos-table styles kept for compatibility (no longer used) */
.pagos-table { overflow-x: auto; }
.pagos-table table { min-width: 1100px;}
.pagos-table .month-cell {
  text-align: center; font-family: 'JetBrains Mono'; font-size: 12px; padding: 8px 4px;
  cursor: pointer; position: relative;
}
.pagos-table .month-cell.paid { background: rgba(29,128,100,.1); color: var(--green); font-weight: 600;}
.pagos-table .month-cell.unpaid { color: var(--red); }
.pagos-table .month-cell.exempt { color: var(--muted); }
.pagos-table .month-cell.partial { background: rgba(196,131,31,.12); color: var(--amber); font-weight: 600;}
.pagos-table .month-cell:hover { background: var(--bg-2);}
.pagos-table th.month-hdr { text-align: center; }

/* Inline editable controls in pagos */
.pago-method-select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  min-width: 110px;
}
.pago-method-select:hover { border-color: var(--ink-2); }
.pago-method-select:focus { border-color: var(--brand-dark); box-shadow: 0 0 0 2px rgba(46,136,136,.15); }
.pago-tarifa-input {
  width: 70px;
  padding: 5px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  color: var(--ink);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.pago-tarifa-input:hover { border-color: var(--ink-2); }
.pago-tarifa-input:focus { border-color: var(--brand-dark); box-shadow: 0 0 0 2px rgba(46,136,136,.15); }
.pago-tarifa-input::-webkit-outer-spin-button,
.pago-tarifa-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pago-tarifa-input { -moz-appearance: textfield; }

/* PRECIOS */
.precios-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.precio-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 22px;
  position: relative; overflow: hidden;
}
.precio-card::before {
  content: ''; position: absolute; top: 0; right: 0; width: 80px; height: 80px;
  background: radial-gradient(circle at top right, rgba(154,213,213,.35), transparent 70%);
  pointer-events: none;
}
.precio-tipo { font-family: 'Fraunces', serif; font-size: 18px; font-weight: 600; margin-bottom: 8px;}
.precio-mensual { font-size: 36px; font-weight: 700; font-family: 'Fraunces', serif; color: var(--brand-dark); }
.precio-mensual .unit { font-size: 14px; color: var(--muted); font-weight: 500; font-family: 'Inter';}
.precio-anual { color: var(--muted); font-size: 13px; margin-top: 8px; font-family: 'JetBrains Mono';}
.precio-actions { margin-top: 14px; display: flex; gap: 6px; }

/* PROFESORES */
.prof-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.prof-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 22px;
  border-top: 4px solid var(--ink);
}
.prof-card.iniaki { border-top-color: var(--iniaki); }
.prof-card.odei { border-top-color: var(--odei); }
.prof-name { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 600;}
.prof-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px;}
.prof-stat { background: var(--bg); padding: 10px; border-radius: 8px;}
.prof-stat .ps-label { font-family: 'JetBrains Mono'; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;}
.prof-stat .ps-value { font-family: 'Fraunces',serif; font-size: 20px; font-weight: 600; margin-top: 2px;}

/* RESPONSIVE */
@media (max-width: 768px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand { font-size: 18px; }
  .nav { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .nav button { white-space: nowrap; padding: 6px 10px; font-size: 12px; }
  .curso-selector { width: 100%; }
  .view-title { font-size: 24px; }
  .main { padding: 14px 10px 60px; }
  .cal-grid.week { min-width: 600px; }
  .info-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .modal { border-radius: 12px; }
  .modal-header, .modal-body, .modal-footer { padding: 14px 16px; }
  .modal-title { font-size: 20px; }
  .prof-stats { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .prof-stat { padding: 8px; }
  .prof-stat .ps-value { font-size: 16px; }
  .month-day { min-height: 70px; padding: 4px; }
  .month-day .day-number { font-size: 12px; min-width: 20px; height: 20px; line-height: 20px;}
  .date-nav .current-label { min-width: 120px; font-size: 14px; padding: 0 8px;}
  .view-switcher button { padding: 5px 10px; font-size: 11px;}
  .cal-toolbar { gap: 6px;}
}

/* TOAST */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-hi);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 300;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px);}
.toast.error { background: var(--red); }

.fab-reset {
  position: fixed; bottom: 18px; right: 18px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; font-size: 11px; color: var(--muted);
  cursor: pointer; font-family: 'JetBrains Mono'; letter-spacing: .04em;
  box-shadow: var(--shadow); z-index: 50;
}
.fab-reset:hover { color: var(--red); border-color: var(--red); }

.empty-state {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty-state .emoji { font-size: 32px; margin-bottom: 8px; }

/* ====== ESTADOS DE CLASE ====== */
.event .status-dot {
  position: absolute; top: 4px; right: 4px;
  width: 9px; height: 9px; border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.1);
}
.event.cancelled { opacity: .55; }
.event.cancelled .event-name { text-decoration: line-through; }
.event-mini .status-dot-mini {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  margin-right: 4px; vertical-align: middle;
}
.event-mini.cancelled { opacity: .55; }
.event-mini.cancelled .event-mini-text { text-decoration: line-through; }

/* Status colors */
.status-color-normal { background: transparent; }
.status-color-confirmada { background: #1d8064; }
.status-color-cancelada { background: #E02360; }
.status-color-cambiada { background: #d97706; }
.status-color-recuperacion { background: #2563eb; }
.status-color-aviso { background: #d4af37; }

/* Color picker en formulario */
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-option {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: #fff; border: 1px solid var(--line);
  border-radius: 999px; cursor: pointer; font-size: 12px; font-weight: 500;
  transition: all .15s;
}
.color-option:hover { border-color: var(--ink-2); }
.color-option.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.color-option .swatch {
  width: 12px; height: 12px; border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.1);
}
.color-option .swatch.empty { background: transparent; border: 1px dashed var(--muted); }

/* Cal cell clickable for new event */
.cal-cell { cursor: pointer; }
.cal-cell:hover:not(.drop-target) { background: var(--bg-2); }
.cal-cell.today-col:hover { background: rgba(184,69,31,.06); }

/* Event mini clickable hover */
.event-mini { cursor: pointer; transition: transform .12s; }
.event-mini:hover { transform: translateX(2px); }

/* === Calendario académico extensible === */
.academic-toggle {
  display: flex; gap: 8px; align-items: center; margin-bottom: 16px;
}
.academic-year-header {
  font-family: 'Fraunces',serif; font-size: 20px; font-weight: 600;
  margin-bottom: 12px; color: var(--ink-2);
  letter-spacing: -0.01em;
}
.month-card.out-of-course { opacity: .45; }
.year-month-card.out-of-course { opacity: .45; }
.year-month-card.out-of-course::after {
  content: 'Fuera de curso'; position: absolute; top: 8px; right: 8px;
  font-family: 'JetBrains Mono'; font-size: 9px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.year-month-card { position: relative; }

/* === Sección de excepciones en ficha === */
.exception-section {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-top: 12px;
}
.exception-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 10px; max-height: 240px; overflow-y: auto;
}
.exception-item {
  display: flex; align-items: center; gap: 10px;
  background: #fff; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line-2);
}
.exception-item .exc-date {
  font-family: 'JetBrains Mono'; font-size: 11px; font-weight: 600;
  color: var(--ink-2);
  min-width: 80px;
}
.exception-item .exc-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
}
.exception-item .exc-info { flex: 1; font-size: 12px; }
.exception-item .exc-info .label { font-weight: 600; color: var(--ink); }
.exception-item .exc-info .obs { color: var(--muted); font-size: 11px; margin-top: 2px;}
.exception-item button { background: transparent; border: none; color: var(--red); cursor: pointer; font-size: 16px; padding: 4px 6px; }
.exception-item button:hover { background: var(--bg-2); border-radius: 4px;}

/* === Custom radio buttons for estado === */
.estado-options {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px;
}
.estado-option {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; background: #fff;
  border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; font-size: 12px; font-weight: 500;
  transition: all .15s;
}
.estado-option:hover { border-color: var(--ink-2); }
.estado-option.active {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.estado-option .swatch {
  width: 10px; height: 10px; border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.1);
}
.estado-option.active .swatch {
  box-shadow: 0 0 0 1px rgba(255,255,255,.4);
}

/* === Scope options for profesor change === */
.scope-option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
}
.scope-option:hover { border-color: var(--brand-dark); }
.scope-option.active {
  border-color: var(--brand-dark);
  background: var(--bg-2);
  box-shadow: 0 0 0 2px rgba(46,136,136,.15);
}
.scope-option input[type=radio] { margin-top: 3px; flex-shrink: 0; accent-color: var(--brand-dark);}
.scope-option .scope-label {
  font-weight: 600; font-size: 14px; color: var(--ink);
}
.scope-option .scope-hint {
  font-size: 12px; color: var(--muted); margin-top: 2px;
}

/* Date picker (month calendar inside multiple-scope) */
.pc-calendar {
  margin-top: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.pc-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.pc-month-label {
  font-family: 'Fraunces', serif;
  font-size: 15px; font-weight: 600;
  letter-spacing: -.01em;
}
.pc-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.pc-dayhdr {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--muted);
  text-align: center; padding: 4px 0;
  font-weight: 600; text-transform: uppercase;
}
.pc-day {
  text-align: center;
  padding: 8px 0;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  cursor: pointer;
  transition: all .12s;
  user-select: none;
}
.pc-day:hover:not(.empty):not(.holiday):not(.out) {
  border-color: var(--ink-2);
  transform: scale(1.06);
}
.pc-day.empty { background: transparent; border: none; cursor: default; }
.pc-day.out { color: var(--muted); background: var(--bg-2); cursor: not-allowed; opacity: .5;}
.pc-day.weekend { color: var(--muted); }
.pc-day.habitual-day {
  background: rgba(46,136,136,.08);
  border-color: rgba(46,136,136,.3);
  font-weight: 600;
  color: var(--brand-dark);
}
.pc-day.selected {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: white;
  font-weight: 700;
}
.pc-day.holiday {
  background: var(--accent-soft);
  color: var(--accent);
  cursor: not-allowed;
  text-decoration: line-through;
}
.pc-day.today {
  box-shadow: inset 0 0 0 2px var(--accent);
}
.pc-legend {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-top: 10px;
  font-size: 11px; color: var(--muted);
}
.pc-legend span {
  display: inline-flex; align-items: center; gap: 5px;
}
.pc-swatch {
  width: 12px; height: 12px; border-radius: 3px;
  border: 1px solid var(--line);
  display: inline-block;
}
.pc-swatch.habitual { background: rgba(46,136,136,.15); border-color: rgba(46,136,136,.3);}
.pc-swatch.selected { background: var(--brand-dark); border-color: var(--brand-dark);}
.pc-swatch.holiday { background: var(--accent-soft); border-color: var(--accent);}

/* ========================================
   MOBILE CARD COMPONENTS
   Default: hidden on desktop. Media query below
   activates them at mobile widths.
   ======================================== */
.mobile-cards { display: none; }
.mobile-cards.show-mobile { display: none; }
.compact-grand-mobile { display: none !important; }
.mcard {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all .12s;
}
.mcard:hover { border-color: var(--brand); }
.mcard:active { transform: scale(.98); }
.mcard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.mcard-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mcard-meta {
  font-size: 11px;
  color: var(--ink-2);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}
.mcard-extra {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  flex-wrap: wrap;
}

/* ========================================
   MOBILE & TABLET RESPONSIVE STYLES
   ======================================== */

/* Tablet: 768px - 1024px */
@media (max-width: 1024px) {
  .container { padding: 12px 14px; }
  .view-header { flex-wrap: wrap; gap: 10px; }
  .view-title { font-size: 22px; }
  .pagos-grand-total { min-width: 0; padding: 8px 14px; }
  .pgt-value { font-size: 24px; }
}

/* Mobile: below 768px */
@media (max-width: 768px) {
  body { font-size: 14px; }
  .container { padding: 8px; }

  /* TOPBAR */
  .topbar {
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 8px;
  }
  .topbar .brand { font-size: 16px; flex: 1; min-width: 0; }
  .topbar .brand .dot { width: 8px; height: 8px; }
  #curso-selector { font-size: 12px; }
  #curso-selector select {
    font-size: 12px; padding: 4px 8px; max-width: 120px;
  }

  /* TABS - horizontal scroll */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    margin-bottom: 10px;
    scrollbar-width: thin;
  }
  .tabs::-webkit-scrollbar { height: 4px; }
  .tabs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
  .tabs button {
    flex-shrink: 0;
    font-size: 12px;
    padding: 6px 12px;
    white-space: nowrap;
  }

  /* HEADERS */
  .view-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding-bottom: 10px;
    margin-bottom: 10px;
  }
  .view-header > * { width: 100%; }
  .view-title { font-size: 20px; }
  .view-sub { font-size: 12px; }

  /* MODALS - full screen */
  .modal-backdrop { padding: 0; }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    margin: 0;
  }
  .modal-header {
    position: sticky; top: 0;
    background: #fff;
    z-index: 10;
    padding: 12px 14px;
    flex-wrap: wrap;
  }
  .modal-title { font-size: 18px; }
  .modal-sub { font-size: 11px; }
  .modal-body {
    padding: 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-footer {
    position: sticky; bottom: 0;
    background: #fff;
    z-index: 10;
    padding: 10px 14px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
  }
  .modal-footer .btn { flex: 1; min-width: 90px; }
  .form-row { grid-template-columns: 1fr !important; gap: 10px;}
  .info-grid { grid-template-columns: 1fr !important; }

  /* BUTTONS */
  .btn { font-size: 13px; padding: 7px 12px; }
  .btn-sm { font-size: 11px; padding: 4px 8px;}

  /* ========== CLASES (week view) ==========
     Show ONE day at a time in mobile */
  .cal-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px;
  }
  .date-nav {
    justify-content: center;
    width: 100%;
  }
  .current-label.clickable-label {
    font-size: 14px;
    min-width: 0;
    flex: 1;
    padding: 4px 8px;
  }
  .week-picker-pop {
    position: fixed;
    left: 8px !important;
    right: 8px !important;
    top: 60px !important;
    width: auto !important;
  }

  /* Calendar grid: show all 6 days but compress them */
  .cal-grid {
    font-size: 10px;
  }
  .cal-hdr {
    padding: 4px 2px;
    font-size: 9px;
  }
  .cal-hdr .day-num { font-size: 13px; }
  .cal-hdr .holiday-label {
    font-size: 7px !important;
    letter-spacing: 0;
  }
  .cal-time {
    font-size: 9px;
    padding: 2px 4px;
  }
  .event {
    font-size: 9px;
    padding: 2px 3px;
    border-left-width: 2px;
  }
  .event .event-name {
    font-size: 9px;
    line-height: 1.1;
  }
  .event .event-meta {
    font-size: 8px;
  }
  .event.on-holiday::after {
    font-size: 6px;
    bottom: 1px; right: 2px;
  }
  /* Filter chips */
  .chip {
    font-size: 11px;
    padding: 4px 8px;
  }
  .chip .swatch { width: 8px; height: 8px;}

  /* ========== CALENDARIO ESCOLAR ========== */
  .year-view-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .year-month-card {
    padding: 10px;
  }
  .year-month-name {
    font-size: 14px;
  }
  .year-month-count {
    font-size: 10px;
  }
  .year-mini-grid {
    gap: 2px;
  }
  .year-day {
    padding: 6px 0;
    font-size: 11px;
  }
  .month-fest-item { font-size: 10px;}

  /* ========== ALUMNOS - cards instead of table ========== */
  .data-table.alumnos-tbl,
  .data-table.pagadores-tbl {
    display: none;
  }
  .mobile-cards.show-mobile { display: flex !important; flex-direction: column; gap: 8px; }
  .compact-grand-mobile { display: block !important; }

  /* ========== PAGOS - tarjetas verticales ========== */
  .compact-pagos,
  .grand-table {
    display: none;
  }
  .pagos-section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 10px 12px;
  }
  .pagos-section-title { font-size: 15px; }
  .pagos-section-meta { font-size: 11px; }

  .pago-mobile-card {
    background: #fff;
    border-top: 1px solid var(--line);
    padding: 12px;
  }
  .pago-mobile-card:first-of-type { border-top: none; }
  .pmc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
  }
  .pmc-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--ink);
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .pmc-alumno {
    font-size: 11px;
    color: var(--muted);
    font-family: 'JetBrains Mono', monospace;
    margin-top: 1px;
  }
  .pmc-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
  }
  .pmc-controls select,
  .pmc-controls input {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    padding: 5px 6px;
  }
  .pmc-meses {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }
  .pmc-mes {
    background: var(--bg-2);
    border: 1px solid var(--line-2);
    border-radius: 6px;
    padding: 5px 4px;
    cursor: pointer;
    text-align: center;
    transition: all .12s;
    min-height: 42px;
  }
  .pmc-mes .pmc-mes-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--muted);
    text-transform: uppercase;
    font-weight: 600;
  }
  .pmc-mes .pmc-mes-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 700;
    margin-top: 2px;
  }
  .pmc-mes.paid { background: rgba(29,128,100,.12); border-color: rgba(29,128,100,.3);}
  .pmc-mes.paid .pmc-mes-val { color: var(--green); }
  .pmc-mes.partial { background: rgba(196,131,31,.14); border-color: rgba(196,131,31,.3);}
  .pmc-mes.partial .pmc-mes-val { color: var(--amber); }
  .pmc-mes.exempt { background: var(--bg); }
  .pmc-mes.exempt .pmc-mes-val { color: var(--muted); }
  .pmc-mes.unpaid .pmc-mes-val { color: var(--accent); font-size: 10px;}

  .pagos-grand-row { margin-top: 8px; }
  .pagos-grand-row .compact-grand-mobile {
    display: block !important;
    background: var(--ink);
    color: #fff;
    border-radius: 12px;
    padding: 14px;
    text-align: center;
  }
  .compact-grand-mobile .gm-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px; letter-spacing: .1em;
    opacity: .7; text-transform: uppercase;
  }
  .compact-grand-mobile .gm-value {
    font-family: 'Fraunces', serif;
    font-size: 32px; font-weight: 700;
    color: var(--accent);
    margin-top: 4px;
  }

  /* Grand total panel */
  .pagos-grand-total {
    text-align: center;
    padding: 10px;
    min-width: 0;
  }

  /* ========== PROFESORES ========== */
  .prof-cards {
    grid-template-columns: 1fr !important;
  }
  .prof-card { padding: 14px; }
  .prof-name { font-size: 18px; }
  .prof-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }
  .prof-stat { padding: 6px; }
  .ps-value { font-size: 14px; }
  .ps-label { font-size: 9px; }
  .prof-tarifa-row { padding: 8px 12px;}
  .prof-tarifa-inline { font-size: 16px; width: 60px; }
  .prof-meses-table { font-size: 11px; }
  .prof-meses-table th, .prof-meses-table td {
    padding: 4px 5px;
  }
  .prof-mes-input { font-size: 11px; padding: 3px 5px;}

  /* ========== Date/scope picker (prof change) ========== */
  .pc-calendar { padding: 8px; }
  .pc-day { padding: 5px 0; font-size: 11px; }
  .scope-option { padding: 8px 10px; }
  .scope-option .scope-label { font-size: 13px; }
  .scope-option .scope-hint { font-size: 11px; }

  /* ========== Calendar selector dropdowns ========== */
  .wp-grid { gap: 1px; }
  .wp-day { padding: 5px 0; font-size: 11px;}

  /* ========== Toasts ========== */
  .toast {
    bottom: 12px;
    left: 12px;
    right: 12px;
    max-width: none;
    font-size: 12px;
  }
}

/* Very small phones (320-380px) */
@media (max-width: 380px) {
  .container { padding: 6px; }
  .topbar .brand { font-size: 14px; }
  .pmc-meses { grid-template-columns: repeat(3, 1fr); }
  .pmc-mes { min-height: 38px; padding: 4px 2px; }
  .pmc-mes .pmc-mes-val { font-size: 11px; }
  .event { font-size: 8px; }
  .event .event-name { font-size: 8px; }
  /* Calendar: hide minutes column on tiny screens? keep but make it tighter */
  .cal-time { width: 35px; }
}

/* ========================================
   CSS DE LA SECCIÓN FACTURAS
   ======================================== */

.tabs-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 4px;
  align-self: center;
  flex-shrink: 0;
}
.tabs .tab-destacado {
  background: linear-gradient(135deg, var(--brand-dark), #1a6363);
  color: #fff;
  font-weight: 600;
  border-color: var(--brand-dark);
  box-shadow: 0 2px 6px rgba(46,136,136,.25);
}
.tabs .tab-destacado:hover {
  background: linear-gradient(135deg, #1a6363, #134e4e);
  color: #fff;
  border-color: #1a6363;
}
.tabs .tab-destacado.active {
  background: linear-gradient(135deg, var(--accent), #b81d52);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 3px 10px rgba(224,35,96,.35);
}

@media (max-width: 768px) {
  .tabs-sep { display: none; }
  .tabs .tab-destacado { order: 999; }
}

.facturas-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(196,131,31,.10);
  border: 1px solid rgba(196,131,31,.30);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 14px;
}
.fb-icon { font-size: 22px; }
.fb-text {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.4;
  flex: 1;
}
.facturas-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.fac-stat {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid;
  border-radius: 8px;
  padding: 10px;
}
.fs-count {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}
.fs-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  margin-top: 4px;
}
.facturas-tbl code {
  background: var(--bg-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.gf-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .12s;
}
.gf-row:hover { background: #fff; border-color: var(--line); }
.gf-row.gf-exists { opacity: .65; background: rgba(91,141,232,.05); }
.gf-row input[type=checkbox] {
  accent-color: var(--brand-dark);
  flex-shrink: 0;
}
.gf-row-info { flex: 1; min-width: 0; }
.gf-row-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gf-row-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.gf-row-total {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 13px;
  color: var(--brand-dark);
  flex-shrink: 0;
}

.factura-preview {
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 24px;
  font-family: 'Inter', sans-serif;
  max-width: 700px;
  margin: 0 auto;
}
.fac-prev-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--ink);
}
.fac-prev-asoc {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}
.fac-prev-cif, .fac-prev-addr {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.4;
}
.fac-prev-num {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .15em;
  text-transform: uppercase;
  font-weight: 600;
}
.fac-prev-numval {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 2px;
}
.fac-prev-fecha {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.fac-prev-receptor {
  background: var(--bg);
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.fac-prev-receptor-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  margin-bottom: 4px;
}
.fac-prev-receptor-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.fac-prev-receptor-info {
  font-size: 11px;
  color: var(--ink-2);
  margin-top: 2px;
}
.fac-prev-lineas {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}
.fac-prev-lineas thead th {
  background: var(--bg);
  padding: 8px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.fac-prev-lineas tbody td {
  padding: 8px 10px;
  font-size: 12px;
  border-bottom: 1px solid var(--line-2);
}
.fac-prev-totales {
  margin-left: auto;
  width: 240px;
  margin-top: 8px;
}
.fac-prev-tot-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 10px;
  font-size: 12px;
}
.fac-prev-tot-row span:last-child {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}
.fac-prev-tot-row.total {
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  margin-top: 4px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
}
.fac-prev-tot-row.total span:last-child {
  color: var(--accent);
  font-size: 16px;
}
.fac-prev-pago {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.6;
}
.fac-prev-qr {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}
.fac-prev-qr-box {
  width: 90px;
  height: 90px;
  border: 1px dashed var(--muted);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 9px;
  color: var(--muted);
  background: var(--bg-2);
  flex-shrink: 0;
  padding: 4px;
  line-height: 1.3;
}
.fac-prev-qr-box.placeholder { font-style: italic; }
.fac-prev-qr-text {
  font-size: 10px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}

@media (max-width: 768px) {
  .data-table.facturas-tbl { display: none; }
  .facturas-banner { font-size: 12px; padding: 10px 12px; }
  .fb-icon { font-size: 18px; }
  .facturas-stats { grid-template-columns: repeat(3, 1fr); }
  .fac-stat { padding: 7px; }
  .fs-count { font-size: 18px; }
  .fs-label { font-size: 9px; }
  .factura-preview { padding: 14px; }
  .fac-prev-header { flex-direction: column; gap: 10px; }
  .fac-prev-totales { width: 100%; }
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}
.card-title {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.fac-form-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fac-form-grid {
  display: grid;
  grid-template-columns: 2fr 80px 110px 110px 130px;
  gap: 8px;
  align-items: start;
}
.fac-form-col, .fac-form-col-sm { min-width: 0; }
.fac-form-col-sm { width: 100%; }
.fac-form-grid input[disabled], .fac-form-grid select[disabled] {
  background: var(--bg-2);
  color: var(--ink-2);
  cursor: not-allowed;
  border-color: var(--line-2);
}

.fac-form-cliente {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
}
.fac-form-cliente .fac-form-grid {
  grid-template-columns: 1.5fr 1fr 2fr;
  margin-bottom: 8px;
}
.ffc-title {
  font-family: 'Fraunces', serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ffc-title::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--brand-dark);
  border-radius: 2px;
}

.fac-form-tb {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
  border-left: 3px solid var(--brand-dark);
}
.tb-status-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}
.tb-status-ok {
  color: #1d8064;
  font-weight: 700;
  background: rgba(29,128,100,.1);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.tb-status-err {
  color: var(--accent);
  font-weight: 700;
  background: rgba(224,35,96,.1);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.tb-status-pending {
  color: var(--muted);
  font-weight: 600;
  background: var(--bg-2);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.tb-qr-preview {
  width: 60px;
  height: 60px;
  background: var(--bg-2);
  border: 1px dashed var(--muted);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--muted);
}
.tb-meta {
  font-size: 11px;
  color: var(--ink-2);
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
}
.tb-meta code {
  background: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
}

.tb-ok { color: #1d8064; font-weight: 600; font-size: 11px; }
.tb-err { color: var(--accent); font-weight: 600; font-size: 11px; }
.tb-pending { color: var(--muted); font-size: 11px; }

.fac-lineas-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.fac-lineas-tbl {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
}
.fac-lineas-tbl thead th {
  background: var(--bg);
  padding: 8px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.fac-lineas-tbl tbody td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.fac-lineas-tbl input {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
.fac-lineas-tbl input:focus {
  outline: none;
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 2px rgba(46,136,136,.15);
}
.fac-lineas-tbl input[disabled] {
  background: var(--bg-2);
  color: var(--ink-2);
  cursor: not-allowed;
}
.btn-icon-del {
  background: transparent;
  border: 1px solid transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon-del:hover {
  background: rgba(224,35,96,.1);
  border-color: rgba(224,35,96,.2);
}

.fac-totales-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-left: auto;
  width: 280px;
  align-self: flex-end;
}
.fac-tot-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 13px;
  background: var(--bg);
  border-radius: 6px;
}
.fac-tot-row span:last-child {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--ink);
}
.fac-tot-row.total {
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
  margin-top: 6px;
}
.fac-tot-row.total span:last-child {
  color: var(--accent);
  font-size: 18px;
}

@media (max-width: 768px) {
  .fac-form-grid { grid-template-columns: 1fr !important; gap: 6px; }
  .fac-form-cliente .fac-form-grid { grid-template-columns: 1fr !important; }
  .fac-totales-block { width: 100%; }
  .fac-lineas-tbl { font-size: 11px; }
  .fac-lineas-tbl thead th { padding: 5px 3px; font-size: 9px; }
  .fac-lineas-tbl tbody td { padding: 4px 2px; }
  .fac-lineas-tbl input { padding: 4px 5px; font-size: 11px; }
}

.fac-filtros {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.fac-filtros .ff-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.fac-filtros .ff-group label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}
.fac-filtros .ff-group input, .fac-filtros .ff-group select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  background: #fff;
}
.fac-filtros .ff-group input[type=date] { width: 130px; }
.fac-filtros .ff-group input[type=text] { width: 180px; }
.fac-filtros .ff-actions { margin-left: auto; display: flex; gap: 6px; }

.fac-registro-tbl {
  font-size: 12px;
  width: 100%;
  border-collapse: collapse;
}
.fac-registro-tbl thead th {
  padding: 7px 6px;
  background: var(--bg);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-bottom: 2px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
.fac-registro-tbl tbody td {
  padding: 6px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
  font-size: 11px;
}
.fac-registro-tbl tbody tr:hover { background: var(--bg); cursor: pointer; }
.fac-registro-tbl .num-col {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--accent);
}
.fac-registro-tbl .fecha-col {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  white-space: nowrap;
}
.fac-registro-tbl .imp-col {
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
  white-space: nowrap;
}
.fac-registro-tbl .imp-col.total { font-weight: 700; color: var(--ink); }
.fac-registro-tbl .estado-cell { white-space: nowrap; }
.fac-registro-tbl .tb-cell {
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}
.fac-registro-tbl .enviada-cell {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--ink-2);
  white-space: nowrap;
}
.fac-registro-tbl .enviada-cell .ev-hora { color: var(--muted); font-size: 9px; }

.fac-registro-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
  max-height: calc(100vh - 320px);
}
.fac-registro-wrap table { min-width: 1300px; }

.tb-icon-ok {
  display: inline-block;
  width: 14px; height: 14px;
  background: #1d8064;
  color: #fff;
  border-radius: 50%;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  margin-right: 4px;
}
.tb-icon-err {
  display: inline-block;
  width: 14px; height: 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  text-align: center;
  font-size: 10px;
  line-height: 14px;
  margin-right: 4px;
}
.tb-icon-pending {
  display: inline-block;
  width: 14px; height: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.fac-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--line);
  border-radius: 4px;
  background: #fff;
}
.fac-flag.checked {
  background: #1d8064;
  border-color: #1d8064;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.fac-flag.checked::before { content: '✓'; }

@media (max-width: 768px) {
  .fac-filtros { flex-direction: column; align-items: stretch; }
  .fac-filtros .ff-group input { width: 100% !important; }
  .fac-filtros .ff-actions { margin-left: 0; }
  .fac-registro-wrap { overflow-x: auto; }
}

.fac-envio-info {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
  border-left: 3px solid var(--brand-dark);
}
.fac-envio-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 4px 0;
}
.fac-envio-row .fer-label {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.fac-envio-row .fer-value {
  font-family: 'JetBrains Mono', monospace;
  color: var(--ink);
  font-weight: 600;
}
.fac-envio-row .fer-value.ok { color: #1d8064; }
.fac-envio-row .fer-value.err { color: var(--accent); }

.fac-subtabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  background: var(--bg-2);
  border-radius: 10px;
  border: 1px solid var(--line);
  width: fit-content;
}
.fac-subtab {
  background: transparent;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: all .15s;
}
.fac-subtab:hover { background: rgba(46,136,136,.08); color: var(--brand-dark); }
.fac-subtab.active {
  background: #fff;
  color: var(--brand-dark);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

@media (max-width: 768px) {
  .fac-subtabs { width: 100%; }
  .fac-subtab { flex: 1; padding: 8px 10px; font-size: 12px; }
}

.fac-emisor-block {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #fafdfd, var(--bg));
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 4px;
}
.fac-emisor-logo {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  overflow: hidden;
}
.fac-emisor-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.fac-emisor-datos { flex: 1; min-width: 0; }
.fac-emisor-name {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}
.fac-emisor-info {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 768px) {
  .fac-emisor-block { gap: 12px; padding: 10px 12px; }
  .fac-emisor-logo { width: 50px; height: 50px; }
  .fac-emisor-name { font-size: 14px; }
  .fac-emisor-info { font-size: 10px; }
}
