/* Capa responsive del facturador. El diseño de escritorio sigue en app.css. */
.mobile-menu-toggle,.mobile-sidebar-head,.mobile-sidebar-backdrop,.mobile-logout-link,.mobile-sale-steps,.mobile-payment-panel,.mobile-sale-bar{display:none}
.visually-hidden{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
img,svg,iframe{max-width:100%}
.shell,main,.panel,.grid,.cards,.row-between,.two-col,.mini-cards,.sale-layout,.guide-form{min-width:0}
.tablewrap,.ccf-table-wrap{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
.actions,.row-actions,.sale-actions,.guide-actions,.note-actions{flex-wrap:wrap}
.pagehead h1,.panel h2,.panel h3,.wrap-cell,.mini-cards strong{overflow-wrap:anywhere}
.modal-backdrop,.ccf-overlay,.guide-modal{overscroll-behavior:contain}
.action-modal,.ccf-dialog,.guide-modal-card{max-width:100%;max-height:calc(100dvh - 20px)}

@media(max-width:991px){
  .top{min-height:64px;height:auto;padding:8px 14px;gap:10px;z-index:45}
  .top-brand{min-width:0;flex:1}
  .top-brand strong{display:block;font-size:17px;line-height:1.12;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .top-brand small{font-size:10px}
  .top-right{min-width:0;max-width:48%;gap:8px}
  .top-right form{min-width:0;width:100%}
  .top-right select{width:100%;max-width:100%;min-width:0;text-overflow:ellipsis}
  .top-right>span{display:none}
  .mobile-menu-toggle{display:inline-flex;align-items:center;justify-content:center;flex:0 0 44px;width:44px;height:44px;padding:0;border-radius:8px;font-size:22px}
  .mobile-sidebar-backdrop{position:fixed;inset:0;background:rgba(14,25,39,.55);z-index:48;border:0;border-radius:0;padding:0;width:100%;height:100%;display:block;visibility:hidden;opacity:0;pointer-events:none;transition:opacity .2s}
  body.mobile-menu-open .mobile-sidebar-backdrop{visibility:visible;opacity:1;pointer-events:auto}
  body.mobile-menu-open{overflow:hidden}
  .shell{display:block;min-height:calc(100dvh - 64px)}
  .shell>aside{display:flex;justify-content:flex-start;position:fixed;top:0;bottom:0;left:0;z-index:49;width:min(84vw,330px);height:100dvh;padding:12px;overflow-y:auto;overscroll-behavior:contain;box-shadow:16px 0 32px rgba(0,0,0,.16);transform:translateX(-105%);visibility:hidden;transition:transform .2s,visibility .2s}
  body.mobile-menu-open .shell>aside{visibility:visible;transform:translateX(0)}
  .mobile-sidebar-head{display:flex;justify-content:space-between;align-items:center;padding:4px 5px 12px}
  .mobile-sidebar-head strong{font-size:20px}
  .mobile-sidebar-head button{background:#edf3f8;color:#243342;width:44px;height:44px;padding:0;font-size:28px}
  .shell>aside nav a{min-height:44px;display:flex;align-items:center;margin-bottom:3px}
  .shell>aside .status{margin-top:auto}
  .mobile-logout-link{display:flex!important}
  main{padding:18px}
  .pagehead{gap:12px;align-items:flex-start;flex-wrap:wrap}
  .pagehead h1{font-size:24px}
  .pagehead .actions{margin-bottom:0}
  .filters,.report-filters{flex-wrap:wrap;align-items:end}
  .filters label,.filters input,.filters select{min-width:0;max-width:none}
  .cards.dashboard-cards{grid-template-columns:repeat(2,minmax(0,1fr))}
  .currency-report-grid,.sire-summary-grid,.guide-route-grid,.sale-top-grid{grid-template-columns:1fr}
  .sunat-flow{grid-template-columns:1fr}
  .sire-toolbar,.sire-sync-actions{width:100%}
  .sire-table::before{content:'Desliza la tabla para ver todas las columnas y acciones';display:block;color:#607286;font-size:12px;padding:4px 0 10px}
  .sire-table table{min-width:970px}
  .guide-step-tabs{position:static}
  .guide-modal{padding:10px}
  .guide-modal-card{width:min(100%,680px);max-height:calc(100dvh - 20px)}
  .guide-modal-results{min-height:0;max-height:none;flex:1}
  .ccf-dialog{width:100%;max-height:calc(100dvh - 16px)}
  .ccf-overlay{padding:8px;align-items:flex-start}
  .modal-backdrop{padding:8px;align-items:flex-start;overflow-y:auto}
  .action-modal{width:100%;max-height:calc(100dvh - 16px);overflow-y:auto}
}

@media(max-width:767px){
  input,select,textarea{font-size:16px;min-height:44px;max-width:100%}
  input[type=checkbox],input[type=radio],input[type=hidden]{min-height:0}
  button,.btn{min-height:44px;touch-action:manipulation}
  .btn.small,.btn.tiny,.ghost{min-height:40px}
  .grid,.two-col,.settings-summary-grid,.credential-grid,.sire-meta-grid,.diagnostic-grid{grid-template-columns:1fr}
  .span2{grid-column:auto}
  .panel,.company-card{padding:14px}
  .panel h2{font-size:19px}
  .row-between{align-items:stretch}
  .row-between .btn,.actions .btn{max-width:100%}
  .smart-search,.product-smart-search{min-width:0}
  .smart-results{max-height:min(38dvh,340px);overscroll-behavior:contain}
  .smart-item{min-height:54px;white-space:normal}
  .smart-item span,.smart-item b,.smart-item small{min-width:0;overflow-wrap:anywhere}
  .smart-item strong{white-space:nowrap}
  .lookup-inline{flex-direction:column}
  .lookup-inline .btn{width:100%}
  .mini-cards,.mini-cards.four,.mini-cards.five,.sire-detail-cards{grid-template-columns:1fr 1fr}
  .mini-cards strong{white-space:normal}
  .ccf-action-cards,.action-grid{grid-template-columns:1fr}
  .ccf-dialog-head,.ccf-dialog-foot{padding:14px}
  .ccf-dialog-head{flex-wrap:wrap}
  .ccf-head-actions{width:100%}
  .ccf-preview-dialog{height:calc(100dvh - 16px);max-height:calc(100dvh - 16px)}
  .ccf-preview-stage{min-height:100px;flex:1;margin:8px;height:auto}
  .ccf-preview-note{margin:8px}
  .ccf-stat-grid{grid-template-columns:1fr 1fr}
  .ccf-tab-panel{padding:12px}
  .guide-step-tabs{display:flex;overflow-x:auto;scroll-snap-type:x mandatory}
  .guide-step-tabs button,.guide-step-tabs a{flex:0 0 min(72vw,270px);min-height:52px;scroll-snap-align:start;border-right:1px solid #e1e8f0;border-bottom:0}
  .guide-product-search-row{grid-template-columns:1fr}
  .guide-actions{display:grid;grid-template-columns:1fr 1fr}
  .guide-actions .btn{width:100%;white-space:normal}
  .guide-next .btn{width:100%}
  .guide-form .tablewrap{overflow:visible}
  #guide-lines,#guide-lines tbody,#guide-lines tr{display:block;width:100%}
  #guide-lines thead{display:none}
  #guide-lines tr{border:1px solid #dce5ed;border-radius:9px;padding:10px;margin:10px 0;background:#fff}
  #guide-lines td{display:block;width:100%;white-space:normal;border:0;padding:5px 0}
  #guide-lines td:nth-child(1)::before{content:'Cantidad'}
  #guide-lines td:nth-child(2)::before{content:'Descripción'}
  #guide-lines td:nth-child(3)::before{content:'Unidad'}
  #guide-lines td:nth-child(4)::before{content:'Referencia'}
  #guide-lines td:nth-child(5)::before{content:'Detalle / serie'}
  #guide-lines td:not(:last-child)::before{display:block;color:#5b6b7d;font-size:11px;text-transform:uppercase;font-weight:700;margin-bottom:4px}
  #guide-lines td input{min-width:0!important;width:100%}
  #guide-lines td:last-child{text-align:right}
  .mobile-card-table,.mobile-card-table tbody,.mobile-card-table tr{display:block;width:100%}
  .mobile-card-table thead{display:none}
  .mobile-card-table tbody tr{border:1px solid #dce5ed;border-radius:9px;background:#fff;padding:8px 11px;margin:10px 0}
  .mobile-card-table td{display:block;width:100%;border:0;padding:6px 0;white-space:normal;overflow-wrap:anywhere}
  .mobile-card-table td[data-label]::before{content:attr(data-label);display:block;color:#607286;font-size:10px;font-weight:800;text-transform:uppercase;margin-bottom:3px}
  .mobile-card-table td:has(.doc-actions-link) .btn{width:100%}
  .mobile-card-table .num{text-align:left}
  .mobile-card-table td.empty{text-align:center}
  .mobile-sale-steps{display:flex;gap:6px;overflow-x:auto;padding:4px 0 8px;scroll-snap-type:x mandatory}
  .mobile-sale-steps a{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;min-height:42px;padding:0 12px;background:#fff;border:1px solid #cbd9e5;border-radius:22px;font-weight:700;scroll-snap-align:start}
  #sale-form>.panel{scroll-margin-top:76px}
  #sale-form>.panel:first-of-type{margin-top:6px}
  .mobile-payment-panel{display:block;scroll-margin-top:76px}
  .mobile-payment-grid{grid-template-columns:1fr}
  #sale-form .sale-actions{display:grid;grid-template-columns:1fr;gap:8px;margin:18px 0 10px}
  #sale-form .sale-actions .btn{width:100%;white-space:normal}
  #sale-form .help{display:block;margin:8px 0}
  #sale-form .tablewrap:has(#sale-lines){overflow:visible}
  #sale-form .tablewrap:has(#sale-lines)>table,#sale-lines{display:block;width:100%}
  #sale-form .tablewrap:has(#sale-lines) thead{display:none}
  #sale-lines tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px 11px;border:1px solid #dce5ed;border-radius:10px;padding:12px;margin:11px 0;background:#fff}
  #sale-form .tablewrap:has(#sale-lines) #sale-lines td{display:block;width:100%;border:0;padding:0;min-width:0;white-space:normal}
  #sale-lines td:nth-child(2){grid-column:1/-1;grid-row:1}
  #sale-lines td:nth-child(4),#sale-lines td:nth-child(7){grid-column:1/-1}
  #sale-lines td:nth-child(1)::before{content:'Cantidad'}
  #sale-lines td:nth-child(2)::before{content:'Descripción'}
  #sale-lines td:nth-child(3)::before{content:'Unidad'}
  #sale-lines td:nth-child(4)::before{content:'Afectación'}
  #sale-lines td:nth-child(5)::before{content:'Descuento %'}
  #sale-lines td:nth-child(6)::before{content:'Precio unitario'}
  #sale-lines td:nth-child(7)::before{content:'Total'}
  #sale-lines td:not(:last-child)::before{display:block;color:#607286;font-size:10px;font-weight:800;text-transform:uppercase;margin-bottom:4px}
  #sale-lines td:nth-child(7){font-size:18px;font-weight:800;text-align:right;padding-top:6px;border-top:1px solid #e2e9ef}
  #sale-lines td:last-child{grid-column:1/-1;text-align:right}
  #sale-lines td input,#sale-lines td select{min-width:0;width:100%}
  #sale-lines td .remove{width:44px;height:44px;padding:0;font-size:22px}
  #sale-lines .sale-description-cell{min-width:0}
  #sale-lines .line-detail-tools{align-items:flex-start;flex-wrap:wrap}
  #sale-lines .line-detail-summary{flex:1 1 100%;max-height:4.2em}
  .ccf-line-detail-overlay{padding:8px;align-items:flex-start}
  .ccf-line-detail-dialog{width:100%;max-height:calc(100dvh - 16px)}
  .ccf-line-detail-body{padding:16px 14px}
  .ccf-line-detail-body textarea{min-height:180px}
  .ccf-line-detail-meta{flex-direction:column}
  .ccf-line-detail-error{text-align:left}
  #sale-form .totals{max-width:none}
  .installment-tools,.installment-tools label,.installment-tools input{width:100%;max-width:none}
  .credit-quick{gap:6px}
  .credit-quick .btn{flex:1 0 62px}
  .mobile-sale-bar{display:flex;position:fixed;bottom:0;left:0;right:0;z-index:38;align-items:center;justify-content:space-between;gap:10px;padding:9px max(12px,env(safe-area-inset-right)) calc(9px + env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));background:#fff;border-top:1px solid #cfdbe6;box-shadow:0 -7px 22px rgba(19,38,63,.10)}
  .mobile-sale-bar span{font-size:12px;color:#5c6c7c}
  .mobile-sale-bar strong{display:block;font-size:19px;color:#17202a}
  .mobile-sale-bar .btn{white-space:nowrap}
  .mobile-sale-bar.keyboard-open,body:has(#sale-form :is(input,select,textarea):focus) .mobile-sale-bar{display:none}
  body:has(#sale-form) main{padding-bottom:92px}
}

/* 1.10.41 · el visor ocupa casi toda la pantalla y conserva su scroll interno. */
@media(max-width:767px){
  .ccf-preview-overlay{padding:4px}
  .ccf-preview-dialog{width:100%;height:calc(100dvh - 8px);max-height:calc(100dvh - 8px);border-radius:8px}
  .ccf-preview-dialog .ccf-dialog-head{padding:12px 13px 10px}
  .ccf-preview-dialog .ccf-dialog-head p{font-size:12px}
  .ccf-preview-note{margin:8px 8px 0;padding:8px;align-items:stretch}
  .ccf-preview-note label,.ccf-preview-note select,.ccf-preview-links{width:100%}
  .ccf-preview-links{margin-left:0}
  .ccf-preview-links .btn{flex:1;text-align:center}
  .ccf-preview-stage{margin:8px;min-height:220px;height:auto}
  .ccf-preview-dialog .ccf-dialog-foot{padding:8px}
  .ccf-preview-dialog .ccf-dialog-foot .btn{flex:1}
}

@media(max-width:576px){
  .top{display:grid;grid-template-columns:44px minmax(0,1fr);gap:4px 9px;padding:7px 10px}
  .top-brand strong{font-size:16px}
  .top-brand small{margin:1px 0}
  .top-right{grid-column:1/-1;max-width:none;width:100%}
  .top-right form,.top-right select{width:100%;max-width:none}
  .top-right>a{display:none}
  #sale-form>.panel{scroll-margin-top:112px}
  main{padding:12px}
  .pagehead h1{font-size:21px}
  .cards.dashboard-cards{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .cards.dashboard-cards .card{padding:11px}
  .cards.dashboard-cards .card strong{font-size:19px}
  .filters{display:grid;grid-template-columns:1fr;gap:9px}
  .filters>*,.filters label,.filters select,.filters input,.filters button{width:100%;max-width:none}
  .mini-cards,.mini-cards.four,.mini-cards.five,.sire-detail-cards,.ccf-stat-grid{grid-template-columns:1fr}
  .guide-actions{grid-template-columns:1fr}
  .ccf-dialog-foot .btn{width:100%}
  .ccf-head-actions .btn{flex:1}
  .currency-head{align-items:flex-start;flex-direction:column;gap:4px}
  .sale-top-grid{grid-template-columns:1fr}
  .note-actions{justify-content:stretch}
  .note-actions>*{width:100%}
}

@media(orientation:landscape) and (max-height:520px){
  .ccf-dialog,.action-modal,.guide-modal-card{max-height:calc(100dvh - 12px)}
  .ccf-preview-stage{min-height:120px}
}
