:root{
  --navy:#073a7c;--blue:#0c4b94;--blue2:#0c488e;--light:#eaf4ff;--border:#c8d7e9;
  --red:#d52631;--green:#078433;--green-l:#e2f8e9;--green-m:#b9edcc;
  --warn-bg:#fff1de;--warn:#965112;--ok-bg:#e2f9e8;--ok:#086327;--err-bg:#ffe8ea;--err:#9f1425;
  --text:#16365d;--muted:#5a6f87;--bg:#eef3f9;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);font:14px Arial,Helvetica,sans-serif;color:var(--text);padding-block:14px;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}
h2{color:var(--navy);margin:0 0 8px}
h3{color:var(--navy);margin:6px 0 8px;font-size:15px}
label{display:block;font-size:12px;font-weight:700;margin:9px 0 4px}
label.inline{display:flex;gap:6px;align-items:center;margin:0 0 6px}
label.check{display:flex;gap:6px;align-items:center;font-weight:600;margin-top:24px}
label.check input{width:17px;height:17px}
input,select,textarea{font:inherit;color:#173968;border:1px solid #afc3d8;border-radius:7px;padding:7px 8px;width:100%;background:#fff}
input[readonly]{background:#f3f6fa}
input:disabled,select:disabled,textarea:disabled{background:#f3f6fa;color:#6b7f95}
textarea{min-height:60px;resize:vertical}
textarea.tall{min-height:130px}
textarea.clinico{min-height:120px;font-size:13px;line-height:1.45}
input.falta,select.falta{border:2px solid var(--red);background:#fff5f5}
input:focus,select:focus,textarea:focus{outline:2px solid #8ac5ff;outline-offset:0}
button{border:0;border-radius:7px;background:var(--blue2);color:#fff;padding:9px 11px;font-weight:700;cursor:pointer;font:inherit;font-weight:700}
button:hover{filter:brightness(.95)}
button:disabled{opacity:.45;cursor:not-allowed}
button.secondary{background:#dfeafb;color:#11457e}
button.danger{background:var(--err-bg);color:var(--err)}
button.green{background:var(--green)}
button.small{padding:6px 9px;font-size:12px}
button.big{width:100%;padding:12px;margin:4px 0}
.row{display:flex;gap:8px;align-items:flex-end;flex-wrap:wrap}
.row>div,.row>input,.row>select{flex:1;min-width:110px}
.row>button{flex:0 0 auto}
.row.end{justify-content:flex-end;margin-top:12px}
.stack{display:flex;flex-direction:column;gap:6px;margin-top:10px}
.tiny{font-size:12px;color:var(--muted);line-height:1.45}
.divider{height:1px;background:#dbe4f1;margin:14px 0}
.notice{border-radius:7px;padding:9px 10px;margin:8px 0;font-size:13px;line-height:1.45}
.notice.warn{background:var(--warn-bg);color:var(--warn)}
.notice.ok{background:var(--ok-bg);color:var(--ok)}
.notice.err{background:var(--err-bg);color:var(--err)}
.notice.info{background:var(--light);color:#0b4a86}
.notice ul{margin:4px 0 0 18px;padding:0}
.control{background:#f0f6ff;border:1px solid #dbe9fa;border-radius:9px;padding:9px 10px;margin:9px 0}
.control summary{cursor:pointer;font-weight:700;color:var(--navy)}

.faixa-demo{background:var(--warn-bg);color:var(--warn);border:1px solid #f0c98b;border-radius:10px;padding:8px 12px;margin-bottom:10px;font-size:13px;font-weight:600}
.banner{display:flex;justify-content:space-between;align-items:center;gap:14px;flex-wrap:wrap;background:#fff;padding:12px 18px;border:2px solid var(--red);border-radius:14px}
.brand{font:900 32px Georgia,serif;color:#111;line-height:1}
.brand span{color:var(--red)}
.brand small{display:block;font:700 12px Arial;text-align:center;margin-top:3px}
.banner-mid{display:flex;flex-direction:column;align-items:center;gap:4px}
.banner-right{min-width:300px;flex:0 1 560px}
.badge{padding:6px 12px;border-radius:50px;background:#def4ff;color:#0b548a;font-weight:700;font-size:13px}
.badge.fechado{background:var(--green-m);color:#065a26}
.badge.cancelado{background:var(--err-bg);color:var(--err)}
.badge.pendente{background:var(--warn-bg);color:var(--warn)}

.workspace{display:grid;grid-template-columns:350px minmax(0,1fr);gap:14px;margin-top:14px}
.panel,.paper{background:#fff;border-radius:13px;padding:15px;box-shadow:0 3px 14px #12346a14}
.paper{border:2px solid var(--red);min-width:0}
.paper.etapa2{border-color:#df8a22}
.paper.fechado{border-color:var(--green)}
.stagebar{display:flex;gap:6px;margin-bottom:8px}
.stagebar button{flex:1;padding:11px 6px;font-size:13px;background:#e5eef9;color:#205083}
.stagebar button.active{background:var(--blue);color:#fff}
.stage-info{padding:9px 10px;background:#e8f5ff;border-left:5px solid #219be1;border-radius:8px;font-size:13px}
.stage-info.neg{background:var(--warn-bg);border-color:#df8a22}
.stage-info.ok{background:var(--ok-bg);border-color:var(--green)}

.headline{background:var(--blue);color:#fff;font-weight:900;padding:11px 12px;border-radius:8px;font-size:18px}
.headline.neg{background:#b86a12}
.headline.fechado{background:var(--green)}
.meta{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:6px 12px;margin:10px 0;font-size:13px}
.tabletoolbar{display:flex;gap:7px;flex-wrap:wrap;align-items:center;margin:8px 0}
.tablearea{overflow:auto;border-radius:8px}

table.grid{width:100%;border-collapse:collapse;font-size:12px;min-width:640px}
table.grid th,table.grid td{border:1px solid #bdcee0;padding:4px;vertical-align:middle}
table.grid th{background:#083e83;color:#fff;text-align:center;font-weight:700}
table.grid th.plan{min-width:128px}
table.grid th.plan.base{background:#0e5fb8;box-shadow:inset 0 0 0 3px #8ac5ff}
table.grid th.plan.aprov{background:var(--green-m);color:#065a26}
table.grid td.cell.base{background:#f2f8ff}
table.grid td.cell.aprov{background:var(--green-l)}
table.grid td.cell.def input{background:#fff7e0;border-color:#e6b65c}
table.grid td.cell.pend input{background:#ffe9cf;border-color:#df8a22}
table.grid td.cell.ni input{color:#8a9ab0;font-style:italic}
table.grid td input,table.grid td select{font-size:12px;padding:5px}
table.grid td.desc{min-width:190px}
table.grid td.qtd input{width:58px;text-align:right}
table.grid td.cell input{text-align:right;min-width:96px}
table.grid .hint{display:block;font-size:10px;color:#8a6a2a;text-align:right;margin-top:2px}
table.grid .hint.novo{color:#0b6b9a}
table.grid tfoot td{font-weight:700;background:#073f82;color:#fff;text-align:right;font-size:13px}
table.grid tfoot td:first-child{text-align:left}
table.grid tfoot td.aprov{background:var(--green);color:#fff}
table.grid tfoot tr.ancora td,.doc-table tfoot tr.ancora td{background:#dcebfb;color:#2a5f99;font-size:10.5px;font-weight:600;padding:2px 6px;line-height:1.3}
table.grid tfoot tr.ancora td:first-child,.doc-table tfoot tr.ancora td:first-child{font-weight:400;font-style:italic}
tr.ancora s{text-decoration-thickness:1px}
/* parcelas de cada plano (forma escolhida na barra lateral) — logo abaixo do TOTAL DO PLANO */
table.grid tfoot tr.parcelas td,.doc-table tfoot tr.parcelas td{background:#e7f6ec;color:#11632f;font-weight:800;font-size:12px;padding:4px 6px;text-align:right;border-top:1px solid #b9e3c6}
table.grid tfoot tr.parcelas td:first-child,.doc-table tfoot tr.parcelas td:first-child{text-align:left}
tr.parcelas small{font-weight:500;color:#5b7f68}
#pSalvar{width:100%;margin-top:8px}
table.grid tfoot small{display:block;font-weight:400;font-size:10px;color:#ffe6a8}
.rotulo-plano{font-size:13px;font-weight:800;letter-spacing:.3px;margin-bottom:4px;text-transform:uppercase}
.ph{display:flex;align-items:center;justify-content:center;gap:3px}
.ph input{width:52px;text-align:center;padding:3px;font-weight:700}
.pa{display:flex;justify-content:center;gap:4px;margin-top:4px;flex-wrap:wrap}
.pa label{display:flex;align-items:center;gap:4px;margin:0;font-size:11px;color:#fff;font-weight:600}
.pa label input{width:14px;height:14px}
table.grid th.aprov .pa label{color:#065a26}
.qb{width:28px;height:28px;padding:0;display:inline-flex;align-items:center;justify-content:center;border-radius:7px;font-size:15px;line-height:1}
.qb.add{background:#e1f3ff;color:#06477f;border:1px solid #9dcbe9}
.qb.del{background:var(--err-bg);color:var(--err);border:1px solid #f2bbc2}
.qb.neutral{background:#eef4fb;color:#11457e;border:1px solid #c3d6ec}
td.acts{white-space:nowrap;text-align:center}
.colar{border:2px dashed #46a9e8;background:#f2f9ff;border-radius:10px;padding:12px;margin:8px 0}
.colar textarea{min-height:110px;margin:8px 0 0;font-family:Consolas,monospace;font-size:12px}
.botao-arquivo{display:inline-flex;align-items:center;gap:4px;background:#dfeafb;color:#11457e;border-radius:7px;padding:6px 9px;font-size:12px;font-weight:700;cursor:pointer}
.botao-arquivo:hover{filter:brightness(.95)}
.aviso-print{background:var(--warn-bg);color:var(--warn);border-radius:6px;padding:5px 8px;margin:4px 0}
.print-previa{display:flex;gap:12px;align-items:flex-start;flex-wrap:wrap;margin-top:8px;padding:8px;background:#fff;border:1px solid #c8d7e9;border-radius:8px}
.print-mini{padding:0;background:#fff;border:1px solid #c8d7e9;border-radius:6px;cursor:zoom-in;flex:0 0 auto}
.print-mini img{display:block;max-width:240px;max-height:170px;border-radius:5px}
.print-info{flex:1;min-width:200px;display:flex;flex-direction:column;gap:6px;font-size:13px}
.print-info .notice{margin:0}
#modalPrint{z-index:85}
.print-box{width:min(1200px,100%)}
.print-box img{display:block;max-width:100%;height:auto;margin:0 auto 8px;border:1px solid #c8d7e9}
.print-disp{font-size:12px;font-weight:600;margin-top:6px;padding:4px 8px;border-radius:6px}
.print-disp.ok{background:var(--ok-bg);color:var(--ok)}
.print-disp.warn{background:var(--warn-bg);color:var(--warn)}
.print-disp.info{background:var(--light);color:#0b4a86}
.colar.compacto{padding:8px 12px;background:#f7fbff}
.colar.compacto textarea{min-height:42px;height:42px}
#colarBox{margin-bottom:8px}
.empty{padding:26px;text-align:center;color:var(--muted)}
.quick{display:flex;gap:6px;justify-content:center;flex-wrap:wrap;margin-top:10px}

.diff{border:1px solid #f0c98b;background:#fffaf1;border-radius:9px;padding:10px;margin:8px 0;font-size:13px}
.diff h4{margin:0 0 6px;color:var(--warn)}
.diff ul{margin:4px 0 6px 18px;padding:0}
.diff li{margin:3px 0}
.diff .just{display:block;color:var(--muted);font-size:11px}
.audit{max-height:280px;overflow:auto;font-size:12px}
.audit div{border-bottom:1px solid #e3ebf5;padding:5px 0}
.audit b{color:var(--navy)}
.versao{display:flex;justify-content:space-between;align-items:center;gap:6px;font-size:12px;padding:5px 0;border-bottom:1px solid #e3ebf5}
.retirado{display:flex;justify-content:space-between;align-items:center;gap:6px;font-size:12px;padding:4px 0;color:#9c4652}

.modal{position:fixed;inset:0;background:#0b1f3a88;display:flex;align-items:flex-start;justify-content:center;padding:30px 12px;z-index:50;overflow:auto}
.modal[hidden]{display:none}
.modal-box{background:#fff;border-radius:12px;padding:18px;width:min(1100px,100%)}
.modal table{border-collapse:collapse;font-size:12px;width:100%}
.modal th,.modal td{border:1px solid #d5e1ee;padding:4px;text-align:left;white-space:nowrap}
.modal th select,.modal th input{font-size:11px;padding:3px;min-width:105px}
.modal td.proib{background:#f3f3f3;color:#aaa;text-decoration:line-through}
#modalFin{z-index:70}
#dlg{z-index:90;align-items:center}
.dlg-box{max-width:520px}
.dlg-box{max-height:85vh;overflow:auto}
.dlg-box p{white-space:pre-wrap;font-size:15px;line-height:1.5;margin:0 0 12px}
.dlg-box input{margin-bottom:4px}
button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,summary:focus-visible{outline:3px solid #8ac5ff;outline-offset:1px}
#modalPgEdit{z-index:75}
.pg-edit{max-width:760px}
.pg-edit #peObs{min-height:80px}
.tag-pg.pendente{background:#e8eef6;color:#41566f}
table.pagos td.saldo{color:var(--warn)}
.abas{display:flex;gap:4px;border-bottom:2px solid #c8d7e9;margin:6px 0 12px;flex-wrap:wrap}
.aba{background:#e5eef9;color:#205083;border-radius:8px 8px 0 0;padding:9px 14px}
.aba.ativa{background:var(--green);color:#fff}
.fc-dados{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:4px 12px;margin:10px 0}
.fc-dados label{margin:0 0 3px}
table.fc{width:100%;border-collapse:collapse;font-size:13px;min-width:560px}
table.fc th{background:var(--green);color:#fff;padding:5px;text-align:left}
table.fc td{border-bottom:1px solid #e3ebf5;padding:3px 4px;vertical-align:middle}
table.fc td input,table.fc td select{padding:5px;font-size:13px}
table.fc td.v input{text-align:right;min-width:100px}
table.fc td.q input{width:60px;text-align:right}
table.fc td.prop{color:#5a6f87;text-align:right;white-space:nowrap;font-size:12px}
table.fc tfoot td{font-weight:800;background:var(--green-l);color:#065a26;padding:6px}
.fc-acoes{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end;margin-top:12px}
table.pagos{width:100%;border-collapse:collapse;font-size:13px;margin-top:10px}
table.pagos th{background:var(--green);color:#fff;text-align:left;padding:6px}
table.pagos td{border-bottom:1px solid #e3ebf5;padding:6px;white-space:nowrap}
table.pagos .obs-pg{display:inline-block;max-width:220px;white-space:normal;vertical-align:middle}
table.pagos td.v{text-align:right;font-weight:700}
table.pagos tfoot td{background:var(--green-l);font-weight:700;color:#065a26}
@media (max-width:760px){
  table.pagos thead{display:none}
  table.pagos,table.pagos tbody,table.pagos tr,table.pagos td{display:block;width:100%}
  table.pagos tbody tr{border:1px solid #cfe3d6;border-radius:9px;margin:10px 0;padding:6px 10px;background:#fbfffc}
  table.pagos td{border:0;padding:3px 0;white-space:normal;display:flex;justify-content:space-between;gap:10px;text-align:right}
  table.pagos td::before{content:attr(data-l);font-weight:700;color:#5a6f87;text-align:left}
  table.pagos td.acoes{justify-content:flex-end;padding-top:6px}
  table.pagos td.acoes::before{content:none}
  table.pagos tfoot tr{display:block;border-radius:9px;padding:6px 10px}
  table.pagos tfoot td[colspan]{display:block}
}
table.pagos tr.detalhe > td{background:#f6faff;white-space:normal;padding:8px 10px;display:table-cell}
.det{display:flex;flex-direction:column;gap:6px;font-size:12px}
.det-tit{font-weight:800;color:var(--navy);font-size:12px;margin-top:4px}
.det-tit.verde{color:#065a26}
table.mini{border-collapse:collapse;width:100%;font-size:11.5px;background:#fff}
table.mini th{background:#083e83;color:#fff;padding:3px 6px;text-align:left;font-weight:700}
table.mini.fechada th{background:var(--green)}
table.mini td{border-bottom:1px solid #e3ebf5;padding:3px 6px;white-space:nowrap}
table.mini .v{text-align:right;font-variant-numeric:tabular-nums}
table.mini .c{text-align:center}
table.mini tfoot td{font-weight:800;background:#eaf2fc}
table.mini.fechada tfoot td{background:var(--green-l);color:#065a26}
table.mini tr.ok td{color:#6b7f95;text-decoration:line-through}
table.mini tr.ok td:last-child{text-decoration:none}
table.mini input[type=checkbox]{width:16px;height:16px}
.det-pg{line-height:1.5}
.copia-fallback{min-height:80px;font-family:Consolas,monospace;font-size:11px}
@media (max-width:760px){
  table.pagos tr.detalhe{padding:0;border:0;background:none}
  table.pagos tr.detalhe > td{display:block}
  table.pagos tr.detalhe > td::before{content:none}
  table.mini,table.mini tbody,table.mini tr,table.mini td{display:table;}
  table.mini{display:table} table.mini thead{display:table-header-group} table.mini tbody{display:table-row-group} table.mini tfoot{display:table-footer-group}
  table.mini tr{display:table-row} table.mini td,table.mini th{display:table-cell;text-align:inherit}
  table.mini td::before{content:none}
  table.mini tbody tr{border:0;margin:0;padding:0;background:none;border-radius:0}
  table.mini tfoot tr{display:table-row;padding:0}
  table.mini tfoot td[colspan]{display:table-cell}
  table.mini td{white-space:normal}
  .det,table.mini td,table.mini th{text-align:left}
  table.mini td.v,table.mini th.v{text-align:right}
  table.mini td.c,table.mini th.c{text-align:center}
}
.tag-pg{display:inline-block;padding:2px 8px;border-radius:50px;font-size:11px;font-weight:700}
.tag-pg.concluido{background:var(--green-m);color:#065a26}
.tag-pg.parcial{background:var(--warn-bg);color:var(--warn)}
.fin-previa{background:#eef3f9;border-radius:8px;padding:8px;margin:8px 0;max-height:46vh;overflow:auto;text-align:center}
.fin-previa img{max-width:100%;height:auto;border:1px solid #c8d7e9;background:#fff}
.lista-item{display:flex;justify-content:space-between;gap:8px;align-items:center;padding:7px 0;border-bottom:1px solid #e3ebf5}

/* ---------- visualizador e documentos ---------- */
.viewer{position:fixed;inset:0;background:#dfe6ef;z-index:60;overflow:auto}
.viewer[hidden]{display:none}
.viewer-bar{position:sticky;top:0;background:#fff;border-bottom:2px solid #c8d7e9;padding:10px 14px;display:flex;gap:10px;flex-wrap:wrap;align-items:center;justify-content:space-between;z-index:2}
.viewer-bar .seg{display:flex;gap:6px;flex-wrap:wrap}
.viewer-bar .seg button{background:#e5eef9;color:#205083}
.viewer-bar .seg button.active{background:var(--blue);color:#fff}
.viewer-bar .seg button.green{background:var(--green);color:#fff}
.viewer-bar .tiny{flex-basis:100%}
.viewer-docs{padding:18px 12px 40px}
.doc-sep{max-width:1050px;margin:0 auto 18px;text-align:center;font-weight:700;color:var(--navy)}
.doc{background:#fff;max-width:1050px;margin:0 auto 26px;padding:18px 22px;border:2px solid var(--red);border-radius:6px;color:#16365d;font-size:12.5px}
.doc-aprovado{border-color:var(--green)}
.doc-head{display:flex;justify-content:space-between;align-items:center;gap:12px;border-bottom:2px solid #e0e9f5;padding-bottom:8px}
.doc-logo{font:900 30px Georgia,serif;color:#111}
.doc-logo span{color:var(--red)}
.doc-sub{font-weight:700;font-size:11px;text-align:center}
.doc-clinica{font-size:11px;text-align:right;color:#425a77}
.doc-title{margin-top:10px;padding:9px 12px;border-radius:6px;font-weight:900;font-size:16px;color:#fff;background:var(--blue)}
.doc-title.verde{background:var(--green)}
.doc-status{margin:8px 0;padding:6px 10px;border-radius:6px;font-weight:700;font-size:12px}
.doc-status.azul{background:#e8f2ff;color:#0b4a86}
.doc-status.verde{background:var(--green-l);color:#065a26}
.doc-meta{display:grid;grid-template-columns:1fr 1fr;gap:4px 14px;margin:8px 0}
.doc-clinico{background:#eaf4ff;border-radius:6px;padding:8px 10px;margin:8px 0}
.doc-clinico p{margin:4px 0 0}
.doc-table{width:100%;border-collapse:collapse;margin:8px 0;table-layout:auto}
.doc-table th,.doc-table td{border:1px solid #bdcee0;padding:5px 6px;overflow-wrap:anywhere}
.doc-table th{background:#083e83;color:#fff;text-align:center}
.doc-table td.c-val,.doc-table th.c-val{text-align:right;white-space:nowrap}
.doc-table td.c-num{text-align:center}
.doc-table td.c-def{color:#965112;font-weight:700}
.doc-table th.c-aprov-h{background:var(--green-m);color:#065a26}
.doc-table td.c-aprov{background:var(--green-l)}
.doc-table tfoot td{background:#073f82;color:#fff;font-weight:700;text-align:right}
.doc-table tfoot td:first-child{text-align:left}
.doc-table tfoot td.c-aprov-t{background:var(--green)}
.doc-table tfoot small{font-weight:400;font-size:9px}
.doc[data-cols="5"] .doc-table,.doc[data-cols="6"] .doc-table{font-size:11px}
.doc[data-cols="7"] .doc-table,.doc[data-cols="8"] .doc-table,.doc[data-cols="9"] .doc-table,.doc[data-cols="10"] .doc-table{font-size:9.5px}
/* documento comparativo: apresentado (em cima) × efetivado (embaixo), na mesma página */
.doc-comparativo{border-color:var(--green);font-size:11.5px}
.doc-comparativo .doc-table{font-size:11px;margin:4px 0 8px}
.doc-comparativo .doc-table th,.doc-comparativo .doc-table td{padding:3px 5px}
.doc-comparativo .doc-meta{margin:6px 0}
.doc-comparativo .doc-pay,.doc-comparativo .doc-resp{padding:5px 8px;margin:6px 0;line-height:1.45}
.doc-comparativo .doc-foot{margin-top:6px;padding-top:5px}
.doc-comparativo .doc-sign{margin:12px 0 4px}
.doc-parte{margin-top:8px;padding:5px 8px;border-radius:5px;font-weight:800;font-size:11.5px;color:#fff}
.doc-parte.azul{background:var(--blue)}
.doc-parte.verde{background:var(--green)}
.doc-table th.c-escolhido{background:#0e5fb8;box-shadow:inset 0 0 0 2px #8ac5ff}
.doc-table td.c-escolhido{background:#eef6ff;font-weight:700}
.doc-table td.c-prop{color:#5a6f87}
.doc-table tr.c-retirado td{color:#9c4652;text-decoration:line-through}
.doc-table tr.c-retirado td .c-tag{text-decoration:none;display:inline-block}
.c-tag{font-size:9.5px;font-weight:800;border-radius:9px;padding:1px 6px;margin-left:4px;vertical-align:middle}
.c-tag.novo{background:#e1f3ff;color:#06477f}
.c-tag.mudou{background:var(--warn-bg);color:var(--warn)}
.c-tag.ret{background:var(--err-bg);color:var(--err)}
.doc-pay,.doc-resp{border:1px solid #d5e4f5;border-radius:6px;padding:8px 10px;margin:8px 0;line-height:1.6}
.doc-paystatus{margin-top:4px}
.doc-nota{font-size:10.5px;color:#556a83}
.doc-foot{border-top:2px solid #e0e9f5;margin-top:10px;padding-top:8px;line-height:1.6;font-size:11.5px}
.doc-sign{display:flex;justify-content:space-between;gap:20px;margin:22px 0 6px}
.doc-slogan{font-weight:700;margin-top:6px}
.print-hint{display:none}

@media (max-width:950px){
  .workspace{grid-template-columns:1fr}
  .paper{order:-1}
  .banner-right{min-width:0;flex-basis:100%}
  .doc-meta{grid-template-columns:1fr}
}
@media print{
  body{background:#fff;padding:0}
  .app,.modal,.viewer-bar{display:none!important}
  .viewer{position:static;display:block;background:#fff;overflow:visible}
  .viewer[hidden]{display:none!important}
  .viewer[hidden]~.print-hint{display:block;padding:30px;font-size:18px}
  .viewer-docs{padding:0}
  .doc-sep{display:none}
  .doc{max-width:none;margin:0;border-radius:0;padding:6mm 7mm;break-after:page;page-break-after:always}
  .doc:last-child{break-after:auto;page-break-after:auto}
  .doc-table thead{display:table-header-group}
  .doc-table tr{break-inside:avoid;page-break-inside:avoid}
  .doc-pay,.doc-resp,.doc-foot,.doc-clinico{break-inside:avoid}
  *{-webkit-print-color-adjust:exact;print-color-adjust:exact}
}

/* formas de pagamento desmembradas (fechamento) */
.fc-tit { margin: 14px 0 4px; font-size: 14px; }
table.fc-formas td select, table.fc-formas td input { width: 100%; }
table.fc-formas tr.fp-rec td:first-child { border-left: 4px solid #1f8a4c; }
table.fc-formas tr.fp-arec td:first-child { border-left: 4px solid #d08a00; }
table.fc-formas td.fp-parc { white-space: nowrap; font-size: 12px; color: #334; }
.doc .pg-forma { margin: 2px 0; }
.doc .pg-forma.arec { color: #8a5a00; }
.doc .pg-conf { margin-top: 4px; }
.doc .pg-erro { color: #b00020; }
#fcFormas { overflow-x: auto; }
table.fc-formas { min-width: 760px; }
table.fc-formas td:nth-child(1) { min-width: 120px; }
table.fc-formas td:nth-child(2) { min-width: 110px; }
table.fc-formas td:nth-child(3) { min-width: 200px; }
table.fc-formas td:nth-child(4) { width: 64px; }
table.fc-formas td:nth-child(6) { min-width: 140px; }

/* 🔄 atualização do orçamento por texto */
.atu-box { margin: 14px 0 6px; padding: 10px 12px; border: 1px dashed #8fb3e0; border-radius: 10px; background: #f4f8fe; }
.atu-tit { font-weight: 700; margin-bottom: 6px; color: #0b3d7a; }
.atu-box textarea { width: 100%; min-height: 52px; }
.atu-box .row { margin-top: 6px; align-items: center; gap: 8px; }
@media print { .atu-box { display: none !important; } }

/* plano autorizado pelo tutor (fechamento) */
.fc-planos { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.fc-plano { display: inline-flex; flex-direction: column; align-items: center; padding: 6px 14px; border: 2px solid #9db8dc; border-radius: 10px; background: #fff; color: #0b3d7a; font-weight: 700; cursor: pointer; }
.fc-plano span { font-weight: 600; font-size: 13px; }
.fc-plano:hover { background: #eef4fc; }
.fc-plano.ativo { border-color: #0a7d3b; background: #e3f6ea; color: #0a5c2c; }
table.fc td.fc-acao { white-space: nowrap; }
table.fc td.fc-acao .qb + .qb { margin-left: 4px; }

/* quadro de pagamento: verde recebido · amarelo pendente · vermelho não pago */
.pgq { margin: 12px 0; border: 2px solid #c9d7ea; border-radius: 12px; padding: 10px 12px; background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pgq-topo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; color: #0b3d7a; margin-bottom: 8px; }
.pgq-selo { padding: 3px 10px; border-radius: 999px; font-weight: 800; font-size: 12px; letter-spacing: .3px; }
.pgq-selo.verde, .pgq-tag.verde { background: #1f8a4c; color: #fff; }
.pgq-selo.amarelo, .pgq-tag.amarelo { background: #f2b705; color: #3d2e00; }
.pgq-selo.vermelho, .pgq-tag.vermelho { background: #c62828; color: #fff; }
.pgq-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.pgq-card { border-radius: 10px; padding: 7px 10px; border: 1.5px solid; display: flex; flex-direction: column; }
.pgq-card span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.pgq-card b { font-size: 18px; }
.pgq-card.azul { background: #eaf2fc; border-color: #9db8dc; color: #0b3d7a; }
.pgq-card.verde { background: #e3f6ea; border-color: #1f8a4c; color: #0e5c30; }
.pgq-card.amarelo { background: #fff6d6; border-color: #e0a800; color: #6b4e00; }
.pgq-card.vermelho { background: #fde8e8; border-color: #c62828; color: #8e1b1b; }
.pgq-card.cinza { background: #f3f5f8; border-color: #c9d1dc; color: #5a6575; }
table.pgq-tab { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.pgq-tab th { background: #0b3d7a; color: #fff; text-align: left; padding: 5px 8px; font-size: 11.5px; }
table.pgq-tab td { padding: 6px 8px; border-bottom: 1px solid #e3e8ef; }
table.pgq-tab .v { text-align: right; }
table.pgq-tab tr.verde td { background: #edf9f1; }
table.pgq-tab tr.amarelo td { background: #fffaea; }
table.pgq-tab tr.vermelho td { background: #fdeeee; }
table.pgq-tab tr.verde td:first-child { border-left: 5px solid #1f8a4c; }
table.pgq-tab tr.amarelo td:first-child { border-left: 5px solid #f2b705; }
table.pgq-tab tr.vermelho td:first-child { border-left: 5px solid #c62828; }
.pgq-tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-weight: 800; font-size: 11px; white-space: nowrap; }
.pgq-conf { margin-top: 8px; font-size: 12.5px; padding: 5px 8px; border-radius: 8px; }
.pgq-conf.ok { background: #edf9f1; color: #0e5c30; }
.pgq-conf.erro { background: #fdeeee; color: #8e1b1b; font-weight: 700; }
.pgq-obs { margin-top: 6px; font-size: 12.5px; color: #333; }
.pgq-vazio { padding: 8px; color: #8e1b1b; background: #fdeeee; border-radius: 8px; font-size: 12.5px; }
@media (max-width: 560px) { .pgq-cards { grid-template-columns: 1fr; } }

/* título inadimplente: vermelho */
table.fc-formas tr.fp-inad td:first-child { border-left: 4px solid #c62828; }
table.fc-formas tr.fp-inad td { background: #fdeeee; }
table.fc-formas tr.fp-inad select { color: #8e1b1b; font-weight: 700; }
.pgq.inad { border-color: #c62828; }
.pgq-inad { background: #c62828; color: #fff; font-weight: 800; padding: 6px 10px; border-radius: 8px; margin-bottom: 8px; letter-spacing: .3px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pgq-cards.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 560px) { .pgq-cards.c4 { grid-template-columns: 1fr; } }
.tag-pg.inadimplente { background: #c62828; color: #fff; }
table.pagos tr.inad td { background: #fdeeee; }
table.pagos tr.inad td:first-child { border-left: 5px solid #c62828; }
.inad-val { color: #8e1b1b; font-weight: 700; }

table.fc-formas td:nth-child(1) { min-width: 155px; }


@media print { .pgq { break-inside: avoid; page-break-inside: avoid; } }


/* botão WhatsApp: copiar imagem inteira */
button.whats { background: #25d366; color: #073b1c; border: 0; font-weight: 800; }
button.whats:hover { background: #1fbe5b; }
button.whats:disabled { opacity: .6; }
#finPrevia img { max-height: 60vh; width: auto; max-width: 100%; display: block; margin: 0 auto; border: 1px solid #c9d7ea; }

/* botões de copiar imagem: discretos */
button.copia { background: transparent; color: #0b3d7a; border: 1px solid #b9cbe3; font-weight: 600; font-size: 12.5px; padding: 5px 10px; border-radius: 8px; box-shadow: none; }
button.copia:hover { background: #eef4fc; border-color: #8fb0d9; }
button.copia:disabled { opacity: .6; }

@media print { button.copia, #btnCopiarProposta, #vCopiarProp, #vCopiarImg { display: none !important; } }


#dlgMsg { white-space: pre-line; }
#dlgExtra { margin-right: 6px; }


/* banco de orçamentos (busca por nº de atendimento e período) */
.banco-datas { align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.banco-datas input[type=date] { width: auto; padding: 4px 6px; }
.banco-info { margin: 8px 0 4px; color: #0b3d7a; }
.tag-pg.aberto { background: #e7edf6; color: #34506f; }
table.pagos tr.em-aberto td { background: #fafbfd; }
table.pagos tr.achado td { background: #fff8d9; }
table.pagos tr.achado td:first-child { border-left: 5px solid #f2b705; }
.ref-orc { color: #5a6b80; }

/* 💊 receita */
.receita-box { margin: 10px 0 6px; padding: 10px 12px; border: 1px dashed #c9a8e0; border-radius: 10px; background: #fbf7fe; }
.receita-box textarea { width: 100%; min-height: 70px; }
.receita-box .row { margin-top: 6px; align-items: center; gap: 8px; flex-wrap: wrap; }
.rx-modal { max-width: 900px; }
#rxDoc { max-height: 65vh; overflow: auto; border: 1px solid #dde3ec; border-radius: 8px; background: #f3f5f8; padding: 10px; }
.doc-receita { background: #fff; color: #222; font-family: Arial, Helvetica, sans-serif; padding: 26px 34px; max-width: 760px; margin: 0 auto; outline: none; }
.doc-receita .rx-cab { display: flex; align-items: center; gap: 18px; border-bottom: 2px solid #444; padding-bottom: 10px; }
.doc-receita .rx-cab img { height: 70px; }
.doc-receita .rx-clinica { font-size: 12px; color: #444; line-height: 1.5; }
.doc-receita .rx-clinica b { font-size: 15px; color: #222; }
.doc-receita .rx-tit { text-align: center; font-size: 26px; font-weight: 800; letter-spacing: 1px; margin: 22px 0 14px; }
.doc-receita .rx-campos { font-size: 15px; line-height: 2; margin-left: 30px; }
.doc-receita .rx-texto { min-height: 260px; margin: 16px 30px; font-size: 15px; line-height: 1.6; }
.doc-receita .rx-texto p { margin: 0 0 8px; }
.doc-receita .rx-vazio { color: #999; font-style: italic; }
.doc-receita .rx-ass { text-align: center; margin: 20px 0 18px; font-size: 14px; line-height: 1.6; }
.doc-receita .rx-linha { width: 280px; border-top: 1px solid #333; margin: 0 auto 4px; }
.doc-receita .rx-ident { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid #555; font-size: 12.5px; color: #333; }
.doc-receita .rx-ident > div { padding: 8px 10px; line-height: 2; }
.doc-receita .rx-ident > div + div { border-left: 1px solid #555; }
.doc-receita .rx-forn { height: 52px; border-bottom: 1px solid #555; margin-bottom: 4px; }
.doc-receita .rx-rod { text-align: center; font-size: 11.5px; color: #444; border-top: 2px solid #444; margin-top: 18px; padding-top: 6px; }
@media print { .receita-box { display: none !important; } }
.doc.doc-receita { border: none !important; box-shadow: none !important; border-radius: 0 !important; }


/* 📋 termos de autorização (destaque âmbar) */
.termos-box { margin: 10px 0 6px; padding: 10px 12px; border: 1px dashed #e0a800; border-radius: 10px; background: #fffaeb; }
.termos-box .atu-tit { color: #7a4b00; }
.termo-msg { margin-top: 8px; padding: 6px 8px; background: #eef7f0; border: 1px solid #bfe3c8; border-radius: 6px; }
.erro-termo { color: #b42318; font-weight: 700; background: #fde2e2; border: 1px solid #f3a3a3; border-radius: 6px; padding: 4px 8px; }
.pend-tag { display: inline-block; background: #fde2e2; color: #b42318; border: 1px solid #f3a3a3; border-radius: 6px; padding: 0 6px; font-size: 11px; font-weight: 800; letter-spacing: .3px; }
.termo-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; margin: 6px 0; background: #fff; border: 1px solid #f1d58a; border-left: 5px solid #e0a800; border-radius: 8px; }
.termo-item .row { margin: 0; }
.termo-modal { max-width: 860px; }
.termo-campos { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 12px; max-height: 58vh; overflow: auto; padding: 4px 2px; }
.termo-campos .tc label { font-size: 12px; font-weight: 700; display: block; margin-bottom: 2px; }
.termo-campos .tc input, .termo-campos .tc textarea { width: 100%; }
.termo-campos .tc.pend input, .termo-campos .tc.pend textarea { border-color: #f3a3a3; background: #fff5f5; }
.termo-campos .tc.sens .tc-mao { font-size: 12px; color: #6b4e00; background: #fff6d6; border: 1px dashed #e0a800; border-radius: 6px; padding: 6px 8px; }
.termo-campos .tc-auto { color: #1f8a4c; font-weight: 800; }
.doc.doc-termo { border: none !important; box-shadow: none !important; background: #fff; color: #111; font-family: Arial, Helvetica, sans-serif; padding: 26px 40px; font-size: 13.5px; line-height: 1.7; text-align: justify; }
.doc-termo .tt-tit { text-align: center; font-size: 16px; font-weight: 800; margin: 18px 0; }
.doc-termo u { text-decoration: underline; font-weight: 700; }
.doc-termo .tt-ass { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 40px; }
.doc-termo .tt-ass > span:last-child { text-align: center; }
.doc-termo .rx-cab { display: flex; align-items: center; gap: 18px; border-bottom: 2px solid #444; padding-bottom: 10px; }
.doc-termo .rx-cab img { height: 60px; }
.doc-termo .rx-linha { display: block; width: 260px; border-top: 1px solid #333; margin: 0 auto 4px; }
@media print { .termos-box { display: none !important; } }
/* escolher termo (um botão; lista só ao clicar) */
.termo-escolher { display: inline-flex; align-items: center; gap: 8px; background: #fff; color: #7a4b00; border: 1.5px solid #e0a800; border-radius: 10px; padding: 8px 14px; font-weight: 800; cursor: pointer; }
.termo-escolher:hover { background: #fff3cc; }
.termo-menu { margin-top: 6px; border: 1px solid #f1d58a; border-radius: 10px; background: #fff; overflow: hidden; max-width: 640px; }
.termo-op { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; background: #fff; border: 0; border-bottom: 1px solid #f6e7b8; padding: 9px 12px; cursor: pointer; color: #222; font-weight: 400; }
.termo-op:last-child { border-bottom: 0; }
.termo-op:hover { background: #fff8e1; }
.termo-op b { color: #5c3b00; }
