:root {
  --blue: #2563d8;
  --blue-dark: #1b4fb4;
  --blue-soft: #e8f0fe;
  --sky: #eaf3ff;
  --navy: #14233f;
  --navy-2: #1d3157;
  --ink: #1c2a44;
  --muted: #6a7790;
  --line: #e1e8f3;
  --bg: #f1f6fd;
  --card: #ffffff;
  --ok: #167a4a;
  --ok-bg: #dff5e8;
  --warn-bg: #fff1d6;
  --danger: #c53030;
  --danger-bg: #fde4e4;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.45; }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
a { color: var(--blue); }
.icon { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.center { text-align: center; }
:focus-visible { outline: 3px solid #86b2ff; outline-offset: 2px; }

/* Estructura */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: none; background: var(--navy); color: #fff; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: block; text-decoration: none; padding: 4px 8px 18px; color: #fff; }
.brand img { max-width: 100%; max-height: 56px; display: block; }
.brand-name { display: block; font-size: 1.3rem; font-weight: 800; letter-spacing: -.01em; color: #fff; }
.brand-sub { display: block; font-size: .8rem; color: #9fb4d8; }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #d6e0f3; text-decoration: none; font-weight: 500; }
.nav-link:hover { background: var(--navy-2); color: #fff; }
.nav-link.is-active { background: var(--blue); color: #fff; }
.nav-link.is-soon { color: #8b9dc1; }
.soon-tag { margin-left: auto; font-size: .68rem; background: var(--navy-2); color: #9fb4d8; padding: 2px 7px; border-radius: 99px; }
.sidebar-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--navy-2); }
.sidebar-user .who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sidebar-user strong { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user span { font-size: .75rem; color: #9fb4d8; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--blue-soft); color: var(--blue-dark); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.avatar-img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-lg { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; display: block; margin-bottom: 8px; }
.icon-btn { background: transparent; border: 0; color: inherit; cursor: pointer; padding: 8px; border-radius: 8px; display: inline-flex; }
.icon-btn:hover { background: rgba(255,255,255,.12); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar-title { font-weight: 700; }
.topbar-date { margin-left: auto; color: var(--muted); font-size: .9rem; }
.menu-btn { display: none; color: var(--ink); }
.menu-btn:hover { background: var(--sky); }
.content { padding: 24px; max-width: 1180px; width: 100%; }
.scrim { position: fixed; inset: 0; background: rgba(10,20,40,.45); z-index: 20; }

/* Componentes */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.empty { text-align: center; padding: 36px 20px; }
.empty p { margin: 0 0 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { margin: 0; display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-size: 2rem; font-weight: 800; color: var(--blue); line-height: 1; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.link-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); margin: 0; }
.link-card .icon { color: var(--blue); width: 26px; height: 26px; }
a.link-card:hover { border-color: #b8cdf5; background: var(--sky); }
.link-card.is-off { opacity: .6; }
.quick { display: flex; flex-wrap: wrap; gap: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; background: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: var(--blue-soft); color: var(--blue-dark); }
.btn-secondary:hover { background: #d6e5fd; }
.btn-ghost { color: var(--blue-dark); padding: 7px 10px; }
.btn-ghost:hover { background: var(--sky); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-disabled { background: #eef1f6; color: #98a3b8; cursor: not-allowed; }
.btn-block { width: 100%; }
.text-danger { color: var(--danger); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-off { background: #eceff5; color: #5b6880; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; margin: 2px 4px 2px 0; color: var(--ink); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; border: 1px solid rgba(0,0,0,.12); }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-info { background: var(--blue-soft); color: var(--blue-dark); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .right { text-align: right; }
.is-inactive td { opacity: .6; }
.actions { white-space: nowrap; }
.actions form { display: inline; }
.person { display: flex; align-items: center; gap: 12px; }

.rowlist { list-style: none; margin: 0; padding: 0; }
.rowlist li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rowlist li:last-child { border-bottom: 0; }
.grow { flex: 1; min-width: 0; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { padding: 8px 16px; border-radius: 99px; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); font-weight: 600; font-size: .92rem; }
.tab:hover { background: var(--sky); }
.tab.is-active { background: var(--blue); border-color: var(--blue); color: #fff; }
.tab-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #f2b134; margin-left: 6px; }

/* Formularios */
.form fieldset { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.form legend { font-weight: 700; padding: 0; margin-bottom: 12px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=time], input[type=file], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #c9d5e8; border-radius: 10px; padding: 9px 12px;
}
input[type=color] { width: 64px; height: 40px; padding: 2px; border: 1px solid #c9d5e8; border-radius: 10px; background: #fff; }
input:disabled { background: #f1f4f9; color: #8793a8; }
textarea { resize: vertical; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.error { color: var(--danger); font-size: .85rem; margin: 5px 0 0; }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.span-all { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
[hidden] { display: none !important; }

.sched { display: grid; gap: 8px; margin-bottom: 8px; }
.sched-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 90px; align-items: center; gap: 12px; padding: 10px 12px; background: var(--sky); border-radius: 10px; }
.sched-row.has-error { outline: 2px solid var(--danger); }
.sched-times { display: flex; align-items: center; gap: 8px; max-width: 320px; }
.sched-times input { min-width: 0; }

/* Acceso */
body.guest { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: linear-gradient(160deg, #eaf3ff, #f7fbff 60%); }
.guest-box { width: 100%; max-width: 400px; }
.guest-brand { text-align: center; margin-bottom: 18px; }
.guest-brand img { max-width: 220px; max-height: 80px; }
.guest-brand .brand-name { color: var(--blue); font-size: 1.9rem; }
.guest-brand .brand-sub { color: var(--muted); }
.guest-card h1 { margin-bottom: 14px; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.is-open { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 10px 14px; }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
  .sched-row { grid-template-columns: 1fr; gap: 6px; }
  .topbar-date { display: none; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Fase 2 */
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 14px 20px; }
.filters .field { margin-bottom: 0; }
.filters input[type=search] { width: 100%; font: inherit; border: 1px solid #c9d5e8; border-radius: 10px; padding: 9px 12px; }
.chip-child { background: var(--blue-soft); }
.chip.is-off { opacity: .55; text-decoration: line-through; }
.badge-warn { background: var(--warn-bg); color: #8a5a00; }
.child-row { border: 1px solid var(--line); background: var(--sky); border-radius: 12px; padding: 12px 14px 2px; margin-bottom: 12px; }
.child-row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dl { display: grid; grid-template-columns: 210px 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); font-weight: 600; font-size: .9rem; }
.dl dd { margin: 0; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-head .actions form { display: inline; }
input[type=tel] { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #c9d5e8; border-radius: 10px; padding: 9px 12px; }
@media (max-width: 600px) { .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 10px; } }

/* Fase 3: calendario */
.cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
.seg { display: inline-flex; background: var(--blue-soft); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-wide { margin-bottom: 14px; }
.seg-item { padding: 7px 18px; border-radius: 8px; text-decoration: none; color: var(--blue-dark); font-weight: 600; font-size: .92rem; }
.seg-item.is-active { background: var(--blue); color: #fff; }
.seg-item.is-off { color: #8a98b3; cursor: not-allowed; }
.cal-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; margin: 0 0 12px; align-items: center; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: 4px; border: 2px solid transparent; background: #dbe7fb; }
.lg-reagendada { border: 2px dashed #e0a21b; }
.lg-no_asistio { border-color: var(--danger); }
.lg-cancelada { background: #e5e8ee; border-color: #aab2c2; }
.lg-free { background: #fff; border: 1px dashed #8fb1ee; }
.cal-wrap { padding: 0; overflow-x: auto; }
.cal { width: 100%; border-collapse: collapse; min-width: 720px; table-layout: fixed; }
.cal th, .cal td { border: 1px solid var(--line); vertical-align: top; padding: 6px; }
.cal thead th { background: #f7faff; font-size: .88rem; position: sticky; top: 0; }
.cal thead th a { text-decoration: none; color: var(--ink); }
.cal th.is-today { background: var(--blue-soft); }
.cal .cal-time { width: 86px; font-size: .78rem; color: var(--muted); text-align: right; background: #fbfdff; font-weight: 600; }
.cal td { height: 74px; }
.sess { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; border-radius: 10px; margin-bottom: 4px; text-decoration: none; color: var(--ink); font-size: .8rem; border-left: 4px solid rgba(0,0,0,.18); line-height: 1.25; }
a.sess:hover { filter: brightness(.96); }
.sess strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess-meta { font-size: .74rem; opacity: .85; }
.sess-tag { font-style: normal; font-weight: 700; }
.sess.st-reagendada { border-left-color: #e0a21b; outline: 1px dashed #e0a21b; }
.sess.st-no_asistio { border-left-color: var(--danger); }
.sess.st-cancelada { opacity: .55; border-left-color: #8a94a8; text-decoration: line-through; filter: grayscale(.6); }
.free, .slot { display: block; text-align: center; padding: 8px 4px; border-radius: 10px; font-size: .78rem; text-decoration: none; }
.free { border: 1px dashed #b5cdf5; color: #5b83c9; background: #fbfdff; }
a.free:hover, a.slot-free:hover { background: var(--blue-soft); border-color: var(--blue); }
.slot-free { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.slot-busy { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.avail td { height: 52px; }
.cal-month td { height: 118px; position: relative; }
.cal-month td.is-out { background: #f6f8fc; }
.cal-month td.is-out .mday { color: #a7b0c4; }
.cal-month td.is-today { background: var(--blue-soft); }
.mday { font-weight: 700; text-decoration: none; color: var(--ink); display: block; margin-bottom: 3px; }
.mrow { display: block; font-size: .76rem; padding: 1px 0; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow.st-cancelada { text-decoration: line-through; opacity: .55; }
.mrow .dot { width: 8px; height: 8px; margin-right: 4px; }
.more { font-size: .74rem; }
.mcount { position: absolute; top: 6px; right: 8px; font-size: .68rem; color: var(--muted); }
.miss-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.miss-card { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: #fff; border: 2px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.miss-card:hover { border-color: #b8cdf5; }
.miss-card.is-active { border-color: var(--blue); background: var(--sky); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.stat-link { text-decoration: none; color: inherit; }
a.stat-link:hover { border-color: #b8cdf5; background: var(--sky); }
.slot-picker { margin: 4px 0 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; color: var(--muted); font-size: .88rem; }
.chip-btn { border: 1px solid #b5cdf5; background: #fff; color: var(--blue-dark); border-radius: 99px; padding: 6px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.chip-btn:hover { background: var(--blue-soft); }
.chip-btn.is-selected { background: var(--blue); border-color: var(--blue); color: #fff; }
.exception { background: var(--sky); border-radius: 10px; padding: 10px 14px; margin-top: 8px; }
.exception summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.cancel-form { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.inline { display: flex; gap: 10px; flex-wrap: wrap; }
.inline input { flex: 1; min-width: 220px; }
.st-badge { background: var(--blue-soft); color: var(--blue-dark); }
.st-badge.st-reagendada { background: var(--warn-bg); color: #8a5a00; }
.st-badge.st-no_asistio { background: var(--danger-bg); color: var(--danger); }
.st-badge.st-cancelada { background: #eceff5; color: #5b6880; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* Fase 4: paquetes */
.bar { height: 8px; border-radius: 99px; background: #e3ebf8; overflow: hidden; margin-bottom: 3px; }
.bar i { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.pk-activo { background: var(--ok-bg); color: var(--ok); }
.pk-pendiente { background: var(--warn-bg); color: #8a5a00; }
.pk-vencido { background: var(--danger-bg); color: var(--danger); }
.pk-agotado { background: var(--blue-soft); color: var(--blue-dark); }
.pk-anulado { background: #eceff5; color: #5b6880; }
.table-rows input, .table-rows select { padding: 6px 8px; font-size: .9rem; min-width: 118px; }
.table-rows td { vertical-align: middle; }
.row-bad td { background: #fff6f6; }
.static { margin: 0; padding: 9px 0; font-weight: 600; }
.radio-row { display: flex; margin-bottom: 8px; align-items: flex-start; }
.days { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }

/* Fase 5 */
.slot-absent { background: #eceff5; color: #5b6880; font-weight: 600; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding-top: 12px; }
.resolve .inline { align-items: center; }
.resolve .inline input { min-width: 130px; }

/* Fase 6: pagos */
.fs-pagado { background: var(--ok-bg); color: var(--ok); }
.fs-parcial { background: var(--warn-bg); color: #8a5a00; }
.fs-pendiente { background: var(--blue-soft); color: var(--blue-dark); }
.fs-vencido { background: var(--danger-bg); color: var(--danger); }
.fs-anulado { background: #eceff5; color: #5b6880; }
.fin-ok { color: var(--ok); }
.fin-warn { color: #b26a00; }
.fin-bad { color: var(--danger); }
.stat-num.fin-ok, .stat-num.fin-warn { font-size: 1.6rem; }
.two-col.wide-left { grid-template-columns: 2fr 1fr; }
.receipt-title { font-weight: 800; color: var(--blue-dark); margin-bottom: 14px; }
@media (max-width: 900px) { .two-col.wide-left { grid-template-columns: 1fr; } }
@media print {
  .sidebar, .topbar, .scrim, .no-print, .page-head .actions, .alert { display: none !important; }
  body { background: #fff; }
  .shell, .main, .content { display: block; padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
}

.receipt-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-weight: 700; color: var(--blue-dark); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.receipt-head span { font-weight: 600; color: var(--muted); }

/* Fase 7: talleres */
.sess.st-taller { border-left-color: #d9a400; }
.mrow.st-taller { font-weight: 600; }
.lg-taller { background: #fdf1b8; border-color: #d9a400; }
.slot-group { background: #fdf1b8; color: #7a5a00; font-weight: 600; }
a.slot-group:hover { filter: brightness(.96); }

/* Fase 8: WhatsApp y respaldos */
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.chip-stat { text-decoration: none; padding: 4px 12px; border-radius: 99px; font-size: .85rem; font-weight: 600; background: #eceff5; color: #44526b; }
.chip-stat strong { margin-left: 4px; }
.wa-pendiente, .wa-enviando { background: var(--warn-bg); color: #8a5a00; }
.wa-enviado { background: var(--blue-soft); color: var(--blue-dark); }
.wa-entregado { background: #d6f0e0; color: var(--ok); }
.wa-leido { background: var(--ok-bg); color: var(--ok); }
.wa-fallido { background: var(--danger-bg); color: var(--danger); }
.msg summary { cursor: pointer; }
.msg-body { margin-top: 6px; padding: 8px 10px; background: var(--sky); border-radius: 8px; font-size: .85rem; max-width: 420px; }
.event-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.event-row:last-child { border-bottom: 0; }
.event-row.has-error textarea, .event-row.has-error input[type=text] { border-color: var(--danger); }
.meta-text { background: #f4f7fc; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: .82rem; white-space: pre-wrap; overflow-x: auto; }
code { background: #eef2f9; padding: 1px 6px; border-radius: 5px; font-size: .88em; }

/* ===== Mejoras de uso y responsive ===== */

/* Menú lateral: arriba (logo) y abajo (usuario) fijos; la lista se desplaza si no cabe (pantallas de 13–14") */
.sidebar { height: 100vh; height: 100dvh; overflow: hidden; }
.brand, .sidebar-user { flex: none; }
.sidebar nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin-right: -6px; padding-right: 6px; scrollbar-width: thin; scrollbar-color: #3d5586 transparent; }
.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-thumb { background: #3d5586; border-radius: 6px; }
.sidebar-user { margin-top: 8px; }
@media (max-height: 860px) {
  .sidebar { padding-top: 12px; padding-bottom: 10px; }
  .brand { padding-bottom: 10px; }
  .nav { gap: 2px; }
  .nav-link { padding: 8px 12px; }
}
@media (max-height: 680px) {
  .brand-sub { display: none; }
  .nav-link { padding: 6px 10px; font-size: .92rem; }
}

/* Horarios por fila en paquetes */
.row-time-label { font-weight: 700; margin-bottom: 6px; color: var(--blue-dark); }
.table-rows .chips { gap: 6px; }
.table-rows .chip-btn { padding: 5px 11px; font-size: .86rem; }

/* Arrastrar sesiones */
[data-drag] { cursor: grab; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.is-dragging { opacity: .35; }
.drag-ghost { position: fixed; z-index: 150; pointer-events: none; margin: 0; box-shadow: 0 10px 28px rgba(20, 35, 63, .3); transform: rotate(1.5deg); opacity: .96; }
body.is-dragging-session { -webkit-user-select: none; user-select: none; cursor: grabbing; }
td.drop-hover { outline: 2px dashed var(--blue); outline-offset: -3px; background: var(--blue-soft); }
.drag-hint { margin: -4px 0 12px; }
.hint-list { margin: 10px 0 16px; padding-left: 20px; color: var(--muted); font-size: .92rem; }
.hint-list li { margin-bottom: 4px; }

/* Ventana de confirmación */
.modal-back { position: fixed; inset: 0; background: rgba(10, 20, 40, .5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 14px; padding: 20px; width: min(460px, 100%); max-height: 90vh; max-height: 90dvh; overflow: auto; box-shadow: 0 18px 50px rgba(10, 20, 40, .35); }
.modal h2 { margin-bottom: 8px; }
.modal p { margin: 6px 0; }
.modal label { display: block; font-weight: 600; font-size: .9rem; margin-top: 10px; }
.modal input { margin-top: 5px; }
.modal-change { white-space: pre-line; background: var(--sky); border-radius: 10px; padding: 10px 12px; }
.modal-link { display: inline-block; margin-top: 6px; font-size: .9rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

/* Calendario: columna de horas fija al desplazar de lado */
.cal .cal-time { position: sticky; left: 0; z-index: 2; }
.cal thead th.cal-time { z-index: 4; }
.cal td { min-width: 112px; }

/* ---- Tabletas y celulares ---- */
@media (max-width: 900px) {
  .sidebar { width: min(290px, 86vw); }
  .page-head { gap: 10px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  input, select, textarea { font-size: 16px; }  /* evita el acercamiento automático de iOS al enfocar */
  .btn { min-height: 42px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters .field { flex: 1 1 auto; width: 100%; }
  .filters .btn { width: 100%; }
  .cal-bar { flex-direction: column; align-items: stretch; }
  .cal-nav { justify-content: space-between; }
  .cal-nav strong { flex: 1; text-align: center; }
  .seg { width: 100%; }
  .seg-item { flex: 1; text-align: center; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; }
  .chip-btn { padding: 9px 16px; }
}

@media (max-width: 700px) {
  .content { padding: 12px; }
  .card { padding: 14px; border-radius: 12px; }
  .rowlist li { flex-wrap: wrap; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-num { font-size: 1.5rem; }
  .cal { min-width: 620px; }
  .cal td { min-width: 104px; padding: 4px; }
  .sess { font-size: .76rem; }

  /* Tablas como tarjetas */
  .card:has(> .table-wrap) { background: transparent; border: 0; padding: 0; }
  .table-wrap { overflow: visible; }
  .table { min-width: 0; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; margin-bottom: 10px; }
  .table td { position: relative; border: 0; padding: 8px 0 8px 40%; min-height: 1.5em; text-align: left; }
  .table td::before { content: attr(data-label); position: absolute; left: 0; top: 8px; width: 36%; font-weight: 600; font-size: .8rem; color: var(--muted); line-height: 1.5; }
  .table td[data-label=""]::before { content: none; }
  .table td:first-child { padding: 10px 0; font-size: 1.02rem; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
  .table td:first-child::before { content: none; }
  .table td.right, .table td.actions { padding: 8px 0; white-space: normal; display: flex; flex-wrap: wrap; gap: 4px 8px; justify-content: flex-end; }
  .table td.right::before, .table td.actions::before { content: none; }
  .table td.actions form { display: inline; }
  .table-rows input, .table-rows select { width: 100%; min-width: 0; }
  .table-rows td.cell-time { padding-left: 0; min-width: 0; }
  .table-rows td.cell-time::before { position: static; display: block; width: auto; margin-bottom: 6px; }
  .table .person { text-align: left; }
  .is-inactive { opacity: .6; }
}

/* Paquetes: la columna de horas debe permitir varios botones por línea */
.table-rows td.cell-time { min-width: 340px; }
.table-rows .check { white-space: nowrap; }
@media (max-width: 700px) { .table-rows td.cell-time { min-width: 0; } }
.table-rows input[type=checkbox] { min-width: 0; width: 18px; padding: 0; }

/* Paquetes (confirmar / programar pendientes): en tabletas y portátiles (hasta 1400 px) cada fila pasa a tarjeta de 2 columnas */
@media (max-width: 1400px) {
  .card:has(> .table-wrap > .table-rows) { background: transparent; border: 0; padding: 0; }
  .table-rows thead { display: none; }
  .table-rows, .table-rows tbody { display: block; width: 100%; min-width: 0; }
  .table-rows tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; align-items: start; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; }
  .table-rows td { display: block; position: static; width: auto; min-width: 0; padding: 4px 0; border: 0; order: 5; text-align: left; }
  .table-rows td::before { content: attr(data-label); position: static; display: block; width: auto; margin-bottom: 4px; font-weight: 600; font-size: .78rem; color: var(--muted); }
  .table-rows td[data-label=""]::before { content: none; }
  .table-rows td:nth-child(1) { grid-column: 1 / -1; order: 1; font-size: 1.02rem; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .table-rows td:nth-child(1)::before { content: none; }
  .table-rows td:nth-child(2) { order: 2; }
  .table-rows td:nth-child(4) { order: 3; }
  .table-rows td.cell-time { grid-column: 1 / -1; order: 4; padding-left: 0; min-width: 0; }
  .table-rows input[type=date], .table-rows select { width: 100%; min-width: 0; }
}
@media (max-width: 700px) {
  .table-rows tr { grid-template-columns: 1fr; }
  .table-rows td:nth-child(n) { grid-column: 1 / -1; }
}

/* Paquete: horarios libres solo en parte de las fechas; vista Mes con arrastre */
.chip-btn.chip-partial { border-style: dashed; }
.modal-sub { margin: 10px 0 4px; font-weight: 600; font-size: .9rem; }
.modal .chips { margin-top: 4px; }
.mrow[data-drag] { cursor: grab; }
.drag-ghost.mrow { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: .8rem; }
