/* Celular (v0.92): navegación inferior tipo app, barra superior compacta,
   tablas que no entran pasan a tarjetas y diálogos como hoja desde abajo.
   Se carga al final; en escritorio solo oculta los accesos propios del celular. */
.topbar-brand,.topbar-tools{display:none}

@media(max-width:700px){
  /* Barra de navegación inferior */
  body .sidebar{position:fixed!important;top:auto!important;left:0!important;right:0!important;bottom:0!important;width:auto!important;height:auto!important;min-height:0!important;z-index:60;display:block!important;padding:6px 6px calc(6px + env(safe-area-inset-bottom))!important;margin:0!important;background:rgba(250,249,246,.94)!important;-webkit-backdrop-filter:saturate(180%) blur(20px);backdrop-filter:saturate(180%) blur(20px);border:0!important;border-top:1px solid var(--sep)!important;box-shadow:0 -6px 20px rgba(40,30,20,.06);overflow:visible!important}
  body .sidebar .brand,body .sidebar .nav-label,body .sidebar nav:last-of-type{display:none!important}
  /* v0.102: más contraste. La barra es un «riel» gris como el selector Semana/Mes/Trimestre y la pestaña activa, una pastilla blanca en relieve. */
  body .sidebar{background:rgba(250,249,246,.98)!important;border-top:1px solid rgba(29,26,23,.14)!important;box-shadow:0 -8px 24px rgba(40,30,20,.10)}
  body .sidebar nav:first-of-type{display:grid!important;grid-template-columns:repeat(6,minmax(0,1fr));gap:3px;width:100%;margin:0;padding:4px!important;border-radius:16px;background:rgba(118,104,88,.12);overflow:visible!important}
  body .sidebar nav:first-of-type a{display:flex!important;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-height:50px;height:auto!important;padding:6px 1px!important;margin:0!important;border-radius:12px!important;font-size:10.5px!important;font-weight:600;letter-spacing:0;line-height:1.1;color:#3a342e!important;background:transparent!important;box-shadow:none!important;white-space:nowrap;text-align:center;overflow:hidden;transition:background-color .18s ease,box-shadow .18s ease,color .18s ease}
  body .sidebar nav:first-of-type a svg{width:23px!important;height:23px!important;min-width:0;color:var(--ink);stroke-width:1.85}
  body .sidebar nav:first-of-type a>span{display:block!important;opacity:1!important;visibility:visible!important;max-width:100%;overflow:hidden;text-overflow:ellipsis}
  body .sidebar nav:first-of-type a.active{color:var(--ink)!important;font-weight:700;background:var(--surface)!important;box-shadow:0 1px 2px rgba(40,30,20,.12),0 3px 10px rgba(40,30,20,.10)!important}
  body .sidebar nav:first-of-type a.active svg{color:var(--ink);stroke-width:2.05}
  /* Pastilla deslizante (motion.mjs): la blanca se mueve de una sección a otra. */
  body .sidebar nav.main-nav.has-ind{position:relative;isolation:isolate}
  body .sidebar nav.main-nav.has-ind a.active{background:transparent!important;box-shadow:none!important}
  body .sidebar nav.main-nav>.seg-ind{border-radius:12px;background:var(--surface);box-shadow:0 1px 2px rgba(40,30,20,.12),0 3px 10px rgba(40,30,20,.10)}
  body .sidebar nav:first-of-type a:focus-visible{outline:2px solid var(--gold);outline-offset:-2px}
  .main{margin-left:0!important;padding-bottom:calc(78px + env(safe-area-inset-bottom))}

  /* Barra superior compacta: logo a la izquierda; herramientas, avisos a la derecha */
  .topbar{height:auto!important;min-height:56px;padding:calc(6px + env(safe-area-inset-top)) 12px 6px 16px!important;gap:8px}
  .topbar-brand{display:flex;align-items:center;flex:0 0 auto}
  .topbar-brand img{width:108px;height:auto;display:block}
  .topbar .breadcrumb,.topbar .brand-avatar{display:none!important}
  .top-actions{gap:2px!important;margin-left:auto}
  .topbar .mode-tag{font-size:10.5px;padding:5px 8px;margin-right:4px;white-space:nowrap}
  .topbar-tools{display:flex;gap:2px}
  .topbar .icon-btn{width:40px;height:40px;min-width:40px;display:inline-grid;place-items:center;border-radius:12px;color:var(--ink-2)}
  .topbar-tools .icon-btn.is-active,.topbar .icon-btn.notification.is-active{background:rgba(213,160,33,.13);color:var(--ink)}

  /* Encabezado de cada sección */
  .main main{padding:18px 16px 0!important}
  .page-heading{flex-wrap:wrap;align-items:center;gap:10px 12px;margin-bottom:18px}
  .page-heading h1{font-size:28px;line-height:1.15;margin:0}
  .page-heading-actions{display:flex;flex-wrap:wrap;gap:8px;margin-left:auto}
  .page-heading .btn{margin-top:0!important}

  /* Botones y campos con tamaño cómodo para el dedo; 16px evita el zoom automático del iPhone */
  .btn{min-height:40px}
  input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea{font-size:16px!important}

  /* Tablero de pedidos: columnas que se deslizan de a una */
  .kanban{display:grid!important;grid-template-columns:none!important;grid-auto-flow:column;grid-auto-columns:86%;gap:12px!important;overflow-x:auto;scroll-snap-type:x mandatory;overscroll-behavior-x:contain;padding-bottom:8px;scrollbar-width:none}
  .kanban::-webkit-scrollbar{display:none}
  .kanban>*{scroll-snap-align:start;min-width:0}

  /* Tablas que no entran: cada fila es una tarjeta (lo decide mobile-tables.mjs) */
  .table-wrap.is-stacked{overflow:visible!important}
  .table-wrap.is-stacked>table{display:block;width:100%!important;min-width:0!important;table-layout:auto}
  .table-wrap.is-stacked>table>colgroup,.table-wrap.is-stacked>table>thead{display:none}
  .table-wrap.is-stacked>table>tbody{display:block}
  .table-wrap.is-stacked>table>tbody>tr{display:block;position:relative;padding:12px 16px;border-bottom:1px solid var(--sep)}
  .table-wrap.is-stacked>table>tbody>tr:last-child{border-bottom:0}
  .table-wrap.is-stacked>table>tbody>tr>td{display:flow-root;width:auto!important;max-width:none!important;padding:3px 0!important;border:0!important;text-align:right!important;white-space:normal!important;font-size:13px;min-height:0;height:auto}
  .table-wrap.is-stacked>table>tbody>tr>td::before{content:attr(data-label);float:left;margin-right:14px;color:var(--ink-3);font-size:12px;font-weight:500;text-align:left}
  .table-wrap.is-stacked>table>tbody>tr>td:not([data-label])::before{content:none}
  .table-wrap.is-stacked>table>tbody>tr>td:empty{display:none}
  /* La primera celda (o la que sigue a un casillero) es el título de la tarjeta */
  .table-wrap.is-stacked>table>tbody>tr>td:first-child,.table-wrap.is-stacked>table>tbody>tr>td:has(>input[type=checkbox]:only-child)+td{text-align:left!important;font-size:14px;padding:0 44px 6px 0!important}
  .table-wrap.is-stacked>table>tbody>tr>td:first-child::before,.table-wrap.is-stacked>table>tbody>tr>td:has(>input[type=checkbox]:only-child)+td::before{content:none}
  /* Casillero de selección arriba a la derecha */
  .table-wrap.is-stacked>table>tbody>tr>td:has(>input[type=checkbox]:only-child){position:absolute;top:10px;right:12px;padding:0!important}
  .table-wrap.is-stacked>table>tbody>tr>td:has(>input[type=checkbox]:only-child)::before{content:none}
  /* Acciones (columna sin título) alineadas a la derecha, en su propia línea */
  .table-wrap.is-stacked>table>tbody>tr>td:not([data-label]):not(:first-child){padding-top:6px!important}
  .table-wrap.is-stacked>table>tbody>tr>td:not([data-label]):not(:first-child) :is(.btn,button,a){margin-left:6px}

  /* Diálogos como hoja que sube desde abajo */
  dialog#modal,dialog.sheet{width:100%!important;max-width:100%!important;margin:auto 0 0!important;border-radius:22px 22px 0 0!important;max-height:94dvh!important;padding:20px 16px calc(20px + env(safe-area-inset-bottom))!important}
  dialog .form-grid{grid-template-columns:minmax(0,1fr)!important}
  dialog .form-actions{position:sticky;bottom:calc(-20px - env(safe-area-inset-bottom));background:var(--surface);padding:12px 0 calc(12px + env(safe-area-inset-bottom));margin-bottom:calc(-20px - env(safe-area-inset-bottom));z-index:2;flex-wrap:wrap;gap:8px}

  /* Avisos flotantes por encima de la barra inferior */
  #toast{left:50%!important;bottom:calc(84px + env(safe-area-inset-bottom))!important;max-width:calc(100vw - 32px)}

  /* Egresos: tarjeta de retiros ordenada como las demás */
  .metric.kpi.withdrawal-summary{display:flex!important;flex-direction:column!important;align-items:stretch!important}
}

/* App instalada (sin barra del navegador): respeta la muesca y la barra de estado */
@media(display-mode:standalone) and (max-width:700px){
  .topbar{padding-top:calc(10px + env(safe-area-inset-top))!important}
}
@media(prefers-reduced-motion:reduce){.kanban{scroll-behavior:auto}}
@media(max-width:700px){
  .metric.kpi.withdrawal-summary>*{flex:0 0 auto!important}
  .metric.kpi.withdrawal-summary .kpi-meta{flex-wrap:wrap}
  /* Filtros de productos en dos columnas parejas */
  .filter-pills{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;width:100%}
  .filter-pills select{width:100%;min-width:0}
}
@media(max-width:700px){
  /* Entregas: cada parada con sus botones en fila y «Registrar entrega» a todo el ancho */
  .delivery-route li{display:grid!important;grid-template-columns:32px minmax(0,1fr);column-gap:12px;row-gap:10px;align-items:start}
  .delivery-route li>div{grid-column:2}
  .delivery-route li>.btn{grid-column:2;width:100%;justify-content:center;font-size:14px!important;min-height:44px;background:var(--ink);color:#fff;border-color:transparent}
  .delivery-route strong{font-size:15px}
  .delivery-route small{font-size:12px}
  .route-stop-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
  .route-stop-actions .btn,.route-stop-contact .btn{min-height:40px;font-size:13px}
}
/* v0.101: un botón oculto por permisos (ej. la campanita) no reaparece por el estilo de celular */
.topbar .icon-btn[hidden]{display:none!important}

@media(max-width:700px){
  /* Pedidos de la parada (v0.102) */
  .route-order-detail{border-radius:16px;margin-bottom:14px;background:var(--surface)}
  .route-order-head{padding:14px 16px 10px;gap:6px 8px}
  .route-order-head h3{flex:1 1 100%;min-width:0;font-size:16px;line-height:1.3}
  .route-order-detail .table-wrap{display:none}
  .route-order-lines{display:block;list-style:none;margin:0;padding:0 16px 4px}
  .route-order-lines li{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:10px 0;border-top:1px solid var(--sep)}
  .route-order-lines li>div{display:grid;gap:2px;min-width:0}
  .route-order-lines strong{font-size:14.5px;font-weight:600}
  .route-order-lines small{font-size:12.5px;color:var(--ink-2);font-variant-numeric:tabular-nums}
  .route-order-lines b{font-size:14.5px;font-weight:600;white-space:nowrap;font-variant-numeric:tabular-nums}
  .route-order-sum{display:grid;gap:10px;padding:14px 16px;margin:4px 0 0}
  .route-order-breakdown{min-width:0;font-size:13px}
  .route-order-breakdown:empty{display:none}
  .route-order-total{grid-template-columns:1fr auto;justify-items:start;align-items:center;text-align:left;gap:2px 12px}
  .route-order-total>span{grid-column:1/-1}
  .route-order-total>strong{font-size:26px}
  .route-order-total>em{justify-self:end}
  .route-order-actions{padding:12px 16px 14px}
}

/* v0.102: barra de pedidos seleccionados. En el celular flota arriba de la barra de secciones y no empuja el tablero. */
.orders-selection-bar>span{color:rgba(255,255,255,.88)!important;font-weight:600}
.orders-selection-bar .btn.ghost{color:#f3d68a}
@media(max-width:700px){
  .orders-selection-bar{position:fixed;left:12px;right:12px;bottom:calc(82px + env(safe-area-inset-bottom));z-index:55;margin:0!important;display:flex!important;flex-wrap:nowrap!important;align-items:center;justify-content:space-between!important;gap:6px!important;padding:8px 8px 8px 16px!important;border-radius:16px!important;background:rgba(36,30,26,.94)!important;box-shadow:0 10px 28px rgba(20,14,10,.28)!important}
  .orders-selection-bar>span{flex:1;font-size:14px;white-space:nowrap}
  .orders-selection-bar .btn{min-height:38px;padding:8px 14px!important;font-size:13.5px!important;border-radius:12px;white-space:nowrap}
  .orders-selection-bar .btn.secondary{background:#fff;color:var(--ink);border:0}
  .orders-selection-bar .btn.ghost{background:transparent;border:0;padding:8px 10px!important}
  .main:has(.orders-selection-bar){padding-bottom:calc(140px + env(safe-area-inset-bottom))}
}

/* v0.102: período en una sola fila (Semana/Mes/Trimestre + flechas con la etiqueta corta). */
@media(max-width:700px){
  .dash-period{flex-wrap:nowrap!important;gap:6px!important;width:100%}
  .dash-period .seg{flex:0 0 auto;padding:3px}
  .dash-period .seg-btn{padding:7px 7px;font-size:12px}
  .dash-period .week-stepper{flex:1 1 auto;min-width:0;display:grid;grid-template-columns:24px minmax(0,1fr) 24px;align-items:center;padding:3px 2px}
  .dash-period .week-stepper .icon-btn{width:24px;height:32px;min-width:0;padding:0}
  .dash-label{justify-content:center;min-width:0}
  .dash-label .dash-full,.dash-label>em{display:none!important}
  .dash-label .dash-short{display:block;min-width:0!important;text-align:center;font-size:13px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .dash-label.is-now .dash-short{color:#a2761c}
}
@media(max-width:700px){.hide-sm{display:none}.show-sm{display:inline}}

/* v0.102: encabezado y barra de secciones como «islas» flotantes en espresso, redondeadas, separadas del contenido. */
.logo-dark{display:none}
@media(max-width:700px){
  .topbar{position:sticky!important;top:calc(6px + env(safe-area-inset-top))!important;margin:calc(6px + env(safe-area-inset-top)) 10px 0!important;padding:6px 8px 6px 14px!important;min-height:54px;border-radius:22px!important;background:rgba(38,31,27,.94)!important;-webkit-backdrop-filter:saturate(160%) blur(18px);backdrop-filter:saturate(160%) blur(18px);border:0!important;box-shadow:0 8px 24px rgba(20,14,10,.22)!important}
  .topbar .logo-light{display:none!important}
  .topbar .logo-dark{display:block!important;width:104px}
  .topbar .icon-btn{color:#f6efe3!important;border-radius:14px}
  .topbar .icon-btn svg{stroke-width:1.9}
  .topbar-tools .icon-btn.is-active,.topbar .icon-btn.notification.is-active{background:rgba(255,255,255,.14)!important;color:#fff!important}
  .topbar .notification-count{box-shadow:0 0 0 2px rgb(38,31,27)!important}
  body .sidebar{left:10px!important;right:10px!important;bottom:max(8px,calc(env(safe-area-inset-bottom) - 14px))!important;padding:6px!important;border-radius:26px!important;background:rgba(38,31,27,.95)!important;-webkit-backdrop-filter:saturate(160%) blur(18px);backdrop-filter:saturate(160%) blur(18px);border:0!important;box-shadow:0 10px 30px rgba(20,14,10,.28)!important}
  body .sidebar nav:first-of-type{background:transparent!important;padding:0!important;border-radius:20px}
  body .sidebar nav:first-of-type a{color:rgba(246,239,227,.78)!important;border-radius:20px!important;min-height:52px}
  body .sidebar nav:first-of-type a svg{color:#f6efe3}
  body .sidebar nav:first-of-type a.active{color:#2a211b!important}
  body .sidebar nav:first-of-type a.active svg{color:#2a211b}
  body .sidebar nav.main-nav>.seg-ind{border-radius:20px;background:linear-gradient(180deg,#f0c75a,#d9a521);box-shadow:0 2px 10px rgba(217,165,33,.35)}
  body .sidebar nav.main-nav:not(.has-ind) a.active{background:linear-gradient(180deg,#f0c75a,#d9a521)!important}
  .main{padding-bottom:calc(84px + max(8px,env(safe-area-inset-bottom) - 14px))!important}
  .orders-selection-bar{bottom:calc(80px + max(8px,env(safe-area-inset-bottom) - 14px))!important}
  #toast{bottom:calc(84px + max(8px,env(safe-area-inset-bottom) - 14px))!important}
}


/* v0.102: Productos recomendados (legajo del cliente) más legible en el celular. */
@media(max-width:700px){
  .pet-rec-categories{display:flex!important;flex-wrap:nowrap!important;width:100%;overflow-x:auto;scrollbar-width:none;margin:10px 0 8px!important}
  .pet-rec-categories::-webkit-scrollbar{display:none}
  .pet-rec-category{flex:1 1 0;padding:8px 10px!important;font-size:14px!important;white-space:nowrap}
  .pet-rec-toolbar{display:grid!important;grid-template-columns:1fr 1fr;gap:8px!important;margin:6px 0 4px!important}
  .pet-rec-toolbar label{display:grid;gap:4px;font-size:12px!important;color:var(--ink-3);font-weight:500}
  .pet-rec-toolbar select{max-width:none!important;width:100%;height:40px;font-size:16px!important;padding:0 32px 0 12px;border-radius:12px}
  .pet-rec-group{padding:14px 0!important}
  .pet-rec-main{grid-template-columns:repeat(3,minmax(0,1fr)) 30px!important;gap:10px 8px!important;align-items:end;font-size:15px!important}
  .pet-rec-name{grid-column:1/-1;display:grid;gap:2px}
  .pet-rec-name strong{font-size:15.5px;font-weight:650;line-height:1.3}
  .pet-rec-name small{font-size:13px!important;color:var(--ink-3)}
  .pet-rec-metric{display:grid;gap:2px;text-align:left}
  .pet-rec-metric small{font-size:12px!important;color:var(--ink-3)}
  .pet-rec-metric strong{font-size:15.5px!important;font-weight:650;font-variant-numeric:tabular-nums}
  .pet-rec-main .pet-rec-utility strong{font-size:15px!important;font-weight:500;color:var(--ink-2)}
  .pet-rec-expand{grid-column:4;grid-row:2;align-self:center;width:30px;height:30px;padding:0!important;border-radius:10px!important;background:var(--fill)!important;font-size:20px!important}
}
@media(max-width:700px){
  /* Cada producto recomendado como tarjeta propia, bien separada de la siguiente. */
  .pet-rec-group{background:#f7f3ec;border:1px solid rgba(66,54,47,.10)!important;border-radius:16px;padding:12px 14px!important;margin:0 0 10px}
  .pet-rec-group:last-of-type{margin-bottom:0}
  .pet-rec-presentations{background:var(--surface);border-radius:12px}
}
@media(max-width:700px){
  .delivery-toolbar{display:grid!important;grid-template-columns:minmax(0,1fr) auto;gap:8px!important;align-items:center}
  .delivery-toolbar .day-stepper{grid-column:1;grid-row:1;min-width:0}
  .delivery-toolbar .delivery-all-toggle{grid-column:2;grid-row:1;height:40px;padding:0 12px;font-size:13.5px}
  .delivery-toolbar>.toolbar-note,.delivery-toolbar>.delivery-chip,.delivery-toolbar>.toolbar-end{grid-column:1/-1}
  .delivery-toolbar>.toolbar-end:empty{display:none}
  .saved-routes-picker select{font-size:16px;height:40px;max-width:170px}
}
@media(max-width:700px){
  .delivery-toolbar .day-stepper .week-stepper-label{flex:1;min-width:0;justify-content:center;gap:6px}
  .delivery-toolbar .day-stepper .week-stepper-label span{min-width:0!important}
  .delivery-toolbar .day-stepper .icon-btn{flex:0 0 auto}
}
@media(max-width:700px){
  .delivery-toolbar .day-stepper .week-stepper-label>em{display:none}
  .delivery-toolbar .day-stepper .week-stepper-label:has(em) span{color:#a2761c;font-weight:650}
  .saved-routes-picker select{max-width:200px!important;width:auto}
}
@media(max-width:700px){
  dialog.delivery-mode{width:100vw!important;max-width:100vw!important;height:100dvh;max-height:100dvh;margin:0;border-radius:0;padding:calc(12px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom))}
  .delivery-mode-head{position:sticky;top:calc(-12px - env(safe-area-inset-top));z-index:2;background:var(--bg,#f5f3ef);padding:6px 4px 8px;margin:0 -4px 8px}
  .delivery-mode-head h2{font-size:22px}
  .delivery-toolbar>.toolbar-end{display:flex}
  .delivery-mode-btn{width:100%;justify-content:center;height:46px;font-size:15px}
}
