/* Aasperu · Escala institucional única para vistas y roles 38
   Base visual: Sistema Administrativo aprobado.
   Usar en Administrativo, CRM y Financiero (incluido Compras).
   No asigna permisos ni altera la navegación del usuario.
*/
@media screen {
  :root { --aas37-sidebar:220px; --aas37-oro:#d6b06b; --aas37-vino:#790018; }
  /* Escalas idénticas de barra principal y nombre del operador para los roles. */
  html body.app .aas-layout:not(.aas-collapsed) { grid-template-columns:var(--aas37-sidebar) minmax(0,1fr)!important; }
  html body.crm-shell {padding-left:var(--aas37-sidebar)!important;}
  html body.aasperu-finance:not(.compras) {padding-left:var(--aas37-sidebar)!important;}
  html body.compras-with-sidebar:not(.compras-menu-collapsed)>main {
    width:calc(100% - var(--aas37-sidebar))!important;
    margin-left:var(--aas37-sidebar)!important;
    max-width:none!important;
    box-sizing:border-box!important;
  }
  :is(html body.app aside.aas-sidebar,
      html body.crm-shell aside#crm-sidebar,
      html body.aasperu-finance:not(.compras)>header.finance-header,
      html body.compras-with-sidebar aside.compras-sidebar) {
    width:var(--aas37-sidebar)!important;
    min-width:var(--aas37-sidebar)!important;
    max-width:var(--aas37-sidebar)!important;
    box-sizing:border-box!important;
    font-family:Roboto,Arial,sans-serif!important;
  }
  :is(html body.app .aas-sidebar .aas-user>strong,
      html body.crm-shell #crm-sidebar .operator,
      html body.aasperu-finance:not(.compras) .aas-sidebar-profile-v33>strong,
      html body.compras-with-sidebar .compras-sidebar-profile>strong) {
    font:600 11px/1.5 Roboto,Arial,sans-serif!important;
    overflow-wrap:anywhere!important;
  }
  :is(html body.app .aas-sidebar .aas-user>span,
      html body.crm-shell #crm-sidebar .operator>small,
      html body.aasperu-finance:not(.compras) .aas-sidebar-profile-v33>small,
      html body.compras-with-sidebar .compras-sidebar-profile>small) {
    font:400 10px/1.5 Roboto,Arial,sans-serif!important;
  }
  /* El submenú Ventas/Compras es el mismo enlace en cualquiera de las sesiones. */
  :is(html body.app .aas-sidebar,
      html body.crm-shell #crm-sidebar,
      html body.aasperu-finance:not(.compras) .finance-header,
      html body.compras-with-sidebar .compras-sidebar) nav[aria-label="Navegación principal"] a,
  :is(html body.app .aas-sidebar,
      html body.crm-shell #crm-sidebar,
      html body.aasperu-finance:not(.compras) .finance-header,
      html body.compras-with-sidebar .compras-sidebar) nav[aria-label="Navegación principal"] summary {
    font-family:Roboto,Arial,sans-serif!important;
    font-size:11px!important;
    line-height:1.4!important;
  }
  /* Misma densidad de las dos pantallas de comprobantes; no cambia formularios de otros módulos. */
  html body.app main.aas-workspace section.cp,
  html body.compras-with-sidebar>main {
    font-family:Roboto,Arial,sans-serif!important;
    font-size:13px!important;
    line-height:1.45!important;
  }
  html body.app main.aas-workspace section.cp .cp-top h2,
  html body.compras-with-sidebar>main .compras-page-head h1 {
    font:700 22px/1.25 Roboto,Arial,sans-serif!important;
    color:#681c35!important;
    letter-spacing:0!important;
  }
  html body.app main.aas-workspace section.cp .cp-entorno,
  html body.compras-with-sidebar>main .compras-eyebrow {
    font:600 10px/1.5 Roboto,Arial,sans-serif!important;
    letter-spacing:.6px!important;
    color:#956b49!important;
    text-transform:uppercase!important;
  }
  html body.app main.aas-workspace section.cp .cp-filtros label,
  html body.compras-with-sidebar>main .compras-search label {
    font-family:Roboto,Arial,sans-serif!important;
    font-size:12px!important;
    line-height:1.35!important;
  }
  html body.app main.aas-workspace section.cp .cp-filtros input,
  html body.app main.aas-workspace section.cp .cp-filtros select,
  html body.compras-with-sidebar>main .compras-search input,
  html body.compras-with-sidebar>main .compras-search select {
    box-sizing:border-box!important;
    min-height:34px!important;
    font:400 12px/1.3 Roboto,Arial,sans-serif!important;
  }
  html body.app main.aas-workspace section.cp .cp-filtro-botones button,
  html body.compras-with-sidebar>main .compras-search button {
    box-sizing:border-box!important;
    min-height:34px!important;
    font:600 12px/1.3 Roboto,Arial,sans-serif!important;
  }
  /* Evita que los links de Ventas hereden la regla global a 10px.
     Compras conserva su misma escala. No agrandamos ni alteramos la maquetación de las tablas. */
  html body.app main.aas-workspace section.cp .cp-archivos-fila a,
  html body.app main.aas-workspace section.cp .cp-paginacion a {
    font:500 12px/1.3 Roboto,Arial,sans-serif!important;
  }
  html body.app main.aas-workspace section.cp table,
  html body.compras-with-sidebar>main .compras-listado table {
    width:100%!important;
    font-family:Roboto,Arial,sans-serif!important;
    font-size:12px!important;
    line-height:1.4!important;
  }
  html body.app main.aas-workspace section.cp table th,
  html body.app main.aas-workspace section.cp table td,
  html body.compras-with-sidebar>main .compras-listado table th,
  html body.compras-with-sidebar>main .compras-listado table td {
    font-size:12px!important;
    line-height:1.4!important;
    padding:8px 10px!important;
    height:auto!important;
    vertical-align:middle!important;
  }
  html body.app main.aas-workspace section.cp table td a[href],
  html body.compras-with-sidebar>main .compras-listado table td a[href] {
    font-size:12px!important;
    line-height:1.3!important;
    padding:5px 8px!important;
    min-height:28px!important;
  }
}
@media screen and (max-width:800px) {
  /* La barra móvil sigue el mecanismo de despliegue que ya usa cada aplicación. */
  html body.crm-shell,
  html body.aasperu-finance:not(.compras) {padding-left:0!important;}
  html body.compras.compras-with-sidebar:not(.compras-menu-collapsed)>main {width:100%!important;max-width:100%!important;margin-left:0!important;}
  html body.app .aas-layout.aas-mobile-open aside.sidebar.aas-sidebar,
  html body.compras.compras-with-sidebar aside.compras-sidebar {width:100%!important;min-width:0!important;max-width:none!important;}
  html body.aasperu-finance:not(.compras)>header.finance-header {width:min(260px,85vw)!important;min-width:0!important;max-width:85vw!important;}
  html body.app .aas-layout:not(.aas-collapsed) {grid-template-columns:minmax(0,1fr)!important;}
  html body.compras-with-sidebar>main .compras-page-head h1,
  html body.app main.aas-workspace section.cp .cp-top h2 {font-size:19px!important;}
}

/* Patrón v38: mismos encabezados, controles, tablas y superficies para Ventas y Compras.
   Se limita a estas dos vistas. No modifica rutas ni autorización. */
@media screen and (min-width:801px) {
  html body.app:has(section.cp-ventas) main.aas-workspace .aas-page-content,
  html body.compras-with-sidebar>main {
    min-width:0;
  }
}
@media screen {
  html body.app:has(section.cp-ventas) main.aas-workspace header.page-head.aas-head,
  html body.compras-with-sidebar>main header.compras-page-head {
    display:flex!important;
    align-items:center!important;
    gap:13px!important;
    background:transparent!important;
    border-bottom:1px solid #e5dcd5!important;
    padding:0 0 15px!important;
    margin:0 0 20px!important;
    box-shadow:none!important;
    text-align:left!important;
  }
  html body.app:has(section.cp-ventas) main.aas-workspace header.page-head.aas-head h1,
  html body.compras-with-sidebar>main header.compras-page-head h1 {
    font:700 22px/1.25 Roboto,Arial,sans-serif!important;
    letter-spacing:0!important;
    color:#681c35!important;
    margin:4px 0 0!important;
  }
  html body.app:has(section.cp-ventas) main.aas-workspace header.page-head.aas-head .eyebrow,
  html body.compras-with-sidebar>main header.compras-page-head .compras-eyebrow {
    font:600 10px/1.5 Roboto,Arial,sans-serif!important;
    text-transform:uppercase!important;
    letter-spacing:.6px!important;
    color:#956b49!important;
  }
  html body.app:has(section.cp-ventas) main.aas-workspace header.page-head.aas-head .aas-toggle,
  html body.compras-with-sidebar>main header.compras-page-head .compras-menu-toggle {
    display:flex!important;
    justify-content:center!important;
    align-items:center!important;
    box-sizing:border-box!important;
    flex:0 0 34px!important;
    width:34px!important;
    height:34px!important;
    min-height:34px!important;
    background:#fff!important;
    border:1px solid #d6c3b8!important;
    border-radius:6px!important;
    color:#681c35!important;
    font:500 19px/1 Roboto,Arial,sans-serif!important;
  }
  html body.app main.aas-workspace section.cp-ventas,
  html body.compras-with-sidebar>main {
    font:400 13px/1.45 Roboto,Arial,sans-serif!important;
  }
  html body.app main.aas-workspace section.cp-ventas .cp-ventas-kicker {
    color:#956b49!important;
    font:600 10px/1.5 Roboto,Arial,sans-serif!important;
    letter-spacing:.6px!important;
    text-transform:uppercase!important;
    margin:0 0 8px!important;
  }
  /* Buscador: ambos módulos tienen tarjeta independiente con la misma retícula visual. */
  html body.app main.aas-workspace section.cp-ventas form.cp-filtros,
  html body.compras-with-sidebar>main section.card:has(form.compras-search) {
    box-sizing:border-box!important;
    width:100%!important;
    background:#fff!important;
    border:1px solid #e4d9ce!important;
    border-radius:9px!important;
    box-shadow:0 3px 12px rgba(75,29,41,.035)!important;
    padding:16px!important;
    margin:0 0 14px!important;
  }
  html body.compras-with-sidebar>main section.card:has(form.compras-search) form.compras-search {
    align-items:end!important;
    gap:10px!important;
    margin:0!important;
  }
  html body.app main.aas-workspace section.cp-ventas form.cp-filtros label,
  html body.compras-with-sidebar>main form.compras-search label {
    font:600 12px/1.35 Roboto,Arial,sans-serif!important;
    color:#43393d!important;
    min-width:0!important;
  }
  html body.app main.aas-workspace section.cp-ventas form.cp-filtros :is(input,select),
  html body.compras-with-sidebar>main form.compras-search :is(input,select) {
    box-sizing:border-box!important;
    width:100%!important;
    min-height:34px!important;
    height:34px!important;
    border:1px solid #d8c4c8!important;
    border-radius:5px!important;
    background:#fff!important;
    padding:6px 9px!important;
    font:400 12px/1.3 Roboto,Arial,sans-serif!important;
  }
  html body.app main.aas-workspace section.cp-ventas form.cp-filtros button,
  html body.compras-with-sidebar>main form.compras-search button,
  html body.compras-with-sidebar>main form.compras-search a {
    box-sizing:border-box!important;
    display:inline-flex!important;
    justify-content:center!important;
    align-items:center!important;
    height:34px!important;
    min-height:34px!important;
    padding:6px 12px!important;
    border-radius:5px!important;
    font:600 12px/1.3 Roboto,Arial,sans-serif!important;
    white-space:nowrap!important;
  }
  html body.app main.aas-workspace section.cp-ventas form.cp-filtros button,
  html body.compras-with-sidebar>main form.compras-search button {
    background:#752139!important;
    color:#fff!important;
    border:1px solid #752139!important;
  }
  /* Listados: mismo contenedor, densidad y contraste, sin alterar columnas ni acciones. */
  html body.app main.aas-workspace section.cp-ventas .table-wrap,
  html body.compras-with-sidebar>main section.card.compras-listado {
    box-sizing:border-box!important;
    width:100%!important;
    background:#fff!important;
    border:1px solid #e4d9ce!important;
    border-radius:9px!important;
    padding:0!important;
    margin:0 0 14px!important;
    overflow-x:auto!important;
    box-shadow:0 3px 12px rgba(75,29,41,.035)!important;
  }
  html body.app main.aas-workspace section.cp-ventas .table-wrap table,
  html body.compras-with-sidebar>main section.card.compras-listado table {
    box-sizing:border-box!important;
    border-collapse:collapse!important;
    width:100%!important;
    min-width:0!important;
    font:400 12px/1.4 Roboto,Arial,sans-serif!important;
    background:#fff!important;
  }
  html body.app main.aas-workspace section.cp-ventas .table-wrap table th,
  html body.compras-with-sidebar>main section.card.compras-listado table th {
    font:700 11px/1.35 Roboto,Arial,sans-serif!important;
    background:#f5efe9!important;
    color:#705d4e!important;
    text-align:center!important;
    padding:9px 10px!important;
    border-bottom:1px solid #dfd3ca!important;
  }
  html body.app main.aas-workspace section.cp-ventas .table-wrap table td,
  html body.compras-with-sidebar>main section.card.compras-listado table td {
    font:400 12px/1.4 Roboto,Arial,sans-serif!important;
    padding:9px 10px!important;
    border-bottom:1px solid #e8ded5!important;
    vertical-align:middle!important;
  }
  html body.app main.aas-workspace section.cp-ventas .table-wrap table td a[href],
  html body.compras-with-sidebar>main section.card.compras-listado table td a[href] {
    font:600 12px/1.3 Roboto,Arial,sans-serif!important;
    min-height:30px!important;
  }
  html body.compras-with-sidebar>main section.card.compras-listado p.muted {
    padding:0 12px 12px!important;
    margin:0!important;
  }
}
@media screen and (max-width:900px) {
  html body.app main.aas-workspace section.cp-ventas form.cp-filtros {
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
  html body.app main.aas-workspace section.cp-ventas form.cp-filtros .cp-buscar {
    grid-column:1/-1!important;
  }
}
@media screen and (max-width:600px) {
  html body.app main.aas-workspace section.cp-ventas form.cp-filtros {grid-template-columns:minmax(0,1fr)!important;}
  html body.app main.aas-workspace section.cp-ventas form.cp-filtros .cp-buscar {grid-column:1!important;}
  html body.app:has(section.cp-ventas) main.aas-workspace header.page-head.aas-head h1,
  html body.compras-with-sidebar>main header.compras-page-head h1 {font-size:19px!important;}
}
