*{box-sizing:border-box}body{margin:0;font-family:Arial,Helvetica,sans-serif;background:#f4f6f8;color:#17202a}.app{display:flex;min-height:100vh}aside{width:240px;background:#111827;color:white;padding:22px;flex-shrink:0}aside p{color:#cbd5e1}nav{display:flex;flex-direction:column;gap:8px;margin-top:15px}nav a,.btn,button{background:#2563eb;color:white;border:0;border-radius:8px;padding:10px 14px;text-decoration:none;cursor:pointer;display:inline-block}nav a{background:transparent;color:#e5e7eb;padding:9px 0}.page{flex:1;display:block}.page-inner{padding:24px}.chat-main{flex:1;display:flex;flex-direction:column}.chat{flex:1;overflow:auto;padding:24px}.msg{max-width:850px;margin:10px 0;padding:14px 16px;border-radius:14px;white-space:pre-wrap;line-height:1.35}.user{margin-left:auto;background:#2563eb;color:#fff}.bot{background:#fff;border:1px solid #e5e7eb}.composer{display:flex;gap:10px;padding:16px;background:white;border-top:1px solid #e5e7eb}.composer input{flex:1;padding:14px;border:1px solid #cbd5e1;border-radius:8px}.login-body{display:grid;place-items:center;height:100vh}.login{width:340px;background:white;padding:24px;border-radius:16px;box-shadow:0 10px 30px #0002;display:flex;flex-direction:column;gap:12px}.login input,.form-control,textarea,select{padding:10px;border:1px solid #cbd5e1;border-radius:8px;width:100%}.error{background:#fee2e2;color:#991b1b;padding:10px;border-radius:8px}.ok{background:#dcfce7;color:#166534;padding:10px;border-radius:8px}small{color:#64748b}.card{background:white;border:1px solid #e5e7eb;border-radius:14px;padding:18px;margin-bottom:18px}.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.grid3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}label{font-weight:bold;font-size:13px;color:#374151}table{border-collapse:collapse;width:100%;background:white;border-radius:12px;overflow:hidden}th,td{padding:10px;border-bottom:1px solid #e5e7eb;text-align:left;font-size:14px}th{background:#f1f5f9}.actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.muted{color:#64748b}.right{text-align:right}.proforma{background:white;color:#111;padding:25px;max-width:1100px;margin:0 auto;font-size:12px}.pf-title{font-size:30px;color:#1d4ed8;font-weight:bold;margin-bottom:8px}.pf-top{display:grid;grid-template-columns:1fr 1fr;gap:28px}.pf-box p{margin:3px 0}.pf-company{text-align:left}.pf-table th{background:#e5e7eb;color:#111;font-size:11px}.pf-totales{margin-left:auto;width:330px}.printbar{padding:12px;background:#111827;position:sticky;top:0}.printbar a,.printbar button{margin-right:8px}@media print{aside,.printbar{display:none}.app{display:block}.page-inner{padding:0}.proforma{max-width:none}.no-print{display:none}body{background:white}}@media(max-width:800px){.app{display:block}aside{width:100%}.grid,.grid3,.pf-top{grid-template-columns:1fr}.composer{position:sticky;bottom:0}}
.chat-toolbar{display:flex;align-items:center;gap:12px;padding:10px 14px;background:#f8fafc;border-bottom:1px solid #e5e7eb;font-size:13px;color:#475569}
.chat-toolbar button{background:#111827;color:white;border:0;border-radius:8px;padding:8px 12px;cursor:pointer}
.chat-toolbar button:hover{opacity:.9}
.chat-toolbar select{max-width:320px;padding:8px 10px;border:1px solid #cbd5e1;border-radius:8px;background:#fff}
.composer button:disabled,.composer input:disabled{opacity:.65;cursor:not-allowed}
.attachment-history{max-width:850px;margin:10px 0;padding:10px 12px;border:1px dashed #cbd5e1;border-radius:8px;background:#f8fafc;color:#475569;font-size:13px;line-height:1.35}
.attachment-history strong{display:block;color:#111827;margin-bottom:4px}
.logs-audio-table{table-layout:fixed;width:100%}
.logs-audio-table th:nth-child(1),.logs-audio-table td:nth-child(1){width:74px}
.logs-audio-table th:nth-child(2),.logs-audio-table td:nth-child(2){width:72px}
.logs-audio-table th:nth-child(3),.logs-audio-table td:nth-child(3){width:96px}
.log-text-cell{width:auto;max-width:0}
.log-detail{margin:0;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;font:12px/1.35 Consolas,"Courier New",monospace;max-width:100%}
.stats-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-bottom:18px}
.stat{background:white;border:1px solid #e5e7eb;border-radius:8px;padding:16px}
.stat b{display:block;font-size:24px;color:#111827}
.stat span{color:#64748b;font-size:13px}
.tool-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.tool-list label{display:block;background:#f8fafc;border:1px solid #e5e7eb;border-radius:8px;padding:10px;font-weight:normal}
.tool-list span{color:#64748b;font-size:12px}
.clientes-table{table-layout:auto}
.client-address{max-width:360px;white-space:normal;overflow-wrap:anywhere}
@media(max-width:900px){.stats-grid,.tool-list{grid-template-columns:1fr}}
.bar-chart{display:grid;gap:10px}.bar-row{display:grid;grid-template-columns:90px 1fr 120px 1fr 120px;gap:10px;align-items:center}.bar-track{height:18px;background:#eef2f7;border-radius:999px;overflow:hidden}.bar-track span{display:block;height:100%;border-radius:999px}.bar-income{background:#16a34a}.bar-expense{background:#dc2626}.bar-value{font-size:12px;color:#475569;text-align:right}.work-monitors{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.monitor{border:1px solid #e5e7eb;border-radius:8px;padding:14px;background:#f8fafc}.monitor h3{margin-top:0}.work-item{background:white;border:1px solid #e5e7eb;border-radius:8px;padding:10px;margin-bottom:10px}.work-item b,.work-item small{display:block;margin-bottom:6px}@media(max-width:900px){.bar-row{grid-template-columns:1fr}.bar-value{text-align:left}.work-monitors{grid-template-columns:1fr}}
.ot-monitor-page{margin:0;min-height:100vh;background:#111;color:#7dff75;font-family:"Courier New",monospace;overflow:auto}.ot-monitor-grid{display:grid;grid-template-columns:repeat(auto-fill,270px);grid-auto-rows:170px;gap:5px;align-content:start;justify-content:start;padding:5px;background:#111}.ot-monitor-card{margin:0}.ot-monitor-card button{border:1px solid #82fff3;background:#151313;height:170px;width:100%;overflow:hidden;padding:8px;display:grid;align-content:start;gap:6px;text-align:left;font-family:"Courier New",monospace;cursor:pointer}.ot-monitor-card button:hover{outline:3px solid #facc15}.ot-monitor-top{display:flex;justify-content:space-between;gap:10px;margin:-8px -8px 0;padding:4px 8px;background:#ff77df;color:#190014;font-weight:900}.ot-monitor-card strong{color:#dcff6d;font-size:14px}.ot-monitor-card small{color:#f3ffb0;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ot-monitor-card em{color:#54ff78;font-style:normal;font-size:13px}.ot-monitor-card span{color:#7dff75;font-size:14px;line-height:1.25}.ot-monitor-empty{min-height:100vh;display:grid;place-items:center;background:#111;color:#7dff75;font:700 22px "Courier New",monospace}.ot-monitor-flash{position:fixed;top:8px;right:8px;z-index:5;background:#dcfce7;color:#166534;border:1px solid #86efac;padding:10px 14px;border-radius:6px;font-family:Arial,Helvetica,sans-serif}
.sep{border:0;border-top:1px solid #e5e7eb;margin:24px 0}.file-btn{display:inline-flex;align-items:center;justify-content:center;background:#e5e7eb;color:#111827;border-radius:8px;padding:10px 12px;cursor:pointer;font-size:18px}.file-btn input{display:none}.icon-btn{width:44px;height:44px;padding:0}.icon-btn svg{width:22px;height:22px;display:block;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.mic-btn{background:#0f172a}.mic-btn.recording{background:#dc2626}.attach-info{padding:0 16px 10px;background:#fff;color:#475569;font-size:13px}.composer input#message{min-width:0}.composer button,.composer .file-btn{flex-shrink:0}


/* Layout fijo del chat: solo la zona de mensajes tiene scroll */
html, body {
  height: 100%;
  overflow: hidden;
}

.app {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

aside {
  height: 100vh;
  overflow-y: auto;
}

.chat-main {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.chat-toolbar {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
}

.chat {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 24px;
}

.chat-bottom {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  position: relative;
  z-index: 2;
}

.chat-bottom .composer {
  border-top: 0;
  padding: 12px 14px;
}

.chat-bottom .attach-info {
  min-height: 0;
  padding: 6px 14px 0;
  background: #fff;
}

.chat-bottom .attach-info:empty {
  display: none;
}

@media(max-width:800px){
  html, body { overflow: hidden; }
  .app {
    display: flex;
    flex-direction: column;
    height: 100vh;
  }
  aside {
    width: 100%;
    height: auto;
    max-height: 190px;
    overflow-y: auto;
  }
  .chat-main {
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
  }
  .composer {
    position: static;
  }
  .chat-bottom .composer {
    gap: 6px;
    padding: 10px;
  }
  .chat-bottom .composer input {
    padding: 12px;
  }
  .chat-bottom .composer button,
  .chat-bottom .composer .file-btn {
    padding: 10px 12px;
  }

  .chat-bottom .composer .icon-btn {
    width: 44px;
    height: 44px;
    padding: 0;
  }
}

/* Las paginas internas necesitan scroll independiente; el overflow fijo solo aplica al chat. */
.page {
  min-height: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

@media(max-width:800px){
  .page {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    overflow-y: auto;
  }
}

.proforma-sheet{background:#fff;color:#000;width:1000px;min-height:1120px;margin:0 auto;padding:28px 18px 18px;font-family:Arial,Helvetica,sans-serif;font-size:12px}
.pf-header{display:grid;grid-template-columns:1fr 1fr;gap:30px;align-items:start;margin-bottom:14px}
.pf-header h1{font-size:22px;margin:0 0 8px;color:#000}
.pf-company-block{text-align:right;font-size:11px;line-height:1.25}
.pf-company-block h2{font-size:11px;margin:4px 0 8px;font-weight:bold}
.pf-company-block p{margin:1px 0}
.pf-meta{width:100%;background:transparent;border-radius:0}
.pf-meta th,.pf-meta td{border:0;padding:1px 4px;font-size:11px;background:transparent}
.pf-meta th{width:140px;color:#000;font-weight:bold}
.pf-lines{font-size:11px;border-radius:0}
.pf-lines th{background:#0b4668;color:#fff;border:0;text-align:center;font-size:10px;padding:6px 4px}
.pf-lines td{border-bottom:1px solid #d7dde3;padding:7px 4px;vertical-align:top;font-size:10px}
.pf-bottom{display:grid;grid-template-columns:62.5% 37.5%;gap:0;margin-top:220px;align-items:start;width:100%}
.pf-section-title{background:#0b4668;color:#fff;font-weight:bold;text-align:center;padding:3px 4px;font-size:8px}
.pf-observaciones,.pf-totals-box{min-width:0}
.pf-observaciones{border-left:1px solid #cbd5e1;border-right:1px solid #cbd5e1;min-height:110px}
.pf-observaciones p{padding:7px 8px;margin:0;white-space:pre-wrap;font-size:8px;line-height:1.2}
.pf-totals-box table{font-size:8px;border-radius:0;table-layout:fixed;width:100%}
.pf-totals-box td,.pf-totals-box th{padding:2px 5px;border-bottom:1px solid #d7dde3;font-size:8px;line-height:1.2}
.pf-totals-rows{width:100%;min-width:0;font-size:8px}
.pf-total-row{display:grid;grid-template-columns:minmax(0,1fr) 120px;align-items:center;border-bottom:1px solid #d7dde3;line-height:1.2;min-width:0}
.pf-total-row span{min-width:0;padding:2px 5px;overflow:hidden;text-overflow:ellipsis}
.pf-total-row strong{min-width:0;padding:2px 5px;text-align:right;white-space:nowrap;font-weight:normal}
.pf-total-final{background:#f1f5f9;font-weight:bold}
.pf-total-final strong,.pf-total-final span{font-weight:bold}
.pf-footer{background:#0b4668;color:#fff;text-align:center;font-size:10px;padding:7px;margin-top:0;white-space:pre-wrap}
@page{size:letter portrait;margin:8mm}
@media print{
  html,body{height:auto;overflow:visible;background:#fff}
  *{-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .proforma-sheet{width:100%;min-height:250mm;margin:0;padding:8mm;box-shadow:none;font-size:10px}
  .pf-header h1{font-size:20px}
  .pf-company-block,.pf-meta th,.pf-meta td,.pf-lines{font-size:9px}
  .pf-section-title,.pf-observaciones p,.pf-totals-box table{font-size:7px}
  .pf-totals-box td,.pf-totals-box th{padding:2px 4px;font-size:7px}
  .pf-lines th{font-size:8px;padding:4px 2px}
  .pf-lines td{padding:5px 2px;font-size:8px}
  .pf-bottom{margin-top:205px}
  .pf-footer{font-size:8px;padding:6px}
}

/* Navegacion y pantallas moviles */
.sidebar-head{display:block}
.sidebar-head h2{margin:0 0 18px}
.sidebar-head p{margin:0;color:#cbd5e1}
.menu-toggle{display:none}

@media(max-width:800px){
  html,body{
    width:100%;
    height:100%;
    overflow:hidden;
  }

  .app{
    width:100%;
    height:100dvh;
    min-height:100dvh;
    display:flex;
    flex-direction:column;
    overflow:hidden;
  }

  aside{
    width:100%;
    height:auto;
    max-height:none;
    padding:0;
    overflow:visible;
    flex:0 0 auto;
    position:relative;
    z-index:20;
    box-shadow:0 1px 0 rgba(255,255,255,.08);
  }

  .sidebar-head{
    min-height:62px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    padding:12px 16px;
  }

  .sidebar-head h2{
    margin:0;
    font-size:20px;
    line-height:1.1;
  }

  .sidebar-head p{
    display:none;
  }

  .menu-toggle{
    display:inline-flex;
    width:44px;
    height:44px;
    align-items:center;
    justify-content:center;
    flex-direction:column;
    gap:5px;
    padding:0;
    border-radius:10px;
    background:#0f172a;
    border:1px solid #334155;
  }

  .menu-toggle span{
    display:block;
    width:21px;
    height:2px;
    border-radius:999px;
    background:#fff;
  }

  aside nav{
    display:none;
    margin:0;
    padding:6px 16px 14px;
    max-height:calc(100dvh - 62px);
    overflow-y:auto;
    background:#111827;
    border-top:1px solid #1f2937;
  }

  aside.menu-open nav{
    display:flex;
  }

  nav a{
    padding:12px 0;
    font-size:16px;
  }

  .page{
    flex:1 1 auto;
    height:auto;
    min-height:0;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
  }

  .page-inner{
    padding:16px;
  }

  .page-inner h1{
    font-size:26px;
    margin-top:0;
  }

  .card{
    padding:14px;
    border-radius:10px;
    overflow-x:auto;
  }

  table{
    min-width:640px;
  }

  th,td{
    padding:9px;
    font-size:13px;
  }

  .actions{
    align-items:stretch;
  }

  .actions .btn,
  .actions button,
  .actions a{
    text-align:center;
  }

  .chat-main{
    flex:1 1 auto;
    height:auto;
    min-height:0;
    overflow:hidden;
  }

  .chat-toolbar{
    display:grid;
    grid-template-columns:1fr auto;
    gap:8px;
    padding:8px;
  }

  .chat-toolbar select{
    max-width:none;
    min-width:0;
    height:40px;
  }

  .chat-toolbar button{
    height:40px;
    padding:8px 10px;
  }

  .chat-toolbar span{
    display:none;
  }

  .chat{
    padding:12px 10px;
  }

  .msg{
    max-width:100%;
    margin:8px 0;
    padding:12px 14px;
    font-size:15px;
  }

  .chat-bottom{
    flex:0 0 auto;
  }

  .chat-bottom .composer{
    display:grid;
    grid-template-columns:1fr auto auto;
    gap:8px;
    padding:8px;
  }

  .chat-bottom .composer input#message{
    grid-column:1 / -1;
    width:100%;
    min-height:44px;
    font-size:16px;
  }

  .chat-bottom .composer button,
  .chat-bottom .composer .file-btn{
    min-height:42px;
    padding:10px;
    font-size:14px;
  }

  .chat-bottom .composer .icon-btn{
    width:44px;
    height:44px;
    min-height:44px;
    padding:0;
  }

  .chat-bottom .composer button[type="submit"]{
    grid-column:auto;
    min-width:82px;
  }

  .attach-info{
    font-size:12px;
    padding:6px 8px 0;
  }

  .stats-grid,
  .tool-list,
  .work-monitors{
    grid-template-columns:1fr;
  }

  .proforma-sheet{
    width:100%;
    min-height:auto;
    padding:16px 10px;
    overflow-x:auto;
  }
}

/* En moviles el navegador necesita que la pagina raiz pueda desplazarse para permitir
   el gesto nativo de actualizar/deslizar hacia abajo. */
@media(max-width:800px){
  html,
  body{
    height:auto;
    min-height:100%;
    overflow-y:auto;
    overflow-x:hidden;
  }

  .app{
    height:auto;
    min-height:100dvh;
    overflow:visible;
  }

  .chat-main{
    min-height:calc(100dvh - 62px);
    overflow:visible;
  }

  .chat{
    flex:0 0 auto;
    min-height:calc(100dvh - 210px);
    overflow:visible;
  }
}


/* Correccion formato proforma PDF/impresion */
.pf-company-block{min-width:0;max-width:380px;justify-self:end;margin-top:30px;overflow-wrap:normal;word-break:normal;hyphens:none}
.pf-company-block h2,.pf-company-block p{overflow-wrap:normal;word-break:normal;hyphens:none}
@media print{
  @page{size:letter portrait;margin:8mm}
  body{margin:0 !important}
  .proforma-sheet{width:190mm !important;max-width:190mm !important;min-height:250mm;margin:0 auto !important;padding:4mm !important;overflow:visible !important}
  .pf-header{grid-template-columns:47% 53%;gap:4mm;align-items:start}
  .pf-company-block{max-width:76mm;justify-self:end;margin-top:7mm;text-align:right;font-size:7px;line-height:1.16;white-space:normal;overflow:visible}
  .pf-company-block h2{font-size:8px;line-height:1.15;margin:2px 0 5px;font-weight:bold}
  .pf-company-block p{font-size:7px;line-height:1.16;margin:1px 0}
  .pf-meta th,.pf-meta td{font-size:8px;padding:1px 2px}
  .pf-meta th{width:30mm}
  .pf-lines{width:100%;table-layout:fixed;font-size:7px}
  .pf-lines th{font-size:6.3px;padding:3px 1px}
  .pf-lines td{font-size:6.7px;padding:4px 1px;word-break:normal;overflow-wrap:break-word}
  .pf-lines th:nth-child(1),.pf-lines td:nth-child(1){width:8%}
  .pf-lines th:nth-child(2),.pf-lines td:nth-child(2){width:6%}
  .pf-lines th:nth-child(3),.pf-lines td:nth-child(3){width:22%}
  .pf-lines th:nth-child(n+4),.pf-lines td:nth-child(n+4){width:auto}
  .pf-bottom{grid-template-columns:61% 39%;margin-top:205px;width:100%;overflow:visible}
  .pf-observaciones,.pf-totals-box{min-width:0}
  .pf-totals-box table{table-layout:fixed;width:100%}
  .pf-totals-box td:first-child,.pf-totals-box th:first-child{width:54%}
  .pf-totals-box td:last-child,.pf-totals-box th:last-child{width:46%;text-align:right}
}

/* Impresion/PDF: mantener las mismas proporciones visuales que la vista web. */
@media print{
  @page{size:letter portrait;margin:8mm}
  html,body{height:auto !important;overflow:visible !important;background:#fff !important}
  body{margin:0 !important}
  .printbar{display:none !important}
  .proforma-sheet{
    width:190mm !important;
    max-width:190mm !important;
    min-height:250mm !important;
    margin:0 auto !important;
    padding:5.3mm 3.4mm 3.4mm !important;
    font-size:12px !important;
    overflow:visible !important;
  }
  .pf-header{
    display:grid !important;
    grid-template-columns:46% 54% !important;
    gap:18px !important;
    align-items:start !important;
    margin-bottom:14px !important;
  }
  .pf-header h1{font-size:22px !important;margin:0 0 8px !important}
  .pf-company-block{
    width:100% !important;
    max-width:100% !important;
    justify-self:end !important;
    margin-top:30px !important;
    text-align:right !important;
    font-size:10.5px !important;
    line-height:1.25 !important;
    white-space:normal !important;
    overflow-wrap:normal !important;
    word-break:normal !important;
  }
  .pf-company-block h2{font-size:10.5px !important;line-height:1.2 !important;margin:4px 0 8px !important;font-weight:bold !important;white-space:nowrap !important}
  .pf-company-block p{font-size:10.5px !important;line-height:1.25 !important;margin:1px 0 !important;overflow-wrap:normal !important;word-break:normal !important}
  .pf-meta th,.pf-meta td{font-size:11px !important;padding:1px 4px !important}
  .pf-meta th{width:140px !important}
  .pf-lines{width:100% !important;table-layout:fixed !important;font-size:11px !important}
  .pf-lines th{font-size:10px !important;padding:6px 4px !important}
  .pf-lines td{font-size:10px !important;padding:7px 4px !important;word-break:normal !important;overflow-wrap:break-word !important}
  .pf-lines th:nth-child(1),.pf-lines td:nth-child(1){width:7% !important}
  .pf-lines th:nth-child(2),.pf-lines td:nth-child(2){width:6% !important}
  .pf-lines th:nth-child(3),.pf-lines td:nth-child(3){width:28% !important}
  .pf-lines th:nth-child(n+4),.pf-lines td:nth-child(n+4){width:auto !important}
  .pf-bottom{
    display:grid !important;
    grid-template-columns:62.5% 37.5% !important;
    gap:0 !important;
    margin-top:220px !important;
    align-items:start !important;
    width:100% !important;
  }
  .pf-observaciones,.pf-totals-box{min-width:0 !important}
  .pf-section-title{font-size:8px !important;padding:3px 4px !important}
  .pf-observaciones{min-height:110px !important}
  .pf-observaciones p{font-size:8px !important;line-height:1.2 !important;padding:7px 8px !important}
  .pf-totals-box table{width:100% !important;table-layout:fixed !important;font-size:8px !important}
  .pf-totals-box td,.pf-totals-box th{font-size:8px !important;line-height:1.2 !important;padding:2px 5px !important}
  .pf-totals-box td:first-child,.pf-totals-box th:first-child{width:48% !important}
  .pf-totals-box td:last-child,.pf-totals-box th:last-child{width:52% !important;text-align:right !important;white-space:nowrap !important}
  .pf-footer{font-size:10px !important;padding:7px !important}
}

/* Correccion final de montos en impresion: no dejar que la tabla expulse importes. */
@media print{
  .pf-lines,
  .pf-bottom,
  .pf-footer{
    width:calc(100% + 4px) !important;
    max-width:calc(100% + 4px) !important;
    margin-right:-4px !important;
  }
  .pf-totals-box table,
  .pf-totals-box tbody{
    display:block !important;
    width:100% !important;
    table-layout:auto !important;
    overflow:visible !important;
  }
  .pf-totals-box tr{
    display:grid !important;
    grid-template-columns:minmax(0,1fr) 92px !important;
    width:100% !important;
    min-width:0 !important;
    border-bottom:1px solid #d7dde3 !important;
  }
  .pf-totals-box td,
  .pf-totals-box th{
    display:block !important;
    min-width:0 !important;
    width:auto !important;
    border-bottom:0 !important;
    overflow:visible !important;
  }
  .pf-totals-box td:first-child,
  .pf-totals-box th:first-child{
    width:auto !important;
    text-align:left !important;
  }
  .pf-totals-box td:last-child,
  .pf-totals-box th:last-child{
    width:auto !important;
    text-align:right !important;
    white-space:nowrap !important;
  }
  .pf-totals-rows{
    display:block !important;
    width:100% !important;
    min-width:0 !important;
    font-size:8px !important;
    overflow:visible !important;
  }
  .pf-total-row{
    display:grid !important;
    grid-template-columns:minmax(0,1fr) 96px !important;
    width:100% !important;
    min-width:0 !important;
    border-bottom:1px solid #d7dde3 !important;
    line-height:1.2 !important;
  }
  .pf-total-row span{
    min-width:0 !important;
    padding:2px 5px !important;
    overflow:hidden !important;
    text-overflow:ellipsis !important;
  }
  .pf-total-row strong{
    min-width:0 !important;
    padding:2px 5px !important;
    text-align:right !important;
    white-space:nowrap !important;
    font-weight:normal !important;
  }
  .pf-total-final span,
  .pf-total-final strong{
    font-weight:bold !important;
  }
}

/* PDF/impresion final: usar la misma maqueta que la vista web y escalarla completa. */
@media print{
  @page{size:letter portrait;margin:8mm}
  html,body{height:auto !important;overflow:visible !important;background:#fff !important}
  body{margin:0 !important}
  .printbar{display:none !important}
  .proforma-sheet{
    width:1000px !important;
    max-width:1000px !important;
    min-height:1120px !important;
    margin:0 auto !important;
    padding:28px 18px 18px !important;
    font-size:12px !important;
    overflow:visible !important;
    zoom:.72;
  }
  .pf-header{
    display:grid !important;
    grid-template-columns:1fr 1fr !important;
    gap:30px !important;
    align-items:start !important;
    margin-bottom:14px !important;
  }
  .pf-header h1{font-size:22px !important;margin:0 0 8px !important}
  .pf-company-block{
    width:auto !important;
    max-width:380px !important;
    justify-self:end !important;
    margin-top:30px !important;
    text-align:right !important;
    font-size:11px !important;
    line-height:1.25 !important;
    white-space:normal !important;
    overflow-wrap:normal !important;
    word-break:normal !important;
  }
  .pf-company-block h2{font-size:11px !important;line-height:1.2 !important;margin:4px 0 8px !important;font-weight:bold !important;white-space:normal !important}
  .pf-company-block p{font-size:11px !important;line-height:1.25 !important;margin:1px 0 !important;overflow-wrap:normal !important;word-break:normal !important}
  .pf-meta th,.pf-meta td{font-size:11px !important;padding:1px 4px !important}
  .pf-meta th{width:140px !important}
  .pf-lines{
    width:100% !important;
    max-width:100% !important;
    margin-right:0 !important;
    table-layout:auto !important;
    font-size:11px !important;
  }
  .pf-lines th{font-size:10px !important;padding:6px 4px !important}
  .pf-lines td{font-size:10px !important;padding:7px 4px !important;word-break:normal !important;overflow-wrap:break-word !important}
  .pf-lines th:nth-child(n),
  .pf-lines td:nth-child(n){width:auto !important}
  .pf-bottom{
    display:grid !important;
    grid-template-columns:62.5% 37.5% !important;
    gap:0 !important;
    margin-top:220px !important;
    align-items:start !important;
    width:100% !important;
    max-width:100% !important;
    margin-right:0 !important;
  }
  .pf-observaciones,.pf-totals-box{min-width:0 !important}
  .pf-section-title{font-size:8px !important;padding:3px 4px !important}
  .pf-observaciones{min-height:110px !important}
  .pf-observaciones p{font-size:8px !important;line-height:1.2 !important;padding:7px 8px !important}
  .pf-totals-rows{width:100% !important;min-width:0 !important;font-size:8px !important;overflow:visible !important}
  .pf-total-row{
    display:grid !important;
    grid-template-columns:minmax(0,1fr) 120px !important;
    width:100% !important;
    min-width:0 !important;
    border-bottom:1px solid #d7dde3 !important;
    line-height:1.2 !important;
  }
  .pf-total-row span{min-width:0 !important;padding:2px 5px !important;overflow:hidden !important;text-overflow:ellipsis !important}
  .pf-total-row strong{min-width:0 !important;padding:2px 5px !important;text-align:right !important;white-space:nowrap !important;font-weight:normal !important}
  .pf-total-final{background:#f1f5f9 !important;font-weight:bold !important}
  .pf-total-final span,.pf-total-final strong{font-weight:bold !important}
  .pf-footer{
    width:100% !important;
    max-width:100% !important;
    margin-right:0 !important;
    font-size:10px !important;
    padding:7px !important;
  }
}
