/* ==========================================================================
   Gestión de estudio — sistema de diseño (compartido por la app y /admin)
   Sin dependencias externas: CSS propio + íconos SVG inline + fuente del sistema.
   ========================================================================== */

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --hover: #f4f6f9;
  --border: #dfe3e8;
  --border-strong: #c5ccd6;
  --text: #1a2230;
  --text-2: #414b5b;
  --muted: #667085;

  --primary: #1f3a5f;
  --primary-hover: #172d4a;
  --primary-soft: #e8eef6;
  --on-primary: #ffffff;
  --nav-bg: #14233a;
  --nav-text: #b9c5d6;
  --nav-active: rgba(255, 255, 255, .11);

  --success: #1b6b45;
  --success-soft: #e6f2eb;
  --warning: #8a5a00;
  --warning-soft: #fbf1dc;
  --danger: #a4291f;
  --danger-soft: #fbeae8;
  --danger-solid: #b3261e;

  --ring: rgba(37, 99, 176, .45);
  --shadow-sm: 0 1px 1px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .2);
  --radius: 6px;
  --radius-lg: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d1219;
  --surface: #151b24;
  --surface-2: #1a212c;
  --hover: #1a212c;
  --border: #283241;
  --border-strong: #3a475c;
  --text: #e6eaf0;
  --text-2: #b4bfcd;
  --muted: #8b97a9;

  --primary: #4a7abf;
  --primary-hover: #5988cd;
  --primary-soft: #1b2a41;
  --nav-bg: #0a0f16;
  --nav-text: #a9b5c6;
  --nav-active: rgba(255, 255, 255, .09);

  --success: #5cc48c;
  --success-soft: #14291f;
  --warning: #e8b45c;
  --warning-soft: #2b2212;
  --danger: #f08279;
  --danger-soft: #341917;
  --danger-solid: #c8382e;

  --ring: rgba(120, 165, 245, .55);
  --shadow-sm: none;
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1219; --surface: #151b24; --surface-2: #1a212c; --hover: #1a212c; --border: #283241; --border-strong: #3a475c;
    --text: #e6eaf0; --text-2: #b4bfcd; --muted: #8b97a9;
    --primary: #4a7abf; --primary-hover: #5988cd; --primary-soft: #1b2a41;
    --nav-bg: #0a0f16; --nav-text: #a9b5c6; --nav-active: rgba(255, 255, 255, .09);
    --success: #5cc48c; --success-soft: #14291f; --warning: #e8b45c; --warning-soft: #2b2212;
    --danger: #f08279; --danger-soft: #341917; --danger-solid: #c8382e;
    --ring: rgba(120, 165, 245, .55); --shadow-sm: none; --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, dl, dd { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: var(--primary); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 34px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 550; font-size: 13px; line-height: 1; white-space: nowrap; transition: background-color .12s, border-color .12s;
}
.btn:disabled, .btn.loading { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-solid-danger { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-sm { min-height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-icon { width: 30px; min-height: 30px; padding: 0; }
.btn-block { width: 100%; }
@media (hover: hover) {
  .btn:not(:disabled):hover { background: var(--hover); border-color: var(--border-strong); }
  .btn-primary:not(:disabled):hover { background: var(--primary-hover); border-color: var(--primary-hover); }
  .btn-solid-danger:not(:disabled):hover { background: var(--danger-solid); filter: brightness(.92); }
  .btn-ghost:not(:disabled):hover { background: var(--primary-soft); }
  .btn-quiet-danger:not(:disabled):hover { background: var(--danger-soft); color: var(--danger); }
}
.btn.loading::after { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: giro .7s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 34px; padding: 6px 10px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); transition: border-color .12s, box-shadow .12s;
}
.textarea { resize: vertical; min-height: 72px; line-height: 1.45; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .75; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.select { appearance: none; padding-right: 30px; background-repeat: no-repeat; background-position: right 10px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23808a9b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { padding: 8px 10px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); font-size: 13px; font-weight: 500; border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
.form-ok { padding: 8px 10px; border-radius: var(--radius); background: var(--success-soft); color: var(--success); font-size: 13px; font-weight: 500; border: 1px solid color-mix(in srgb, var(--success) 25%, transparent); }
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; width: 16px; height: 16px; }
.search .input { padding-left: 32px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

/* ---------- Paneles, etiquetas, controles ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.panel-pad { padding: 20px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--border);
  font-size: 12px; font-weight: 550; line-height: 1.5; white-space: nowrap; background: var(--surface-2); color: var(--text-2);
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
:root[data-theme="dark"] .badge-info { color: #9dbbe6; }

.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { border: 0; background: transparent; color: var(--text-2); font-weight: 550; font-size: 12.5px; min-height: 28px; padding: 0 12px; border-radius: 4px; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 240px; max-width: 380px; }
.toolbar .count { margin-left: auto; font-size: 12.5px; color: var(--muted); }

.bar { display: block; width: 100%; height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--success); }

/* ---------- Estados ---------- */
.empty { text-align: center; padding: 36px 20px; color: var(--muted); font-size: 13.5px; }
.empty .icon { width: 26px; height: 26px; margin-bottom: 8px; color: var(--border-strong); stroke-width: 1.5; }
.empty strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 2px; }
.empty .btn { margin-top: 12px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: brillo 1.4s ease-in-out infinite; }
@keyframes brillo { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-row { height: 44px; border-bottom: 1px solid var(--border); }

/* ---------- Estructura de la app ---------- */
.app { display: none; min-height: 100vh; min-height: 100dvh; }
.app.on { display: block; }
.sidebar { display: none; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; height: 48px; padding: env(safe-area-inset-top) 14px 0; background: var(--nav-bg); color: #fff; }
.topbar strong { font-size: 14px; font-weight: 600; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; background: rgba(255, 255, 255, .14); color: #fff; flex: none; }
.brand-mark .icon { width: 16px; height: 16px; }
.main { padding: 16px 14px calc(76px + env(safe-area-inset-bottom)); max-width: 1680px; margin: 0 auto; }
.page { display: none; }
.page.on { display: block; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 19px; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
.page-head p { color: var(--muted); font-size: 13px; margin-top: 1px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); padding: 2px 2px calc(2px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 50px; border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 550; }
.tabbar button[aria-current="page"] { color: var(--primary); }
:root[data-theme="dark"] .tabbar button[aria-current="page"] { color: #fff; }

@media (min-width: 900px) {
  .app.on { display: grid; grid-template-columns: 220px minmax(0, 1fr); }
  .topbar, .tabbar { display: none; }
  .sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh; padding: 14px 10px; background: var(--nav-bg); color: var(--nav-text); }
  .main { padding: 24px 32px 40px; width: 100%; }
  .page-head h1 { font-size: 21px; }
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.side-brand strong { display: block; font-size: 14px; line-height: 1.2; font-weight: 600; }
.side-brand span { font-size: 11.5px; color: var(--nav-text); }
.side-nav { display: flex; flex-direction: column; gap: 1px; }
.side-nav button, .side-foot button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 0 10px; border: 0; border-radius: var(--radius); background: transparent; color: var(--nav-text); font-weight: 500; font-size: 13.5px; text-align: left; }
.side-nav button[aria-current="page"] { background: var(--nav-active); color: #fff; font-weight: 600; }
@media (hover: hover) { .side-nav button:hover, .side-foot button:hover { background: var(--nav-active); color: #fff; } }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 1px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .1); }
.user-chip { padding: 6px 10px 10px; min-width: 0; line-height: 1.3; }
.user-chip strong { display: block; font-size: 13px; color: #fff; font-weight: 600; }
.user-chip span { display: block; font-size: 12px; color: var(--nav-text); }

/* ---------- Indicadores (KPI) ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.kpi { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 16px; border: 0; border-left: 1px solid var(--border); background: transparent; text-align: left; min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi span { font-size: 12px; color: var(--muted); font-weight: 550; }
.kpi b { font-size: 22px; line-height: 1.2; font-weight: 650; letter-spacing: -.01em; }
.kpi.warn b { color: var(--warning); }
.kpi.ok b { color: var(--success); }
button.kpi { cursor: pointer; }
@media (hover: hover) { button.kpi:hover { background: var(--hover); } }
@media (max-width: 719px) {
  .kpi { padding: 10px 12px; } .kpi b { font-size: 19px; }
  .kpis-money { grid-template-columns: 1fr; }
  .kpis-money .kpi { flex-direction: row; align-items: center; justify-content: space-between; border-left: 0; border-top: 1px solid var(--border); }
  .kpis-money .kpi:first-child { border-top: 0; }
  .kpis-money .kpi b { font-size: 17px; }
}
.dash-grid { display: grid; gap: 14px; }
.dash-grid > * { min-width: 0; }
@media (min-width: 1100px) { .dash-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 10px; border-radius: var(--radius-lg); background: var(--warning-soft); border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent); }
.banner .actions { display: flex; gap: 6px; }
.notice { padding: 10px 12px; border-radius: var(--radius); background: var(--primary-soft); font-size: 13px; color: var(--text-2); }

/* ---------- Tablas de datos ---------- */
.dt { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.dt-h, .dt-r { display: grid; grid-template-columns: var(--cols); column-gap: 16px; align-items: center; padding: 0 16px; }
.dt-h { min-height: 34px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 650; color: var(--text-2); }
.dt-r { min-height: 44px; padding-top: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); min-width: 0; }
.dt > :last-child { border-bottom: 0; }
.dt-g { border-bottom: 1px solid var(--border); }
.dt-g > .dt-r, .dt-g > .dt-sub { border-bottom: 0; }
.dt-g > .dt-sub { border-top: 1px solid var(--border); }
.dt-r.click { cursor: pointer; }
@media (hover: hover) { .dt-r.click:hover { background: var(--hover); } }
.dt .r { text-align: right; }
.dt-r > * { min-width: 0; }
.t1 { font-weight: 600; line-height: 1.3; }
.t2 { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.due { font-weight: 600; color: var(--warning); font-size: 12.5px; }
.due.late { color: var(--danger); }
.dt-sub { padding: 0 16px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.dt-sub table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dt-sub th { text-align: left; font-size: 12px; font-weight: 650; color: var(--text-2); padding: 8px 8px 6px; }
.dt-sub td { padding: 6px 8px; border-top: 1px solid var(--border); }
.dt-sub .r { text-align: right; }
.m-only { display: none; }
.chev.open .icon { transform: rotate(90deg); }
.chev-sp { width: 30px; flex: none; }

/* Cada tabla pasa a filas apiladas segun SU ancho disponible (container query), no segun la ventana:
   con la barra lateral visible el area de contenido es mas angosta que el viewport.
   La clase dt-wN indica el ancho minimo (px) que necesitan sus columnas. */
.dt { container-type: inline-size; }
@container (max-width: 479px) {
  .dt-w480 .dt-h { display: none; }
  .dt-w480 .dt-r { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; padding: 10px 14px; }
  .dt-w480 .dt-r > .m-full { flex: 1 0 100%; }
  .dt-w480 .dt-r > [data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: 12px; }
  .dt-w480 .dt-r > .m-right { margin-left: auto; }
  .dt-w480 .r { text-align: left; }
  .dt-w480 .dt-sub { padding: 0 10px 8px; }
  .dt-w480 .chev-sp { display: none; }
  .dt-w480 .dt-sub th:nth-child(3), .dt-w480 .dt-sub td:nth-child(3) { display: none; }
  .dt-w480 .dt-sub td, .dt-w480 .dt-sub th { padding-left: 4px; padding-right: 4px; }
  .dt-w480 .m-only { display: inline; }
}
@container (max-width: 619px) {
  .dt-w620 .dt-h { display: none; }
  .dt-w620 .dt-r { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; padding: 10px 14px; }
  .dt-w620 .dt-r > .m-full { flex: 1 0 100%; }
  .dt-w620 .dt-r > [data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: 12px; }
  .dt-w620 .dt-r > .m-right { margin-left: auto; }
  .dt-w620 .r { text-align: left; }
  .dt-w620 .dt-sub { padding: 0 10px 8px; }
  .dt-w620 .chev-sp { display: none; }
  .dt-w620 .dt-sub th:nth-child(3), .dt-w620 .dt-sub td:nth-child(3) { display: none; }
  .dt-w620 .dt-sub td, .dt-w620 .dt-sub th { padding-left: 4px; padding-right: 4px; }
  .dt-w620 .m-only { display: inline; }
}
@container (max-width: 879px) {
  .dt-w880 .dt-h { display: none; }
  .dt-w880 .dt-r { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; padding: 10px 14px; }
  .dt-w880 .dt-r > .m-full { flex: 1 0 100%; }
  .dt-w880 .dt-r > [data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: 12px; }
  .dt-w880 .dt-r > .m-right { margin-left: auto; }
  .dt-w880 .r { text-align: left; }
  .dt-w880 .dt-sub { padding: 0 10px 8px; }
  .dt-w880 .chev-sp { display: none; }
  .dt-w880 .dt-sub th:nth-child(3), .dt-w880 .dt-sub td:nth-child(3) { display: none; }
  .dt-w880 .dt-sub td, .dt-w880 .dt-sub th { padding-left: 4px; padding-right: 4px; }
  .dt-w880 .m-only { display: inline; }
}
@container (max-width: 959px) {
  .dt-w960 .dt-h { display: none; }
  .dt-w960 .dt-r { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; padding: 10px 14px; }
  .dt-w960 .dt-r > .m-full { flex: 1 0 100%; }
  .dt-w960 .dt-r > [data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: 12px; }
  .dt-w960 .dt-r > .m-right { margin-left: auto; }
  .dt-w960 .r { text-align: left; }
  .dt-w960 .dt-sub { padding: 0 10px 8px; }
  .dt-w960 .chev-sp { display: none; }
  .dt-w960 .dt-sub th:nth-child(3), .dt-w960 .dt-sub td:nth-child(3) { display: none; }
  .dt-w960 .dt-sub td, .dt-w960 .dt-sub th { padding-left: 4px; padding-right: 4px; }
  .dt-w960 .m-only { display: inline; }
}

/* ---------- Audiencias + calendario interno ---------- */
.aud-layout { display: grid; gap: 14px; }
.aud-layout > * { min-width: 0; }
.cal-wrap { max-width: 440px; }
@media (min-width: 1180px) { .aud-layout { grid-template-columns: 300px minmax(0, 1fr); align-items: start; } .cal-wrap { position: sticky; top: 24px; max-width: none; } }
.cal { padding: 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.cal-head h2 { font-size: 14px; font-weight: 650; }
.cal-nav { display: flex; gap: 2px; align-items: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.cal-dow { text-align: center; font-size: 11.5px; font-weight: 650; color: var(--muted); padding: 4px 0; }
.cal-day { position: relative; min-height: 38px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 1px solid transparent; background: transparent; border-radius: var(--radius); font-size: 13px; font-weight: 500; color: var(--text); }
.cal-day.out { color: var(--muted); opacity: .5; }
.cal-day.today { border-color: var(--primary); font-weight: 700; }
.cal-day[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
@media (hover: hover) { .cal-day:not([aria-pressed="true"]):hover { background: var(--hover); border-color: var(--border); } }
.dots { display: flex; gap: 2px; height: 4px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--primary); }
.dots i.v { background: var(--warning); }
:root[data-theme="dark"] .dots i { background: #8fb0e0; }
.cal-day[aria-pressed="true"] .dots i { background: var(--on-primary); }
.cal-legend { display: flex; gap: 14px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend i { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.cal-legend i.v { background: var(--warning); }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; min-height: 30px; margin-bottom: 8px; }
.list-head h2 { font-size: 14px; font-weight: 650; }
.dt-r.past { opacity: .6; }

/* ---------- Modal (hoja inferior en celular) ---------- */
.modal-back { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(10, 15, 24, .5); }
.modal { width: 100%; max-width: 520px; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; background: var(--surface); border-radius: 12px 12px 0 0; box-shadow: var(--shadow-lg); animation: sube .16s ease-out; }
.modal.lg { max-width: 780px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; font-weight: 650; line-height: 1.3; }
.modal-head p { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.modal-body { padding: 16px 20px 20px; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) {
  .modal-back { align-items: center; padding: 24px; }
  .modal { border-radius: var(--radius-lg); }
  .modal-body { padding-bottom: 20px; }
}
@keyframes sube { from { transform: translateY(16px); opacity: .6; } to { transform: none; opacity: 1; } }
body.sin-scroll { overflow: hidden; }
.split { display: grid; gap: 20px; }
@media (min-width: 720px) { .split { grid-template-columns: 1fr 1fr; } }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.kv dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.kv dd { margin-top: 1px; font-weight: 500; overflow-wrap: anywhere; }
.kv .full { grid-column: 1 / -1; }
.sep { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.section-title { font-size: 12px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.tarea { display: flex; align-items: flex-start; gap: 9px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.tarea.hecha { opacity: .55; }
.tarea.hecha .tt { text-decoration: line-through; }
.check { flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 4px; border: 1.5px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; color: #fff; padding: 0; }
.check.on { background: var(--success); border-color: var(--success); }
.check .icon { width: 12px; height: 12px; stroke-width: 3; }
.inline-form { display: flex; gap: 6px; }
.inline-form .input { flex: 1; }

/* ---------- Diálogo nativo (admin) ---------- */
dialog.dlg { border: 0; border-radius: var(--radius-lg); padding: 0; width: calc(100% - 32px); max-width: 440px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog.dlg::backdrop { background: rgba(10, 15, 24, .5); }
dialog.dlg form { padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 14px; }
dialog.dlg h2 { font-size: 16px; font-weight: 650; }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(66px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; width: min(92vw, 400px); pointer-events: none; }
@media (min-width: 900px) { .toasts { bottom: 20px; } }
.toast { pointer-events: auto; padding: 10px 14px; border-radius: var(--radius); background: #1c2735; color: #fff; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); animation: sube .16s ease-out; }
.toast.error { background: #a4291f; }
.toast.ok { background: #1b6b45; }

/* ---------- Login (pantalla dividida) ---------- */
.login { display: none; min-height: 100vh; min-height: 100dvh; background: var(--surface); }
.login.on { display: grid; grid-template-columns: 11fr 9fr; }
.login-side {
  --oro: #c9a25e;
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  padding: 40px 56px; background: var(--nav-bg); color: #a9b8cd;
}
.login-side > * { position: relative; }
.login-deco { position: absolute; right: -150px; bottom: -150px; width: 480px; height: 480px; color: #fff; opacity: .06; pointer-events: none; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand .brand-mark { width: 34px; height: 34px; }
.login-brand strong { display: block; color: #fff; font-size: 16px; font-weight: 650; letter-spacing: .01em; line-height: 1.2; }
.login-tag { display: none; font-size: 12.5px; color: #9fb0c7; }
.gold-rule { display: block; width: 44px; height: 2px; margin-bottom: 20px; background: var(--oro); }
.login-pitch h2 { max-width: 460px; color: #fff; font-size: clamp(26px, 2.5vw, 35px); font-weight: 650; line-height: 1.2; letter-spacing: -.015em; }
.login-pitch > p { max-width: 440px; margin-top: 14px; font-size: 15px; line-height: 1.55; color: #9fb0c7; }
.login-features { list-style: none; margin: 32px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 18px 28px; max-width: 520px; }
.login-features li { display: flex; align-items: flex-start; gap: 12px; }
.login-features .fi { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border: 1px solid rgba(201, 162, 94, .4); border-radius: 6px; color: var(--oro); }
.login-features b { display: block; color: #fff; font-size: 14px; font-weight: 600; line-height: 1.3; }
.login-features div > span { display: block; margin-top: 1px; font-size: 13px; color: #8497b1; }
.login-foot { font-size: 12.5px; color: #7488a4; }
.login-main { display: flex; align-items: center; justify-content: center; padding: 40px 32px; background: var(--surface); }
.login-card { width: 100%; max-width: 400px; }
.login-card h1 { font-size: 24px; font-weight: 650; letter-spacing: -.015em; line-height: 1.25; }
.login-sub { margin-top: 6px; color: var(--muted); font-size: 14px; }
.login-card form { display: flex; flex-direction: column; gap: 18px; margin-top: 28px; }
.login-note { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.input-lg { min-height: 42px; font-size: 14.5px; }
.btn-lg { min-height: 44px; font-size: 14px; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 28%, transparent); }
.field-error { font-size: 12.5px; color: var(--danger); font-weight: 500; }
.pw { position: relative; }
.pw .input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: var(--radius); background: transparent; color: var(--muted); }
@media (hover: hover) { .pw-toggle:hover { background: var(--hover); color: var(--text); } }
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent); }
.alert .icon { margin-top: 1px; }
.alert strong { display: block; font-size: 13.5px; font-weight: 650; line-height: 1.35; }
.alert span { display: block; margin-top: 1px; font-size: 13px; line-height: 1.45; color: var(--text-2); }
.alert-warn { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
@media (max-width: 1100px) {
  .login-side { padding: 32px 36px; }
  .login-features { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 899px) {
  .login.on { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-side { padding: 16px 20px; gap: 0; }
  .login-pitch, .login-foot, .login-deco { display: none; }
  .login-tag { display: block; margin-top: 1px; }
  .login-main { align-items: flex-start; padding: 28px 20px 40px; }
  .login-card h1 { font-size: 22px; }
  .input-lg { min-height: 46px; }
  .btn-lg { min-height: 48px; }
  .pw-toggle { width: 38px; height: 38px; }
}

/* ---------- Administración ---------- */
.admin-bar { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 20px; background: var(--nav-bg); color: #fff; }
.admin-bar .grow { flex: 1; display: flex; align-items: center; gap: 10px; }
.admin-bar strong { font-size: 14px; font-weight: 600; }
.admin-bar .sub { font-size: 12.5px; color: var(--nav-text); border-left: 1px solid rgba(255, 255, 255, .2); padding-left: 10px; }
.admin-bar a, .admin-bar button { color: var(--nav-text); font-size: 13px; text-decoration: none; background: none; border: 0; padding: 6px 8px; border-radius: var(--radius); display: inline-flex; align-items: center; gap: 6px; }
@media (hover: hover) { .admin-bar a:hover, .admin-bar button:hover { background: var(--nav-active); color: #fff; } }
.admin-main { max-width: 1080px; margin: 0 auto; padding: 20px 20px 48px; }
.gate { max-width: 400px; margin: 56px auto 0; }
.gate h1 { font-size: 16px; font-weight: 650; margin-bottom: 4px; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.row-actions .btn-quiet-danger { color: var(--muted); }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 650; font-size: 11.5px; flex: none; }
:root[data-theme="dark"] .avatar { color: #cfe0f7; }

@media (max-width: 899px) {
  .input, .select, .textarea { font-size: 16px; min-height: 40px; }
  .btn { min-height: 38px; }
  .btn-sm { min-height: 32px; }
  .btn-icon { width: 36px; min-height: 36px; }
  .form-row { grid-template-columns: 1fr; }
  .form-row.keep { grid-template-columns: 1fr 1fr; }
  .admin-bar { padding: 0 12px; }
  .admin-bar .sub { display: none; }
  .admin-main { padding: 14px 12px 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
