/*
 * Capa visual amigable 1.10.36.
 * Solo redefine presentación: no cambia formularios, nombres de campos ni flujos.
 */
:root{
  --blue:#4f46e5;
  --blue-strong:#4338ca;
  --blue-soft:#eef2ff;
  --ink:#172033;
  --muted:#64748b;
  --line:#e2e8f0;
  --bg:#f6f7fb;
  --green:#059669;
  --red:#dc2626;
  --orange:#b45309;
  --shadow:0 8px 24px rgba(30,41,59,.065);
}

html{scroll-behavior:smooth}
body{
  background:linear-gradient(180deg,#f8f9fd 0,#f3f5fa 100%);
  color:var(--ink);
  font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  font-size:14px;
  line-height:1.45;
}
a{color:#4f46e5}
a:hover{color:#3730a3}

/* Cabecera */
.top{
  height:76px;
  padding:0 26px;
  border-bottom:1px solid rgba(226,232,240,.9);
  box-shadow:0 3px 14px rgba(30,41,59,.035);
  backdrop-filter:saturate(1.2) blur(12px);
  background:rgba(255,255,255,.94);
  z-index:46;
}
.top-brand{display:flex;align-items:center;gap:12px;min-width:230px}
.brand-mark{
  display:grid;
  place-items:center;
  width:42px;
  height:42px;
  flex:0 0 42px;
  border-radius:13px;
  color:#fff;
  font-size:19px;
  font-weight:900;
  background:linear-gradient(145deg,#6366f1,#4f46e5 55%,#7c3aed);
  box-shadow:0 7px 16px rgba(79,70,229,.28);
}
.brand-copy{display:block;min-width:0}
.top .brand-copy strong{display:block;font-size:19px;line-height:1.1;letter-spacing:-.02em}
.top .brand-copy strong span{color:#4f46e5}
.top .brand-copy small{margin-top:5px;color:#8491a5;font-size:11px}
.top-right{gap:12px}
.company-switcher select,.top select{
  min-width:285px;
  min-height:42px;
  border-color:#d8deea;
  border-radius:10px;
  padding:9px 38px 9px 12px;
  color:#273248;
  background-color:#fff;
  box-shadow:0 1px 2px rgba(15,23,42,.025);
}
.user-chip{display:flex!important;align-items:center;gap:8px;color:#334155;font-weight:700;white-space:nowrap}
.user-avatar{display:grid;place-items:center;width:34px;height:34px;border-radius:50%;background:#eef2ff;color:#4f46e5;font-size:13px;font-weight:900}
.logout-link{padding:9px 11px;border-radius:9px;color:#64748b;font-weight:700}
.logout-link:hover{background:#fff1f2;color:#be123c}

/* Navegación */
.shell{grid-template-columns:252px minmax(0,1fr);min-height:calc(100vh - 76px)}
.shell>aside{
  position:sticky;
  top:76px;
  height:calc(100vh - 76px);
  padding:18px 14px 16px;
  border-right:1px solid #e4e8f0;
  background:rgba(255,255,255,.92);
  overflow-y:auto;
}
.shell>aside nav{display:block}
.nav-section{
  display:block;
  padding:4px 12px 8px;
  color:#94a3b8;
  font-size:10px;
  font-weight:850;
  letter-spacing:.105em;
  text-transform:uppercase;
}
.nav-section.admin-section{margin-top:16px;padding-top:14px;border-top:1px solid #edf0f5}
.shell>aside nav a{
  position:relative;
  display:flex;
  align-items:center;
  gap:11px;
  min-height:43px;
  margin:2px 0;
  padding:9px 12px;
  border-radius:10px;
  color:#475569;
  font-size:13px;
  font-weight:700;
  transition:background .16s,color .16s,transform .16s;
}
.shell>aside nav a[data-icon]::before{
  display:grid;
  place-items:center;
  width:25px;
  height:25px;
  flex:0 0 25px;
  border-radius:7px;
  color:#7c879a;
  background:#f3f5f9;
  font-size:14px;
  font-weight:900;
  transition:background .16s,color .16s;
}
.shell>aside nav a[data-icon="home"]::before{content:"⌂"}
.shell>aside nav a[data-icon="sale"]::before{content:"＋"}
.shell>aside nav a[data-icon="docs"]::before{content:"▤"}
.shell>aside nav a[data-icon="collection"]::before{content:"$";font-size:12px}
.shell>aside nav a[data-icon="contacts"]::before{content:"◎"}
.shell>aside nav a[data-icon="catalog"]::before{content:"◇"}
.shell>aside nav a[data-icon="reports"]::before{content:"▥"}
.shell>aside nav a[data-icon="notes"]::before{content:"↺"}
.shell>aside nav a[data-icon="guides"]::before{content:"➜"}
.shell>aside nav a[data-icon="sire"]::before{content:"S";font-size:11px}
.shell>aside nav a[data-icon="companies"]::before{content:"▦"}
.shell>aside nav a[data-icon="settings"]::before{content:"⚙"}
.shell>aside nav a[data-icon="backup"]::before{content:"↓"}
.shell>aside nav a[data-icon="users"]::before{content:"♙"}
.shell>aside nav a[data-icon="records"]::before{content:"≡"}
.shell>aside nav a:hover{background:#f5f6ff;color:#4338ca;transform:translateX(2px)}
.shell>aside nav a:hover::before{background:#e9eaff;color:#4f46e5}
.shell>aside nav a.active{
  color:#4338ca;
  background:linear-gradient(90deg,#eef2ff,#f7f7ff);
  box-shadow:inset 3px 0 0 #4f46e5;
}
.shell>aside nav a.active::before{color:#fff;background:linear-gradient(145deg,#6366f1,#4f46e5);box-shadow:0 4px 9px rgba(79,70,229,.21)}
.shell>aside nav a.muted{opacity:.55}
.shell>aside .status{
  display:grid;
  grid-template-columns:10px 1fr;
  gap:10px;
  align-items:start;
  margin-top:18px;
  padding:13px;
  border-color:#e3e8f0;
  border-radius:12px;
  background:#f8fafc;
  line-height:1.35;
}
.shell>aside .status strong,.shell>aside .status small{display:block}
.shell>aside .status strong{color:#334155;font-size:12px}
.shell>aside .status small{margin-top:3px;color:#7c899b;font-size:10px}
.status-dot{width:9px;height:9px;margin-top:3px;border-radius:50%;background:#f59e0b;box-shadow:0 0 0 4px #fef3c7}
.status-dot.online{background:#10b981;box-shadow:0 0 0 4px #d1fae5}

/* Contenido y componentes */
main{padding:28px 30px 56px;min-width:0}
main>*{max-width:1680px;margin-left:auto;margin-right:auto}
.pagehead{margin-bottom:20px;min-height:48px}
.pagehead h1{margin-bottom:5px;color:#172033;font-size:27px;line-height:1.12;letter-spacing:-.025em}
.pagehead p{color:#718096}
h1,h2,h3{letter-spacing:-.018em}
.card,.panel,.company-card,.currency-card,.sire-meta-grid>div{
  border-color:#e2e7ef;
  border-radius:14px;
  background:#fff;
  box-shadow:var(--shadow);
}
.panel{margin-top:18px;padding:18px}
.panel h2{color:#1e293b;font-size:20px}
.cards{gap:14px;margin:18px 0}
.card{position:relative;overflow:hidden;padding:18px}
.card::after{content:"";position:absolute;right:-22px;top:-24px;width:72px;height:72px;border-radius:50%;background:rgba(99,102,241,.055)}
.card small{color:#718096;letter-spacing:.035em}
.card strong{color:#1e293b;font-size:24px;letter-spacing:-.025em}
.cards.dashboard-cards .card:first-child{border-top:3px solid #6366f1}
.cards.dashboard-cards .card:nth-child(2){border-top:3px solid #8b5cf6}
.cards.dashboard-cards .card:nth-child(3){border-top:3px solid #0ea5e9}
.cards.dashboard-cards .card:nth-child(4){border-top:3px solid #f59e0b}
.cards.dashboard-cards .card:nth-child(5){border-top:3px solid #10b981}

.btn,button{
  border-radius:9px;
  background:linear-gradient(135deg,#5b56e8,#4f46e5);
  box-shadow:0 4px 10px rgba(79,70,229,.14);
  transition:transform .14s,box-shadow .14s,background .14s;
}
.btn:hover,button:hover{transform:translateY(-1px);box-shadow:0 7px 14px rgba(79,70,229,.18);background:linear-gradient(135deg,#4f46e5,#4338ca)}
.btn:active,button:active{transform:translateY(0)}
.btn.secondary,.btn.ghost{
  border-color:#d5dbe7;
  background:#fff;
  color:#475569;
  box-shadow:0 1px 2px rgba(15,23,42,.035);
}
.btn.secondary:hover,.btn.ghost:hover{border-color:#aeb7c8;background:#f8fafc;color:#334155}
.btn.danger,.danger{background:linear-gradient(135deg,#e1453d,#c9342d)!important}

input,select,textarea{
  border-color:#d5dce7;
  border-radius:9px;
  color:#263247;
  transition:border-color .15s,box-shadow .15s,background .15s;
}
input:hover,select:hover,textarea:hover{border-color:#b9c3d2}
input:focus,select:focus,textarea:focus{
  outline:0;
  border-color:#6366f1!important;
  box-shadow:0 0 0 3px rgba(99,102,241,.12)!important;
  background:#fff!important;
}
label{color:#3f4c61}
.filters{padding:14px;border-color:#e1e6ee;border-radius:13px;box-shadow:0 5px 18px rgba(30,41,59,.04)}
.tablewrap{border:1px solid #edf0f5;border-radius:11px}
table{background:#fff}
th{padding:12px 10px;color:#64748b;background:#f8fafc;letter-spacing:.045em}
td{padding:12px 10px;border-bottom-color:#edf0f4}
tbody tr{transition:background .12s}
tbody tr:hover{background:#fafbff}
.badge{padding:5px 9px;letter-spacing:.025em}
.badge.production{background:#e7f8ef;color:#057548}
.badge.blue{background:#eef2ff;color:#4338ca}
.info-note,.warning,.flash{border-radius:11px}
.info-note{border-color:#dbe4ff;background:#f3f5ff;color:#3f4e78}
.warning{border-color:#f3d49a;background:#fff8e8}
.mini-cards>div,.settings-summary-grid>div,.credential-state{border-radius:11px}
.action-modal,.ccf-dialog,.guide-modal-card{border-radius:17px}
.modal-head{background:linear-gradient(135deg,#5b56e8,#4f46e5 58%,#7c3aed)}
.action-btn{border-radius:10px;background:#4f46e5}
.action-btn:hover{background:#4338ca}
.login-card,.install-card{border-radius:18px;box-shadow:0 24px 60px rgba(30,41,59,.11)}

@media(max-width:1200px){
  .shell{grid-template-columns:230px minmax(0,1fr)}
  main{padding:24px 22px 48px}
  .company-switcher select,.top select{min-width:230px}
}

@media(max-width:991px){
  .top{min-height:66px;height:auto;padding:8px 14px}
  .top-brand{min-width:0;gap:9px}
  .brand-mark{width:38px;height:38px;flex-basis:38px;border-radius:11px}
  .brand-copy{overflow:hidden}
  .shell{display:block;min-height:calc(100dvh - 66px)}
  .shell>aside{position:fixed;top:0;bottom:0;height:100dvh;background:#fff}
  .nav-section{margin-top:4px}
  main{padding:18px}
  .user-chip{display:none!important}
  .company-switcher select,.top select{min-width:0}
}

@media(max-width:576px){
  .top{grid-template-columns:44px minmax(0,1fr)}
  .brand-mark{display:none}
  .top .brand-copy strong{font-size:16px}
  .pagehead h1{font-size:23px}
  .panel{padding:14px;border-radius:12px}
  .cards.dashboard-cards .card{border-top-width:2px}
  main{padding:12px 12px 44px}
}

@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{scroll-behavior:auto!important;transition:none!important}
}

/* Vistas rápidas de Comprobantes: consulta, sin alterar documentos ni emisión. */
.documents-pagehead{align-items:center}
.documents-new-sale{white-space:nowrap}
.document-quick-views{
  display:flex;
  gap:10px;
  margin:0 0 14px;
}
.document-quick-view{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:260px;
  padding:11px 14px;
  border:1px solid #dce3ee;
  border-radius:11px;
  background:#fff;
  color:#475569;
  box-shadow:0 3px 10px rgba(30,41,59,.035);
  text-decoration:none;
  transition:border-color .15s,box-shadow .15s,transform .15s;
}
.document-quick-view>span:first-child{
  display:grid;
  place-items:center;
  width:30px;
  height:30px;
  flex:0 0 30px;
  border-radius:8px;
  background:#f1f5f9;
  color:#64748b;
  font-weight:900;
}
.document-quick-view strong,.document-quick-view small{display:block}
.document-quick-view strong{font-size:13px}
.document-quick-view small{margin-top:2px;color:#7a8799;font-size:11px;font-weight:600}
.document-quick-view:hover{border-color:#aeb9ce;box-shadow:0 6px 14px rgba(30,41,59,.08);transform:translateY(-1px)}
.document-quick-view.real.active{border-color:#86c7a5;background:#f1fcf6;color:#087447;box-shadow:inset 0 0 0 1px #86c7a5}
.document-quick-view.real.active>span:first-child{background:#d9f7e5;color:#087447}
.document-quick-view.proformas.active{border-color:#c9a5f1;background:#faf5ff;color:#7e22ce;box-shadow:inset 0 0 0 1px #c9a5f1}
.document-quick-view.proformas.active>span:first-child{background:#f0e2ff;color:#7e22ce}
.document-advanced-filters{
  margin:0 0 16px;
  border:1px solid #e0e6ef;
  border-radius:11px;
  background:#fff;
}
.document-advanced-filters summary{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  color:#475569;
  cursor:pointer;
  font-size:13px;
  font-weight:800;
}
.document-advanced-filters summary span{color:#7a8799;font-size:11px;font-weight:600}
.document-advanced-filters[open] summary{border-bottom:1px solid #edf0f5}
.document-advanced-filters .filters{margin:0;border:0;border-radius:0;box-shadow:none}
.documents-list-panel{margin-top:0}
.documents-list-head{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-bottom:14px}
.documents-list-head h2{margin:0;font-size:18px}
.documents-list-head p{margin:3px 0 0;color:#7a8799;font-size:12px}
@media(max-width:700px){
  .documents-pagehead{align-items:flex-start}
  .documents-new-sale{width:100%;text-align:center}
  .document-quick-views{display:grid;grid-template-columns:1fr}
  .document-quick-view{min-width:0}
  .document-advanced-filters summary{align-items:flex-start;flex-direction:column}
  .document-advanced-filters .filters{display:grid;grid-template-columns:1fr}
  .document-advanced-filters .filters>*{width:100%}
}

/* Espacios de trabajo inspirados en los patrones de consulta rápida. */
body:has(.report-filters) .pagehead{padding-bottom:4px}
body:has(.report-filters) .report-filters{
  display:grid;
  grid-template-columns:repeat(3,minmax(180px,1fr));
  gap:12px;
  align-items:end;
  margin-bottom:14px;
  padding:18px;
}
body:has(.report-filters) .report-filters label{min-width:0;margin:0}
body:has(.report-filters) .report-filters .report-client{grid-column:span 2;min-width:0}
body:has(.report-filters) .report-filters .report-client input{min-width:0}
body:has(.report-filters) .report-filters .btn{min-height:42px;text-align:center}
body:has(.report-filters) .report-summary-line{margin:14px 0;padding:12px 14px;border:1px solid #dce7f5;border-radius:10px;background:#f7faff;color:#40536b}
body:has(.report-filters) .currency-card{overflow:hidden}
body:has(.report-filters) .currency-head{padding-bottom:12px;border-bottom:1px solid #edf0f5}

.two-col:has(#contact-doc),.two-col:has(input[name="save_product"]){
  grid-template-columns:minmax(0,1.3fr) minmax(330px,.7fr);
  align-items:start;
  gap:18px;
}
.two-col:has(#contact-doc)>section:first-child,.two-col:has(input[name="save_product"])>section:first-child{padding:8px;overflow:hidden}
.two-col:has(#contact-doc)>section:last-child,.two-col:has(input[name="save_product"])>section:last-child{
  position:sticky;
  top:94px;
  margin-top:0;
  padding:18px;
  border-top:3px solid #6366f1;
}
.two-col:has(#contact-doc)>section:last-child h2,.two-col:has(input[name="save_product"])>section:last-child h2{font-size:18px}
.two-col:has(#contact-doc) table,.two-col:has(input[name="save_product"]) table{table-layout:fixed;width:100%}
.two-col:has(#contact-doc) td,.two-col:has(input[name="save_product"]) td{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.two-col:has(#contact-doc) tbody tr:hover,.two-col:has(input[name="save_product"]) tbody tr:hover{box-shadow:inset 3px 0 0 #818cf8}
.two-col:has(#contact-doc) td:last-child,.two-col:has(input[name="save_product"]) td:last-child{overflow:visible;text-align:right}

body:has(.sire-toolbar) .sire-toolbar{
  margin:0 0 14px;
  padding:12px 14px;
  border:1px solid #e0e6ef;
  border-radius:12px;
  background:#fff;
  box-shadow:0 5px 18px rgba(30,41,59,.04);
}
body:has(.sire-toolbar) .sire-toolbar .filters{margin:0;padding:0;border:0;box-shadow:none}
body:has(.sire-toolbar) .tabs{
  display:flex;
  gap:4px;
  margin:16px 0;
  padding:5px;
  border:1px solid #e0e6ef;
  border-radius:11px;
  background:#fff;
  overflow-x:auto;
}
body:has(.sire-toolbar) .tabs a{flex:1;min-width:max-content;border-radius:8px;text-align:center}
body:has(.sire-toolbar) .tabs a.active{background:#eef2ff;color:#4338ca;box-shadow:none}
body:has(.sire-toolbar) .subtabs{margin:14px 0 0;border-bottom-color:#e2e8f0}
body:has(.sire-toolbar) .comparison-pills{gap:6px}

@media(max-width:980px){
  body:has(.report-filters) .report-filters{grid-template-columns:repeat(2,minmax(0,1fr))}
  .two-col:has(#contact-doc),.two-col:has(input[name="save_product"]){grid-template-columns:1fr}
  .two-col:has(#contact-doc)>section:last-child,.two-col:has(input[name="save_product"])>section:last-child{position:static}
}
@media(max-width:640px){
  body:has(.report-filters) .report-filters{grid-template-columns:1fr;padding:14px}
  body:has(.report-filters) .report-filters .report-client{grid-column:auto}
  body:has(.report-filters) .report-filters .btn{width:100%}
  .two-col:has(#contact-doc)>section:first-child,.two-col:has(input[name="save_product"])>section:first-child{padding:0}
  .two-col:has(#contact-doc) table,.two-col:has(input[name="save_product"]) table{table-layout:auto}
  body:has(.sire-toolbar) .sire-toolbar{padding:10px}
}

/* Tipo de comprobante: confirma visualmente la elección antes de procesar. */
.visually-hidden{
  position:absolute!important;
  width:1px!important;
  height:1px!important;
  padding:0!important;
  margin:-1px!important;
  overflow:hidden!important;
  clip:rect(0,0,0,0)!important;
  white-space:nowrap!important;
  border:0!important;
}
#sale-form .sale-top-grid .doc-type-field{
  display:block;
  grid-column:1/-1;
  padding:16px;
  border:1px solid #dce3ee;
  border-top:3px solid #4f46e5;
  border-radius:10px;
  background:#fbfcff;
}
.doc-type-label{display:block;color:#213d5b;font-size:14px;font-weight:800}
.doc-type-guidance{margin:4px 0 13px;color:#60758d;font-size:12px;font-weight:500;line-height:1.45}
.document-type-choices{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,160px),1fr));gap:10px}
.document-type-choice{
  display:flex;
  min-height:76px;
  flex-direction:column;
  align-items:flex-start;
  justify-content:center;
  gap:5px;
  padding:12px 14px;
  border:1px solid #ced8e5;
  border-radius:8px;
  background:#fff;
  color:#3f5368;
  box-shadow:none;
  text-align:left;
  transition:border-color .15s,box-shadow .15s,background .15s;
}
.document-type-choice b{font-size:14px;line-height:1.2}
.document-type-choice small{font-size:11px;font-weight:600;line-height:1.2;color:#748398}
.document-type-choice:hover:not(:disabled){border-color:#8292aa}
.document-type-choice:focus-visible{outline:3px solid rgba(79,70,229,.25);outline-offset:2px}
.document-type-choice.proforma.active{border-color:#a78bfa;background:#f6f3ff;box-shadow:inset 0 0 0 1px #a78bfa;color:#5b21b6}
.document-type-choice.invoice.active{border-color:#1677c8;background:#eff8ff;box-shadow:inset 0 0 0 1px #1677c8;color:#075c9e}
.document-type-choice.receipt.active{border-color:#0c9860;background:#effcf5;box-shadow:inset 0 0 0 1px #0c9860;color:#087447}
.document-type-choice.active small{color:inherit;opacity:.8}
.document-type-choice:disabled{cursor:not-allowed;opacity:.52}
.document-type-status{display:flex;align-items:baseline;gap:8px;margin-top:12px;padding:10px 12px;border-radius:7px;background:#f1f5f9;color:#40536b;font-size:12px;line-height:1.4}
.document-type-status b{font-size:11px;letter-spacing:0;font-weight:900}
.document-type-status span{color:#5f7184}
.document-type-choice.proforma.active~.document-type-status{background:#f6f3ff}

@media(max-width:680px){
  #sale-form .sale-top-grid .doc-type-field{padding:14px}
  .document-type-choices{grid-template-columns:1fr}
  .document-type-choice{min-height:62px}
  .document-type-status{align-items:flex-start;flex-direction:column;gap:3px}
}

/* Marca CompuCallao y acción de descarga directa. */
.top-brand{gap:10px;min-width:0}
.brand-mark{
  width:176px;
  height:58px;
  flex:0 0 176px;
  border-radius:0;
  background:transparent url("compucallao-logo-email.png") center / contain no-repeat;
  box-shadow:none;
  color:transparent;
  font-size:0;
}
.top .brand-copy strong{font-size:0;letter-spacing:0}
.top .brand-copy strong::after{content:"Facturador";color:#4338ca;font-size:18px;line-height:1.1;letter-spacing:0}
.top .brand-copy strong span{display:none}
.action-btn.pdf-download{background:#0b70bd}

@media(max-width:991px){
  .brand-mark{width:138px;height:46px;flex-basis:138px;display:block}
  .top .brand-copy small{display:none}
}
@media(max-width:576px){
  .brand-mark{width:124px;height:42px;flex-basis:124px}
  .brand-copy{display:none}
}

/* Recuperación local y explícita de Nueva venta. */
.sale-draft-toolbar,.sale-draft-recovery{
  display:flex;align-items:center;justify-content:space-between;gap:16px;
  margin:0 0 14px;padding:12px 14px;border:1px solid #cbd5e1;border-radius:12px;background:#f8fafc;
}
.sale-draft-toolbar>div,.sale-draft-recovery>div:first-child{display:flex;flex-direction:column;gap:2px}
.sale-draft-toolbar small,.sale-draft-recovery span{color:#64748b}
.sale-draft-privacy{max-width:520px;text-align:right}
.sale-draft-recovery{border-color:#86b7fe;background:#eff6ff}
.sale-draft-actions{display:flex;gap:8px;flex:0 0 auto}
@media(max-width:700px){
  .sale-draft-toolbar,.sale-draft-recovery{align-items:stretch;flex-direction:column}
  .sale-draft-privacy{text-align:left;max-width:none}
  .sale-draft-actions{display:grid;grid-template-columns:1fr}
  .sale-draft-actions .btn{width:100%}
}
