/* Compact layouts for phones and tablets. Touch controls retain their hit area. */
@media (max-width: 1199px) {
  .app-shell .app-content:has(.ref-page, .ventas-page, .productos-page, .cotizaciones-page, .catalogos-page, .caja-page, .pos-terminal, .producto-nuevo) {
    padding: 12px 16px 16px;
  }

  .app-content :is(.ref-page, .ventas-page, .productos-page, .cotizaciones-page, .catalogos-page, .caja-page, .pos-terminal) { gap: 12px; }
  .app-content :is(.ref-page, .ventas-page, .productos-page, .cotizaciones-page, .catalogos-page, .caja-page, .pos-terminal, .producto-nuevo) .ui-page-heading h1 {
    font-size: clamp(23px, 3.2vw, 30px);
    line-height: 1.12;
  }
  .app-content :is(.ref-page, .ventas-page, .productos-page, .cotizaciones-page, .catalogos-page, .caja-page, .pos-terminal) .ui-page-heading p { font-size: 14px; line-height: 1.35; }
  .ref-page>.ui-page-heading, .ref-page>.reportes>.ui-page-heading { min-height: 52px; padding-left: 56px; }
  .app-content .ref-page .ref-heading-icon { width: 40px; height: 40px; top: 0; border-radius: 12px; }
  .app-content .ref-page .ref-heading-icon>svg { width: 26px; height: 26px; }
  .app-content .ref-page .ref-footer { margin-inline: -16px; }
  .ref-page>.ui-page-heading::after, .app-content .ref-page .reportes>.ui-page-heading::after { display: none; }

  .app-content .ref-page .ref-kpis, .ref-page.ref-reportes .report-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .app-content .ref-page .ref-supplier-kpis>:last-child { grid-column: 1 / -1; }
  .app-content .ref-page .ref-kpis .ui-metric,
  .ref-page.ref-reportes .report-kpis>.ui-metric {
    min-height: 74px;
    padding: 10px;
    border-radius: 12px;
    align-items: center;
    flex-direction: row;
    gap: 8px;
  }
  .app-content .ref-page .ref-kpis .ui-metric-icon,
  .ref-page.ref-reportes .report-kpis .ui-metric-icon { flex: 0 0 34px; width: 34px; height: 34px; min-height: 0; align-self: center; border-radius: 9px; }
  .app-content .ref-page .ref-kpis .ui-metric-icon svg, .ref-page.ref-reportes .report-kpis .ui-metric-icon svg { width: 20px; height: 20px; }
  .app-content .ref-page .ref-kpis .ui-metric>div { padding-left: 0; border-left: 0; }
  .app-content :is(.ref-page, .ventas-page) :is(.ref-kpis, .report-kpis) .ui-metric>div>p:first-child { font-size: 13px; line-height: 1.18; }
  .app-content :is(.ref-page, .ventas-page) :is(.ref-kpis, .report-kpis) .ui-metric>div>p:nth-child(2) { font-size: clamp(17px, 2.5vw, 24px); margin-top: 4px; line-height: 1.15; }
  .app-content .ref-page .ref-kpis .ui-metric::after { opacity: .1; }
  .app-content .ref-page .ref-filters, .ventas-page .ventas-filtros, .productos-page .productos-filtros, .cotizaciones-page .cotizaciones-filtros { gap: 8px; padding: 8px; border-radius: 12px; }
  .app-content .ref-page .ref-filters .input, .app-content .ref-page .ref-filters select.input { height: 44px; min-height: 44px; }
  .app-content :is(.ref-filters, .ventas-filtros, .productos-filtros, .cotizaciones-filtros, .pos-toolbar) > * { min-width: 0; }
  .app-content .ref-page .ui-table table { min-width: 0; }
  .app-content .ventas-tabla table { min-width: 790px; }
  .app-content .productos-tabla table { min-width: 950px; }
  .app-content .productos-page[data-editor=false] .productos-tabla table { min-width: 660px; }
  .app-content :is(.ventas-tabla, .productos-tabla) .ui-table :is(.th, .td) { padding: 7px 8px; }
  .app-content .productos-tabla .td:nth-child(2) p:first-child { font-size: 14px; }
  .app-content .productos-tabla :is(.productos-categoria, .productos-compra, .productos-venta, .productos-margen, .productos-stock) {
    min-width: 0;
    padding-inline: 6px;
    gap: 4px;
    font-size: 14px;
  }
  .app-content .productos-tabla :is(.productos-categoria, .productos-margen, .productos-stock) svg { width: 15px; flex-shrink: 0; }
  .app-content .ref-page .ui-table :is(.td, .th) { height: auto; padding: 8px 10px; font-size: 14px; }
  .app-content .ref-page .ui-table .th { white-space: nowrap; }
  .app-content .ref-page .ui-table .th:last-child::after { display: none; }
  .app-content .ref-page .ui-table .ref-title { gap: 6px; }
  .app-content .ref-page .ui-table .ref-title svg { width: 16px; height: 16px; }
  .app-content .ref-page .ui-table .ref-person { min-width: 180px; gap: 8px; }
  .app-content .ref-page .ui-table .ref-avatar { width: 36px; min-height: 36px; font-size: 15px; }
  .app-content .ref-page .ui-table :is(.ref-count, .ref-money) { min-width: 0; font-size: 15px; padding-inline: 8px; white-space: nowrap; }
  .app-content .ref-page .ui-table .ui-badge { font-size: 13px; padding-inline: 8px; }
  .app-content .ref-page .ui-table .td :is(button, a):has(>svg:only-child) { min-height: 44px; min-width: 44px; }
  .app-content .ref-page .ref-empty { min-height: 0; padding: 12px 10px 14px; }
  .app-content .ref-page .ref-empty-art { width: 160px; height: 96px; }
  .app-content .ref-page .ref-empty-art>.ref-empty-box { width: 85px; height: 70px; }
  .app-content .ref-page .ref-empty-coins { right: 12px; bottom: 4px; padding: 4px; }
  .app-content .ref-page .ref-empty-coins svg { width: 36px; height: 36px; }
  .app-content .ref-page .ref-empty h2 { font-size: 19px; }
  .app-content .ref-page .ref-empty p, .app-content .ref-page .ref-empty .ui-button { font-size: 14px; }
  .app-content .caja-page .caja-open-ilustracion { width: 105px; height: 70px; object-fit: contain; margin-block: 0 5px; }
  .caja-page .caja-history-empty>img { height: 90px; object-fit: contain; }
  .app-content .catalogos-page .catalogos-vacio { min-height: 0; padding: 12px 12px 18px; }
  .catalogos-page .catalogos-vacio img { width: 160px; height: 100px; }
  .catalogos-page .catalogos-vacio h3 { font-size: 20px; }
  .cotizaciones-page .cotizaciones-vacio { min-height: 0; padding: 16px 12px; }
  .cotizaciones-page .cotizaciones-vacio img { height: 95px; object-fit: contain; }
}

@media (max-width: 599px) {
  .app-shell .app-content:has(.ref-page, .ventas-page, .productos-page, .cotizaciones-page, .catalogos-page, .caja-page, .pos-terminal, .producto-nuevo) { padding-inline: 12px; }
  .app-content .ref-page .ref-footer, .app-content :is(.caja-pie, .productos-pie, .cotizaciones-pie, .catalogos-pie) { margin-inline: -12px; }
  .app-content .productos-page::after { inset-inline: -12px; }
  .app-content :is(.ref-page, .productos-page, .cotizaciones-page, .catalogos-page) > .experience-tip {
    min-height: 0;
    padding: 8px 10px;
    gap: 4px 8px;
    border-radius: 12px;
  }
  .app-content :is(.ref-page, .productos-page, .cotizaciones-page, .catalogos-page) > .experience-tip > svg { width: 23px; height: 23px; padding: 0; align-self: start; }
  .app-content :is(.ref-page, .productos-page, .cotizaciones-page, .catalogos-page) > .experience-tip strong { font-size: 15px; }
  .app-content :is(.ref-page, .productos-page, .cotizaciones-page, .catalogos-page) > .experience-tip p { font-size: 13px; line-height: 1.35; }
  .app-content :is(.ref-page, .productos-page, .cotizaciones-page, .catalogos-page) > .experience-tip button { margin: 0 0 0 31px; background: transparent; border: 0; box-shadow: none; padding-inline: 0; }

  .app-content .ref-page:not(.listado-operativo) .ref-kpis .ui-metric-icon, .ref-page.ref-reportes .report-kpis .ui-metric-icon { display: none; }
  .ref-page.ref-reportes .report-kpis>.ui-metric { min-height: 94px; align-items: flex-start; }
  .ref-page.ref-reportes .report-kpis .ui-metric>div>p:nth-child(3) { margin-top: 4px; font-size: 12px; line-height: 1.25; }
  .ref-page.ref-reportes .report-filters { padding: 10px; }
  .ref-page.ref-reportes .report-presets { display: grid; grid-template-columns: 1fr 1fr; }
  .ref-page.ref-reportes .report-presets button { min-width: 0; padding-inline: 4px; }
  .ref-page.ref-reportes .report-tabs button { min-width: 0; padding-inline: 8px; font-size: 13px; white-space: normal; line-height: 1.2; }

  .app-content :is(.ref-filters, .ventas-filtros, .productos-filtros, .cotizaciones-filtros) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-content :is(.ref-filters, .ventas-filtros, .productos-filtros, .cotizaciones-filtros) > :first-child,
  .app-content :is(.ref-filters, .ventas-filtros, .productos-filtros, .cotizaciones-filtros) > button,
  .ref-compras .ref-filters > :nth-child(4),
  .ref-clientes .ref-filters > :last-child,
  .ref-proveedores .ref-filters > :last-child,
  .cotizaciones-page .cotizaciones-filtros > :nth-child(2) { grid-column: 1 / -1; }
  .app-content .productos-page .productos-filtros { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .productos-page .productos-filtros > :nth-child(4) { grid-column: 1 / -1; }
  .ref-inventario .ref-filters > :nth-child(2) { grid-column: 1 / -1; }
  .app-content .caja-page .caja-heading { min-height: 0; margin-bottom: 8px; gap: 10px; align-items: flex-start; }
  .app-content .caja-page .caja-heading h1 { font-size: 25px; }
  .app-content .caja-page .caja-heading p { margin-top: 22px; line-height: 1.3; }
  .app-content .caja-page .caja-heading .caja-turno-badge { left: 50px; top: 27px; padding-block: 1px; }
  .app-content .caja-page .caja-heading-icon { width: 40px; height: 40px; }
  .app-content .caja-page .caja-open { padding: 12px; border-width: 2px; }
  .app-content .caja-page .caja-open-ilustracion { display: none; }
  .app-content .caja-page .caja-open-intro h2 { font-size: 18px; }
  .app-content .caja-page .caja-open-intro p { line-height: 1.35; }
  .app-content .caja-page .caja-open form { margin-top: 10px; }
  .app-content .caja-page .caja-open fieldset { gap: 8px; }
  .app-content .caja-page .caja-open fieldset > button { font-size: 16px; }
  .app-content .caja-page .caja-open-monto .input { font-size: 17px; height: 44px; min-height: 44px; }
  .app-content .caja-page .caja-open-monto > span { font-size: 17px; }
  .app-content .caja-page .caja-tip { padding: 7px 11px; gap: 2px; font-size: 13px; }
  .app-content .caja-page .caja-history h2 { font-size: 19px; }
  .app-content .caja-page .caja-history-empty > img { height: 65px; }
  .app-content .caja-page .caja-history-empty h3 { font-size: 17px; }
  .app-content .caja-page .caja-metric { padding: 10px; gap: 5px; }
  .app-content .caja-page .caja-metric strong { font-size: 18px; overflow-wrap: anywhere; }
  .pos-terminal .pos-product-photo { height: 46px; }
  .pos-terminal .pos-product { gap: 5px; padding: 7px; }
  .pos-terminal .pos-toolbar { gap: 6px; margin-bottom: 8px; }
  .pos-terminal .pos-tip { margin-bottom: 8px; }
}

@media (min-width: 700px) and (max-width: 1199px) {
  .app-content :is(.ref-page, .ventas-page, .productos-page, .cotizaciones-page, .catalogos-page, .caja-page, .pos-terminal, .producto-nuevo) .ui-page-heading h1 { font-size: clamp(29px, 3.5vw, 36px); }
  .app-content :is(.ref-page, .ventas-page, .productos-page, .cotizaciones-page, .catalogos-page, .pos-terminal) .ui-page-heading p { font-size: 16px; }
  .app-content .ref-page .ui-table :is(.td, .th) { font-size: 15px; }
  .app-content .productos-tabla .td:nth-child(2) p:first-child { font-size: 16px; }
  .app-content .pos-terminal .pos-product-name { font-size: 14px; }
  .app-content .pos-terminal .pos-product-price { font-size: 16px; }

  .app-content .ref-page .ref-supplier-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-content .ref-page .ref-supplier-kpis>:last-child { grid-column: auto; }
  .app-content .ref-page:where(:not(.listado-operativo)) .ref-kpis:not(.ref-supplier-kpis):has(>:nth-child(4)), .ref-page.ref-reportes .report-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ref-page.ref-reportes .report-overview { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 12px; }
  .ref-page.ref-configuracion>form { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 12px; }
  .ref-page.ref-configuracion .ref-company .ui-panel-content>div { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .app-content .productos-page .productos-filtros { grid-template-columns: minmax(0, 1.35fr) repeat(3, minmax(0, 1fr)); }
  .catalogos-page .catalogos-columnas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}

@media (min-width: 700px) and (max-width: 899px) {
  .pos-terminal .pos-products[data-vista=tarjetas] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 900px) and (max-width: 1199px) {
  .app-shell:has(.pos-terminal) .app-topbar { min-height: 52px; }
  .pos-terminal .pos-products[data-vista=tarjetas] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pos-terminal .pos-products[data-vista=tarjetas] .pos-product { min-height: 108px; height: auto; padding: 8px; }
  .pos-terminal .pos-charge { min-height: 44px; font-size: 15px; }
}
