:root{
  --enterprise-bg:#f4f1ed;
  --enterprise-panel:rgba(255,253,250,.97);
  --enterprise-ink:#211b17;
  --enterprise-muted:#756b62;
  --enterprise-line:#ddd2c6;
  --enterprise-taupe:#6c6259;
  --enterprise-black:#191613;
  --enterprise-gold:#b79a72;
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;background:radial-gradient(circle at 80% -10%,rgba(183,154,114,.14),transparent 28%),linear-gradient(180deg,#f7f4f0,#f0ebe5);color:var(--enterprise-ink)}
button,input,select,textarea{font:inherit}
button{transition:transform .16s ease,box-shadow .16s ease,background .16s ease,border-color .16s ease}
button:hover{transform:translateY(-1px)}
button:active{transform:translateY(0)}
button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{outline:3px solid rgba(183,154,114,.28);outline-offset:2px}
.app-utility{box-shadow:0 8px 28px rgba(42,31,23,.06)}
.command-button{min-height:38px;min-width:210px;padding:7px 10px;display:flex;align-items:center;gap:9px;border:1px solid var(--enterprise-line);border-radius:12px;background:#fff;color:#70655c;font-size:12px;font-weight:650;box-shadow:0 5px 16px rgba(42,31,23,.05)}
.command-button .command-icon{font-size:18px;color:#554a41}.command-button kbd{margin-left:auto;padding:3px 6px;border:1px solid #ddd3c8;border-radius:6px;background:#f7f3ee;color:#8d8177;font-size:10px}
.utility-chip.saving .live-dot{background:#c68a35;animation:pulse 1s infinite}.utility-chip.error .live-dot{background:#a84444}.utility-chip.error{color:#8d3535;border-color:#e8c1c1}
@keyframes pulse{50%{opacity:.35}}
.top{align-items:flex-start}.top h1{font-size:clamp(25px,2.1vw,34px)}
.panel,.form-card,.mini-card,.kpi{background:var(--enterprise-panel);border:1px solid rgba(134,113,94,.18);box-shadow:0 16px 40px rgba(48,36,27,.075)}
.form-card{border-radius:22px;padding:22px}.form-card::before{width:4px}
.section-head{margin-bottom:8px}.step-badge{box-shadow:none}
.current-sale-cards{grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}.mini-card{border-radius:18px;padding:17px 18px}
input,select,textarea{min-height:45px;border-radius:13px;background:#fff;border:1px solid #ddd1c4;padding:10px 13px}
textarea{min-height:96px;resize:vertical}
.primary{background:linear-gradient(135deg,#70645b,#594f47);box-shadow:0 8px 18px rgba(75,62,52,.16)}
.dark{background:linear-gradient(135deg,#211d19,#0f0d0b);box-shadow:0 8px 18px rgba(20,16,13,.18)}
.secondary{background:#f5efe8;border-color:#ddcfbf;color:#302821}
.workgrid{align-items:start}.paper-wrap{min-width:0}.preview-top{position:sticky;top:74px;z-index:12;padding:10px 0;background:linear-gradient(180deg,var(--enterprise-bg) 70%,transparent)}
.legacy-paper{display:none!important}
.enterprise-preview{display:grid;gap:22px;max-width:940px;margin:0 auto 40px;min-height:520px}
.preview-loading,.preview-error{min-height:520px;border:1px dashed #cdbca9;border-radius:22px;background:rgba(255,255,255,.7);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;color:#776c63}.preview-loading span{width:38px;height:38px;border:3px solid #e3d8cc;border-top-color:#6c6259;border-radius:50%;animation:spin .8s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}
.enterprise-page{position:relative;width:100%;aspect-ratio:210/297;border-radius:6px;overflow:hidden;background:#fff;box-shadow:0 26px 70px rgba(34,26,20,.18),0 0 0 1px rgba(102,82,66,.08)}
.enterprise-page canvas{display:block;width:100%;height:100%;object-fit:contain;background:#fff}
.enterprise-page-badge{position:absolute;right:12px;bottom:12px;padding:6px 9px;border-radius:999px;background:rgba(28,23,19,.75);color:#fff;font-size:10px;font-weight:700;backdrop-filter:blur(8px)}
.command-palette{position:fixed;inset:0;z-index:300;display:none}.command-palette.open{display:block}.command-backdrop{position:absolute;inset:0;background:rgba(18,14,11,.48);backdrop-filter:blur(5px)}
.command-dialog{position:relative;width:min(660px,calc(100vw - 28px));max-height:min(720px,calc(100vh - 50px));margin:8vh auto 0;border:1px solid rgba(255,255,255,.2);border-radius:22px;background:#fff;box-shadow:0 35px 100px rgba(20,15,12,.34);overflow:hidden}
.command-search-row{display:grid;grid-template-columns:28px 1fr auto;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid #ebe3da}.command-search-row>span{font-size:22px;color:#5c5148}.command-search-row input{border:0;box-shadow:none!important;outline:0!important;min-height:42px;font-size:16px}.command-search-row kbd,.command-results kbd{padding:4px 7px;border:1px solid #ded5cc;border-radius:7px;background:#f7f3ef;color:#8a7f75;font-size:10px}
.command-results{max-height:560px;overflow:auto;padding:8px}.command-results button{width:100%;display:grid;grid-template-columns:36px 1fr auto;align-items:center;gap:10px;padding:11px 12px;border:0;border-radius:13px;background:transparent;color:#28211c;text-align:left}.command-results button:hover,.command-results button.selected{background:#f2ebe4;transform:none}.command-results button>span{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;background:#e9ded3;color:#5d5046;font-size:17px}.command-results strong{display:block;font-size:13px}.command-results small{display:block;margin-top:2px;color:#877b71;font-size:11px}.command-dialog footer{display:flex;gap:18px;padding:10px 16px;border-top:1px solid #ebe3da;background:#faf7f3;color:#8b8076;font-size:10px}
@media(max-width:1500px){.command-button{min-width:auto}.command-button>span:nth-child(2),.command-button kbd{display:none}.current-sale-cards{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:1100px){.command-button{display:none}.preview-top{position:static}.enterprise-preview{max-width:850px}.workgrid{grid-template-columns:1fr!important}.paper-wrap{width:100%}}
@media(max-width:720px){.current-sale-cards{grid-template-columns:1fr 1fr}.form-card{padding:17px;border-radius:18px}.enterprise-preview{gap:14px}.enterprise-page{border-radius:3px}.preview-top{display:grid;grid-template-columns:1fr 1fr}.preview-top h2{grid-column:1/-1}.preview-top button{width:100%;padding:9px 8px}.command-dialog{margin-top:18px}.command-dialog footer{display:none}}
@media(max-width:480px){.current-sale-cards{grid-template-columns:1fr}.preview-top{grid-template-columns:1fr}.preview-top h2{grid-column:auto}}

/* V32 — Acciones PDF robustas para ejecución local file:// */
.preview-top{
  position:sticky;
  z-index:60 !important;
  pointer-events:auto !important;
  isolation:isolate;
}
.preview-top button{
  position:relative;
  z-index:2;
  pointer-events:auto !important;
  touch-action:manipulation;
}
.preview-top button.is-busy{
  opacity:.68;
  cursor:wait;
}
.preview-top button.is-busy::after{
  content:"";
  display:inline-block;
  width:12px;
  height:12px;
  margin-left:8px;
  border:2px solid currentColor;
  border-right-color:transparent;
  border-radius:50%;
  vertical-align:-2px;
  animation:enterpriseSpin .7s linear infinite;
}
.enterprise-preview{
  position:relative;
  z-index:1;
}
.pdf-action-hint{
  max-width:940px;
  margin:-4px auto 12px;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  color:#756a60;
  font-size:11px;
  font-weight:700;
}
.pdf-action-dot{
  width:8px;
  height:8px;
  border-radius:50%;
  background:#b79a72;
  box-shadow:0 0 0 4px rgba(183,154,114,.13);
}
.pdf-action-hint.ready .pdf-action-dot{
  background:#3b8a62;
  box-shadow:0 0 0 4px rgba(59,138,98,.13);
}
.pdf-action-hint.error .pdf-action-dot{
  background:#ad4848;
  box-shadow:0 0 0 4px rgba(173,72,72,.13);
}

.enterprise-pdf-center{
  position:fixed;
  inset:0;
  z-index:5000;
  display:none;
}
.enterprise-pdf-center.open{
  display:block;
}
.enterprise-pdf-backdrop{
  position:absolute;
  inset:0;
  background:rgba(20,16,13,.56);
  backdrop-filter:blur(8px);
}
.enterprise-pdf-dialog{
  position:relative;
  width:min(620px,calc(100% - 28px));
  max-height:calc(100vh - 40px);
  margin:20px auto;
  overflow:auto;
  border:1px solid rgba(117,96,78,.18);
  border-radius:24px;
  background:#fffdfa;
  box-shadow:0 30px 90px rgba(24,18,14,.34);
}
.enterprise-pdf-dialog>header{
  display:grid;
  grid-template-columns:50px minmax(0,1fr) 36px;
  align-items:center;
  gap:13px;
  padding:20px 22px;
  border-bottom:1px solid #e2d7ca;
}
.enterprise-pdf-dialog>header div{
  min-width:0;
}
.enterprise-pdf-dialog>header strong{
  display:block;
  color:#211b17;
  font-size:17px;
}
.enterprise-pdf-dialog>header span:not(.enterprise-pdf-mark){
  display:block;
  margin-top:4px;
  color:#756a60;
  font-size:12px;
  line-height:1.4;
}
.enterprise-pdf-mark{
  width:48px;
  height:48px;
  display:grid;
  place-items:center;
  border-radius:15px;
  background:linear-gradient(135deg,#786b60,#4d443d);
  color:#fff;
  font-size:11px;
  font-weight:900;
  letter-spacing:.08em;
}
.enterprise-pdf-close{
  width:36px;
  height:36px;
  padding:0;
  border-radius:50%;
  background:#f2ece5;
  color:#5e5248;
  font-size:23px;
}
.enterprise-pdf-progress,
.enterprise-pdf-ready,
.enterprise-pdf-error{
  padding:24px;
}
.enterprise-pdf-progress{
  text-align:center;
  color:#756a60;
}
.enterprise-pdf-progress>span{
  width:46px;
  height:46px;
  margin:3px auto 15px;
  display:block;
  border:4px solid #e6dbcf;
  border-top-color:#6c6259;
  border-radius:50%;
  animation:enterpriseSpin .8s linear infinite;
}
.enterprise-pdf-progress p{
  margin:0;
  font-size:13px;
}
.enterprise-pdf-file{
  display:flex;
  align-items:center;
  gap:13px;
  padding:15px;
  border:1px solid #ded2c5;
  border-radius:17px;
  background:#faf6f1;
}
.enterprise-pdf-file>span{
  width:40px;
  height:40px;
  display:grid;
  place-items:center;
  border-radius:12px;
  background:#e4f3ea;
  color:#2d7652;
  font-weight:900;
}
.enterprise-pdf-file strong,
.enterprise-pdf-file small{
  display:block;
}
.enterprise-pdf-file strong{
  color:#211b17;
  overflow-wrap:anywhere;
}
.enterprise-pdf-file small{
  margin-top:4px;
  color:#756a60;
}
.enterprise-pdf-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-top:16px;
}
.enterprise-pdf-actions>a,
.enterprise-pdf-actions>button{
  min-height:44px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:10px 13px;
  border-radius:12px;
  text-decoration:none;
  font-size:13px;
  font-weight:800;
}
.enterprise-pdf-note{
  margin:15px 2px 0;
  color:#756a60;
  font-size:11px;
  line-height:1.5;
}
.enterprise-pdf-error{
  text-align:center;
}
.enterprise-pdf-error strong,
.enterprise-pdf-error span{
  display:block;
}
.enterprise-pdf-error strong{
  color:#9e3f3f;
  font-size:16px;
}
.enterprise-pdf-error span{
  margin:8px 0 16px;
  color:#756a60;
}
.enterprise-print-frame{
  position:fixed;
  left:-10000px;
  top:0;
  width:1px;
  height:1px;
  border:0;
  opacity:.01;
  pointer-events:none;
}
body.pdf-center-open{
  overflow:hidden;
}
@keyframes enterpriseSpin{
  to{transform:rotate(360deg)}
}
@media(max-width:620px){
  .enterprise-pdf-dialog{
    margin:10px auto;
    max-height:calc(100vh - 20px);
    border-radius:20px;
  }
  .enterprise-pdf-dialog>header{
    padding:17px;
  }
  .enterprise-pdf-progress,
  .enterprise-pdf-ready,
  .enterprise-pdf-error{
    padding:18px;
  }
  .enterprise-pdf-actions{
    grid-template-columns:1fr;
  }
  .pdf-action-hint{
    justify-content:flex-start;
  }
}

/* V33 auditoría funcional */
.catalog-form-actions-three{grid-template-columns:1fr 1fr 1.35fr!important}
.nav[aria-current="page"]{box-shadow:inset 3px 0 0 var(--enterprise-gold),0 8px 18px rgba(0,0,0,.18)}
button:disabled{opacity:.48;cursor:not-allowed;transform:none!important}
.file-label:focus-visible{outline:3px solid rgba(183,154,114,.28);outline-offset:2px}
@media(max-width:620px){.catalog-form-actions-three{grid-template-columns:1fr!important}}

/* V35: PWA profesional, iPad y diagnóstico */
.utility-install,.utility-health{min-height:38px;display:inline-flex;align-items:center;gap:8px;padding:8px 12px;border-radius:12px;background:#fff;color:#40372f;border:1px solid #ddd1c4;box-shadow:0 6px 16px rgba(39,29,22,.06)}
.utility-install[hidden]{display:none!important}.utility-install.attention{background:#f3e9de;border-color:#ccb397}.utility-health{padding:8px 10px}.health-dot{width:8px;height:8px;border-radius:50%;background:#3f9568;box-shadow:0 0 0 4px rgba(63,149,104,.12)}.utility-health.warn .health-dot{background:#b78530}.utility-health.bad .health-dot{background:#ae4848}.health-label{font-size:11px;font-weight:800}
.enterprise-sheet{position:fixed;inset:0;z-index:6200;display:none}.enterprise-sheet.open{display:block}.enterprise-sheet-backdrop{position:absolute;inset:0;background:rgba(20,16,13,.58);backdrop-filter:blur(9px)}.enterprise-sheet-card{position:relative;width:min(680px,calc(100% - 28px));max-height:calc(100vh - 36px);margin:18px auto;overflow:auto;border-radius:25px;background:#fffdfa;border:1px solid rgba(113,91,72,.18);box-shadow:0 30px 90px rgba(24,18,14,.34)}.enterprise-sheet-card>header{display:flex;justify-content:space-between;gap:18px;padding:23px 25px;border-bottom:1px solid #e2d7ca}.enterprise-sheet-card h2{margin:4px 0 5px;font-size:23px}.enterprise-sheet-card header p{margin:0;color:#766a60;font-size:13px}.sheet-eyebrow{font-size:9px;font-weight:900;letter-spacing:.16em;color:#9b856f}.sheet-close{width:38px;height:38px;min-width:38px;padding:0;border-radius:50%;background:#f1ebe4;color:#5f5349;font-size:24px}.sheet-content{padding:24px 25px}
.install-steps{list-style:none;padding:0;margin:0;display:grid;gap:13px}.install-steps li{display:grid;grid-template-columns:38px 1fr;gap:12px;padding:14px;border:1px solid #e0d5c8;border-radius:16px;background:#fff}.install-steps li>span{width:34px;height:34px;border-radius:11px;display:grid;place-items:center;background:#eee3d8;color:#5d4e42;font-weight:900}.install-steps p{margin:4px 0 0;color:#756a60;font-size:12px;line-height:1.45}.install-warning,.install-ready,.install-success{padding:17px;border-radius:17px;border:1px solid #dfd2c4;background:#faf6f1}.install-warning{margin-top:16px;border-color:#e4cda9;background:#fff7e8}.install-warning strong,.install-warning span{display:block}.install-warning span{margin-top:5px;color:#776a5f;font-size:12px;line-height:1.45}.install-ready{text-align:center}.install-ready p{color:#756a60}.install-success{display:flex;align-items:center;gap:13px}.install-success>span{width:42px;height:42px;display:grid;place-items:center;border-radius:13px;background:#e4f3ea;color:#28764f;font-weight:900}.install-success p{margin:4px 0 0;color:#756a60}
.health-list{display:grid;gap:10px}.health-item{display:grid;grid-template-columns:14px 1fr;gap:12px;padding:15px;border-radius:16px;border:1px solid #e1d6ca;background:#fff}.health-status{width:10px;height:10px;margin-top:5px;border-radius:50%;background:#7a8b92}.health-item.good .health-status{background:#3f9568}.health-item.warn .health-status{background:#b78530}.health-item.bad .health-status{background:#ae4848}.health-item strong,.health-item b,.health-item p{display:block}.health-item b{margin-top:3px;font-size:12px}.health-item p{margin:5px 0 0;color:#756a60;font-size:11px;line-height:1.45}.health-actions{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:17px}body.sheet-open{overflow:hidden}
@media(max-width:620px){.utility-install{display:none!important}.enterprise-sheet-card{margin:9px auto;max-height:calc(100vh - 18px);border-radius:20px}.enterprise-sheet-card>header,.sheet-content{padding:18px}.health-actions{grid-template-columns:1fr}}

/* V36 Cloud */
.utility-cloud{min-height:38px;display:inline-flex;align-items:center;gap:8px;padding:8px 11px;border-radius:12px;background:#fff;color:#40372f;border:1px solid #ddd1c4;box-shadow:0 6px 16px rgba(39,29,22,.06)}
.cloud-dot{width:8px;height:8px;border-radius:50%;background:#8b8178;box-shadow:0 0 0 4px rgba(139,129,120,.12)}
.utility-cloud.online .cloud-dot{background:#3f9568;box-shadow:0 0 0 4px rgba(63,149,104,.12)}
.utility-cloud.warn .cloud-dot{background:#b78530}.utility-cloud.error .cloud-dot{background:#ae4848}.cloud-label{font-size:11px;font-weight:800}
.cloud-summary{display:flex;gap:13px;align-items:center;padding:16px;border:1px solid #dfd3c6;border-radius:17px;background:#faf6f1}.cloud-summary.connected{background:#eef8f2;border-color:#cce4d5}.cloud-summary-icon{width:42px;height:42px;display:grid;place-items:center;border-radius:13px;background:#e7ddd2;font-size:20px}.cloud-summary.connected .cloud-summary-icon{background:#d8efdf;color:#26744d}.cloud-summary strong,.cloud-summary p{display:block}.cloud-summary p{margin:4px 0 0;color:#756a60;font-size:12px}
.cloud-section{margin-top:16px;padding:17px;border:1px solid #e1d6ca;border-radius:17px;background:#fff}.cloud-section h3{margin:0 0 13px;font-size:15px}.cloud-section textarea{resize:vertical}.cloud-auth-actions,.cloud-sync-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}.cloud-sync-actions{grid-template-columns:1fr 1fr 1fr}.cloud-account{padding:12px;border-radius:13px;background:#f7f2ec;margin-bottom:10px}.cloud-account strong,.cloud-account span{display:block}.cloud-account span{margin-top:4px;color:#756a60;font-size:11px}.cloud-caution{margin:11px 0 0;color:#8c5b26;font-size:11px;line-height:1.45}.cloud-help{background:#f7f2ec}.cloud-help p{margin:0;color:#756a60;font-size:12px;line-height:1.5}.cloud-loading{text-align:center;padding:30px;color:#756a60}.cloud-busy .cloud-card{cursor:wait}.cloud-busy .cloud-card button{pointer-events:none;opacity:.65}
@media(max-width:720px){.cloud-label{display:none}.cloud-sync-actions,.cloud-auth-actions{grid-template-columns:1fr}.utility-cloud{padding:8px 10px}}

/* V39: diagnóstico y recuperación */
.recovery-panel{margin-top:18px;padding-top:18px;border-top:1px solid #e3d8cc}.recovery-panel h3{margin:0 0 5px;font-size:16px}.recovery-panel>p{margin:0 0 12px;color:#756a60;font-size:12px;line-height:1.45}.recovery-list{display:grid;gap:8px}.recovery-list article{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 13px;border:1px solid #e2d7ca;border-radius:14px;background:#fff}.recovery-list strong,.recovery-list span{display:block}.recovery-list strong{font-size:12px}.recovery-list span{margin-top:3px;color:#786d63;font-size:10px}.recovery-list button{min-height:34px;padding:7px 10px}.empty-recovery{padding:14px;border:1px dashed #d7c9bb;border-radius:13px;color:#7b7066;font-size:12px;text-align:center}@media(max-width:620px){.recovery-list article{align-items:flex-start;flex-direction:column}.recovery-list button{width:100%}}

/* v40: proyecto Supabase preconfigurado */
.cloud-project-row{display:flex;gap:12px;align-items:flex-start;padding:14px;border:1px solid #ded2c5;border-radius:15px;background:#fbf7f2;margin-bottom:12px}.cloud-project-check{display:grid;place-items:center;width:34px;height:34px;min-width:34px;border-radius:11px;background:#e3f1e8;color:#28734d;font-weight:900}.cloud-project-row p{margin:4px 0 0;color:#75695f;font-size:12px;line-height:1.45}

/* v43 Operaciones */
.four-cards{grid-template-columns:repeat(4,minmax(0,1fr))}
.ops-toolbar{margin-bottom:18px}.grid.four{grid-template-columns:repeat(4,minmax(0,1fr))}
.production-board{display:grid;grid-template-columns:repeat(auto-fit,minmax(330px,1fr));gap:16px}
.production-card{background:#fffdfa;border:1px solid #e2d7ca;border-radius:20px;padding:18px;box-shadow:0 10px 30px rgba(44,34,26,.06)}
.production-card.late{border-color:#d79a8f;box-shadow:0 0 0 3px rgba(173,72,61,.08)}
.production-card-head{display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.production-card-head span{font-size:11px;color:#8b7a6c;font-weight:800}.production-card-head h3{margin:4px 0 0;font-size:17px}
.priority{font-size:10px;padding:6px 9px;border-radius:999px;background:#eee5dc}.priority.alta{background:#f7ded9;color:#983a2e}.priority.media{background:#f4ecd8;color:#8a6921}.priority.baja{background:#e1efe7;color:#316b4d}
.production-progress{height:8px;background:#eee7df;border-radius:999px;overflow:hidden;margin:15px 0}.production-progress i{display:block;height:100%;background:linear-gradient(90deg,#9c8068,#2f2924);border-radius:inherit}
.grid.compact{gap:9px}.grid.compact label{font-size:10px}.grid.compact input,.grid.compact select{min-height:38px;padding:8px 10px}
.inventory-low{background:#fff3ef}.tablebox td small{display:block;color:#8a7d72;margin-top:3px}.empty-state{text-align:center;color:#796d63}
@media(max-width:980px){.grid.four,.four-cards{grid-template-columns:repeat(2,minmax(0,1fr))}.production-board{grid-template-columns:1fr}}
@media(max-width:620px){.grid.four,.four-cards{grid-template-columns:1fr}.production-card{padding:14px}}

/* v44: producción automática */
.production-auto-note{display:flex;flex-direction:column;justify-content:center;gap:4px;min-height:70px;padding:12px 15px;border:1px solid #dfd2c4;border-radius:15px;background:#f8f2eb;color:#5f5146}.production-auto-note strong{font-size:12px}.production-auto-note span{font-size:10px;line-height:1.4;color:#7b6c60}
