/* Adaptación progresiva: sin alterar estados, permisos ni reglas de negocio. */
.section-head.module-hero{border-bottom:0;gap:20px}
.section-head.module-hero>div{min-width:0}
.section-head.module-hero>.btn{flex-shrink:0;max-width:100%;white-space:normal}
.section-head.module-hero .eyebrow{color:inherit;opacity:.9}
/* El rol y las opciones se ajustan al ancho útil, incluida la barra vertical. */
.sidebar-scroll{min-width:0;overflow-x:hidden;overflow-y:auto;scrollbar-width:thin;scrollbar-color:#8295a5 transparent}
.sidebar-scroll::-webkit-scrollbar{width:6px;height:0}
.sidebar-scroll::-webkit-scrollbar-thumb{background:#8295a5;border-radius:8px}
.sidebar-scroll::-webkit-scrollbar-track{background:transparent}
.sidebar .role-card{min-width:0;max-width:100%;gap:8px;padding:12px}
.sidebar .role-card>div{flex:1;min-width:0;gap:9px}
.sidebar .role-card p{flex:1;min-width:0}
.sidebar .role-card b{max-width:100%;white-space:normal;overflow:visible;overflow-wrap:anywhere;text-overflow:clip;line-height:1.4}
.sidebar .role-icon{flex:0 0 38px}
.sidebar .role-card>i{flex:0 0 14px;font-size:calc(14px * var(--business-font-scale,1))}
.sidebar #mainNav,.sidebar .nav-item{min-width:0;max-width:100%}
.sidebar .nav-item>i{flex:0 0 22px}
.sidebar .nav-item>span{min-width:0;white-space:normal;overflow-wrap:anywhere}
@media(min-width:961px){
  .sidebar.collapsed .role-card>i{display:none}
  .sidebar.collapsed .role-card{padding:12px 0}
  .sidebar.collapsed .role-card>div{justify-content:center}
}
.erp-layout,.main{height:100dvh}
.content-wrapper{overscroll-behavior:contain;scrollbar-gutter:stable}
:where(button,a,input,select,textarea,summary):focus-visible{outline:3px solid #0798cc;outline-offset:3px}
:where(.history-identity,.document-name,.file-identity,.counterparty-card-head,.audit-event-content){overflow-wrap:anywhere}
.table-wrap{max-width:100%;overscroll-behavior-x:contain}
@media (min-width:961px) and (max-width:1360px){
  .sidebar{width:230px;min-width:230px}
  .sidebar-top img{width:150px}
  .topbar{gap:12px;padding-inline:16px}
  .top-title{min-width:0;flex:1}
  .top-title h1{font-size:calc(18px * var(--business-font-scale,1))}
  .top-title small{font-size:calc(12px * var(--business-font-scale,1))}
  .context-button{max-width:210px}
  .user-button{min-width:0}
  .user-button>span:nth-child(2){display:none}
  .approved-directory-card{grid-template-columns:54px minmax(0,1fr)}
  .approved-directory-card .approved-date{grid-column:1/-1;border-right:0;height:auto;flex-direction:row;gap:8px}
  .approved-directory-card .approved-document-summary{grid-column:2}
  .approved-directory-card .approved-actions{grid-column:1/-1}
  .organization-layout,.dashboard-layout,.dashboard-lower{grid-template-columns:1fr}
}
@media(max-width:960px){
  .topbar{padding-top:env(safe-area-inset-top);height:auto;min-height:calc(72px + env(safe-area-inset-top))}
  .content-wrapper{padding-bottom:calc(14px + env(safe-area-inset-bottom))}
  .modal{padding:12px}
  .modal-card{max-height:calc(100dvh - 24px);overscroll-behavior:contain}
  .pdf-viewer-card{height:calc(100dvh - 24px)}
  .module-hero h2,.history-hero h2{font-size:clamp(calc(24px * var(--business-font-scale,1)),calc(4vw * var(--business-font-scale,1)),calc(32px * var(--business-font-scale,1)))}
  .module-filter-grid,.audit-filter-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .module-filter-grid>*,.audit-filter-grid>*,.form-grid>*{min-width:0}
  .document-row{grid-template-columns:36px minmax(0,1fr);gap:10px}
  .document-row .document-status{grid-column:2;justify-self:start}
  .document-row-actions{grid-column:2;flex-wrap:wrap}
  .document-row-actions button,.document-row-actions a,.document-row-actions label{min-width:42px;min-height:42px;margin:0}
  .document-name>div{grid-template-columns:minmax(0,1fr);gap:8px}
  .document-rule-icons{justify-content:flex-start;width:auto}
  .document-name b{font-size:calc(13px * var(--business-font-scale,1));line-height:1.5}
  .document-name small{font-size:calc(12px * var(--business-font-scale,1));line-height:1.5}
  .btn,.table-action,.clear-filters{min-height:44px}
  .history-actions,.approved-actions{gap:8px;flex-wrap:wrap}
  .history-actions button,.history-pdf-menu>summary{min-height:44px}
  .notification-panel{max-height:calc(100dvh - 90px - env(safe-area-inset-top));overflow-y:auto}
  .notification-list{max-height:55dvh}
}
@media(max-width:600px){
  .topbar{display:grid;grid-template-columns:minmax(0,1fr);gap:8px;padding:12px 12px 10px;padding-top:calc(12px + env(safe-area-inset-top))}
  .top-title h1{font-size:calc(18px * var(--business-font-scale,1));white-space:normal;line-height:1.3}
  .top-actions{width:100%;gap:8px}
  .context-button{flex:1;max-width:none;min-width:0;min-height:44px}
  .context-button>span{display:block}
  .context-button b{font-size:calc(12px * var(--business-font-scale,1))}
  .context-button small{font-size:calc(12px * var(--business-font-scale,1))}
  .user-button,.notification-button{flex:0 0 44px;min-width:44px;min-height:44px}
  .notification-panel{top:calc(128px + env(safe-area-inset-top));max-height:calc(100dvh - 145px - env(safe-area-inset-top))}
  .content-wrapper{padding:10px 8px calc(16px + env(safe-area-inset-bottom));scrollbar-gutter:auto}
  .content-panel{padding:12px;border-radius:18px}
  .module-hero,.history-hero,.dashboard-hero{padding:22px 18px;border-radius:17px}
  .module-hero p,.history-hero p,.dashboard-hero p{font-size:calc(13px * var(--business-font-scale,1));line-height:1.6}
  .module-hero>.btn,.history-hero>.btn,.dashboard-hero>.btn{width:100%;justify-content:center}
  .module-stats,.dashboard-kpis,.kpis{grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
  .module-stats>*,.dashboard-kpis>*{min-width:0;padding:13px 10px}
  .module-filter-grid,.audit-filter-grid,.history-filter-grid,.form-grid,.modal-grid{grid-template-columns:minmax(0,1fr)}
  .module-filter-head,.card-head,.document-settings-toolbar{flex-wrap:wrap;gap:12px}
  .module-filter-actions{width:100%;justify-content:space-between;flex-wrap:wrap}
  .module-control>div,.history-control>div{min-height:48px}
  input:not([type=checkbox]):not([type=radio]),select,textarea,
  .modal-card input:not([type=checkbox]):not([type=radio]),.modal-card select,.modal-card textarea,
  .module-control input,.module-control select,.history-control input,.history-control select{font-size:calc(16px * var(--business-font-scale,1))}
  .counterparty-grid,.file-grid,.document-requirement-grid{grid-template-columns:minmax(0,1fr)}
  .history-card{grid-template-columns:40px minmax(0,1fr);gap:10px;padding:15px}
  .history-identity h3{font-size:calc(15px * var(--business-font-scale,1));line-height:1.4;white-space:normal}
  .approved-directory-card .approved-actions{display:flex;flex-wrap:wrap}
  .approved-actions>button,.approved-actions>details{flex:1 1 120px;min-width:0}
  .approved-actions .history-pdf-menu>summary{width:100%}
  .approved-audit-meta{gap:8px}
  .approved-audit-meta span{font-size:calc(12px * var(--business-font-scale,1));line-height:1.5}
  .approved-file-shortcut{width:40px;height:40px;flex-basis:40px}
  .modal{padding:8px;align-items:center}
  .modal-card{width:100%;max-height:calc(100dvh - 16px);border-radius:18px}
  .modal-head{padding:14px 16px;gap:12px}
  .modal-head h3{font-size:calc(17px * var(--business-font-scale,1));line-height:1.35}
  .modal-head>#closeModal,.modal-head button{width:44px;height:44px;flex:0 0 44px}
  .modal-content{padding:18px 22px}
  .modal-actions{flex-wrap:wrap;gap:8px;padding-bottom:env(safe-area-inset-bottom)}
  .modal-actions>.btn{flex:1 1 140px;justify-content:center}
  .file-modal-hero,.file-modal-title{min-width:0;flex-wrap:wrap;gap:12px}
  .file-modal-hero h3{overflow-wrap:anywhere;font-size:calc(16px * var(--business-font-scale,1));line-height:1.4}
  .document-row{padding:12px 10px;grid-template-columns:30px minmax(0,1fr)}
  .document-rule-legend>span{min-width:0;flex:0 1 auto;font-size:calc(12px * var(--business-font-scale,1))}
  .document-rule-legend>div{min-width:0}
  .document-settings-actions nav{display:flex;flex-wrap:wrap;gap:5px}
  .document-settings-actions nav button{min-height:44px;flex:1 1 auto}
  .requirement-type-option b{font-size:calc(13px * var(--business-font-scale,1));line-height:1.5}
  .pdf-viewer-modal{padding:0}
  .pdf-viewer-card{height:100dvh;max-height:100dvh;border-radius:0}
  .pdf-viewer-actions{flex-wrap:wrap}
  .toast{left:12px;right:12px;bottom:calc(14px + env(safe-area-inset-bottom));max-width:none;overflow-wrap:anywhere}
  .auth-page,.auth-right{min-height:100dvh}
  .auth-right{padding:16px}
  .login-box{width:100%;padding:28px 20px}
  .login-logo{max-width:80%;height:auto}
  .permission-checks,.context-businesses{grid-template-columns:1fr}
}
@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}
}
