/* =======================================================
   SISTEMA INTERNO DFS · Hoja de estilos única
   Colores institucionales: burdeo (#7d002d) y dorado (#c6a15b)
   Tipografías: Poppins (títulos) + Inter (texto)
======================================================= */

/* ---------- 1. Variables ---------- */

:root {
  --vino: #7d002d;
  --vino-oscuro: #56001f;
  --vino-claro: #a42456;
  --vino-suave: #f6e9ee;
  --vino-tenue: #fbf4f7;
  --dorado: #c6a15b;
  --dorado-oscuro: #9c7a34;
  --dorado-suave: #f6efdf;

  --bg: #f7f4f2;
  --surface: #ffffff;
  --surface-2: #faf7f8;
  --surface-3: #f3edf0;
  --text: #1f2937;
  --text-strong: #111827;
  --muted: #5b6470;
  --subtle: #8a8f98;
  --border: #ece4e7;
  --border-strong: #dccfd5;
  --ring: rgba(125, 0, 45, .28);

  --primary: var(--vino);
  --primary-hover: var(--vino-oscuro);
  --primary-text: #ffffff;
  --accent: var(--dorado);
  --heading: var(--vino-oscuro);

  --ok: #15803d;      --ok-bg: #dcfce7;
  --warn: #a16207;    --warn-bg: #fef3c7;
  --danger: #b91c1c;  --danger-bg: #fee2e2;
  --info: #1d4ed8;    --info-bg: #dbeafe;
  --violet: #6d28d9;  --violet-bg: #ede9fe;

  --sidebar-bg: #4a001b;
  --sidebar-bg-2: #2e0011;
  --sidebar-text: #f6d7e2;
  --sidebar-muted: #c89aab;

  --shadow-sm: 0 1px 2px rgba(64, 22, 40, .06);
  --shadow: 0 10px 30px rgba(64, 22, 40, .07);
  --shadow-lg: 0 24px 60px rgba(64, 22, 40, .16);

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Poppins', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar-w: 268px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14090e;
    --surface: #1e1116;
    --surface-2: #24151b;
    --surface-3: #2d1b22;
    --text: #ece4e7;
    --text-strong: #ffffff;
    --muted: #b6a8ae;
    --subtle: #8d7f85;
    --border: #36242c;
    --border-strong: #4a3038;
    --ring: rgba(230, 120, 160, .35);
    --primary: #b8325f;
    --primary-hover: #cf4673;
    --heading: #f3c9d8;
    --vino-suave: #3a1422;
    --vino-tenue: #2a1018;
    --dorado-suave: #3a2f17;
    --ok: #4ade80;     --ok-bg: #12301f;
    --warn: #fbbf24;   --warn-bg: #3a2c0b;
    --danger: #f87171; --danger-bg: #3d1515;
    --info: #93c5fd;   --info-bg: #142640;
    --violet: #c4b5fd; --violet-bg: #2a1f47;
    --sidebar-bg: #1a0a10;
    --sidebar-bg-2: #12070b;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14090e;
  --surface: #1e1116;
  --surface-2: #24151b;
  --surface-3: #2d1b22;
  --text: #ece4e7;
  --text-strong: #ffffff;
  --muted: #b6a8ae;
  --subtle: #8d7f85;
  --border: #36242c;
  --border-strong: #4a3038;
  --ring: rgba(230, 120, 160, .35);
  --primary: #b8325f;
  --primary-hover: #cf4673;
  --heading: #f3c9d8;
  --vino-suave: #3a1422;
  --vino-tenue: #2a1018;
  --dorado-suave: #3a2f17;
  --ok: #4ade80;     --ok-bg: #12301f;
  --warn: #fbbf24;   --warn-bg: #3a2c0b;
  --danger: #f87171; --danger-bg: #3d1515;
  --info: #93c5fd;   --info-bg: #142640;
  --violet: #c4b5fd; --violet-bg: #2a1f47;
  --sidebar-bg: #1a0a10;
  --sidebar-bg-2: #12070b;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- 2. Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body.texto-grande { font-size: 17px; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--heading);
  line-height: 1.2;
  margin: 0 0 .4em;
  letter-spacing: -.01em;
}
h1 { font-size: clamp(1.5rem, 2.4vw, 1.95rem); font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.02rem; font-weight: 700; }
p { margin: 0 0 .8em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
small { font-size: .84em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
code { font-size: .9em; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }

:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

.icon { width: 18px; height: 18px; flex: 0 0 auto; }

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--surface); padding: 8px 14px; border-radius: var(--r-sm);
}
.skip-link:focus { left: 8px; }

.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

body.sin-animaciones *, body.sin-animaciones *::before, body.sin-animaciones *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body.alto-contraste {
  --text: #000; --muted: #222; --subtle: #333; --border: #555; --border-strong: #222;
}
:root[data-theme="dark"] body.alto-contraste { --text: #fff; --muted: #eee; --subtle: #ddd; --border: #aaa; }

/* ---------- 3. Estructura: menú lateral + contenido ---------- */

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-text);
  border-right: 1px solid rgba(255, 255, 255, .04);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(198, 161, 91, .25);
}
.sidebar-brand img { width: 40px; height: auto; filter: drop-shadow(0 4px 10px rgba(0,0,0,.3)); }
.sidebar-brand strong { display: block; font-family: var(--font-display); color: #fff; font-size: 1rem; line-height: 1.15; }
.sidebar-brand span { display: block; font-size: .78rem; color: var(--dorado); letter-spacing: .02em; }
.sidebar .sidebar-close { display: none; margin-left: auto; color: #fff; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.sidebar-section {
  display: block; margin: 16px 10px 6px;
  font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--sidebar-muted);
}
.sidebar-nav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 1px 0;
  border-radius: var(--r-sm);
  color: var(--sidebar-text); font-weight: 500; font-size: .92rem;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.sidebar-nav a .icon { opacity: .85; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar-nav a.active { background: rgba(255, 255, 255, .12); color: #fff; font-weight: 600; }
.sidebar-nav a.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--dorado);
}
.nav-badge {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px;
  display: inline-grid; place-items: center;
  background: var(--dorado); color: #3a2405; border-radius: var(--r-pill);
  font-size: .72rem; font-weight: 800;
}

.sidebar-user {
  display: flex; align-items: center; gap: 6px;
  padding: 12px; border-top: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-user form { margin: 0; }
.sidebar-user .icon-btn { color: var(--sidebar-text); }
.sidebar-user .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-user-link {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--r-sm); color: #fff; text-decoration: none;
}
.sidebar-user-link:hover, .sidebar-user-link.active { background: rgba(255, 255, 255, .08); text-decoration: none; }
.sidebar-user-link span { min-width: 0; }
.sidebar-user-link strong, .sidebar-user-link small {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-link strong { font-size: .88rem; }
.sidebar-user-link small { color: var(--sidebar-muted); font-size: .74rem; }

.sidebar-backdrop { display: none; }

.shell { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: 60px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 600; color: var(--muted); font-size: .92rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; gap: 4px; }
.menu-toggle { display: none; }

.content { flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; padding: 26px 28px 40px; }
.content.ancho-completo { max-width: none; }

.app-footer { padding: 18px 28px; font-size: .8rem; color: var(--subtle); text-align: center; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0; color: var(--muted); max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; margin-bottom: 8px; }
.back-link .icon { width: 16px; height: 16px; }

/* ---------- 4. Botones ---------- */

.btn, button.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  font: 600 .9rem/1 var(--font-body);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:hover { text-decoration: none; }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); color: var(--primary-text); box-shadow: 0 6px 16px rgba(125, 0, 45, .18); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-gold { background: var(--dorado); color: #2f1f05; }
.btn-gold:hover { background: #b8914a; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-soft { background: var(--vino-suave); color: var(--primary); }
.btn-soft:hover { background: color-mix(in srgb, var(--vino-suave) 70%, var(--primary) 12%); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ok { background: var(--ok-bg); color: var(--ok); }
.btn-ok:hover { background: var(--ok); color: #fff; }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: .8rem; border-radius: 9px; gap: 6px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-block { width: 100%; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; padding: 0;
  border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .icon { width: 20px; height: 20px; }
.has-dot .dot {
  position: absolute; top: 8px; right: 8px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--dorado); border: 2px solid var(--bg);
}

.only-dark { display: none; }
:root[data-theme="dark"] .only-dark { display: block; }
:root[data-theme="dark"] .only-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .only-dark { display: block; }
  :root:not([data-theme]) .only-light { display: none; }
}

/* ---------- 5. Tarjetas y paneles ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 20px;
  min-width: 0;
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { padding: 20px 22px 0; }

.kicker {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--dorado-oscuro);
}
:root[data-theme="dark"] .kicker { color: var(--dorado); }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.grid > .card { margin-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
  color: inherit; text-decoration: none;
}
a.stat:hover { border-color: var(--border-strong); text-decoration: none; box-shadow: var(--shadow); }
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 auto;
  background: var(--vino-suave); color: var(--primary);
}
.stat-icon.gold { background: var(--dorado-suave); color: var(--dorado-oscuro); }
.stat-icon.ok { background: var(--ok-bg); color: var(--ok); }
.stat-icon.warn { background: var(--warn-bg); color: var(--warn); }
.stat-icon.info { background: var(--info-bg); color: var(--info); }
.stat-icon.danger { background: var(--danger-bg); color: var(--danger); }
.stat strong { display: block; font-family: var(--font-display); font-size: 1.5rem; line-height: 1.1; color: var(--text-strong); }
.stat > div > span { display: block; font-size: .82rem; color: var(--muted); }

/* Bienvenida del inicio */
.hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 26px 28px; margin-bottom: 20px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, #56001f 0%, #7d002d 55%, #a42456 100%);
  color: #fff;
  box-shadow: var(--shadow);
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px;
  border-radius: 50%; border: 36px solid rgba(198, 161, 91, .18);
}
.hero h1 { color: #fff; margin-bottom: 6px; }
.hero p { color: #f6d7e2; margin: 0; }
.hero .kicker { color: var(--dorado); }
.hero-side { position: relative; z-index: 1; display: flex; gap: 10px; flex-wrap: wrap; }
.hero-chip {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .15);
  border-radius: var(--r); padding: 10px 14px; color: #fff;
}
.hero-chip strong { display: block; font-size: 1.1rem; font-family: var(--font-display); }
.hero-chip small { color: #f6d7e2; }

/* ---------- 6. Alertas, insignias, vacíos ---------- */

.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; margin-bottom: 16px;
  border-radius: var(--r); border: 1px solid transparent;
  font-size: .92rem;
}
.alert .icon { margin-top: 2px; }
.alert span { flex: 1; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-close { border: 0; background: none; color: inherit; font-size: 1.3rem; line-height: 1; cursor: pointer; opacity: .6; padding: 0 4px; }
.alert-close:hover { opacity: 1; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: .75rem; font-weight: 700; line-height: 1.5; white-space: nowrap;
  background: var(--surface-3); color: var(--muted);
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-violet { background: var(--violet-bg); color: var(--violet); }
.badge-vino { background: var(--vino-suave); color: var(--primary); }
.badge-gold { background: var(--dorado-suave); color: var(--dorado-oscuro); }
.badge-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: 36px 20px; color: var(--muted);
}
.empty .icon { width: 34px; height: 34px; color: var(--border-strong); margin-bottom: 6px; }
.empty strong { color: var(--text); }
.empty p { margin: 0; font-size: .9rem; max-width: 46ch; }

/* ---------- 7. Formularios ---------- */

label, .label { display: block; font-size: .84rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.hint { display: block; font-size: .8rem; color: var(--subtle); margin-top: 5px; font-weight: 400; }

input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=search], input[type=url], input[type=file], select, textarea {
  width: 100%; min-height: 42px;
  padding: 9px 12px;
  font: 400 .93rem/1.4 var(--font-body);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; }
input[type=file] { padding: 7px; }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8f98' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
input:disabled, select:disabled { background: var(--surface-3); color: var(--muted); }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--primary); vertical-align: -3px; }

.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid > * { grid-column: span 6; min-width: 0; }
.form-grid .col-3 { grid-column: span 3; }
.form-grid .col-4 { grid-column: span 4; }
.form-grid .col-8 { grid-column: span 8; }
.form-grid .col-12, .form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.form-grid .form-actions { grid-column: 1 / -1; }

.check {
  display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2);
}
.check small { display: block; color: var(--subtle); font-weight: 400; }

.inline-form { display: inline; margin: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.search-input { position: relative; }
.search-input .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--subtle); pointer-events: none; }
.search-input input { padding-left: 38px; }

.segmented { display: inline-flex; background: var(--surface-3); border-radius: var(--r-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented a, .segmented button {
  padding: 6px 12px; border-radius: 8px; font-size: .84rem; font-weight: 600;
  color: var(--muted); text-decoration: none; border: 0; background: none; cursor: pointer;
}
.segmented a.active, .segmented button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ---------- 8. Tablas ---------- */

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); }
.card-flush .table-wrap { border: 0; border-top: 1px solid var(--border); border-radius: 0; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2);
  padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--vino-tenue); }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; }
.cell-user { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.cell-user strong { display: block; color: var(--text-strong); font-weight: 600; }
.cell-user small { display: block; color: var(--subtle); }
.row-danger td { background: color-mix(in srgb, var(--danger-bg) 55%, transparent); }

/* ---------- 9. Avatares ---------- */

.avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
  display: inline-grid; place-items: center;
}
.avatar-fallback {
  background: hsl(var(--h, 340) 45% 90%); color: hsl(var(--h, 340) 55% 28%);
  font-weight: 700; font-size: .85rem; font-family: var(--font-display);
}
:root[data-theme="dark"] .avatar-fallback { background: hsl(var(--h, 340) 30% 25%); color: hsl(var(--h, 340) 60% 85%); }
.avatar-sm { width: 34px; height: 34px; font-size: .75rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.2rem; }
.avatar-xl { width: 104px; height: 104px; font-size: 2rem; }
.online-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); display: inline-block; }

/* ---------- 10. Listas de actividad ---------- */

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed-icon {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 10px;
  display: grid; place-items: center; background: var(--vino-suave); color: var(--primary);
}
.feed-icon .icon { width: 17px; height: 17px; }
.feed-body { min-width: 0; flex: 1; }
.feed-body strong { color: var(--text-strong); font-weight: 600; }
.feed-body p { margin: 2px 0 0; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.feed-time { font-size: .76rem; color: var(--subtle); white-space: nowrap; }
a.feed-link { color: inherit; display: flex; gap: 12px; flex: 1; text-decoration: none; }
a.feed-link:hover strong { color: var(--primary); }

/* ---------- 11. Diálogos ---------- */

dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0; border: 0; border-radius: var(--r-lg);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.dialog-lg { width: min(820px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(30, 6, 15, .55); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; }
.dialog-body { padding: 20px 22px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ---------- 12. Login y páginas simples ---------- */

body.login-page, body.pagina-simple { min-height: 100vh; }

/* Toda la pantalla: foto de la escuela con velo burdeo (igual en modo claro y oscuro) */
body.login-page {
  background:
    radial-gradient(circle at 85% 110%, rgba(198, 161, 91, .22), transparent 45%),
    linear-gradient(135deg, rgba(46, 0, 17, .93) 0%, rgba(86, 0, 31, .86) 45%, rgba(125, 0, 45, .72) 100%),
    url("/img/escuela.jpg") center / cover no-repeat fixed,
    #56001f;
}
.login-layout {
  min-height: 100vh; width: 100%; max-width: 1240px; margin: 0 auto;
  display: grid; grid-template-columns: 1.15fr minmax(0, 440px); gap: 48px;
  align-items: center; padding: 40px 48px;
}
.login-hero {
  position: relative; color: #fff;
  display: flex; flex-direction: column; gap: 34px; justify-content: center;
}
.login-hero-brand { display: flex; align-items: center; gap: 14px; }
.login-hero-brand img { width: 58px; filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .35)); }
.login-hero-brand strong { display: block; font-family: var(--font-display); font-size: 1.1rem; }
.login-hero-brand span { color: var(--dorado); font-size: .85rem; }
.login-hero h1 { color: #fff; font-size: clamp(2rem, 3.6vw, 3rem); max-width: 15ch; margin-bottom: 14px; text-shadow: 0 2px 18px rgba(0, 0, 0, .25); }
.login-hero h1 em { font-style: normal; color: var(--dorado); }
.login-hero p { color: #f6d7e2; max-width: 46ch; font-size: 1.02rem; margin: 0; }
.login-features { display: flex; gap: 10px; flex-wrap: wrap; }
.login-features span {
  display: inline-flex; align-items: center; gap: 7px; font-size: .84rem;
  padding: 8px 13px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18);
  backdrop-filter: blur(4px);
}
.login-features .icon { width: 15px; height: 15px; color: var(--dorado); }

/* Tarjeta blanca del formulario */
.login-side { display: flex; justify-content: center; }
.login-box {
  width: 100%; max-width: 440px;
  background: #ffffff; color: #1f2937;
  border-radius: 24px; padding: 38px 36px 30px;
  border-top: 5px solid var(--dorado);
  box-shadow: 0 30px 70px rgba(20, 0, 8, .45);
}
.login-box .logo { width: 70px; display: block; margin: 0 auto 14px; }
.login-box h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 4px; text-align: center; color: #56001f; }
.login-box > p { color: #5b6470; margin-bottom: 22px; text-align: center; }
.login-box form > div { margin-bottom: 14px; }
.login-box .btn { width: 100%; min-height: 48px; margin-top: 6px; font-size: .95rem; }
.login-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid #ece4e7; font-size: .88rem; }
.login-footer { margin-top: 18px; text-align: center; font-size: .78rem; color: #8a8f98; }
.password-field { position: relative; }
.password-field input { padding-right: 46px; }
.password-field button { position: absolute; right: 4px; top: 2px; }

.error-card {
  max-width: 520px; margin: 12vh auto; padding: 36px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.error-card p { color: var(--muted); }

/* ---------- 13. Reservas: horario semanal ---------- */

.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-nav strong { font-family: var(--font-display); color: var(--heading); min-width: 220px; text-align: center; }

.schedule { width: 100%; border-collapse: separate; border-spacing: 6px; table-layout: fixed; min-width: 680px; }
.schedule th { background: none; border: 0; text-align: center; padding: 6px; text-transform: none; letter-spacing: 0; font-size: .82rem; color: var(--muted); }
.schedule th strong { display: block; font-size: .95rem; color: var(--text-strong); font-family: var(--font-display); }
.schedule th.is-today strong { color: var(--primary); }
.schedule th.is-today { box-shadow: inset 0 -3px 0 var(--dorado); }
.schedule td { padding: 0; border: 0; vertical-align: stretch; height: 74px; }
.schedule tbody tr:hover td { background: none; }
.schedule .hour { text-align: right; font-size: .76rem; font-weight: 600; color: var(--muted); padding-right: 6px; vertical-align: middle; }
.schedule col.col-hour, .schedule th:first-child { width: 96px; }
.schedule-wrap { overflow-x: auto; margin: -6px; }

.slot {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  width: 100%; height: 100%; min-height: 70px; padding: 8px 10px;
  border-radius: 12px; font-size: .8rem; text-align: left;
  border: 1px solid var(--border); background: var(--surface);
}
.slot-free {
  border-style: dashed; color: var(--subtle); align-items: center; text-align: center;
  cursor: pointer; font: 600 .8rem var(--font-body); transition: all .15s;
}
.slot-free:hover { border-color: var(--primary); border-style: solid; color: var(--primary); background: var(--vino-tenue); }
.slot-free .icon { width: 18px; height: 18px; }
.slot-busy { background: var(--vino-suave); border-color: color-mix(in srgb, var(--primary) 22%, transparent); }
.slot-busy strong { color: var(--primary); font-size: .82rem; }
.slot-busy span { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-busy small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-mine { background: var(--dorado-suave); border-color: color-mix(in srgb, var(--dorado) 50%, transparent); }
.slot-mine strong { color: var(--dorado-oscuro); }
.slot-past { background: var(--surface-2); color: var(--subtle); border-style: solid; opacity: .6; }
.slot-maint { background: var(--warn-bg); color: var(--warn); align-items: center; font-weight: 600; }
.slot-actions { display: flex; gap: 4px; margin-top: 4px; }
.slot-actions .btn { min-height: 24px; padding: 0 8px; font-size: .7rem; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid var(--border-strong); }

.day-list { display: none; }

/* ---------- 14. Registro de sala ---------- */

.student-row td:first-child { min-width: 200px; }
.student-row.is-present td { background: color-mix(in srgb, var(--ok-bg) 45%, transparent); }
.student-row select, .student-row input { min-height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: .88rem; }
.pc-duplicado { border-color: var(--danger) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent) !important; }

.obs-tipo-positiva { background: var(--ok-bg); color: var(--ok); }
.obs-tipo-conducta { background: var(--danger-bg); color: var(--danger); }
.obs-tipo-equipo { background: var(--warn-bg); color: var(--warn); }
.obs-tipo-aprendizaje { background: var(--info-bg); color: var(--info); }
.obs-tipo-otra { background: var(--surface-3); color: var(--muted); }

.quick-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-pick a, .quick-pick button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: var(--r);
  background: var(--surface); cursor: pointer; text-align: left; color: var(--text); font: inherit;
}
.quick-pick a:hover, .quick-pick button:hover { text-decoration: none; border-color: var(--primary); background: var(--vino-tenue); }
.quick-pick strong { color: var(--primary); }
.quick-pick small { color: var(--muted); }

/* ---------- 15. Equipos del laboratorio ---------- */

.pc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pc {
  position: relative; padding: 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.pc:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.pc .icon { width: 26px; height: 26px; }
.pc strong { font-size: .9rem; }
.pc small { color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc::after { content: ""; position: absolute; top: 12px; right: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--subtle); }
.pc.st-operativo::after { background: var(--ok); }
.pc.st-revision::after { background: var(--warn); }
.pc.st-fuera::after { background: var(--danger); }
.pc.st-prestado::after { background: var(--info); }
.pc.st-operativo .icon { color: var(--ok); }
.pc.st-revision .icon { color: var(--warn); }
.pc.st-fuera .icon { color: var(--danger); }
.pc.st-prestado .icon { color: var(--info); }

.status-tile { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); }
.status-tile .icon { width: 22px; height: 22px; }
.status-tile strong { display: block; }
.status-tile small { color: var(--muted); }

.meter { height: 8px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--vino-claro)); border-radius: inherit; }
.meter.gold > span { background: linear-gradient(90deg, var(--dorado-oscuro), var(--dorado)); }

/* ---------- 16. Mensajes y chat ---------- */

.chat-layout {
  display: grid; grid-template-columns: 320px minmax(0, 1fr);
  height: calc(100vh - 60px - 26px - 40px - 60px); min-height: 520px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.chat-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.chat-list-head { padding: 14px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; }
.chat-list-items { overflow-y: auto; flex: 1; }
.chat-item {
  display: flex; align-items: center; gap: 11px; padding: 12px 14px;
  color: inherit; text-decoration: none; border-bottom: 1px solid var(--border);
}
.chat-item:hover { background: var(--surface-2); text-decoration: none; }
.chat-item.active { background: var(--vino-suave); }
.chat-item-body { min-width: 0; flex: 1; }
.chat-item-top { display: flex; justify-content: space-between; gap: 8px; }
.chat-item-top strong { font-size: .9rem; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-top small { color: var(--subtle); white-space: nowrap; }
.chat-item p { margin: 1px 0 0; font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.unread strong { color: var(--primary); }
.chat-item.unread p { color: var(--text); font-weight: 600; }
.chat-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--primary); color: #fff; font-size: .72rem; font-weight: 700; display: grid; place-items: center; }
.chat-room-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--dorado-suave); color: var(--dorado-oscuro); flex: 0 0 auto; }

.chat-window { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.chat-head strong { display: block; color: var(--text-strong); }
.chat-head small { color: var(--muted); }
.chat-back { display: none; }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); }
.msg { display: flex; flex-direction: column; max-width: min(72%, 560px); }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg-author { font-size: .74rem; font-weight: 700; color: var(--primary); margin: 6px 4px 2px; }
.msg-bubble {
  padding: 9px 13px; border-radius: 16px; font-size: .92rem; line-height: 1.45;
  background: var(--surface); border: 1px solid var(--border); overflow-wrap: anywhere; white-space: pre-wrap;
}
.msg.me .msg-bubble { background: var(--primary); color: #fff; border-color: transparent; border-bottom-right-radius: 5px; }
.msg.other .msg-bubble { border-bottom-left-radius: 5px; }
.msg-time { font-size: .7rem; color: var(--subtle); margin: 2px 6px 0; }
.msg-row { display: flex; align-items: center; gap: 6px; max-width: 100%; }
.msg.other .msg-row { flex-direction: row-reverse; }
.msg-borrar {
  flex: 0 0 auto; display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--subtle); cursor: pointer;
  opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.msg:hover .msg-borrar, .msg-borrar:focus-visible { opacity: 1; }
.msg-borrar:hover { background: var(--danger-bg); color: var(--danger); }
@media (hover: none) { .msg-borrar { opacity: .55; } }
.msg-day { align-self: center; font-size: .74rem; font-weight: 600; color: var(--muted); background: var(--surface-3); padding: 3px 12px; border-radius: var(--r-pill); margin: 10px 0; }
.chat-form { display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-form textarea { min-height: 44px; max-height: 140px; resize: none; border-radius: 22px; padding: 11px 16px; }
.chat-form .btn { border-radius: 50%; width: 44px; height: 44px; padding: 0; flex: 0 0 auto; }
.chat-empty { flex: 1; display: grid; place-items: center; }

/* ---------- 17. Comunidad ---------- */

.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.person {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: 22px 16px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.person h3 { margin: 6px 0 0; font-size: .98rem; }
.person .muted { font-size: .84rem; margin: 0; }
.person .avatar-wrap { position: relative; }
.person .avatar-wrap .online-dot { position: absolute; right: 4px; bottom: 4px; border: 2px solid var(--surface); width: 14px; height: 14px; }
.person .btn { margin-top: 8px; }

.anuncio { border-left: 4px solid var(--dorado); padding: 14px 16px; background: var(--surface-2); border-radius: 0 var(--r) var(--r) 0; margin-bottom: 12px; }
.anuncio.importante { border-left-color: var(--primary); background: var(--vino-tenue); }
.anuncio h3 { margin: 0 0 4px; }
.anuncio p { margin: 0 0 6px; white-space: pre-line; }
.anuncio small { color: var(--subtle); }

/* ---------- 18. Biblioteca Digital ---------- */

.lib-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 22px; align-items: start; }
.lib-cats { position: sticky; top: 80px; }
.lib-cats a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r-sm);
  color: var(--text); font-size: .9rem; font-weight: 500; text-decoration: none;
}
.lib-cats a:hover { background: var(--surface-3); }
.lib-cats a.active { background: var(--vino-suave); color: var(--primary); font-weight: 700; }
.lib-cats a i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.lib-cats a span { margin-left: auto; font-size: .76rem; color: var(--subtle); }

.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 20px; }
.book { display: flex; flex-direction: column; gap: 8px; color: inherit; text-decoration: none; min-width: 0; }
.book:hover { text-decoration: none; }
.book-cover {
  position: relative; aspect-ratio: 3 / 4; border-radius: 6px 12px 12px 6px; overflow: hidden;
  background: linear-gradient(145deg, var(--c, #7d002d), color-mix(in srgb, var(--c, #7d002d) 55%, #000));
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 10px 22px rgba(64, 22, 40, .16);
  transition: transform .2s, box-shadow .2s;
}
.book:hover .book-cover { transform: translateY(-4px); box-shadow: 0 18px 36px rgba(64, 22, 40, .24); }
.book-cover::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 8px; background: linear-gradient(90deg, rgba(0,0,0,.25), rgba(255,255,255,.08)); z-index: 1; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book-cover .placeholder { position: absolute; inset: 0; padding: 18px 16px 16px 20px; display: flex; flex-direction: column; justify-content: space-between; color: #fff; }
.book-cover .placeholder strong { font-family: var(--font-display); font-size: 1rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.book-cover .placeholder small { color: rgba(255,255,255,.75); border-top: 1px solid rgba(198,161,91,.6); padding-top: 8px; }
.book-flags { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; z-index: 2; }
.book-flags span { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: rgba(20, 5, 10, .65); color: #fff; backdrop-filter: blur(4px); }
.book-flags .icon { width: 14px; height: 14px; }
.book-flags .fav { color: var(--dorado); }
.book-title { font-weight: 600; font-size: .9rem; color: var(--text-strong); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-meta { font-size: .78rem; color: var(--muted); margin-top: -4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.book-detail { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; align-items: start; }
.book-detail .book-cover { width: 100%; }
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: .9rem; margin: 16px 0; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; color: var(--text-strong); font-weight: 500; }

.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--r-lg); padding: 26px; text-align: center;
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--vino-tenue); }
.dropzone .icon { width: 34px; height: 34px; color: var(--primary); }
.dropzone strong { display: block; margin: 8px 0 2px; }
.dropzone input { display: none; }
.cover-preview { width: 120px; aspect-ratio: 3/4; border-radius: 6px; object-fit: cover; box-shadow: var(--shadow); }

/* Visor de lectura */
body.reader-page { background: #2a2326; }
.reader { position: fixed; inset: 0; display: flex; flex-direction: column; background: #3a3235; color: #fff; }
.reader-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; flex-wrap: wrap;
  background: #1e1316; border-bottom: 2px solid var(--dorado);
}
.reader-bar .icon-btn { color: #f6d7e2; }
.reader-bar .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.reader-title { flex: 1; min-width: 140px; }
.reader-title strong { display: block; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-title small { color: #c89aab; font-size: .76rem; }
.reader-pages { display: flex; align-items: center; gap: 6px; font-size: .86rem; color: #f6d7e2; }
.reader-pages input { width: 60px; min-height: 32px; padding: 4px 8px; text-align: center; background: #2d2226; color: #fff; border-color: #5a454c; }
.reader-scroll { flex: 1; overflow-y: auto; overflow-x: auto; scrollbar-gutter: stable; padding: 22px 12px 60px; display: flex; flex-direction: column; align-items: safe center; gap: 16px; }
.reader-page { position: relative; background: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.45); user-select: none; -webkit-user-select: none; }
.reader-page canvas { display: block; }
.reader-watermark {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
  display: grid; place-items: center;
}
.reader-watermark span {
  transform: rotate(-30deg); font: 700 clamp(14px, 2.2vw, 22px) var(--font-body);
  color: rgba(125, 0, 45, .1); white-space: nowrap; letter-spacing: .05em;
}
.reader-loading { padding: 60px; color: #f6d7e2; }
@media print { body.reader-page * { display: none !important; } }

/* ---------- 19. Perfil ---------- */

.profile { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.profile-card { text-align: center; }
.profile-card h2 { margin: 12px 0 2px; }
.profile-card .avatar-xl { margin: 0 auto; }
.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-option { position: relative; }
.theme-option input { position: absolute; opacity: 0; }
.theme-option label {
  display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 0;
  padding: 14px 10px; border: 2px solid var(--border); border-radius: var(--r); cursor: pointer; font-weight: 600;
}
.theme-option input:checked + label { border-color: var(--primary); background: var(--vino-tenue); color: var(--primary); }
.theme-option input:focus-visible + label { outline: 3px solid var(--ring); }
.theme-swatch { width: 100%; height: 44px; border-radius: 8px; border: 1px solid var(--border-strong); }
.sw-light { background: linear-gradient(90deg, #4a001b 30%, #f7f4f2 30%); }
.sw-dark { background: linear-gradient(90deg, #1a0a10 30%, #14090e 30%); }
.sw-auto { background: linear-gradient(135deg, #f7f4f2 50%, #14090e 50%); }

/* ---------- 20. Reportes ---------- */

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 140px minmax(0, 1fr) 46px; gap: 12px; align-items: center; font-size: .86rem; }
.bar-row span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.bar-row b { text-align: right; color: var(--text-strong); }

/* ---------- 21. Responsive ---------- */

@media (max-width: 1100px) {
  .grid-main-side { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lib-layout { grid-template-columns: minmax(0, 1fr); }
  .lib-cats { position: static; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
  .lib-cats a { white-space: nowrap; border: 1px solid var(--border); }
  .lib-cats a span { margin-left: 4px; }
  .lib-cats h3 { display: none; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(30, 6, 15, .5); }
  .sidebar .sidebar-close { display: inline-grid; }
  .shell { margin-left: 0; }
  .menu-toggle { display: inline-grid; }
  .topbar { padding: 0 12px; }
  .content { padding: 20px 16px 32px; }
  .login-layout { grid-template-columns: minmax(0, 1fr); gap: 22px; padding: 24px 16px 32px; align-content: start; }
  .login-hero { gap: 14px; text-align: center; align-items: center; }
  .login-hero h1 { font-size: 1.55rem; margin: 0 auto; }
  .login-hero p, .login-features { display: none; }
  .login-box { padding: 28px 22px 24px; margin: 0 auto; }
  .login-box .logo { display: none; }
  .login-hero-brand { flex-direction: column; gap: 8px; }
  body.login-page { background-attachment: scroll, scroll, scroll; }
  .profile { grid-template-columns: minmax(0, 1fr); }
  .book-detail { grid-template-columns: minmax(0, 1fr); }
  .book-detail .book-cover { max-width: 200px; }
  .chat-layout { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 60px - 20px - 32px - 60px); }
  .chat-layout.has-active .chat-list { display: none; }
  .chat-layout:not(.has-active) .chat-window { display: none; }
  .chat-back { display: inline-grid; }
}

@media (max-width: 700px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid > *, .form-grid .col-3, .form-grid .col-4, .form-grid .col-8 { grid-column: 1 / -1; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 12px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; }
  .stat strong { font-size: 1.2rem; }
  .card { padding: 16px; }
  .card-flush > .card-head { padding: 16px 16px 0; }
  .hero { padding: 20px; }
  .page-head { align-items: flex-start; }
  .schedule-wrap { display: none; }
  .day-list { display: flex; flex-direction: column; gap: 14px; }
  .day-list h3 { margin: 4px 0 8px; }
  .day-list .slot { min-height: 56px; margin-bottom: 6px; }
  .day-list .day-slot { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: center; }
  .day-list .day-slot > small { color: var(--muted); font-weight: 600; }
  .books { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .theme-options { grid-template-columns: minmax(0, 1fr); }
  .msg { max-width: 88%; }
  .bar-row { grid-template-columns: 90px minmax(0, 1fr) 36px; }
  .week-nav strong { min-width: 0; flex: 1 1 100%; order: -1; text-align: left; }
  .hero-side { width: 100%; }
  .hero-chip { flex: 1; }
  td.actions { white-space: normal; }
}

@media print {
  .sidebar, .topbar, .page-actions, .app-footer, .no-print, form button { display: none !important; }
  .shell { margin: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
