:root{--sidebar:260px}body{background:#f5f6f8}.sidebar{width:var(--sidebar);min-height:100vh;background:#1f2937;color:#fff;position:fixed;left:0;top:0;padding:20px}.sidebar a{color:#d1d5db;text-decoration:none;display:block;padding:10px 12px;border-radius:8px;margin:4px 0}.sidebar a:hover,.sidebar a.active{background:#374151;color:#fff}.content{margin-left:var(--sidebar);padding:28px}.brand{font-weight:700;font-size:1.05rem}.subtitle{font-size:.78rem;color:#9ca3af}.metric-card{border:0;border-radius:16px;box-shadow:0 8px 24px rgba(0,0,0,.06)}.metric-value{font-size:1.8rem;font-weight:700}.login-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;background:linear-gradient(135deg,#eef2f7,#fff)}.login-card{width:100%;max-width:430px;border:0;border-radius:18px;box-shadow:0 12px 35px rgba(0,0,0,.08)}
.page-head{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:24px}.page-head h2{margin-bottom:3px}.table thead th{font-size:.78rem;text-transform:uppercase;letter-spacing:.03em;color:#6b7280;background:#f9fafb;border-bottom:1px solid #e5e7eb;white-space:nowrap}.table td,.table th{padding:14px 16px}.section-title{font-weight:700}.detail-list dt{color:#6b7280;font-weight:500}.detail-list dd{font-weight:500}@media(max-width:991px){.sidebar{position:relative;width:100%;min-height:auto}.content{margin-left:0;padding:18px}.page-head{align-items:flex-start;flex-direction:column}}
.score-ring{width:92px;height:92px;border-radius:50%;display:grid;place-items:center;background:#f3f4f6;font-size:1.55rem;font-weight:800}.priority-box{border-left:4px solid #d1d5db}.criteria-help{font-size:.82rem;color:#6b7280}.score-bar{height:9px;border-radius:99px;background:#e5e7eb;overflow:hidden}.score-bar>span{display:block;height:100%;background:#374151}.sticky-actions{position:sticky;bottom:12px;z-index:5}
.sidebar-section{font-size:.68rem;letter-spacing:.09em;color:#6b7280;margin:18px 12px 5px;font-weight:700}.stock-low{background:#fff7ed!important}.stock-zero{background:#fef2f2!important}.kpi-sub{font-size:.78rem;color:#6b7280}.table-actions{white-space:nowrap}.qty-positive{color:#15803d;font-weight:700}.qty-negative{color:#b91c1c;font-weight:700}.filter-card{border:0;border-radius:14px;box-shadow:0 6px 20px rgba(0,0,0,.045)}
#mapaTerritorio{height:520px;border-radius:12px}.map-legend{font-size:.82rem}.report-value{font-weight:800;font-size:1.45rem}@media(max-width:767px){#mapaTerritorio{height:390px}}

.sidebar{overflow-y:auto}.sidebar .badge{font-size:.65rem}.content{max-width:1800px}.card{border-color:#e5e7eb}.progress-bar{background:#1f2937}.list-group-item{border-left:0;border-right:0}.global-search{max-width:520px}

/* Dashboard v1.2 */
.dashboard-content{padding-top:24px}.dashboard-head{margin-bottom:18px}.eyebrow{font-size:.68rem;letter-spacing:.11em;font-weight:800;color:#6b7280;margin-bottom:4px}.metric-label{font-size:.82rem;color:#6b7280;font-weight:600}.metric-footer{font-size:.78rem;margin-top:6px}.metric-money{font-size:1.45rem;font-weight:800;letter-spacing:-.02em;margin-top:4px}.kpi-denom{font-size:.95rem;color:#6b7280;padding-bottom:6px}.dashboard-progress{height:5px;margin:8px 0 6px;background:#e5e7eb}.dashboard-kpis .metric-card .card-body{padding:18px 19px}.secondary-kpis .metric-value{font-size:1.55rem}.card-section-head{padding:18px 20px 10px;display:flex;align-items:center;justify-content:space-between;gap:12px}.card-section-head h5{margin:0;font-size:1rem}.status-flow{display:grid;grid-template-columns:repeat(7,minmax(100px,1fr));gap:8px}.status-chip{border:1px solid #e5e7eb;border-radius:12px;padding:11px 12px;text-decoration:none;color:#111827;background:#fff;transition:.15s ease}.status-chip:hover{border-color:#9ca3af;transform:translateY(-1px)}.status-chip strong{display:block;font-size:1.25rem}.status-chip span{display:block;color:#6b7280;font-size:.75rem;margin-top:2px}.empty-state{padding:24px 18px;text-align:center;color:#6b7280;display:flex;flex-direction:column;gap:4px}.empty-state strong{color:#374151}.empty-state a{margin-top:5px;font-size:.82rem}.chart-card{min-height:330px}.chart-wrap{height:245px}.empty-chart{height:245px;display:flex;align-items:center;justify-content:center;flex-direction:column;text-align:center;color:#6b7280;border:1px dashed #d1d5db;border-radius:12px;background:#fafafa}.empty-chart strong{color:#374151}.empty-chart span{font-size:.82rem;margin-top:4px}.quick-stat,.context-card{border:1px solid #e5e7eb;border-radius:14px;background:#fff}.quick-stat .card-body,.context-card .card-body{padding:17px 18px}.quick-stat span{display:block;font-size:.78rem;color:#6b7280}.quick-stat strong{display:block;font-size:1.35rem;margin:2px 0}.quick-stat small{color:#9ca3af}.context-card a{font-size:.78rem}.onboarding-card{border:1px solid #dbeafe;border-radius:16px;background:linear-gradient(135deg,#eff6ff,#fff)}.setup-step{display:flex;gap:10px;align-items:flex-start;padding:12px;border:1px solid #dbeafe;border-radius:12px;background:#fff;text-decoration:none;color:#111827;height:100%}.setup-step>span{display:grid;place-items:center;width:28px;height:28px;flex:0 0 28px;border-radius:50%;background:#1f2937;color:#fff;font-weight:800;font-size:.8rem}.setup-step strong,.setup-step small{display:block}.setup-step small{color:#6b7280;font-size:.75rem;margin-top:2px}.sidebar{scrollbar-width:thin}.sidebar .brand{line-height:1.2}.sidebar-section{margin-top:14px}.sidebar a{padding:8px 10px;margin:2px 0;font-size:.88rem}.content{max-width:none}.dashboard-content .table td,.dashboard-content .table th{padding:11px 14px}.dashboard-content .table thead th{font-size:.7rem}
@media(max-width:1199px){.status-flow{grid-template-columns:repeat(4,1fr)}}
@media(max-width:767px){.status-flow{grid-template-columns:repeat(2,1fr)}.dashboard-content{padding:14px}.chart-card{min-height:auto}.chart-wrap,.empty-chart{height:220px}}

/* Sidebar retráctil v1.2.2 */
:root{--sidebar:260px;--sidebar-collapsed:76px;--sidebar-bg:#1f2937;--sidebar-hover:#374151}
.sidebar{width:var(--sidebar);transition:width .22s ease,transform .22s ease;padding:14px 12px 12px;display:flex;flex-direction:column;z-index:1040;overflow-x:hidden;box-shadow:8px 0 28px rgba(15,23,42,.08)}
.sidebar-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;min-height:54px;margin-bottom:10px}
.sidebar-brand-wrap{display:flex;align-items:flex-start;gap:10px;min-width:0;overflow:hidden}
.brand-mark{display:grid;place-items:center;flex:0 0 38px;width:38px;height:38px;border-radius:10px;background:#fff;color:#1f2937;font-weight:900;font-size:.78rem;letter-spacing:-.03em}
.brand-copy{min-width:0;transition:opacity .15s ease,width .2s ease}.brand-copy .brand{white-space:normal}.brand-copy .subtitle{line-height:1.25;margin-top:3px}
.sidebar-toggle{flex:0 0 30px;width:30px;height:30px;border:1px solid rgba(255,255,255,.13);border-radius:8px;background:rgba(255,255,255,.06);color:#fff;display:grid;place-items:center;cursor:pointer;transition:.18s ease}
.sidebar-toggle:hover{background:rgba(255,255,255,.14)}.toggle-chevron{font-size:1.45rem;line-height:1;transform:translateY(-1px);transition:transform .2s ease}
.sidebar-search{position:relative;display:flex;gap:5px;margin-bottom:10px}.sidebar-search input{min-width:0;padding-left:30px}.sidebar-search-icon{position:absolute;left:9px;top:6px;z-index:2;color:#6b7280;font-size:.85rem}.sidebar-search button{display:none}
.sidebar-nav{flex:1;min-height:0}.sidebar-link{position:relative;display:flex!important;align-items:center;gap:10px;min-height:38px;padding:8px 10px!important;white-space:nowrap;overflow:hidden}
.sidebar-icon{width:22px;flex:0 0 22px;text-align:center;font-size:1rem;color:#cbd5e1;font-weight:700}.sidebar-link.active .sidebar-icon,.sidebar-link:hover .sidebar-icon{color:#fff}
.sidebar-label{overflow:hidden;text-overflow:ellipsis;transition:opacity .15s ease}.sidebar-badge{margin-left:auto;font-size:.62rem!important;min-width:19px}
.sidebar-section{position:relative;margin:13px 10px 5px!important;white-space:nowrap;overflow:hidden;height:15px}.sidebar-section span{transition:opacity .15s ease}
.sidebar-footer{border-top:1px solid rgba(255,255,255,.12);padding-top:8px;margin-top:8px}.sidebar-version{font-size:.65rem;color:#64748b;padding:5px 10px;text-align:right}
.content{transition:margin-left .22s ease}
.sidebar-mobile-toggle{display:none;position:fixed;left:12px;top:12px;z-index:1060;width:42px;height:42px;border:0;border-radius:11px;background:#1f2937;box-shadow:0 7px 20px rgba(0,0,0,.16);padding:10px}
.sidebar-mobile-toggle span{display:block;height:2px;background:#fff;border-radius:4px;margin:4px 0;transition:.2s ease}.sidebar-overlay{display:none}

@media(min-width:992px){
 body.sidebar-collapsed{--sidebar:var(--sidebar-collapsed)}
 body.sidebar-collapsed .sidebar{padding-left:10px;padding-right:10px}
 body.sidebar-collapsed .brand-copy,body.sidebar-collapsed .sidebar-label,body.sidebar-collapsed .sidebar-section span,body.sidebar-collapsed .sidebar-version{opacity:0;width:0;pointer-events:none}
 body.sidebar-collapsed .sidebar-head{justify-content:center;flex-direction:column;align-items:center;gap:7px}
 body.sidebar-collapsed .sidebar-brand-wrap{justify-content:center}.sidebar-collapsed .brand-mark{flex-basis:38px}
 body.sidebar-collapsed .sidebar-toggle{width:38px}.sidebar-collapsed .toggle-chevron{transform:rotate(180deg) translateY(1px)}
 body.sidebar-collapsed .sidebar-search input{display:none}.sidebar-collapsed .sidebar-search{justify-content:center}.sidebar-collapsed .sidebar-search-icon{display:none}.sidebar-collapsed .sidebar-search button{display:block;width:38px;height:34px;padding:0}
 body.sidebar-collapsed .sidebar-link{justify-content:center;padding:8px!important;overflow:visible}.sidebar-collapsed .sidebar-icon{font-size:1.05rem}
 body.sidebar-collapsed .sidebar-section{margin:8px 0!important;height:1px;background:rgba(255,255,255,.12)}
 body.sidebar-collapsed .sidebar-badge{position:absolute;right:2px;top:2px;font-size:.5rem!important;min-width:15px;padding:2px 4px}
}

@media(max-width:991px){
 .sidebar-mobile-toggle{display:block}.sidebar{position:fixed!important;top:0;bottom:0;left:0;width:min(86vw,300px)!important;min-height:100vh!important;transform:translateX(-105%);padding-top:16px;box-shadow:14px 0 35px rgba(15,23,42,.28)}
 .content{margin-left:0!important;padding:70px 16px 18px!important}.sidebar-toggle{display:flex;align-items:center;justify-content:center}.toggle-chevron{transform:rotate(0deg)}
 body.sidebar-mobile-open{overflow:hidden}.sidebar-mobile-open .sidebar{transform:translateX(0)}
 .sidebar-overlay{position:fixed;inset:0;background:rgba(15,23,42,.45);backdrop-filter:blur(2px);z-index:1030}.sidebar-mobile-open .sidebar-overlay{display:block}
 .sidebar-mobile-open .sidebar-mobile-toggle span:nth-child(1){transform:translateY(6px) rotate(45deg)}.sidebar-mobile-open .sidebar-mobile-toggle span:nth-child(2){opacity:0}.sidebar-mobile-open .sidebar-mobile-toggle span:nth-child(3){transform:translateY(-6px) rotate(-45deg)}
}
/* V1.2.3 - optimización visual del Dashboard */
.dashboard-content{background:#f4f6f9;min-height:100vh}.dashboard-content .metric-card{border:1px solid #e8ebef;box-shadow:0 4px 14px rgba(17,24,39,.045);transition:transform .15s ease,box-shadow .15s ease}.dashboard-content .metric-card:hover{transform:translateY(-1px);box-shadow:0 8px 22px rgba(17,24,39,.07)}.dashboard-head{position:relative}.dashboard-head h2{font-size:1.55rem;font-weight:800;letter-spacing:-.025em}.dashboard-kpis .metric-card{overflow:hidden}.dashboard-kpis .metric-card:before{content:"";display:block;height:3px;background:#374151}.secondary-kpis .metric-card:before{background:#64748b}.dashboard-kpis .metric-value{letter-spacing:-.04em}.dashboard-content .table tbody tr:hover{background:#f8fafc}.status-flow{overflow-x:auto;padding-bottom:2px}.status-chip{min-width:104px}.status-chip strong{letter-spacing:-.035em}.chart-card .card-body{display:flex;flex-direction:column}.chart-wrap{flex:1;min-height:235px}.quick-stat{box-shadow:0 3px 12px rgba(17,24,39,.035)}.context-card{box-shadow:0 3px 12px rgba(17,24,39,.035)}
@media(min-width:1400px){.dashboard-content{padding-left:32px;padding-right:32px}.dashboard-kpis .metric-card .card-body{padding:20px 21px}.chart-card{min-height:350px}.chart-wrap{height:265px}}
@media(max-width:575px){.dashboard-head .d-flex.gap-2{width:100%;justify-content:space-between}.dashboard-kpis .metric-card .card-body{padding:15px}.metric-value{font-size:1.55rem}.metric-money{font-size:1.25rem}.status-flow{display:flex}.status-chip{flex:0 0 112px}}

/* =========================================================
   BMC v1.2.4 - Sidebar: navegación completa y scroll interno
   ========================================================= */
.sidebar{
  height:100vh;
  height:100dvh;
  min-height:0 !important;
  overflow:hidden !important;
  overscroll-behavior:contain;
}
.sidebar-head,
.sidebar-search,
.sidebar-footer{
  flex:0 0 auto;
}
.sidebar-nav{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  padding-right:4px;
  margin-right:-4px;
  scrollbar-width:thin;
  scrollbar-color:rgba(255,255,255,.25) transparent;
  overscroll-behavior:contain;
}
.sidebar-nav::-webkit-scrollbar{width:6px}
.sidebar-nav::-webkit-scrollbar-track{background:transparent}
.sidebar-nav::-webkit-scrollbar-thumb{background:rgba(255,255,255,.22);border-radius:20px}
.sidebar-nav::-webkit-scrollbar-thumb:hover{background:rgba(255,255,255,.36)}

/* Menú un poco más compacto para pantallas de poca altura */
.sidebar-link{min-height:34px;padding:6px 9px!important;margin:1px 0!important;font-size:.82rem!important}
.sidebar-icon{width:20px;flex-basis:20px;font-size:.92rem}
.sidebar-section{margin:9px 9px 3px!important;height:14px;font-size:.62rem!important}
.sidebar-head{min-height:48px;margin-bottom:7px}
.sidebar-search{margin-bottom:7px}
.sidebar-footer{margin-top:5px;padding-top:6px}
.sidebar-footer .sidebar-link{min-height:32px}
.sidebar-version{padding:3px 9px}

/* En pantallas de baja altura, compactar un poco más sin ocultar módulos */
@media (min-width:992px) and (max-height:760px){
  .sidebar{padding-top:9px;padding-bottom:8px}
  .sidebar-head{min-height:44px;margin-bottom:5px}
  .brand-mark{width:34px;height:34px;flex-basis:34px}
  .brand-copy .brand{font-size:.94rem}
  .brand-copy .subtitle{font-size:.67rem}
  .sidebar-search{margin-bottom:5px}
  .sidebar-link{min-height:31px;padding:5px 8px!important;font-size:.77rem!important}
  .sidebar-icon{font-size:.86rem}
  .sidebar-section{margin:7px 8px 2px!important;height:12px;font-size:.57rem!important}
  .sidebar-footer{padding-top:4px;margin-top:4px}
}

@media (max-width:991px){
  .sidebar{
    height:100vh!important;
    height:100dvh!important;
    min-height:0!important;
    overflow:hidden!important;
  }
  .sidebar-nav{-webkit-overflow-scrolling:touch}
}


/* =========================================================
   BMC v1.2.5 - Corrección definitiva altura/scroll sidebar
   ========================================================= */
html,body{min-height:100%;}
.sidebar,
.sidebar *,
.sidebar *::before,
.sidebar *::after{box-sizing:border-box;}

@media (min-width:992px){
  .sidebar{
    position:fixed !important;
    top:0 !important;
    bottom:0 !important;
    left:0 !important;
    height:auto !important;
    min-height:0 !important;
    max-height:none !important;
    overflow:hidden !important;
    display:flex !important;
    flex-direction:column !important;
  }

  .sidebar-head{flex:0 0 auto !important;}
  .sidebar-search{flex:0 0 auto !important;}

  .sidebar-nav{
    flex:1 1 0 !important;
    min-height:0 !important;
    height:0; /* obliga al flex item a usar solo el espacio restante */
    overflow-y:auto !important;
    overflow-x:hidden !important;
    padding-bottom:8px;
    scrollbar-gutter:stable;
  }

  .sidebar-footer{
    flex:0 0 auto !important;
    position:relative !important;
    bottom:auto !important;
    background:var(--sidebar-bg,#1f2937);
    z-index:2;
    margin-top:4px !important;
    padding-top:6px !important;
    padding-bottom:2px !important;
  }
}

/* El scroll debe verse de manera sutil cuando realmente sea necesario */
.sidebar-nav::-webkit-scrollbar{width:7px !important;}
.sidebar-nav::-webkit-scrollbar-thumb{background:rgba(255,255,255,.28) !important;}
.sidebar-nav:hover::-webkit-scrollbar-thumb{background:rgba(255,255,255,.42) !important;}

/* Más aprovechamiento vertical en resoluciones como 1366x768 */
@media (min-width:992px) and (max-height:700px){
  .sidebar{padding:8px 8px 6px !important;}
  .sidebar-head{min-height:40px !important;margin-bottom:4px !important;}
  .brand-mark{width:32px !important;height:32px !important;flex-basis:32px !important;}
  .brand-copy .brand{font-size:.88rem !important;line-height:1.08 !important;}
  .brand-copy .subtitle{font-size:.61rem !important;line-height:1.15 !important;}
  .sidebar-toggle{width:27px !important;height:27px !important;flex-basis:27px !important;}
  .sidebar-search{margin-bottom:4px !important;}
  .sidebar-search input{height:30px !important;font-size:.75rem !important;}
  .sidebar-link{min-height:29px !important;padding:4px 7px !important;font-size:.74rem !important;}
  .sidebar-icon{font-size:.82rem !important;width:19px !important;flex-basis:19px !important;}
  .sidebar-section{margin:5px 7px 1px !important;height:11px !important;font-size:.54rem !important;}
  .sidebar-footer .sidebar-link{min-height:27px !important;}
  .sidebar-version{font-size:.58rem !important;padding:2px 7px !important;}
}

@media (max-width:991px){
  .sidebar{
    position:fixed !important;
    inset:0 auto 0 0 !important;
    height:auto !important;
    min-height:0 !important;
    max-height:none !important;
    box-sizing:border-box !important;
    display:flex !important;
    flex-direction:column !important;
    overflow:hidden !important;
  }
  .sidebar-nav{
    flex:1 1 0 !important;
    height:0;
    min-height:0 !important;
    overflow-y:auto !important;
    -webkit-overflow-scrolling:touch;
  }
  .sidebar-footer{flex:0 0 auto !important;background:var(--sidebar-bg,#1f2937);}
}

/* =========================================================
   BMC v1.2.6 - Scroll total del menú lateral (fallback robusto)
   Garantiza acceso a todas las opciones sin depender del alto
   disponible entre cabecera, buscador y pie.
   ========================================================= */
@media (min-width:992px){
  .sidebar{
    position:fixed !important;
    top:0 !important;
    bottom:0 !important;
    left:0 !important;
    height:100vh !important;
    height:100dvh !important;
    min-height:0 !important;
    max-height:100dvh !important;
    display:block !important;
    overflow-y:scroll !important;
    overflow-x:hidden !important;
    overscroll-behavior:contain;
    scrollbar-gutter:stable;
    padding-bottom:14px !important;
  }

  /* Anulamos el reparto flex anterior que podía ocultar el pie */
  .sidebar-head,
  .sidebar-search,
  .sidebar-nav,
  .sidebar-footer{
    display:block;
    height:auto !important;
    min-height:0 !important;
    max-height:none !important;
    flex:none !important;
  }

  .sidebar-head{display:flex !important;}
  .sidebar-search{display:flex !important;}
  .sidebar-nav{
    overflow:visible !important;
    padding-right:0 !important;
    margin-right:0 !important;
    padding-bottom:2px !important;
  }
  .sidebar-footer{
    position:static !important;
    margin-top:10px !important;
    padding-top:8px !important;
    padding-bottom:8px !important;
  }

  /* Scrollbar claramente visible para indicar que hay más opciones */
  .sidebar{scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.45) rgba(255,255,255,.06);}
  .sidebar::-webkit-scrollbar{width:8px;}
  .sidebar::-webkit-scrollbar-track{background:rgba(255,255,255,.05);}
  .sidebar::-webkit-scrollbar-thumb{background:rgba(255,255,255,.38);border-radius:20px;}
  .sidebar::-webkit-scrollbar-thumb:hover{background:rgba(255,255,255,.58);}
}

@media (min-width:992px) and (max-height:850px){
  .sidebar{padding-top:8px !important;padding-left:8px !important;padding-right:8px !important;}
  .sidebar-head{min-height:auto !important;margin-bottom:5px !important;}
  .sidebar-search{margin-bottom:5px !important;}
  .sidebar-link{min-height:28px !important;padding:4px 7px !important;margin:0 !important;font-size:.73rem !important;}
  .sidebar-icon{width:18px !important;flex-basis:18px !important;font-size:.8rem !important;}
  .sidebar-section{margin:5px 7px 1px !important;height:11px !important;font-size:.53rem !important;}
  .sidebar-footer .sidebar-link{min-height:27px !important;}
}

@media (max-width:991px){
  .sidebar{
    height:100vh !important;
    height:100dvh !important;
    max-height:100dvh !important;
    display:block !important;
    overflow-y:auto !important;
    overflow-x:hidden !important;
    -webkit-overflow-scrolling:touch;
    padding-bottom:18px !important;
  }
  .sidebar-nav{height:auto !important;overflow:visible !important;}
  .sidebar-footer{position:static !important;}
}
