@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap');
:root{--navy:#142b4a;--blue:#245b91;--gold:#d7a84b;--ink:#1e293b;--muted:#64748b;--line:#e2e8f0;--bg:#f5f7fa;--white:#fff}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font-family:'DM Sans',sans-serif}a{color:inherit;text-decoration:none}.top{height:78px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 max(calc((100% - 1180px)/2),24px);gap:20px}.brand{display:flex;align-items:center;gap:12px;color:var(--navy)}.brand b{font:800 16px Manrope}.brand small{display:block;color:var(--muted);font-size:11px;margin-top:3px}.mark{width:42px;height:42px;background:var(--navy);color:#fff;border-radius:12px;display:grid;place-items:center;font:800 14px Manrope}.top nav{display:flex;align-items:center;gap:24px;font-size:14px}.user{color:var(--muted)}.top nav form{margin:0}.link{border:0;background:none;color:var(--blue);font:inherit;cursor:pointer}.container{max-width:1180px;margin:0 auto;padding:36px 24px 70px;min-height:70vh}.hero{background:linear-gradient(115deg,#142b4a,#245b91);color:#fff;border-radius:24px;padding:72px 7%;min-height:380px;position:relative;overflow:hidden}.hero:after{content:"";position:absolute;width:390px;height:390px;border:1px solid #ffffff24;border-radius:50%;right:5%;top:20px;box-shadow:0 0 0 45px #ffffff08,0 0 0 90px #ffffff06}.eyebrow{font-size:11px;letter-spacing:2px;font-weight:700;color:var(--gold);margin-bottom:14px}.hero h1{font:800 clamp(38px,6vw,64px)/1.08 Manrope;margin:0 0 18px;max-width:650px}.hero h1 em{color:#f1ca79;font-style:normal}.hero p{color:#d8e4f1;line-height:1.7;max-width:570px;margin-bottom:28px}.btn{display:inline-flex;align-items:center;justify-content:center;background:var(--gold);color:#172b45;border:0;border-radius:9px;padding:12px 19px;font-weight:700;font:600 14px 'DM Sans';cursor:pointer}.btn.small{padding:9px 13px;font-size:13px}.btn.outline{background:#fff;border:1px solid var(--line);color:var(--navy)}.btn.danger{background:#b42318;color:#fff;border:1px solid #b42318}.btn.danger:hover{background:#921b13;border-color:#921b13}.btn.full{width:100%;margin-top:8px}.section{padding:54px 0 30px}.section-head{display:flex;justify-content:space-between;align-items:end;gap:20px}.section h2,.programs h2{font:700 27px Manrope;margin:0 0 22px}.muted{color:var(--muted);font-size:13px}.search{display:flex;gap:10px;margin:20px 0 25px}.search input{flex:1}.cards{display:grid;grid-template-columns:repeat(3,1fr);gap:18px}.book{background:#fff;border:1px solid var(--line);border-radius:14px;padding:16px;display:flex;gap:15px;min-width:0}.cover{width:92px;min-width:92px;height:128px;background:linear-gradient(145deg,#1c3b61,#3f709c);border-radius:7px;display:grid;place-items:center;color:#fff;text-align:center;font:700 14px Manrope;box-shadow:0 5px 12px #142b4a20;overflow:hidden}.cover img{width:100%;height:100%;object-fit:cover}.book h3{font:700 15px/1.35 Manrope;margin:3px 0 7px}.book p{font-size:13px;color:var(--muted);margin:0 0 9px}.book small{font-size:11px;color:var(--blue)}.actions{margin-top:13px}.programs{background:#eaf0f6;border-radius:18px;padding:30px}.program-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:12px}.program-grid div{background:#fff;border:1px solid var(--line);padding:18px;border-radius:10px;font-weight:600;font-size:13px}.login{max-width:430px;margin:20px auto;background:#fff;border:1px solid var(--line);border-radius:18px;padding:34px;box-shadow:0 12px 35px #142b4a0b}.login h1,.page-title h1{font:800 32px Manrope;margin:0 0 8px}.login p,.page-title p{color:var(--muted);line-height:1.6}.login form{margin:25px 0 18px}.login label,label{display:block;font-size:13px;font-weight:600;margin-bottom:14px}input,select,textarea{width:100%;padding:12px 13px;border:1px solid #cbd5e1;border-radius:8px;background:#fff;font:14px 'DM Sans';margin-top:7px;color:var(--ink)}input:focus,select:focus,textarea:focus{outline:2px solid #d7a84b66;border-color:var(--gold)}.page-title{margin:5px 0 26px}.page-title .eyebrow{margin-bottom:10px}.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:24px}.stat,.panel{background:#fff;border:1px solid var(--line);border-radius:13px;padding:22px}.stat strong{display:block;font:800 30px Manrope;color:var(--navy)}.stat span{font-size:13px;color:var(--muted)}.admin-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:14px}.admin-grid a{background:#fff;border:1px solid var(--line);padding:22px;border-radius:13px}.admin-grid b,.admin-grid span{display:block}.admin-grid b{font:700 17px Manrope;color:var(--navy);margin-bottom:7px}.admin-grid span{color:var(--muted);font-size:13px}.form-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:8px 18px;margin-bottom:20px}.span2{grid-column:span 2}.form-grid fieldset{border:1px solid var(--line);border-radius:9px;padding:12px}.form-grid legend{font-weight:700;font-size:13px}.check{display:flex;align-items:center;gap:8px;font-weight:400;margin:8px 0}.check input{width:auto;margin:0}.table-wrap{overflow-x:auto}table{width:100%;border-collapse:collapse;font-size:13px}th,td{text-align:left;padding:12px;border-bottom:1px solid var(--line)}th{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.7px}.panel h2{font:700 19px Manrope;margin:0 0 15px}.detail{display:grid;grid-template-columns:220px 1fr;gap:36px;background:#fff;border:1px solid var(--line);border-radius:18px;padding:32px}.cover.large{width:200px;height:280px;font-size:22px}.detail h1{font:800 32px Manrope;margin:0 0 10px}.lead{color:var(--blue);font-size:18px}.detail p{line-height:1.7}.detail dl{display:grid;grid-template-columns:130px 1fr;font-size:13px;gap:10px}.detail dt{color:var(--muted)}.detail dd{margin:0;font-weight:600}.notice,.flash{background:#fff7e6;border:1px solid #f1d99c;padding:13px 16px;border-radius:9px;color:#795a1c;font-size:13px}.flash{margin-bottom:18px}.empty{background:#fff;border:1px dashed #cbd5e1;border-radius:13px;padding:35px;text-align:center;color:var(--muted)}.inline-form{display:flex;gap:12px;align-items:center}.inline-form input{flex:1;margin:0}.list-row{padding:12px;border-bottom:1px solid var(--line)}footer{text-align:center;padding:24px;color:var(--muted);font-size:12px;border-top:1px solid var(--line);background:#fff}@media(max-width:850px){.cards{grid-template-columns:repeat(2,1fr)}.program-grid{grid-template-columns:repeat(2,1fr)}.top{padding:0 18px}.top nav{gap:12px}.stats{grid-template-columns:repeat(2,1fr)}}@media(max-width:580px){.top{height:auto;padding:14px;align-items:flex-start}.top nav{flex-wrap:wrap;justify-content:flex-end;font-size:12px}.brand small{max-width:160px}.container{padding:20px 15px 45px}.hero{padding:45px 25px}.cards,.admin-grid,.form-grid{grid-template-columns:1fr}.span2{grid-column:span 1}.program-grid{grid-template-columns:1fr}.section-head{display:block}.stats{gap:8px}.stat{padding:15px}.book{padding:12px}.detail{grid-template-columns:1fr;padding:20px}.cover.large{width:130px;height:180px}.inline-form{align-items:stretch;flex-direction:column}}

/* Dashboard administrativo FHPA */
.admin-body{background:#f3f6fa}.admin-body .top{height:72px;padding:0 30px;position:sticky;top:0;z-index:30;box-shadow:0 2px 12px #172b4608}.admin-body .top nav{gap:22px}.admin-body .top nav form{display:inline-flex}.user{display:inline-flex;align-items:center;gap:9px}.user-dot{width:30px;height:30px;border-radius:50%;display:inline-grid;place-items:center;background:#e8eef6;color:var(--navy);font-size:12px;font-weight:800}.admin-shell{display:flex;min-height:calc(100vh - 72px)}.admin-sidebar{width:248px;flex:0 0 248px;background:#142b4a;color:#dce7f4;padding:28px 16px 18px;display:flex;flex-direction:column;position:relative;z-index:20}.sidebar-label{font-size:10px;font-weight:800;letter-spacing:1.5px;color:#8ea4bf;padding:0 13px 16px}.side-link{height:48px;padding:0 13px;border-radius:9px;display:flex;align-items:center;gap:13px;color:#c8d5e5;font-size:13px;font-weight:600;margin:3px 0;position:relative;transition:.18s}.side-link:hover{background:#ffffff12;color:#fff}.side-link.active{background:#ffffff18;color:#fff}.side-link.active:before{content:"";position:absolute;left:-16px;top:9px;bottom:9px;width:3px;background:#e0b65d;border-radius:0 3px 3px 0}.side-link i{margin-left:auto;width:6px;height:6px;border-radius:50%;background:#e0b65d}.side-icon{width:22px;text-align:center;font-size:19px;color:#dcb65e}.sidebar-bottom{margin-top:auto;padding:18px 8px 0;border-top:1px solid #ffffff20}.sidebar-mini{display:flex;align-items:center;gap:10px}.mini-mark{width:34px;height:34px;border-radius:9px;background:#e0b65d;color:#142b4a;display:grid;place-items:center;font:800 11px Manrope}.sidebar-mini b,.sidebar-mini small{display:block}.sidebar-mini b{font:700 12px Manrope;color:#fff}.sidebar-mini small{font-size:10px;color:#9fb1c7;margin-top:3px}.admin-content{min-width:0;flex:1;display:flex;flex-direction:column}.admin-main{width:100%;max-width:1500px;margin:0 auto;padding:36px 42px 55px;flex:1}.admin-content footer{background:transparent;border-top:1px solid #e2e8f0;padding:18px}.admin-mobilebar{display:none}.admin-main .page-title{margin:0 0 25px}.admin-main .page-title h1,.dashboard-heading h1{font:800 29px Manrope;color:#172b46;letter-spacing:-.7px}.admin-main .page-title p,.dashboard-heading p{font-size:13px;margin:8px 0 0}.dashboard-heading{display:flex;align-items:center;justify-content:space-between;gap:20px;margin:0 0 28px}.dashboard-heading h1{margin:0}.dashboard-heading .btn{white-space:nowrap}.admin-main .stats{gap:18px;margin-bottom:34px}.admin-main .stat{border:1px solid #e8edf3;border-radius:14px;padding:21px 23px;box-shadow:0 4px 15px #1e3a5a06;position:relative;overflow:hidden}.admin-main .stat:after{content:"";position:absolute;right:-18px;top:-22px;width:82px;height:82px;border-radius:50%;background:#edf3f9}.admin-main .stat strong{font-size:32px;position:relative;z-index:1}.admin-main .stat span{display:block;margin-top:4px;position:relative;z-index:1}.quick-section{margin-top:5px}.quick-section .section-head h2{font:700 20px Manrope;margin:0 0 17px;color:#172b46}.quick-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}.quick-grid a{min-height:164px;background:#fff;border:1px solid #e6ebf1;border-radius:14px;padding:20px;display:flex;flex-direction:column;align-items:flex-start;position:relative;transition:transform .18s,box-shadow .18s,border-color .18s}.quick-grid a:hover{transform:translateY(-3px);box-shadow:0 12px 26px #142b4a12;border-color:#cbd8e7}.quick-symbol{width:38px;height:38px;display:grid;place-items:center;border-radius:10px;background:#edf3f9;color:#245b91;font-size:20px;margin-bottom:14px}.quick-grid b{font:700 15px Manrope;color:#172b46;margin-bottom:6px}.quick-grid small{font-size:11px;line-height:1.5;color:#748297;max-width:210px}.quick-arrow{position:absolute;right:18px;top:25px;color:#9aa9bb;font-size:19px}.admin-main .panel{border:1px solid #e7ecf2;border-radius:14px;box-shadow:0 4px 15px #1e3a5a05;margin-bottom:18px}.admin-main .panel h2{color:#172b46}.admin-main .form-grid{gap:8px 18px}.admin-main th{background:#f8fafc}.admin-main td,.admin-main th{padding:13px 14px}.admin-main .inline-form{margin-bottom:18px}.admin-main .flash{margin-bottom:20px}.sidebar-toggle{border:0;background:#edf2f8;color:#173451;border-radius:8px;padding:8px 11px;font-size:18px;cursor:pointer}
@media(max-width:1100px){.quick-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.admin-main{padding:30px 26px 45px}}
@media(max-width:760px){.admin-body .top{height:auto;min-height:66px;padding:12px 15px}.admin-body .top nav{gap:10px;font-size:12px}.admin-body .brand small{max-width:175px}.admin-shell{min-height:calc(100vh - 66px)}.admin-sidebar{position:fixed;left:0;top:66px;bottom:0;width:250px;transform:translateX(-105%);transition:transform .22s;box-shadow:12px 0 25px #142b4a22}.admin-sidebar.open{transform:translateX(0)}.admin-mobilebar{display:flex;align-items:center;gap:12px;padding:12px 17px;background:#fff;border-bottom:1px solid #e5ebf2;color:#52657d;font-size:13px;font-weight:700}.admin-main{padding:24px 16px 38px}.dashboard-heading{align-items:flex-start;flex-direction:column}.admin-main .stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.admin-main .stat{padding:16px}.admin-main .stat strong{font-size:27px}}
@media(max-width:480px){.quick-grid{grid-template-columns:1fr}.quick-grid a{min-height:135px}.admin-body .top .brand b{font-size:14px}.admin-body .top .brand small{font-size:9px}.admin-body .top nav .user{display:none}.admin-main .stats{grid-template-columns:repeat(2,minmax(0,1fr))}}
/* Herramientas de gestión: filtros, estados y acciones compactas */
.panel-heading{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-bottom:14px}.panel-heading h2{margin:0 0 4px!important}.panel-heading p{margin:0}.filter-bar{display:flex;align-items:center;gap:9px;flex-wrap:wrap;margin:0 0 18px}.filter-bar input{flex:1 1 230px;min-width:180px;margin:0}.filter-bar select{width:auto;min-width:145px;margin:0}.filter-bar .btn{white-space:nowrap}.inline-action{display:inline-flex;margin:0}.btn.tiny{padding:7px 10px;font-size:11px}.status{display:inline-flex;align-items:center;padding:5px 9px;border-radius:30px;font-size:11px;font-weight:700;background:#eef2f7;color:#536477}.status.activo,.status.publicado{background:#e8f6ee;color:#247447}.status.inactivo{background:#fff0f0;color:#a33d3d}.status.borrador{background:#fff5df;color:#936a17}.empty-cell{text-align:center;color:#718096;padding:25px!important}.admin-main .filter-bar input,.admin-main .filter-bar select{font-size:12px}.admin-main .table-wrap{border-radius:9px}
@media(max-width:620px){.filter-bar{align-items:stretch}.filter-bar input,.filter-bar select,.filter-bar .btn{width:100%;flex:1 1 100%}.panel-heading{align-items:flex-start}.admin-main .table-wrap table{min-width:650px}}

/* Formularios de alta en páginas independientes */
.module-toolbar{display:flex;align-items:center;justify-content:space-between;gap:18px;padding:18px 20px;margin:0 0 20px;background:#fff;border:1px solid #e5eaf1;border-radius:14px;box-shadow:0 5px 18px rgba(22,42,70,.04)}
.module-toolbar h2{margin:0 0 4px;font-size:17px;color:#1d2c42}.module-toolbar p{margin:0;font-size:12px}
.form-actions{display:flex;justify-content:flex-end;gap:10px;padding-top:12px;border-top:1px solid #edf0f4;margin-top:8px}
.admin-main>.panel.form-grid{max-width:980px;padding:24px}
.admin-main .page-title{margin-bottom:22px}
@media(max-width:620px){.module-toolbar{align-items:stretch;flex-direction:column}.module-toolbar .btn{width:100%;text-align:center}.form-actions{flex-direction:column-reverse}.form-actions .btn{width:100%;text-align:center}}

/* Selector global de tema claro/oscuro */
.theme-toggle{display:inline-flex;align-items:center;justify-content:center;gap:7px;border:1px solid var(--line);background:var(--bg);color:var(--ink);border-radius:9px;padding:8px 11px;font:600 12px 'DM Sans',sans-serif;cursor:pointer;white-space:nowrap;transition:background .2s,border-color .2s,color .2s}
.theme-toggle:hover{border-color:var(--gold)}.theme-icon{font-size:17px;line-height:1}
body[data-theme="dark"]{--ink:#e5edf7;--muted:#a7b5c7;--line:#344459;--bg:#101923;--white:#182432;background:var(--bg);color:var(--ink);color-scheme:dark}
body[data-theme="dark"] .top,body[data-theme="dark"] footer,body[data-theme="dark"] .book,body[data-theme="dark"] .login,body[data-theme="dark"] .stat,body[data-theme="dark"] .panel,body[data-theme="dark"] .admin-grid a,body[data-theme="dark"] .detail,body[data-theme="dark"] .empty,body[data-theme="dark"] .module-toolbar,body[data-theme="dark"] .program-grid div{background:#182432;color:var(--ink);border-color:var(--line)}
body[data-theme="dark"] .top{box-shadow:0 2px 12px #0005}body[data-theme="dark"] .brand,body[data-theme="dark"] .admin-main .page-title h1,body[data-theme="dark"] .dashboard-heading h1,body[data-theme="dark"] .quick-section .section-head h2,body[data-theme="dark"] .admin-main .panel h2,body[data-theme="dark"] .quick-grid b,body[data-theme="dark"] .module-toolbar h2,body[data-theme="dark"] .admin-grid b{color:#e5edf7}
body[data-theme="dark"] .brand small,body[data-theme="dark"] .admin-main .page-title p,body[data-theme="dark"] .dashboard-heading p,body[data-theme="dark"] .quick-grid small,body[data-theme="dark"] .module-toolbar p{color:#a7b5c7}
body[data-theme="dark"] input,body[data-theme="dark"] select,body[data-theme="dark"] textarea{background:#101923;color:#e5edf7;border-color:#42546b}
body[data-theme="dark"] input::placeholder,body[data-theme="dark"] textarea::placeholder{color:#8b9bb0}
body[data-theme="dark"] th{background:#202f40;color:#aebed0}body[data-theme="dark"] td,body[data-theme="dark"] th{border-color:#344459}
body[data-theme="dark"] .admin-content footer{border-color:#344459}body[data-theme="dark"] .admin-mobilebar{background:#182432;border-color:#344459;color:#d5e0ed}
body[data-theme="dark"] .sidebar-toggle{background:#29394c;color:#e5edf7}body[data-theme="dark"] .quick-grid a{background:#182432;border-color:#344459}body[data-theme="dark"] .quick-symbol{background:#26384c;color:#9bc4ef}
body[data-theme="dark"] .programs{background:#1c2b3b}body[data-theme="dark"] .btn.outline{background:#26384c;color:#e5edf7;border-color:#42546b}
body[data-theme="dark"] .notice,body[data-theme="dark"] .flash{background:#3a3020;border-color:#76603a;color:#f1d69c}
body[data-theme="dark"] .status{background:#29394c;color:#d2deeb}body[data-theme="dark"] .status.activo,body[data-theme="dark"] .status.publicado{background:#173d31;color:#9ce0bb}body[data-theme="dark"] .status.inactivo{background:#482b30;color:#ffb8bf}body[data-theme="dark"] .status.borrador{background:#49391d;color:#f3d18a}
body[data-theme="dark"] .theme-toggle{background:#26384c;border-color:#42546b;color:#f3d18a}
body[data-theme="dark"] .admin-sidebar{background:#0c1c2d}body[data-theme="dark"] .hero{background:linear-gradient(115deg,#0c2038,#183e65)}
body[data-theme="dark"] .cover{box-shadow:0 5px 12px #0005}
@media(max-width:580px){.theme-toggle .theme-label{display:none}.theme-toggle{padding:8px 10px}}


/* FASE 7 · Lector digital PDF */
.reader-page{max-width:1120px;margin:8px auto 30px}.reader-heading{display:flex;align-items:center;justify-content:space-between;gap:18px;margin-bottom:18px}.reader-heading h1{font:800 clamp(22px,3vw,30px) Manrope;margin:0 0 6px}.reader-heading p{margin:0;color:var(--muted);font-size:13px}.reader-toolbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;background:#fff;border:1px solid var(--line);border-radius:12px 12px 0 0;padding:12px}.reader-toolbar button:disabled{opacity:.45;cursor:not-allowed}.reader-page-count{font-size:13px;color:var(--muted)}.reader-spacer{flex:1}.reader-stage{position:relative;min-height:520px;display:flex;justify-content:center;align-items:flex-start;overflow:auto;background:#dce3eb;border:1px solid var(--line);border-top:0;padding:28px 18px}.reader-stage canvas{display:block;max-width:100%;height:auto;box-shadow:0 5px 22px #142b4a30;background:#fff}.reader-stage #readerLoading{position:absolute;top:28px;left:0;right:0;text-align:center;color:#334155;font-size:14px;z-index:2}.reader-watermark{position:fixed;z-index:4;left:50%;top:50%;transform:translate(-50%,-50%) rotate(-28deg);color:rgba(30,50,75,.16);font-size:clamp(13px,2vw,22px);font-weight:800;white-space:nowrap;pointer-events:none;user-select:none}.reader-note{padding:12px 15px;background:#fff;border:1px solid var(--line);border-top:0;border-radius:0 0 12px 12px;color:var(--muted);font-size:12px;line-height:1.5}body[data-theme="dark"] .reader-toolbar,body[data-theme="dark"] .reader-note{background:#182432;color:#cbd5e1;border-color:var(--line)}body[data-theme="dark"] .reader-stage{background:#101923;border-color:var(--line)}body[data-theme="dark"] .reader-toolbar .btn.outline{background:#263748;color:#e5edf7;border-color:#40536a}body[data-theme="dark"] .reader-watermark{color:rgba(220,230,245,.18)}@media(max-width:650px){.reader-heading{align-items:flex-start;flex-direction:column}.reader-toolbar{gap:7px;padding:9px}.reader-toolbar .btn{padding:8px 10px}.reader-spacer{display:none}.reader-stage{min-height:400px;padding:14px 8px}.reader-watermark{font-size:12px}}

/* FASE 8 · Importación masiva de usuarios */
.toolbar-actions{display:flex;gap:9px;flex-wrap:wrap}.import-instructions{margin-bottom:18px;padding:22px}.import-instructions h2,.import-results h2{margin:0 0 10px;color:var(--ink)}.import-instructions p{font-size:13px;line-height:1.65;color:var(--muted)}.import-instructions code{display:inline-block;padding:9px 12px;border-radius:8px;background:#edf3f9;color:#23496f;font-size:12px;white-space:normal;overflow-wrap:anywhere}.import-results{padding:22px;margin-bottom:18px}.import-counts{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin:16px 0}.import-counts div{padding:14px;border:1px solid var(--line);border-radius:10px;display:flex;flex-direction:column;gap:4px}.import-counts strong{font-size:26px;color:var(--ink)}.import-counts span{font-size:12px;color:var(--muted)}.import-errors{max-height:260px;overflow:auto;background:#fff8ed;border:1px solid #f0dfc2;border-radius:9px;padding:10px 18px;color:#76531c;font-size:12px;line-height:1.6}.import-errors ul{margin:0;padding-left:18px}.import-instructions small{display:block;color:var(--muted);font-size:11px;font-weight:400;margin-top:5px;line-height:1.5}body[data-theme="dark"] .import-instructions code{background:#26384c;color:#d5e8ff}body[data-theme="dark"] .import-errors{background:#392f20;border-color:#6b5736;color:#f1d69c}
@media(max-width:620px){.toolbar-actions{flex-direction:column;width:100%}.toolbar-actions .btn{width:100%;text-align:center}.import-counts{grid-template-columns:1fr}}


/* FASE 9: administración avanzada de cuentas */
.user-actions{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.user-actions form{margin:0}
.profile-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;align-items:start}
.profile-grid .panel{min-width:0}
.profile-grid h2{margin:0 0 6px}
.profile-grid .muted{margin-top:0}
@media(max-width:850px){.profile-grid{grid-template-columns:1fr}.user-actions{min-width:180px}}

/* Fase 11: barra lateral persistente y gestión de portadas */
@media(min-width:761px){
 .admin-shell{align-items:flex-start}
 .admin-sidebar{position:sticky;top:72px;align-self:flex-start;height:calc(100vh - 72px);min-height:420px;overflow-y:auto;overscroll-behavior:contain}
}
.cover-preview-wrap{display:block;margin-top:10px}
.cover-preview{display:block;width:130px;height:180px;object-fit:cover;border:1px solid var(--line);border-radius:8px;background:#eef2f7;box-shadow:0 4px 14px #142b4a18}
.cover-preview[hidden]{display:none}
.field-help{display:block;margin-top:5px;color:var(--muted);font-size:11px;font-weight:400;line-height:1.5}
.detail .cover.large img{width:100%;height:100%;object-fit:cover}
body[data-theme="dark"] .cover-preview{background:#263748;border-color:var(--line)}
@media(max-width:760px){.admin-sidebar{height:auto;min-height:0;overflow-y:auto;overscroll-behavior:contain}}


/* FASE 13 · Pie inferior y menú lateral contraíble */
@media(min-width:761px){
 .admin-shell{margin-left:248px;min-height:calc(100vh - 72px)}
 .admin-sidebar{position:fixed;left:0;top:72px;bottom:0;width:248px;height:auto;min-height:0;overflow-y:auto;z-index:25;transition:width .2s ease;padding-top:18px}
 .admin-content{min-height:calc(100vh - 72px)}
 .admin-content footer{margin-top:auto;flex-shrink:0}
 .sidebar-head{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:38px;margin:0 2px 14px}
 .sidebar-head .sidebar-label{padding:0 10px;white-space:nowrap}
 .sidebar-collapse{width:34px;height:34px;flex:0 0 34px;border:1px solid #ffffff26;border-radius:8px;background:#ffffff12;color:#fff;font-size:25px;line-height:1;cursor:pointer}
 .sidebar-collapse:hover{background:#ffffff25}
 body.sidebar-collapsed .admin-shell{margin-left:76px}
 body.sidebar-collapsed .admin-sidebar{width:76px;padding-left:10px;padding-right:10px}
 body.sidebar-collapsed .sidebar-head{justify-content:center}
 body.sidebar-collapsed .sidebar-head .sidebar-label,
 body.sidebar-collapsed .side-link>span:not(.side-icon),
 body.sidebar-collapsed .side-link>i,
 body.sidebar-collapsed .sidebar-mini>span:not(.mini-mark){display:none}
 body.sidebar-collapsed .side-link{justify-content:center;padding:0;margin:4px 0}
 body.sidebar-collapsed .side-link.active:before{left:-10px}
 body.sidebar-collapsed .side-icon{width:auto;font-size:21px}
 body.sidebar-collapsed .sidebar-bottom{padding:15px 0 0;display:flex;justify-content:center}
 body.sidebar-collapsed .sidebar-mini{justify-content:center}
 body.sidebar-collapsed .sidebar-collapse{transform:none}
}
@media(max-width:760px){
 .admin-shell{margin-left:0;min-height:calc(100vh - 66px)}
 .admin-sidebar{top:66px;padding-top:18px}
 .sidebar-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
 .sidebar-collapse{display:none}
 .admin-content{min-height:calc(100vh - 66px)}
 .admin-content footer{margin-top:auto}
}

/* Pie de página al fondo de la ventana cuando el contenido es corto (portal y panel). */
body{min-height:100vh;display:flex;flex-direction:column}
body>.container{flex:1}
body>.admin-shell{flex:1}
body>footer{margin-top:auto}

/* FASE 14 · En escritorio, la barra lateral ocupa toda la altura del viewport. */
@media (min-width:761px){
 .admin-body .top{margin-left:248px;width:calc(100% - 248px)}
 .admin-sidebar{top:0;bottom:0;height:100vh;min-height:100vh}
 .admin-shell{margin-left:248px}
 body.sidebar-collapsed .admin-body .top{margin-left:76px;width:calc(100% - 76px)}
}
@media (max-width:760px){
 .admin-body .top{margin-left:0;width:100%}
 .admin-sidebar{top:66px;height:auto;min-height:0}
}

/* FASE 16 · Alertas y confirmaciones modernas FHPA */
.fhpa-modal-backdrop{position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(9,18,32,.58);backdrop-filter:blur(5px);opacity:0;visibility:hidden;transition:opacity .18s ease,visibility .18s ease}
.fhpa-modal-backdrop.is-visible{opacity:1;visibility:visible}
.fhpa-modal{width:min(100%,440px);padding:28px;border:1px solid var(--line);border-radius:20px;background:var(--surface,#fff);color:var(--ink);box-shadow:0 24px 80px rgba(0,0,0,.28);text-align:center;transform:translateY(12px) scale(.98);transition:transform .18s ease}
.fhpa-modal-backdrop.is-visible .fhpa-modal{transform:translateY(0) scale(1)}
.fhpa-modal-icon{width:58px;height:58px;margin:0 auto 16px;display:grid;place-items:center;border-radius:50%;background:#fff1df;color:#b45309;font-size:30px;font-weight:800;border:1px solid #f7d7ad}
.fhpa-modal-icon.is-danger{background:#fff0f0;color:#c62828;border-color:#ffd0d0}
.fhpa-modal h2{margin:0 0 10px;font-size:21px;letter-spacing:-.3px;color:var(--ink)}
.fhpa-modal p{margin:0 auto;max-width:360px;color:var(--muted);font-size:14px;line-height:1.65;overflow-wrap:anywhere}
.fhpa-modal-actions{display:flex;justify-content:center;gap:10px;margin-top:25px;flex-wrap:wrap}
.fhpa-modal-actions .btn{min-width:128px;justify-content:center}
body.modal-open{overflow:hidden}
.fhpa-toast-stack{position:fixed;right:22px;bottom:22px;z-index:10000;display:grid;gap:10px;max-width:min(390px,calc(100vw - 32px))}
.fhpa-toast{padding:13px 17px;border-radius:12px;background:#172b42;color:#fff;box-shadow:0 12px 35px rgba(0,0,0,.2);font-size:13px;line-height:1.5;animation:fhpa-toast-in .2s ease}
.fhpa-toast.is-error{background:#9f2525}
.fhpa-toast.is-leaving{opacity:0;transform:translateY(8px);transition:opacity .2s,transform .2s}
@keyframes fhpa-toast-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
body[data-theme="dark"] .fhpa-modal{background:#182432;border-color:#3b4b5d}
body[data-theme="dark"] .fhpa-modal-icon{background:#49371f;color:#f7c66d;border-color:#71542b}
body[data-theme="dark"] .fhpa-modal-icon.is-danger{background:#492629;color:#ff9b9b;border-color:#74363c}
@media(max-width:480px){.fhpa-modal{padding:23px 18px;border-radius:16px}.fhpa-modal-actions{flex-direction:column-reverse}.fhpa-modal-actions .btn{width:100%}.fhpa-toast-stack{right:12px;bottom:12px}}
/* Mensajes del sistema con presentación coherente con las nuevas alertas. */
.flash{position:relative;padding:14px 18px 14px 48px;border:1px solid #c9e8d5;border-left:4px solid #26945b;border-radius:12px;background:#f0fbf4;color:#17643b;box-shadow:0 5px 18px rgba(22,101,52,.06);line-height:1.5}
.flash:before{content:"✓";position:absolute;left:15px;top:50%;transform:translateY(-50%);width:22px;height:22px;display:grid;place-items:center;border-radius:50%;background:#d7f3e1;color:#187345;font-weight:800}
body[data-theme="dark"] .flash{background:#19372b;border-color:#315d45;border-left-color:#48b879;color:#c8f1d7}
body[data-theme="dark"] .flash:before{background:#28563c;color:#b7f0cc}

/* Filtros avanzados del catálogo público e institucional */
.catalog-filters{display:grid;gap:14px;margin:18px 0 26px;padding:18px;border:1px solid var(--line);border-radius:16px;background:var(--white);box-shadow:0 8px 24px rgba(20,40,65,.045)}
.catalog-search-row,.catalog-filter-row{display:grid;grid-template-columns:1.4fr 1fr;gap:12px;align-items:end}
.catalog-filter-row{grid-template-columns:repeat(3,minmax(150px,1fr)) auto}
.catalog-field{display:grid;gap:7px;min-width:0;color:var(--muted);font-size:12px;font-weight:700}
.catalog-field input,.catalog-field select{width:100%;min-width:0;min-height:43px;padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:var(--white);color:var(--ink);font:inherit;font-size:13px;outline:none}
.catalog-field input:focus,.catalog-field select:focus{border-color:var(--blue);box-shadow:0 0 0 3px rgba(38,102,158,.12)}
.catalog-filter-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.catalog-filter-actions .btn{min-height:43px;white-space:nowrap}
body[data-theme="dark"] .catalog-filters{background:var(--white);border-color:var(--line)}
@media(max-width:900px){.catalog-filter-row{grid-template-columns:repeat(2,minmax(0,1fr))}.catalog-filter-actions{grid-column:1/-1}}
@media(max-width:600px){.catalog-search-row,.catalog-filter-row{grid-template-columns:1fr}.catalog-filter-actions{grid-column:auto}.catalog-filter-actions .btn{flex:1;justify-content:center}}

/* FASE 18: catálogo visual en tarjetas y ficha bibliográfica modal */
.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(245px,1fr));gap:20px;align-items:stretch}
.book{display:flex;flex-direction:column;gap:13px;padding:16px;min-height:100%;transition:transform .18s ease,box-shadow .18s ease}
.book:hover{transform:translateY(-3px);box-shadow:0 12px 28px #142b4a12}
.book-cover-button{border:0;background:transparent;padding:0;cursor:pointer;align-self:center;width:100%;display:flex;justify-content:center}
.book .cover{width:100%;max-width:170px;min-width:0;height:210px;border-radius:9px}
.book .cover img{object-fit:cover}
.book-info{display:flex;flex-direction:column;flex:1;min-width:0}
.book-info h3{font-size:15px;min-height:40px}
.book-info .actions{margin-top:auto;padding-top:12px;display:flex;gap:8px;flex-wrap:wrap}
.book-info .actions .btn{white-space:nowrap}
.home-highlights{margin:30px 0}
.book-modal-backdrop{position:fixed;inset:0;background:rgba(8,20,36,.68);z-index:1200;display:none;align-items:center;justify-content:center;padding:22px;overflow-y:auto}
.book-modal-backdrop.is-visible{display:flex}
.book-modal{position:relative;background:var(--surface,#fff);color:var(--ink,#172b45);width:min(850px,100%);max-height:min(90vh,800px);overflow:auto;border-radius:20px;padding:30px;display:grid;grid-template-columns:190px minmax(0,1fr);gap:28px;box-shadow:0 25px 80px #0005}
.book-modal-close{position:absolute;right:14px;top:10px;border:0;background:transparent;font-size:30px;line-height:1;cursor:pointer;color:inherit}
.book-modal-cover{width:180px;height:250px;border-radius:10px;background:linear-gradient(145deg,#1c3b61,#3f709c);color:#fff;display:grid;place-content:center;text-align:center;font-weight:800;box-shadow:0 8px 22px #142b4a25;overflow:hidden}
.book-modal-cover img{width:100%;height:100%;object-fit:cover}
.book-modal-content h2{font:800 26px/1.25 Manrope;margin:5px 30px 8px 0}
.book-modal-author{color:var(--blue);font-weight:600}
.book-modal-content p{line-height:1.6}
.book-modal-content dl{display:grid;grid-template-columns:150px minmax(0,1fr);gap:9px 14px;font-size:13px;margin:18px 0}
.book-modal-content dt{color:var(--muted)}.book-modal-content dd{margin:0;font-weight:600;overflow-wrap:anywhere}
body.book-modal-open{overflow:hidden}
@media(max-width:620px){.book-modal{grid-template-columns:1fr;padding:24px 20px;gap:16px}.book-modal-cover{width:135px;height:185px;margin:0 auto}.book-modal-content h2{font-size:22px}.book-modal-content dl{grid-template-columns:120px 1fr}.cards{grid-template-columns:repeat(auto-fill,minmax(215px,1fr))}}
/* Fase 19: herramientas avanzadas del lector digital */
.reader-toolbar-main{border-radius:12px 12px 0 0}.reader-page-count input{width:66px;padding:6px 7px;border:1px solid var(--line);border-radius:7px;background:var(--surface,#fff);color:inherit;font:inherit;text-align:center}.reader-progress{display:flex;align-items:center;gap:12px;padding:10px 14px;background:var(--surface,#fff);border:1px solid var(--line);border-top:0}.reader-progress-track{height:7px;flex:1;overflow:hidden;border-radius:99px;background:#e2e8f0}.reader-progress-track span{display:block;width:0;height:100%;border-radius:99px;background:var(--accent,#2563eb);transition:width .2s ease}.reader-progress small{font-size:11px;color:var(--muted);white-space:nowrap}.reader-bookmark-tools{position:relative;display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:10px 12px;background:var(--surface,#fff);border:1px solid var(--line);border-top:0}.reader-bookmark-tools .muted{font-size:12px}.reader-bookmark-list{position:absolute;z-index:8;top:calc(100% + 5px);left:12px;min-width:210px;max-width:min(320px,calc(100vw - 40px));max-height:240px;overflow:auto;padding:8px;background:var(--surface,#fff);border:1px solid var(--line);border-radius:10px;box-shadow:0 12px 35px #0f172a25}.reader-bookmark-item{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:5px;border-bottom:1px solid var(--line)}.reader-bookmark-item:last-child{border-bottom:0}.reader-bookmark-item button{border:0;background:transparent;color:inherit;cursor:pointer;padding:6px 8px;border-radius:6px}.reader-bookmark-item .bookmark-go{flex:1;text-align:left}.reader-bookmark-item button:hover{background:var(--soft,#eef2ff)}.reader-bookmark-item .bookmark-remove{font-size:18px;color:#dc2626}.reader-stage:fullscreen{width:100vw;height:100vh;min-height:100vh;box-sizing:border-box;align-items:flex-start;overflow:auto;padding:28px;background:#dce3eb}.reader-stage:fullscreen canvas{max-width:none}.reader-stage:fullscreen .reader-watermark{position:fixed}body[data-theme="dark"] .reader-progress,body[data-theme="dark"] .reader-bookmark-tools,body[data-theme="dark"] .reader-bookmark-list{background:#182432;color:#e5edf7;border-color:var(--line)}body[data-theme="dark"] .reader-page-count input{background:#263748;color:#e5edf7;border-color:#40536a}body[data-theme="dark"] .reader-progress-track{background:#334155}body[data-theme="dark"] .reader-stage:fullscreen{background:#101923}@media(max-width:650px){.reader-progress{align-items:flex-start;flex-direction:column;gap:6px}.reader-progress-track{width:100%;flex:none}.reader-bookmark-tools{align-items:flex-start}.reader-bookmark-tools .muted{width:100%}.reader-page-count input{width:54px}}
/* Fase 20: biblioteca personal y favoritos */
.favorite-form{display:inline-flex;margin:8px 0 0;}
.favorite-button{border-color:#e7c5cf!important;color:#9b3453!important;background:#fff8fa!important;}
.favorite-button:hover{background:#fdebf1!important;border-color:#d98ba4!important;}
body[data-theme="dark"] .favorite-button{background:#342431!important;color:#ffc2d4!important;border-color:#684154!important;}
body[data-theme="dark"] .favorite-button:hover{background:#493044!important;}
@media(max-width:580px){.favorite-form{display:flex}.favorite-form .btn{width:100%}}

/* ==========================================================
   FASE 21 · SISTEMA DE DISEÑO INTEGRAL FHPA
   Capa de normalización visual para todas las vistas.
   No modifica lógica, rutas ni estructura de datos.
   ========================================================== */
:root{
 --navy:#153451;--blue:#28679b;--gold:#d6ad62;--ink:#1c2b3a;--muted:#65778b;
 --line:#e3eaf1;--bg:#f4f7fb;--white:#fff;--surface:#fff;--soft:#edf3f8;
 --shadow-sm:0 2px 8px rgba(20,48,76,.045);--shadow-md:0 10px 28px rgba(20,48,76,.075);
 --radius-sm:9px;--radius-md:14px;--radius-lg:20px;
}
html{scroll-behavior:smooth;scroll-padding-top:90px}
body{background:var(--bg);color:var(--ink);font-size:14px;line-height:1.55;-webkit-font-smoothing:antialiased}
body,button,input,select,textarea{font-family:'DM Sans',system-ui,-apple-system,'Segoe UI',sans-serif}
h1,h2,h3,h4,.brand b,.page-title h1,.dashboard-heading h1{font-family:'Manrope','DM Sans',sans-serif;letter-spacing:-.025em}
img,svg,canvas{max-width:100%}
button,a,input,select,textarea{ -webkit-tap-highlight-color:transparent }
a{transition:color .16s ease}
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{outline:3px solid rgba(40,103,155,.28);outline-offset:2px}
.top{height:74px;padding-inline:max(calc((100% - 1280px)/2),clamp(16px,3vw,42px));gap:18px;background:var(--surface);border-color:var(--line);box-shadow:var(--shadow-sm)}
.brand{min-width:0;gap:11px}.brand b{font-size:15px}.brand small{font-size:10px;line-height:1.35}
.mark{width:40px;height:40px;border-radius:12px;background:linear-gradient(145deg,#183b5d,#28679b);box-shadow:0 5px 12px #15345124}
.top nav{gap:clamp(10px,1.5vw,22px);font-size:13px;flex-wrap:wrap;justify-content:flex-end}
.top nav>a:not(.btn),.top nav>.link{color:var(--muted);font-weight:600}.top nav>a:not(.btn):hover,.top nav>.link:hover{color:var(--blue)}
.theme-toggle{display:inline-flex;align-items:center;gap:7px;padding:8px 11px;border:1px solid var(--line);border-radius:10px;background:var(--surface);color:var(--ink);font:600 12px 'DM Sans',sans-serif;cursor:pointer;white-space:nowrap;transition:.18s}
.theme-toggle:hover{border-color:#a9bfd2;background:var(--soft)}.theme-icon{font-size:16px;line-height:1}
.container{max-width:1280px;padding:34px clamp(16px,3vw,34px) 64px;min-height:calc(100vh - 145px)}
.hero{border-radius:24px;padding:clamp(38px,6vw,76px) clamp(24px,6vw,76px);background:radial-gradient(circle at 85% 20%,#ffffff1b,transparent 28%),linear-gradient(120deg,#132d49 0%,#1e4d77 58%,#286b9e 100%);box-shadow:0 18px 45px #15345120}
.hero h1{font-size:clamp(34px,5vw,60px);letter-spacing:-.045em;line-height:1.08}.hero p{font-size:15px;max-width:620px}
.btn{min-height:40px;padding:10px 16px;border-radius:10px;background:linear-gradient(135deg,#e2bd75,#d2a653);font-weight:700;box-shadow:0 2px 5px #15345112;transition:transform .16s,box-shadow .16s,filter .16s}
.btn:hover{transform:translateY(-1px);box-shadow:0 6px 14px #1534511b;filter:saturate(1.06)}.btn:active{transform:translateY(0)}
.btn.outline{background:var(--surface);color:var(--navy);border:1px solid var(--line);box-shadow:none}.btn.outline:hover{background:var(--soft);border-color:#b8c9d8}
.btn.danger{background:#b93838;color:#fff}.btn.small{min-height:34px;padding:8px 12px}
.section{padding:42px 0 24px}.section h2,.programs h2{font-size:clamp(20px,2.3vw,26px);letter-spacing:-.035em}
.section-head{margin-bottom:14px}.section-head h2{margin-bottom:5px}
.cards{gap:18px}.book{background:var(--surface);border:1px solid var(--line);border-radius:16px;box-shadow:var(--shadow-sm);padding:16px;min-width:0}
.book:hover{border-color:#c7d6e4;box-shadow:var(--shadow-md)}.book .cover{border-radius:10px;box-shadow:0 8px 18px #15345120}
.book-info h3{font-size:15px;line-height:1.4;overflow-wrap:anywhere}.book p{line-height:1.5}.book-info .actions .btn{font-size:12px;min-height:36px;padding:8px 11px}
.programs{background:var(--soft);border:1px solid var(--line);border-radius:18px}.program-grid div{border-radius:12px;box-shadow:var(--shadow-sm);line-height:1.45}
.login{border-radius:20px;padding:clamp(24px,4vw,38px);box-shadow:0 18px 48px rgba(21,52,81,.09);background:var(--surface)}
.login h1,.page-title h1{letter-spacing:-.04em}.login p,.page-title p{font-size:13px}
label{color:var(--ink);font-size:12px;font-weight:700;margin-bottom:13px}
input,select,textarea{min-height:42px;padding:10px 12px;margin-top:6px;border:1px solid #cbd7e2;border-radius:10px;background:var(--surface);color:var(--ink);font-size:13px;transition:border-color .15s,box-shadow .15s}
textarea{min-height:100px;resize:vertical}input:focus,select:focus,textarea:focus{outline:0;border-color:#6b9bc2;box-shadow:0 0 0 3px rgba(40,103,155,.12)}input::placeholder,textarea::placeholder{color:#91a0af}
.page-title{margin:0 0 24px}.page-title h1{font-size:clamp(25px,3vw,32px)}.eyebrow{letter-spacing:1.6px;font-size:10px}
.stats{gap:14px}.stat,.panel,.admin-grid a{background:var(--surface);border:1px solid var(--line);border-radius:15px;box-shadow:var(--shadow-sm)}
.stat{padding:20px}.stat strong{font-size:clamp(25px,3vw,32px)}
.panel{padding:21px}.panel h2{font-size:18px}.admin-grid{gap:15px}.admin-grid a{padding:20px;transition:.18s}.admin-grid a:hover{transform:translateY(-2px);box-shadow:var(--shadow-md);border-color:#bfd0df}
.form-grid{gap:12px 18px}.form-grid fieldset{border-color:var(--line);border-radius:12px}
.table-wrap{width:100%;overflow-x:auto;border:1px solid var(--line);border-radius:12px;background:var(--surface);-webkit-overflow-scrolling:touch}
table{font-size:12px;min-width:100%;border-collapse:separate;border-spacing:0}
th{background:#f5f8fb;color:#63758a;font-size:10px;letter-spacing:.65px;font-weight:800;white-space:nowrap}
th,td{padding:12px 14px;border-bottom:1px solid var(--line);vertical-align:middle}
tbody tr:last-child td{border-bottom:0}tbody tr:hover td{background:rgba(40,103,155,.035)}td{overflow-wrap:anywhere}
.status{padding:5px 10px;border-radius:7px;font-size:10px;letter-spacing:.15px}
.detail{border-radius:18px;box-shadow:var(--shadow-sm);background:var(--surface)}.detail h1{font-size:clamp(24px,3vw,32px)}
.notice,.flash{border-radius:12px;line-height:1.55}.empty{border-radius:15px;background:var(--surface)}
footer{background:var(--surface);border-color:var(--line);line-height:1.5}
/* Panel administrativo: misma identidad que el portal, con navegación fija y clara. */
.admin-body{background:var(--bg)}.admin-body .top{height:72px;padding-inline:clamp(16px,2.5vw,34px)}
.admin-shell{min-height:calc(100vh - 72px)}.admin-sidebar{background:linear-gradient(180deg,#153451 0%,#102940 100%);box-shadow:5px 0 22px rgba(12,35,56,.07)}
.admin-main{max-width:1560px;padding:clamp(24px,3vw,40px) clamp(18px,3vw,44px) 54px}
.admin-main .page-title h1,.dashboard-heading h1{font-size:clamp(25px,2.5vw,30px);color:var(--ink)}
.admin-main .stat,.admin-main .panel{background:var(--surface);border-color:var(--line);box-shadow:var(--shadow-sm)}
.admin-main .panel h2,.quick-section .section-head h2{color:var(--ink)}
.admin-main th{background:#f5f8fb}.quick-grid a{background:var(--surface);border-color:var(--line);border-radius:15px;box-shadow:var(--shadow-sm)}
.quick-grid a:hover{border-color:#bfd0df;box-shadow:var(--shadow-md)}
.quick-symbol{border-radius:11px;background:#eaf1f7}.sidebar-collapse,.sidebar-toggle{border-radius:9px}
.admin-content footer{color:var(--muted);border-color:var(--line)}
/* Filtros, formularios de administración y acciones en línea. */
.catalog-filters,.report-filters{background:var(--surface);border:1px solid var(--line);border-radius:15px;box-shadow:var(--shadow-sm)}
.catalog-field input,.catalog-field select{border-radius:10px}.filter-bar{gap:10px}.filter-bar input,.filter-bar select{min-height:40px}
.inline-form{flex-wrap:wrap}.inline-form input{min-width:180px}.inline-action{vertical-align:middle}
.favorite-button{border-radius:9px!important}
/* Modal bibliográfico, confirmaciones y ventanas emergentes. */
.book-modal{background:var(--surface);border:1px solid var(--line);color:var(--ink)}
.book-modal-close{width:36px;height:36px;border-radius:9px}.book-modal-close:hover{background:var(--soft)}
.fhpa-modal{background:var(--surface);border:1px solid var(--line);border-radius:20px}
.fhpa-toast-stack{right:clamp(12px,2vw,24px);bottom:clamp(12px,2vw,24px)}
/* Lector PDF: barra de herramientas compacta, controles adaptables. */
.reader-toolbar-main,.reader-progress,.reader-bookmark-tools{background:var(--surface);border-color:var(--line)}
.reader-toolbar-main{padding:12px;gap:9px;flex-wrap:wrap}.reader-toolbar-main button,.reader-toolbar-main .btn{min-height:36px}
.reader-stage{border:1px solid var(--line);border-radius:0 0 14px 14px;overflow:auto}
.reader-stage canvas{height:auto;max-width:100%;box-shadow:0 5px 22px rgba(15,35,55,.16)}
.reader-progress{border-radius:0 0 12px 12px}.reader-bookmark-tools{border-radius:0 0 12px 12px}
/* Modo oscuro real: elimina superficies blancas heredadas en todos los módulos. */
body[data-theme="dark"]{
 --ink:#e5edf6;--muted:#a7b7c9;--line:#34485d;--bg:#0e1823;--white:#172635;--surface:#172635;--soft:#203448;
 --navy:#d7e6f4;--blue:#82b7e4;color:var(--ink);background:var(--bg);color-scheme:dark;
 --shadow-sm:0 2px 9px rgba(0,0,0,.18);--shadow-md:0 12px 30px rgba(0,0,0,.28)
}
body[data-theme="dark"] .top,body[data-theme="dark"] footer,body[data-theme="dark"] .book,body[data-theme="dark"] .login,
body[data-theme="dark"] .stat,body[data-theme="dark"] .panel,body[data-theme="dark"] .admin-grid a,
body[data-theme="dark"] .detail,body[data-theme="dark"] .empty,body[data-theme="dark"] .program-grid div,
body[data-theme="dark"] .catalog-filters,body[data-theme="dark"] .report-filters,body[data-theme="dark"] .report-kpi,
body[data-theme="dark"] .quick-grid a,body[data-theme="dark"] .book-modal,body[data-theme="dark"] .fhpa-modal,
body[data-theme="dark"] .table-wrap{background:var(--surface);color:var(--ink);border-color:var(--line)}
body[data-theme="dark"] .theme-toggle{background:#203448;color:var(--ink);border-color:var(--line)}
body[data-theme="dark"] .theme-toggle:hover{background:#294158}
body[data-theme="dark"] .hero{background:radial-gradient(circle at 85% 20%,#ffffff13,transparent 28%),linear-gradient(120deg,#10283e,#173e60 60%,#20577f)}
body[data-theme="dark"] .programs{background:#172b3d;border-color:var(--line)}
body[data-theme="dark"] .program-grid div{background:#203448}
body[data-theme="dark"] input,body[data-theme="dark"] select,body[data-theme="dark"] textarea,
body[data-theme="dark"] .catalog-field input,body[data-theme="dark"] .catalog-field select,
body[data-theme="dark"] .reader-page-count input{background:#0f1d2a;color:var(--ink);border-color:#40566d}
body[data-theme="dark"] input::placeholder,body[data-theme="dark"] textarea::placeholder{color:#879caf}
body[data-theme="dark"] th,body[data-theme="dark"] .admin-main th{background:#203448;color:#b7c8d9}
body[data-theme="dark"] td,body[data-theme="dark"] th{border-color:var(--line)}
body[data-theme="dark"] tbody tr:hover td{background:#203448}
body[data-theme="dark"] .btn.outline{background:#203448;color:#e5edf6;border-color:#40566d}
body[data-theme="dark"] .btn.outline:hover{background:#294158}
body[data-theme="dark"] .admin-body .top{background:#172635}
body[data-theme="dark"] .admin-main .page-title h1,body[data-theme="dark"] .dashboard-heading h1,
body[data-theme="dark"] .admin-main .panel h2,body[data-theme="dark"] .quick-section .section-head h2,
body[data-theme="dark"] .quick-grid b,body[data-theme="dark"] .admin-grid b{color:var(--ink)}
body[data-theme="dark"] .admin-main .stat:after{background:#203448}
body[data-theme="dark"] .quick-symbol{background:#294158;color:#b9d8f1}
body[data-theme="dark"] .admin-mobilebar{background:#172635;border-color:var(--line);color:var(--ink)}
body[data-theme="dark"] .sidebar-toggle{background:#294158;color:#e5edf6}
body[data-theme="dark"] .admin-content footer{background:transparent;border-color:var(--line)}
body[data-theme="dark"] .status.activo,body[data-theme="dark"] .status.publicado{background:#1d4436;color:#a8e7c4}
body[data-theme="dark"] .status.inactivo{background:#482b30;color:#ffc0c0}
body[data-theme="dark"] .status.borrador{background:#493c24;color:#f3d28d}
body[data-theme="dark"] .flash{background:#19372b;border-color:#315d45;color:#c8f1d7}
body[data-theme="dark"] .notice{background:#40351f;border-color:#6b5730;color:#f2d89c}
body[data-theme="dark"] .book-modal-author{color:#8fc3ec}
body[data-theme="dark"] .bar-track,body[data-theme="dark"] .reader-progress-track{background:#34485d}
body[data-theme="dark"] .reader-stage{background:#0d1721;border-color:var(--line)}
body[data-theme="dark"] .reader-stage:fullscreen{background:#0d1721}
body[data-theme="dark"] .admin-sidebar{background:linear-gradient(180deg,#10283e,#0c2032)}
body[data-theme="dark"] .favorite-button{background:#342431!important;color:#ffc2d4!important;border-color:#684154!important}
/* Responsive global: no permitir que formularios o encabezados rompan el viewport. */
@media(max-width:900px){
 .top{height:auto;min-height:68px;padding:12px 18px;align-items:center}.top nav{gap:9px 13px}
 .container{padding-top:24px}.admin-main{padding:25px 20px 42px}
 .admin-main .stats{grid-template-columns:repeat(2,minmax(0,1fr))}
 .report-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:760px){
 .admin-body .top{height:auto;min-height:66px}.admin-shell{min-height:calc(100vh - 66px)}
 .admin-sidebar{top:66px;max-height:calc(100dvh - 66px);overflow-y:auto}
 .admin-main{padding:22px 16px 36px}.admin-mobilebar{position:sticky;top:0;z-index:25}
 .dashboard-heading{align-items:flex-start;flex-direction:column}.dashboard-heading .btn{width:100%}
 .admin-main>.panel.form-grid{max-width:none;padding:18px}
}
@media(max-width:620px){
 .top{align-items:flex-start;flex-direction:column;gap:10px;padding:12px 14px}
 .top nav{width:100%;justify-content:flex-start;gap:8px 12px;font-size:12px}
 .top nav .user{display:none}.brand small{max-width:none}
 .theme-toggle{padding:7px 9px}.container{padding:18px 14px 38px}
 .hero{padding:38px 23px;border-radius:18px;min-height:0}.hero h1{font-size:clamp(31px,9vw,42px)}
 .section{padding:32px 0 18px}.section-head{align-items:flex-start;flex-direction:column}
 .cards{grid-template-columns:repeat(auto-fill,minmax(min(100%,220px),1fr));gap:13px}
 .book{padding:13px}.book .cover{height:190px}
 .stats,.admin-main .stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
 .stat,.admin-main .stat{padding:14px}.stat strong,.admin-main .stat strong{font-size:24px}
 .form-grid,.admin-grid{grid-template-columns:1fr}.span2{grid-column:auto}
 .detail{grid-template-columns:1fr;padding:18px;gap:18px}.detail dl{grid-template-columns:110px minmax(0,1fr)}
 .panel{padding:15px}.panel-heading,.report-section-head{align-items:flex-start;flex-direction:column}
 .panel-heading .btn,.report-section-head .btn{width:100%}
 .filter-bar{align-items:stretch}.filter-bar input,.filter-bar select,.filter-bar .btn{width:100%;flex:1 1 100%;min-width:0}
 .catalog-search-row,.catalog-filter-row{grid-template-columns:1fr}.catalog-filter-actions{grid-column:auto}
 .report-filters>div{align-items:stretch;flex-direction:column}.report-filters label{width:100%;min-width:0}
 .report-two-col{grid-template-columns:1fr}.report-title{align-items:stretch;flex-direction:column}.report-title>.btn{width:100%}
 .book-modal-backdrop{padding:10px}.book-modal{max-height:94dvh;padding:22px 17px;border-radius:16px}
 .book-modal-content dl{grid-template-columns:105px minmax(0,1fr);gap:8px}
 .reader-toolbar-main{align-items:stretch}.reader-toolbar-main>*{max-width:100%}
 .inline-form{align-items:stretch;flex-direction:column}.inline-form input{min-width:0}
}
@media(max-width:380px){
 .top nav{gap:7px}.top nav .btn{padding:7px 9px}.theme-label{display:none}
 .stats,.admin-main .stats,.report-kpis{grid-template-columns:1fr 1fr}
 .book .cover{height:170px}.book-info .actions .btn{flex:1}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}

/* Corrección de alineación de filtros: neutraliza el margen global heredado de label. */
.catalog-field{margin:0!important;align-self:end}
.catalog-filter-actions{align-items:flex-end!important;margin:0!important;padding:0!important}
.catalog-filter-actions .btn{height:43px;min-height:43px;box-sizing:border-box}


/* Corrección móvil del menú administrativo: panel completo, desplazable y con cierre visible. */
.sidebar-mobile-close{display:none;width:36px;height:36px;flex:0 0 36px;border:1px solid #ffffff35;border-radius:9px;background:#ffffff12;color:#fff;font-size:25px;line-height:1;cursor:pointer;align-items:center;justify-content:center}
@media(max-width:760px){
 .admin-sidebar{position:fixed!important;inset:0 auto 0 0!important;width:min(290px,86vw)!important;height:100vh!important;height:100dvh!important;max-height:100vh!important;max-height:100dvh!important;min-height:0!important;padding:calc(18px + env(safe-area-inset-top,0px)) 16px calc(18px + env(safe-area-inset-bottom,0px))!important;overflow-x:hidden!important;overflow-y:auto!important;overscroll-behavior:contain!important;z-index:1000!important;transform:translateX(-105%);visibility:hidden;transition:transform .22s ease,visibility .22s ease}
 .admin-sidebar.open{transform:translateX(0)!important;visibility:visible}
 .sidebar-head{display:flex!important;align-items:center;justify-content:space-between;gap:8px;min-height:42px;margin:0 0 16px!important}
 .sidebar-head .sidebar-label{display:block!important;padding:0 8px!important;white-space:nowrap}
 .sidebar-mobile-close{display:inline-flex!important}
 .sidebar-collapse{display:none!important}
 .admin-sidebar .side-link{display:flex!important;min-height:48px;height:48px;flex:0 0 48px;visibility:visible!important;opacity:1!important}
 .admin-sidebar .side-link>span:not(.side-icon){display:inline!important;visibility:visible!important}
 .admin-sidebar .side-link.active:before{left:-16px}
 .admin-sidebar .sidebar-bottom{margin-top:20px!important;flex:0 0 auto}
}

/* FASE 23: búsqueda inteligente y sugerencias accesibles */
.smart-search-wrap{position:relative;width:100%;}
.smart-search-wrap input{width:100%;}
.search-hint{display:block;margin-top:5px;color:var(--muted);font-size:11px;font-weight:500;}
.smart-search-suggestions{position:absolute;top:calc(100% + 7px);left:0;right:0;z-index:80;max-height:310px;overflow:auto;border:1px solid var(--line);border-radius:12px;background:var(--surface);box-shadow:0 16px 36px rgba(15,35,60,.16);padding:5px;}
.smart-search-suggestions[hidden]{display:none!important;}
.smart-suggestion{display:flex;width:100%;flex-direction:column;gap:3px;padding:10px 12px;border:0;border-radius:8px;background:transparent;color:var(--ink);text-align:left;cursor:pointer;}
.smart-suggestion strong{font-size:13px;font-weight:750;line-height:1.35;}
.smart-suggestion small{font-size:11px;color:var(--muted);}
.smart-suggestion:hover,.smart-suggestion.is-active{background:var(--surface-2,var(--line));}
.catalog-filter-row{grid-template-columns:repeat(4,minmax(130px,1fr)) auto;}
@media(max-width:1100px){.catalog-filter-row{grid-template-columns:repeat(2,minmax(0,1fr));}.catalog-filter-actions{grid-column:1/-1;}}
@media(max-width:600px){.catalog-filter-row{grid-template-columns:1fr;}.catalog-filter-actions{grid-column:auto;}.smart-search-suggestions{max-height:240px;}}
body[data-theme="dark"] .smart-search-suggestions{background:var(--surface);border-color:var(--line);box-shadow:0 16px 36px rgba(0,0,0,.4);}

/* Fase 24: acceso Google */
.google-login-wrap{margin:22px 0 18px;padding:18px 14px;border:1px solid var(--line);border-radius:12px;background:var(--surface,#fff);text-align:center}
#googleSignInButton{display:flex;justify-content:center;min-height:42px}
.google-hint{font-size:12px!important;line-height:1.5;margin:12px 0 0!important;color:var(--muted)}
.google-login-message{display:none;margin-top:12px;padding:10px 12px;border-radius:8px;font-size:12px;text-align:left}
.google-login-message:not(:empty){display:block}
.google-login-message.is-error{background:#fff0ef;color:#a52820;border:1px solid #f3c6c2}
.google-login-message.is-info{background:#edf5ff;color:#245b91;border:1px solid #c9def5}
.google-setup-note{margin:20px 0;padding:12px 14px;border:1px dashed #d7a84b;border-radius:9px;background:#fff9e9;color:#795a1c;font-size:12px;line-height:1.6}
.login-divider{display:flex;align-items:center;gap:12px;color:var(--muted);font-size:11px;margin:22px 0 0}
.login-divider:before,.login-divider:after{content:"";height:1px;background:var(--line);flex:1}
.login form{margin-top:18px}
body[data-theme="dark"] .google-login-wrap{background:#182432;border-color:var(--line)}
body[data-theme="dark"] .google-setup-note{background:#302b1e;color:#f2d38c;border-color:#76602d}

/* FASE 24.1: identidad institucional FHPA */
.brand{flex:0 1 auto;min-width:0;gap:0}.brand-logo{display:block;width:clamp(190px,26vw,300px);height:auto;max-height:62px;object-fit:contain;object-position:left center}.brand:hover{opacity:.94}
@media(max-width:760px){.brand-logo{width:clamp(160px,34vw,235px);max-height:54px}.top{gap:10px}}
@media(max-width:480px){.brand-logo{width:min(43vw,180px);max-height:48px}.top nav{gap:8px}}
