/* ════════════════════════════════════════════
   BiblioEscolar — estilos.css
   Diseño moderno con glassmorphism + dark mode
   ════════════════════════════════════════════ */

/* ── RESET & BASE ─────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Brand — Paleta basada en #1c3e56 */
  --verde:        #1c3e56;
  --verde-claro:  #e3edf4;
  --verde-oscuro: #132c3e;

  /* Layout */
  --sidebar-w:  230px;
  --header-h:   58px;

  /* ── Light theme (default) ── */
  --fondo:           #E8ECF4;
  --fondo-degradado: linear-gradient(135deg, #D6E4F0 0%, #E4ECF4 25%, #E0ECF4 55%, #E8ECF4 100%);
  --glass-bg:        rgba(255, 255, 255, 0.42);
  --glass-bg-solid:  #FFFFFF;
  --glass-border:    rgba(255, 255, 255, 0.55);
  --glass-blur:      22px;
  --glass-shadow:    0 4px 32px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --glass-glow:      0 0 0 1px rgba(255, 255, 255, 0.15);

  --gris-100:  #F7F8FA;
  --gris-200:  #EAECF0;
  --gris-300:  #D0D5DD;
  --gris-400:  #98A2B3;
  --gris-600:  #475467;
  --gris-900:  #101828;

  --borde:       var(--gris-300);
  --borde-suave: var(--gris-200);
  --texto:       var(--gris-900);
  --texto-muted: var(--gris-400);
  --texto-medio: var(--gris-600);

  /* Sidebar glass */
  --sidebar-bg:    rgba(255, 255, 255, 0.52);
  --sidebar-border: rgba(255, 255, 255, 0.55);

  /* Header */
  --header-bg: linear-gradient(135deg, #1c3e56 0%, #162f44 50%, #0e2030 100%);
  --header-border: rgba(255, 255, 255, 0.08);

  /* Table */
  --th-bg:   rgba(255, 255, 255, 0.35);
  --td-hover: rgba(255, 255, 255, 0.2);

  /* Modal overlay */
  --overlay-bg:   rgba(16, 24, 40, 0.45);
  --modal-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);

  /* Login */
  --login-bg: linear-gradient(145deg, #1c3e56 0%, #162f44 40%, #0e2030 70%, #0a1824 100%);
  --login-card-bg:      rgba(255, 255, 255, 0.78);
  --login-card-border:  rgba(255, 255, 255, 0.35);
  --login-card-shadow:  0 8px 40px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.08);

  /* Badges */
  --badge-verde-bg:   #edf5fa;
  --badge-verde-txt:  #1c3e56;
  --badge-rojo-bg:    #FEF3F2;
  --badge-rojo-txt:   #B42318;
  --badge-amarillo-bg:#FFFAEB;
  --badge-amarillo-txt:#B54708;
  --badge-azul-bg:    #EFF8FF;
  --badge-azul-txt:   #175CD3;

  /* Alerts */
  --alert-success-bg:  #edf5fa;
  --alert-success-txt: #1c3e56;
  --alert-success-bdr: #b3d4e8;
  --alert-danger-bg:   #FEF3F2;
  --alert-danger-txt:  #B42318;
  --alert-danger-bdr:  #FDA29B;

  /* Loading */
  --loading-bg: rgba(240, 242, 245, 0.75);

  /* Dark mode toggle icon */
  --dm-icon-opacity: 1;
}

/* ── Dark theme ── */
[data-theme="dark"] {
  --fondo:           #0E1418;
  --fondo-degradado: linear-gradient(135deg, #0C1218 0%, #0E1418 25%, #0F1820 55%, #0E1418 100%);
  --glass-bg:        rgba(30, 34, 43, 0.45);
  --glass-bg-solid:  #1E222B;
  --glass-border:    rgba(255, 255, 255, 0.08);
  --glass-blur:      24px;
  --glass-shadow:    0 4px 32px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.15);
  --glass-glow:      0 0 0 1px rgba(255, 255, 255, 0.04);

  --gris-100:  #1A1E27;
  --gris-200:  #262B36;
  --gris-300:  #363D4A;
  --gris-400:  #7C8594;
  --gris-600:  #B0B8C9;
  --gris-900:  #E8ECF4;

  --borde:       var(--gris-300);
  --borde-suave: var(--gris-200);
  --texto:       var(--gris-900);
  --texto-muted: var(--gris-400);
  --texto-medio: var(--gris-600);

  /* Sidebar glass */
  --sidebar-bg:     rgba(22, 26, 34, 0.55);
  --sidebar-border: rgba(255, 255, 255, 0.07);

  /* Header */
  --header-bg: linear-gradient(135deg, #0e2030 0%, #0b1a28 50%, #081420 100%);
  --header-border: rgba(255, 255, 255, 0.05);

  /* Table */
  --th-bg:   rgba(26, 30, 39, 0.4);
  --td-hover: rgba(26, 30, 39, 0.2);

  /* Modal overlay */
  --overlay-bg:   rgba(0, 0, 0, 0.6);
  --modal-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);

  /* Login */
  --login-bg: linear-gradient(145deg, #0e2030 0%, #0b1a28 40%, #081420 100%);
  --login-card-bg:      rgba(22, 30, 28, 0.8);
  --login-card-border:  rgba(255, 255, 255, 0.08);
  --login-card-shadow:  0 8px 40px rgba(0, 0, 0, 0.35);

  /* Badges */
  --badge-verde-bg:   rgba(28, 62, 86, 0.25);
  --badge-verde-txt:  #6bb8d9;
  --badge-rojo-bg:    rgba(180, 35, 24, 0.15);
  --badge-rojo-txt:   #F87171;
  --badge-amarillo-bg:rgba(181, 71, 8, 0.15);
  --badge-amarillo-txt:#FBBF24;
  --badge-azul-bg:    rgba(23, 92, 211, 0.15);
  --badge-azul-txt:   #60A5FA;

  /* Alerts */
  --alert-success-bg:  rgba(28, 62, 86, 0.18);
  --alert-success-txt: #6bb8d9;
  --alert-success-bdr: rgba(107, 184, 217, 0.25);
  --alert-danger-bg:   rgba(180, 35, 24, 0.12);
  --alert-danger-txt:  #F87171;
  --alert-danger-bdr:  rgba(248, 113, 113, 0.25);

  /* Loading */
  --loading-bg: rgba(15, 17, 23, 0.8);

  /* Verde claro dark (activo sidebar) */
  --verde-claro: rgba(28, 62, 86, 0.18);
}

body {
  font-family: 'DM Sans', 'Montserrat', sans-serif;
  background: var(--fondo-degradado);
  background-attachment: fixed;
  color: var(--texto);
  min-height: 100vh;
  transition: background 0.35s ease, color 0.25s ease;
  position: relative;
}

/* ── Decorative blurred orbs (enhance glass effect) ── */
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
body::before {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(28, 62, 86, 0.12) 0%, transparent 70%);
  top: -80px; right: -120px;
  filter: blur(60px);
}
body::after {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(107, 184, 217, 0.06) 0%, transparent 70%);
  bottom: -100px; left: -80px;
  filter: blur(60px);
}
[data-theme="dark"] body::before {
  background: radial-gradient(circle, rgba(28, 62, 86, 0.06) 0%, transparent 70%);
}
[data-theme="dark"] body::after {
  background: radial-gradient(circle, rgba(59, 130, 246, 0.04) 0%, transparent 70%);
}

.app-body,
.login-overlay,
#loading-overlay {
  position: relative;
  z-index: 1;
}

/* ════════════════════════════════════════════
   LOGIN
   ════════════════════════════════════════════ */
.login-overlay {
  position: fixed; inset: 0;
  background: var(--login-bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  overflow: hidden;
}
/* Decorative blurred circles for login */
.login-overlay::before,
.login-overlay::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  pointer-events: none;
}
.login-overlay::before {
  width: 400px; height: 400px;
  background: #6bb8d9;
  top: -100px; right: -80px;
}
.login-overlay::after {
  width: 300px; height: 300px;
  background: #1c3e56;
  bottom: -80px; left: -60px;
}

.login-card {
  background: var(--login-card-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--login-card-border);
  border-radius: 8px;
  padding: 2.5rem;
  width: 100%; max-width: 380px;
  text-align: center;
  box-shadow: var(--login-card-shadow);
  position: relative;
  z-index: 1;
}
.login-logo { width: 56px; height: auto; margin-bottom: 0.75rem; border-radius: 8px; }
.login-title {
  font-family: 'Montserrat', serif;
  font-size: 26px; font-weight: 700; letter-spacing: -0.3px;
  color: var(--texto); margin-bottom: 4px;
}
.login-subtitle {
  font-size: 15px; color: var(--texto-muted);
  margin-bottom: 1.5rem;
}
.login-hint { font-size: 14px; color: var(--texto-muted); margin-top: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ════════════════════════════════════════════
   APP VISIBILITY
   ════════════════════════════════════════════ */
.app-hidden  { display: none; }
.app-visible { display: block; }

/* ════════════════════════════════════════════
   HEADER
   ════════════════════════════════════════════ */
header {
  height: var(--header-h);
  background: var(--header-bg);
  display: flex; align-items: center;
  padding: 0 1.5rem; gap: 12px;
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  border-bottom: 1px solid var(--header-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
header .logo-icon {
  width: 34px; height: 34px;
  border-radius: 6px;
  object-fit: contain;
}
header h1 {
  font-family: 'Montserrat', serif;
  font-size: 19px; font-weight: 700;
  color: #fff; letter-spacing: -0.2px;
}
.user-badge {
  margin-left: auto;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 6px;
  background: var(--verde);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff;
}
.user-name { font-size: 15px; color: rgba(255,255,255,0.85); font-weight: 500; }

.btn-logout {
  padding: 6px 14px; font-size: 14px; font-weight: 600;
  font-family: 'DM Sans', 'Montserrat', sans-serif;
  letter-spacing: 0.2px;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  cursor: pointer; transition: all 0.2s;
}
.btn-logout:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.35);
  color: #fff;
}

/* ── Dark mode toggle button ── */
.btn-theme-toggle {
  width: 34px; height: 34px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-theme-toggle:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.35);
}
.btn-theme-toggle svg {
  width: 16px; height: 16px;
  color: rgba(255,255,255,0.85);
  transition: transform 0.3s ease;
}
.btn-theme-toggle:hover svg {
  transform: rotate(20deg);
}
/* Show moon icon in light mode, sun icon in dark mode */
.icon-moon { display: block; }
.icon-sun  { display: none; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun  { display: block; }

/* ════════════════════════════════════════════
   LAYOUT
   ════════════════════════════════════════════ */
.app-body {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

/* ════════════════════════════════════════════
   SIDEBAR (Glass)
   ════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-right: 1px solid var(--sidebar-border);
  padding: 1.25rem 0;
  position: fixed; top: var(--header-h); bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 0.35s ease, border-color 0.35s ease;
}
.sidebar-top {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.sidebar-bottom {
  flex-shrink: 0;
  margin-top: auto;
  padding-bottom: 0;
}
.nav-section { padding: 0 0.75rem; margin-bottom: 0.75rem; }
.nav-label {
  font-size: 12px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--texto-muted);
  padding: 0 0.5rem; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 6px;
  cursor: pointer; font-size: 15px; font-weight: 500;
  color: var(--texto-medio);
  transition: all 0.18s; user-select: none;
}
.nav-item:hover {
  background: var(--glass-bg);
  color: var(--texto);
}
.nav-item.active {
  background: var(--verde-claro);
  color: var(--verde); font-weight: 600;
}
.nav-item .icon {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; opacity: 0.6;
}
.nav-item:hover .icon,
.nav-item.active .icon { opacity: 1; }
.nav-divider {
  height: 1px;
  background: var(--borde-suave);
  margin: 0.5rem 1rem;
  opacity: 0.7;
}

/* ════════════════════════════════════════════
   MAIN
   ════════════════════════════════════════════ */
.main {
  margin-left: var(--sidebar-w);
  flex: 1; padding: 2rem;
}

/* ════════════════════════════════════════════
   SECTIONS
   ════════════════════════════════════════════ */
.section { display: none; }
.section.active { display: block; }

/* ════════════════════════════════════════════
   PAGE HEADER
   ════════════════════════════════════════════ */
.page-header {
  margin-bottom: 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header > div { flex: 1; min-width: 0; }
.page-header > .btn-outline { flex-shrink: 0; align-self: flex-start; margin-top: 4px; }
.page-header h2 {
  font-family: 'Montserrat', serif;
  font-size: 26px; font-weight: 700; letter-spacing: -0.3px;
  color: var(--texto); margin-bottom: 4px;
}
.page-header p { font-size: 15px; color: var(--texto-muted); }

/* ════════════════════════════════════════════
   STAT CARDS (Glass)
   ════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 14px; margin-bottom: 2rem;
}
.stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(calc(var(--glass-blur) + 4px));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) + 4px));
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 1.15rem 1.25rem;
  box-shadow: var(--glass-shadow), var(--glass-glow);
  transition: all 0.2s ease;
}
.stat-card:hover {
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06), var(--glass-glow);
  transform: translateY(-1px);
}
.stat-card .label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--texto-muted); margin-bottom: 6px; text-transform: uppercase;
}
.stat-card .value {
  font-size: 30px; font-weight: 700; color: var(--texto);
  line-height: 1; margin-bottom: 4px;
  transition: color 0.25s;
}
.stat-card .trend {
  font-size: 13px; font-weight: 500; color: var(--verde);
}

/* ════════════════════════════════════════════
   TABLE CARD (Glass)
   ════════════════════════════════════════════ */
.table-card {
  background: var(--glass-bg);
  backdrop-filter: blur(calc(var(--glass-blur) + 4px));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) + 4px));
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  box-shadow: var(--glass-shadow), var(--glass-glow);
  transition: all 0.25s ease;
}
.table-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--borde-suave);
  display: flex; align-items: center; justify-content: space-between;
}
.table-header h3 { font-size: 16px; font-weight: 600; color: var(--texto); }

/* ════════════════════════════════════════════
   TABLA
   ════════════════════════════════════════════ */
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--texto-muted); padding: 10px 1.25rem;
  text-align: left; background: var(--th-bg);
  border-bottom: 1px solid var(--borde-suave);
}
td {
  font-size: 15px; padding: 11px 1.25rem;
  border-bottom: 1px solid var(--borde-suave);
  color: var(--texto-medio); vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--td-hover); }

/* ════════════════════════════════════════════
   BOTONES
   ════════════════════════════════════════════ */
.btn {
  padding: 7px 14px; border-radius: 6px;
  border: 1px solid var(--borde);
  background: var(--glass-bg-solid);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 14px; font-weight: 600;
  font-family: 'DM Sans', 'Montserrat', sans-serif;
  cursor: pointer; color: var(--texto-medio);
  transition: all 0.18s; display: inline-flex;
  align-items: center; gap: 6px;
}
.btn:hover {
  background: var(--gris-100);
  border-color: var(--gris-400);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.btn-primary {
  background: var(--verde); border-color: var(--verde); color: #fff;
  box-shadow: 0 2px 8px rgba(29, 158, 117, 0.25);
}
.btn-primary:hover {
  background: var(--verde-oscuro); border-color: var(--verde-oscuro);
  box-shadow: 0 4px 12px rgba(29, 158, 117, 0.35);
  transform: translateY(-1px);
}
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 4px; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--borde);
  color: var(--texto-medio);
}
.btn-outline:hover {
  background: var(--glass-bg-solid);
  border-color: var(--primary);
  color: var(--primary);
}
.btn-danger {
  border-color: var(--badge-rojo-txt); color: var(--badge-rojo-txt);
  background: transparent;
}
[data-theme="dark"] .btn-danger {
  border-color: rgba(248, 113, 113, 0.4);
  color: #F87171;
}
.btn-danger:hover {
  background: var(--badge-rojo-bg);
  border-color: var(--badge-rojo-txt);
}

/* ════════════════════════════════════════════
   BADGES
   ════════════════════════════════════════════ */
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 4px; font-size: 13px; font-weight: 600;
  letter-spacing: 0.2px;
}
.badge-verde    { background: var(--badge-verde-bg);   color: var(--badge-verde-txt); }
.badge-rojo     { background: var(--badge-rojo-bg);     color: var(--badge-rojo-txt); }
.badge-amarillo { background: var(--badge-amarillo-bg); color: var(--badge-amarillo-txt); }
.badge-azul     { background: var(--badge-azul-bg);     color: var(--badge-azul-txt); }

/* ════════════════════════════════════════════
   FORMULARIOS
   ════════════════════════════════════════════ */
.search-bar { display: flex; gap: 8px; margin-bottom: 1.25rem; }
.form-input, .form-select {
  padding: 9px 14px;
  border: 1px solid var(--borde);
  border-radius: 6px;
  font-size: 15px; font-family: 'DM Sans', 'Montserrat', sans-serif;
  background: var(--glass-bg-solid);
  color: var(--texto); outline: none;
  width: 100%;
  transition: all 0.18s;
}
.form-input::placeholder {
  color: var(--texto-muted);
}
.search-bar input {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  font-size: 15px;
  font-family: 'DM Sans', 'Montserrat', sans-serif;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  color: var(--texto);
  outline: none;
  box-shadow: var(--glass-shadow);
  transition: all 0.18s;
}
.search-bar input::placeholder {
  color: var(--texto-muted);
}
.search-bar input:focus {
  border-color: var(--verde);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.1), var(--glass-shadow);
}
.form-input:focus, .form-select:focus {
  border-color: var(--verde);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.1);
}
.form-grid { display: grid; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: 13px; font-weight: 700; letter-spacing: 0.3px;
  color: var(--texto-medio); text-transform: uppercase;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ════════════════════════════════════════════
   MODALES (Glass)
   ════════════════════════════════════════════ */
.overlay {
  display: none; position: fixed; inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  align-items: center; justify-content: center;
}
.overlay.open { display: flex; }
.modal {
  background: var(--glass-bg);
  backdrop-filter: blur(calc(var(--glass-blur) + 8px));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) + 8px));
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  width: 100%; max-width: 480px; padding: 1.75rem;
  box-shadow: var(--modal-shadow), var(--glass-glow);
  transition: background 0.25s ease;
}
.modal h3 {
  font-family: 'Montserrat', serif;
  font-size: 20px; font-weight: 700; letter-spacing: -0.2px;
  margin-bottom: 1.25rem; color: var(--texto);
}
.modal-footer {
  display: flex; gap: 8px;
  justify-content: flex-end; margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--borde-suave);
}

/* ════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  font-family: 'DM Sans', 'Montserrat', sans-serif;
  line-height: 1.4;
  max-width: 380px;
  min-width: 280px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  animation: toast-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.toast-out {
  animation: toast-out 0.3s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}
.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.toast-close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: inherit;
  opacity: 0.4;
  margin-left: auto;
  transition: opacity 0.15s, background 0.15s;
  font-size: 16px;
  line-height: 1;
}
.toast-close:hover {
  opacity: 0.8;
  background: rgba(0, 0, 0, 0.08);
}

/* Toast types */
.toast-success {
  background: var(--alert-success-bg);
  color: var(--alert-success-txt);
  border-color: var(--alert-success-bdr);
}
.toast-success .toast-icon {
  background: var(--verde);
  color: #fff;
}
.toast-danger {
  background: var(--alert-danger-bg);
  color: var(--alert-danger-txt);
  border-color: var(--alert-danger-bdr);
}
.toast-danger .toast-icon {
  background: #EF4444;
  color: #fff;
}
.toast-warning {
  background: var(--badge-amarillo-bg);
  color: var(--badge-amarillo-txt);
  border-color: rgba(181, 71, 8, 0.2);
}
.toast-warning .toast-icon {
  background: #F59E0B;
  color: #fff;
}
.toast-info {
  background: var(--badge-azul-bg);
  color: var(--badge-azul-txt);
  border-color: rgba(23, 92, 211, 0.2);
}
.toast-info .toast-icon {
  background: #3B82F6;
  color: #fff;
}

/* Progress bar */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 10px 10px;
  animation: toast-progress var(--toast-dur, 3s) linear forwards;
}
.toast-success .toast-progress { background: var(--verde); }
.toast-danger .toast-progress  { background: #EF4444; }
.toast-warning .toast-progress { background: #F59E0B; }
.toast-info .toast-progress    { background: #3B82F6; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(40px) scale(0.95); }
}
@keyframes toast-progress {
  from { width: 100%; }
  to   { width: 0%; }
}

/* Toast responsive */
@media (max-width: 480px) {
  #toast-container {
    top: auto;
    bottom: 16px;
    right: 12px;
    left: 12px;
  }
  .toast {
    max-width: 100%;
    min-width: 0;
  }
}

/* ════════════════════════════════════════════
   TOOLBAR
   ════════════════════════════════════════════ */
.toolbar { display: flex; gap: 8px; margin-bottom: 1.25rem; flex-wrap: wrap; }

/* ════════════════════════════════════════════
   CONFIGURACION
   ════════════════════════════════════════════ */
.config-hint {
  margin-top: 2rem; padding-top: 1.5rem;
  border-top: 1px solid var(--borde-suave);
}
.config-hint p { font-size: 15px; color: var(--texto-muted); line-height: 1.6; }
.config-hint code {
  background: var(--gris-100); padding: 2px 6px;
  border-radius: 4px; font-size: 14px; color: var(--verde);
  border: 1px solid var(--borde-suave);
}
.config-hint strong {
  color: var(--texto-medio);
}

/* ════════════════════════════════════════════
   LOADING OVERLAY
   ════════════════════════════════════════════ */
#loading-overlay {
  background: var(--loading-bg) !important;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ════════════════════════════════════════════
   SCROLLBAR (subtle)
   ════════════════════════════════════════════ */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--gris-300);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gris-400);
}

/* ════════════════════════════════════════════
   SELECTION
   ════════════════════════════════════════════ */
::selection {
  background: rgba(29, 158, 117, 0.2);
  color: var(--texto);
}

/* ════════════════════════════════════════════
   TRANSITIONS GLOBALES (smooth theme switch)
   ════════════════════════════════════════════ */
.sidebar, .stat-card, .table-card, .modal,
.btn, .form-input, .form-select, .toast,
header, .badge {
  transition: background 0.3s ease, border-color 0.3s ease,
              color 0.25s ease, box-shadow 0.3s ease;
}

/* ════════════════════════════════════════════
   HAMBURGER BUTTON (hidden on desktop)
   ════════════════════════════════════════════ */
.btn-hamburger {
  display: none;
  width: 34px; height: 34px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  cursor: pointer;
  align-items: center; justify-content: center;
  color: rgba(255,255,255,0.85);
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-hamburger:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.35);
}

/* ════════════════════════════════════════════
   SIDEBAR OVERLAY (mobile only)
   ════════════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

/* ════════════════════════════════════════════
   RESPONSIVE — TABLET (max-width: 1024px)
   ════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }
  .main {
    padding: 1.5rem;
  }
}

/* ════════════════════════════════════════════
   RESPONSIVE — MOBILE (max-width: 768px)
   ════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Hamburger visible ── */
  .btn-hamburger {
    display: flex;
  }

  /* ── Header compact ── */
  header {
    padding: 0 0.75rem;
    gap: 8px;
  }
  header h1 {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .user-name {
    display: none;
  }
  .btn-logout {
    display: none;
  }
  /* Show logout as icon-only on mobile */
  .user-badge .btn-logout-mobile {
    display: inline-flex !important;
  }

  /* ── Sidebar as drawer ── */
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: 270px;
    z-index: 95;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.35s ease, border-color 0.35s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* ── Main full width ── */
  .main {
    margin-left: 0;
    padding: 1rem;
    width: 100%;
  }

  /* ── Page header ── */
  .page-header {
    margin-bottom: 1.25rem;
  }
  .page-header h2 {
    font-size: 20px;
  }
  .page-header p {
    font-size: 13px;
  }

  /* ── Stats grid: 2 columns ── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 1.25rem;
  }
  .stat-card {
    padding: 0.9rem 1rem;
  }
  .stat-card .value {
    font-size: 24px;
  }
  .stat-card .label {
    font-size: 11px;
  }
  .stat-card .trend {
    font-size: 11px;
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
  .chart-wrap { height: 220px; }
  .chart-wrap-sm { height: 200px; }

  /* ── Table card with horizontal scroll ── */
  .table-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }
  table {
    min-width: 520px;
  }
  th {
    padding: 10px 0.75rem;
    font-size: 11px;
    white-space: nowrap;
  }
  td {
    padding: 10px 0.75rem;
    font-size: 14px;
  }
  .table-header {
    padding: 0.85rem 0.75rem;
  }
  .table-header h3 {
    font-size: 14px;
  }

  /* ── Search bar: stack vertically ── */
  .search-bar {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 1rem;
  }
  .search-bar input {
    width: 100%;
  }
  .search-bar .btn-primary {
    width: 100%;
    justify-content: center;
  }

  /* ── Filter bar full width ── */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-select {
    width: 100%;
    min-width: 0;
  }
  .filter-date-input {
    min-width: 0;
    width: 100%;
  }

  /* ── Toolbar ── */
  .toolbar {
    flex-direction: column;
  }
  .toolbar .btn-primary {
    width: 100%;
    justify-content: center;
  }

  /* ── Modals: near-fullscreen ── */
  .modal {
    max-width: 95vw;
    width: 95vw;
    padding: 1.25rem;
    margin: 0.5rem;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 8px;
  }
  .modal h3 {
    font-size: 18px;
  }

  /* ── Form row: single column ── */
  .form-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* ── Buttons: bigger touch targets ── */
  .btn {
    padding: 9px 16px;
    font-size: 14px;
    min-height: 40px;
  }
  .btn-sm {
    padding: 7px 12px;
    min-height: 36px;
  }

  /* ── Pagination compact ── */
  .pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 0.75rem;
  }
  .pagination-buttons {
    justify-content: center;
    flex-wrap: wrap;
  }

  /* ── Notification dropdown full width ── */
  .notif-dropdown {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    width: 100%;
    max-height: 50vh;
    border-radius: 0 0 8px 8px;
    z-index: 150;
  }

  /* ── Config section ── */
  .config-hint {
    margin-top: 1.25rem;
    padding-top: 1rem;
  }
  .config-hint p {
    font-size: 13px;
  }

  /* ── Login card ── */
  .login-card {
    margin: 0.75rem;
    padding: 1.75rem 1.5rem;
    max-width: 100%;
  }
  .login-title {
    font-size: 22px;
  }
  .login-logo {
    font-size: 32px;
  }
}

/* ════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE (max-width: 400px)
   ════════════════════════════════════════════ */
@media (max-width: 400px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  header h1 {
    font-size: 14px;
  }
  .main {
    padding: 0.75rem;
  }
  .page-header h2 {
    font-size: 18px;
  }
  .stat-card .value {
    font-size: 22px;
  }
}

/* ════════════════════════════════════════════════════════
   FEATURE 5: SORTABLE TABLE HEADERS
   ════════════════════════════════════════════════════════ */
th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover {
  color: var(--texto);
}
.sort-arrow {
  font-size: 11px;
  opacity: 0.5;
  margin-left: 2px;
}
th.sortable.asc .sort-arrow,
th.sortable.desc .sort-arrow {
  opacity: 1;
  color: var(--verde);
}

/* ════════════════════════════════════════════════════════
   FEATURE 3: FILTER BAR & PAGINATION
   ════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.filter-select {
  padding: 9px 14px;
  border: 1px solid var(--borde);
  border-radius: 6px;
  font-size: 14px;
  font-family: 'DM Sans', 'Montserrat', sans-serif;
  background: var(--glass-bg-solid);
  color: var(--texto);
  outline: none;
  width: auto;
  min-width: 160px;
  transition: all 0.18s;
}
.filter-select:focus {
  border-color: var(--verde);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.1);
}

/* ── Date range filter ── */
.filter-date-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.filter-date-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--texto-muted);
  white-space: nowrap;
}
.filter-date-input {
  padding: 9px 10px;
  border: 1px solid var(--borde);
  border-radius: 6px;
  font-size: 13px;
  font-family: 'DM Sans', 'Montserrat', sans-serif;
  background: var(--glass-bg-solid);
  color: var(--texto);
  outline: none;
  transition: all 0.18s;
  min-width: 135px;
  color-scheme: light;
}
[data-theme="dark"] .filter-date-input {
  color-scheme: dark;
}
.filter-date-input:focus {
  border-color: var(--verde);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.1);
}
.filter-date-input::-webkit-calendar-picker-indicator {
  filter: opacity(0.5);
  cursor: pointer;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 1.25rem;
  border-top: 1px solid var(--borde-suave);
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Charts ── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.chart-card {
  padding: 1.25rem;
}
.chart-card h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--texto-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.charts-grid > .chart-card:first-child {
  grid-column: 1 / -1;
}
.chart-wrap {
  position: relative;
  width: 100%;
  height: 260px;
}
.chart-wrap-sm {
  height: 220px;
}
.pagination-info {
  font-size: 13px;
  color: var(--texto-muted);
}
.pagination-buttons {
  display: flex;
  gap: 4px;
}
.pagination-btn {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--borde);
  background: var(--glass-bg-solid);
  color: var(--texto-medio);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'DM Sans', 'Montserrat', sans-serif;
}
.pagination-btn:hover:not(:disabled):not(.active) {
  background: var(--gris-100);
  border-color: var(--gris-400);
}
.pagination-btn.active {
  background: var(--verde);
  border-color: var(--verde);
  color: white;
}
.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ════════════════════════════════════════════════════════
   BULK ACTIONS BAR
   ════════════════════════════════════════════════════════ */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 1.25rem;
  background: var(--badge-amarillo-bg);
  border-bottom: 1px solid var(--borde-suave);
  font-size: 14px;
  font-weight: 600;
  color: var(--texto-medio);
  animation: bulk-bar-in 0.2s ease;
}
@keyframes bulk-bar-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════════════════════
   CUSTOM CHECKBOX (supports light/dark)
   ════════════════════════════════════════════════════════ */
.checkbox-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  width: 18px;
  height: 18px;
}
.checkbox-wrap input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.checkbox-wrap .checkmark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--gris-300);
  border-radius: 3px;
  background: var(--glass-bg-solid);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.checkbox-wrap .checkmark::after {
  content: '';
  width: 4px;
  height: 8px;
  border: solid transparent;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.12s ease;
  margin-top: -2px;
}
.checkbox-wrap input[type="checkbox"]:checked + .checkmark {
  background: var(--verde);
  border-color: var(--verde);
}
.checkbox-wrap input[type="checkbox"]:checked + .checkmark::after {
  border-color: #fff;
  transform: rotate(45deg) scale(1);
}
.checkbox-wrap:hover .checkmark {
  border-color: var(--verde);
}

/* Bulk header cell */
.th-bulk {
  padding: 10px 8px !important;
}

/* ════════════════════════════════════════════════════════
   FEATURE 1: NOTIFICATION BELL & DROPDOWN
   ════════════════════════════════════════════════════════ */
.notif-wrapper {
  position: relative;
}
.btn-notif {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
  color: rgba(255,255,255,0.85);
}
.btn-notif:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.35);
}
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border-radius: 50%;
  background: #EF4444;
  color: white;
  padding: 0 4px;
  display: none;
}
.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 150;
  width: 360px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--glass-bg-solid);
  border: 1px solid var(--borde);
  border-radius: 8px;
  box-shadow: var(--modal-shadow);
  display: none;
}
.notif-dropdown.open {
  display: block;
}
.notif-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--borde-suave);
  font-weight: 600;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  color: var(--texto);
}
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--borde-suave);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.notif-item:last-child {
  border-bottom: none;
}
.notif-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.notif-item-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--texto);
}
.notif-item-meta {
  font-size: 12px;
  color: var(--texto-muted);
}
.notif-item-badge {
  align-self: flex-start;
  flex-shrink: 0;
}
.notif-empty {
  padding: 24px;
  text-align: center;
  color: var(--texto-muted);
  font-size: 14px;
}

/* ════════════════════════════════════════════════════════
   FEATURE 4: COMBOBOX / SEARCH SELECT
   ════════════════════════════════════════════════════════ */
.combobox {
  position: relative;
}
.combobox-input {
  padding: 9px 14px;
  border: 1px solid var(--borde);
  border-radius: 6px;
  font-size: 15px;
  font-family: 'DM Sans', 'Montserrat', sans-serif;
  background: var(--glass-bg-solid);
  color: var(--texto);
  outline: none;
  width: 100%;
  transition: all 0.18s;
}
.combobox-input::placeholder {
  color: var(--texto-muted);
}
.combobox-input:focus {
  border-color: var(--verde);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.1);
}
.combobox-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  max-height: 200px;
  overflow-y: auto;
  background: var(--glass-bg-solid);
  border: 1px solid var(--borde);
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: var(--glass-shadow);
  display: none;
}
.combobox-dropdown.open {
  display: block;
}
.combobox-option {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--borde-suave);
  transition: background 0.1s;
}
.combobox-option:last-child {
  border-bottom: none;
}
.combobox-option:hover,
.combobox-option.highlighted {
  background: var(--verde-claro);
}
.combobox-option-text {
  font-weight: 500;
  color: var(--texto);
}
.combobox-option-meta {
  font-size: 12px;
  color: var(--texto-muted);
  margin-top: 2px;
}

/* ── CARGA MASIVA: Dropzone (import-drop) ────── */
.import-drop {
  border: 2px dashed var(--borde);
  border-radius: 12px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--gris-100);
}

.import-drop:hover,
.import-drop.drag-over {
  border-color: var(--verde);
  background: var(--verde-claro);
}

/* ── CARGA MASIVA: Spinner inline ─────────────── */
.spinner-inline {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--gris-300);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-left: 6px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── CARGA MASIVA: Tabla previa ─────────────── */
#carga-previa-head th {
  position: sticky;
  top: 0;
  background: var(--fondo-card);
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid var(--borde);
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--texto);
  white-space: nowrap;
}

#carga-previa-body tr {
  border-bottom: 1px solid var(--borde);
}

#carga-previa-body tr:last-child {
  border-bottom: none;
}

#carga-previa-body td {
  padding: 6px 10px;
  color: var(--texto);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#carga-previa-body tr:hover {
  background: var(--gris-100);
}

/* ════════════════════════════════════════════
   BOOK DETAIL MODAL
   ════════════════════════════════════════════ */

/* Clickable catalog rows */
#tabla-catalogo tbody tr {
  cursor: pointer;
}

/* Detail modal - wider */
.modal-libro-detalle {
  max-width: 580px;
  position: relative;
}

/* Close button in modal */
.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--texto-muted);
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
  z-index: 2;
  transition: all 0.15s;
  line-height: 1;
}
.modal-close-btn:hover {
  color: var(--texto);
  background: var(--gris-100);
}

/* Detail layout: cover left, info right */
.libro-detalle-layout {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.libro-detalle-cover {
  flex-shrink: 0;
  width: 180px;
}

/* Cover image wrapper */
.libro-cover-wrap {
  width: 180px;
  height: 250px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.06);
  position: relative;
}

/* Cover image */
.libro-cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* Placeholder when no cover */
.libro-cover-placeholder {
  width: 100%;
  height: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px dashed var(--gris-300);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--texto-muted);
}
.libro-cover-placeholder svg {
  opacity: 0.4;
}
.libro-cover-placeholder span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  opacity: 0.5;
}

/* Info section */
.libro-detalle-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.libro-det-titulo {
  font-family: 'Montserrat', serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--texto);
  margin-bottom: 1rem;
  line-height: 1.3;
  letter-spacing: -0.2px;
}

.libro-detalle-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 1.25rem;
}

.libro-det-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.libro-det-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--texto-muted);
}

.libro-det-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--texto);
}

.libro-det-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Action buttons at bottom of detail */
.libro-detalle-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--borde-suave);
}

/* Cover URL management in edit mode */
.libro-cover-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.libro-cover-edit-preview {
  margin-top: 10px;
  width: 100%;
  max-width: 200px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  aspect-ratio: 180/250;
  background: var(--gris-100);
}
.libro-cover-edit-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ISBN toggle switch for bulk import */
.carga-isbn-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--gris-100);
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--texto-medio);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.carga-isbn-toggle:hover {
  background: var(--borde-suave);
}
.carga-isbn-toggle input[type="checkbox"] {
  display: none;
}
.carga-isbn-toggle-slider {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  background: var(--gris-300);
  border-radius: 10px;
  transition: background 0.2s;
}
.carga-isbn-toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.carga-isbn-toggle input:checked + .carga-isbn-toggle-slider {
  background: var(--verde);
}
.carga-isbn-toggle input:checked + .carga-isbn-toggle-slider::after {
  transform: translateX(16px);
}

/* Responsive: stack detail layout on mobile */
@media (max-width: 520px) {
  .modal-libro-detalle {
    max-width: 95vw;
    padding: 1.25rem;
  }
  .libro-detalle-layout {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .libro-detalle-cover {
    width: 140px;
  }
  .libro-cover-wrap {
    width: 140px;
    height: 195px;
  }
  .libro-detalle-actions {
    flex-direction: column;
  }
  .libro-detalle-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ══════════════════════════════════════════════════════════════
   COMPROBANTE DE PRÉSTAMO / DEVOLUCIÓN
   ══════════════════════════════════════════════════════════════ */

.comprobante {
  padding: 1.5rem;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #1a1a2e;
}

.comprobante-header {
  text-align: center;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 2px dashed var(--primary, #1c3e56);
}

.comprobante-header .comprobante-logo {
  width: 48px;
  height: 48px;
  margin-bottom: 0.5rem;
}

.comprobante-header .comprobante-titulo {
  font-size: 1.15rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--primary, #1c3e56);
}

.comprobante-header .comprobante-subtitulo {
  font-size: 0.85rem;
  color: #555;
  margin-top: 2px;
}

.comprobante-body {
  margin: 1rem 0;
}

.comprobante-field {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.55rem 0;
  border-bottom: 1px solid #e8e8e8;
  font-size: 0.92rem;
}

.comprobante-field:last-child {
  border-bottom: none;
}

.comprobante-label {
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  margin-right: 1rem;
}

.comprobante-value {
  text-align: right;
  color: #1a1a2e;
  word-break: break-word;
}

.comprobante-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 2px dashed var(--primary, #1c3e56);
  text-align: center;
}

.comprobante-firma {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
}

.comprobante-firma-col {
  text-align: center;
  flex: 1;
}

.comprobante-firma-linea {
  width: 70%;
  border-bottom: 1px solid #333;
  margin: 0 auto 0.4rem;
}

.comprobante-firma-texto {
  font-size: 0.75rem;
  color: #666;
  font-style: italic;
}

.comprobante-fecha-impresion {
  font-size: 0.72rem;
  color: #999;
  margin-top: 1rem;
  text-align: center;
}

.comprobante-tipo-badge {
  display: inline-block;
  padding: 3px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.75rem;
}

.comprobante-tipo-badge.prestamo {
  background: #e8f5e9;
  color: #2e7d32;
}

.comprobante-tipo-badge.devolucion {
  background: #e3f2fd;
  color: #1565c0;
}

/* ══════════════════════════════════════════════════════════════
   @media print — Ocultar todo excepto el comprobante
   ══════════════════════════════════════════════════════════════ */

@media print {
  /* Ocultar toda la app */
  body > *:not(#modal-comprobante) {
    display: none !important;
  }

  /* El overlay ocupa toda la pantalla */
  #modal-comprobante {
    position: static !important;
    display: block !important;
    background: white !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100vh !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  #modal-comprobante .modal {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    backdrop-filter: none !important;
    border-radius: 0 !important;
  }

  /* Ocultar botones al imprimir */
  #comprobante-botones {
    display: none !important;
  }

  /* Ajustar colores para impresión */
  .comprobante {
    color: #000 !important;
    padding: 0 !important;
  }

  .comprobante-header {
    border-bottom-color: #333 !important;
  }

  .comprobante-header .comprobante-titulo {
    color: #000 !important;
  }

  .comprobante-field {
    border-bottom-color: #ccc !important;
  }

  .comprobante-label {
    color: #000 !important;
  }

  .comprobante-footer {
    border-top-color: #333 !important;
  }

  .comprobante-tipo-badge.prestamo {
    background: #f0f0f0 !important;
    color: #000 !important;
    border: 1px solid #999;
  }

  .comprobante-tipo-badge.devolucion {
    background: #f0f0f0 !important;
    color: #000 !important;
    border: 1px solid #999;
  }

  .comprobante-firma-linea {
    border-bottom-color: #000 !important;
  }

  .comprobante-fecha-impresion {
    color: #666 !important;
  }
}
