:root{--ink:#16343a;--muted:#60757a;--teal:#0d5964;--teal2:#177985;--aqua:#e5f3f3;--lime:#d9eb47;--paper:#f4f7f5;--line:#d9e3e1;--warn:#f4a62a;--danger:#b94646;--blue:#dfeefa;--shadow:0 10px 34px rgba(15,61,67,.1);font-family:Inter,"Segoe UI",Arial,sans-serif;color:var(--ink);background:var(--paper)}*{box-sizing:border-box}body{margin:0;min-width:320px}button,input,select,textarea{font:inherit}button{cursor:pointer}.topbar{position:sticky;top:0;z-index:20;display:flex;justify-content:space-between;align-items:center;gap:20px;padding:14px clamp(18px,3vw,48px);background:#fff;border-bottom:1px solid var(--line)}.brand{display:flex;align-items:center;gap:14px}.brand img{width:112px;height:44px;object-fit:contain}.brand span,.eyebrow{display:block;margin:0 0 3px;color:var(--teal2);font-size:.73rem;font-weight:800;letter-spacing:.11em;text-transform:uppercase}.brand strong{font-size:1.06rem}.top-actions{display:flex;align-items:center;gap:10px}.save-state{color:var(--muted);font-size:.86rem}.button{border:1px solid transparent;border-radius:10px;padding:9px 14px;font-weight:750;background:#fff;color:var(--ink)}.button.primary{background:var(--teal);color:#fff}.button.secondary{border-color:var(--teal);color:var(--teal)}.button.ghost{border-color:var(--line)}.button.danger{color:var(--danger);border-color:#edc5c5}.button:disabled{opacity:.5;cursor:not-allowed}.tabs{display:flex;gap:4px;padding:8px clamp(18px,3vw,48px);overflow-x:auto;background:#fff;border-bottom:1px solid var(--line)}.tab{white-space:nowrap;border:0;border-radius:9px;padding:10px 13px;background:transparent;color:var(--muted);font-weight:700}.tab:hover{background:var(--aqua)}.tab.active{background:var(--teal);color:#fff}main{max-width:1680px;margin:auto;padding:26px clamp(16px,3vw,46px) 50px}.view{display:none}.view.active{display:block}.page-heading{display:flex;align-items:end;justify-content:space-between;gap:20px;margin:5px 0 20px}.page-heading h1{font-size:clamp(1.7rem,3vw,2.5rem);margin:0 0 4px}.page-heading p:not(.eyebrow){margin:0;color:var(--muted)}.page-heading>div:last-child{display:flex;gap:8px}.company-grid{display:grid;grid-template-columns:repeat(3,minmax(180px,1fr));gap:12px;margin-bottom:14px}.company-grid label,.dialog-content label,.table-tools label,.sector-filter,.login-card label{display:flex;flex-direction:column;gap:5px;color:var(--muted);font-size:.78rem;font-weight:700}.company-grid input,.dialog-content input,.dialog-content select,.dialog-content textarea,.table-tools input,.table-tools select,.sector-filter select,.login-card input,.login-card select{min-height:40px;border:1px solid var(--line);border-radius:9px;padding:8px 10px;background:#fff;color:var(--ink)}.company-grid input:focus,.dialog-content :is(input,select,textarea):focus,.table-tools :is(input,select):focus{outline:2px solid rgba(23,121,133,.25);border-color:var(--teal2)}.legend{display:flex;gap:18px;flex-wrap:wrap;margin:12px 0;color:var(--muted);font-size:.84rem}.dot{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:5px}.dot.input{background:#fff0a8}.dot.auto{background:#cde8f8}.dot.alert{background:#f5b5b5}.table-card,.panel{background:#fff;border:1px solid var(--line);border-radius:16px;box-shadow:var(--shadow)}.table-tools{display:flex;align-items:end;gap:12px;padding:14px;border-bottom:1px solid var(--line)}.table-tools label:first-child{min-width:min(420px,60vw)}.table-tools span{margin-left:auto;color:var(--muted);font-size:.86rem}.table-scroll{overflow:auto;max-height:62vh}.data-table{width:100%;border-collapse:separate;border-spacing:0;font-size:.84rem}.data-table th{position:sticky;top:0;z-index:2;background:#eef5f3;color:#31545a;text-align:left;white-space:nowrap;padding:10px;border-bottom:1px solid var(--line)}.data-table td{max-width:320px;padding:9px 10px;border-bottom:1px solid #edf1f0;vertical-align:top}.data-table tr:hover td{background:#fafcfa}.cell-wrap{white-space:normal;line-height:1.35}.status{display:inline-flex;border-radius:99px;padding:4px 8px;font-size:.75rem;font-weight:800}.status.ok{background:#e1f3e7;color:#247440}.status.warn{background:#fff1d6;color:#91600a}.status.danger{background:#f9dede;color:#9c3030}.action-row{display:flex;gap:6px}.mini-button{border:1px solid var(--line);background:#fff;border-radius:7px;padding:5px 8px;color:var(--teal);font-weight:700}.info-banner{margin-bottom:14px;padding:12px 15px;border-left:4px solid var(--teal2);border-radius:10px;background:var(--aqua);color:#31565a}.report-scroll{max-height:70vh}.report-table{min-width:2300px}.metric-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:16px}.metric{padding:17px;background:#fff;border:1px solid var(--line);border-radius:14px}.metric span{display:block;color:var(--muted);font-size:.78rem;font-weight:750;text-transform:uppercase}.metric strong{display:block;margin-top:8px;font-size:1.8rem}.metric small{color:var(--muted)}.dashboard-grid{display:grid;grid-template-columns:1.3fr .7fr;gap:16px}.panel{padding:18px;overflow:hidden}.panel.wide{grid-column:1/-1}.panel-title{display:flex;align-items:start;justify-content:space-between;gap:20px;margin-bottom:16px}.panel-title h2{font-size:1.04rem;margin:0 0 3px}.panel-title p{margin:0;color:var(--muted);font-size:.82rem}.chart-legend{display:flex;align-items:center;gap:6px;white-space:nowrap;color:var(--muted);font-size:.78rem}.chart-legend i{width:16px;height:8px;background:var(--teal2);border-radius:4px}.chart-legend b{width:2px;height:12px;background:var(--danger);margin-left:6px}.bar-chart{display:grid;gap:12px}.bar-row{display:grid;grid-template-columns:minmax(180px,300px) 1fr 64px;align-items:center;gap:12px}.bar-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.82rem;font-weight:650}.bar-track{position:relative;height:22px;border-radius:7px;background:repeating-linear-gradient(90deg,#edf3f2 0,#edf3f2 calc(25% - 1px),#dbe5e3 25%);overflow:visible}.bar-track::after{content:"";position:absolute;left:min(var(--limit-pos),100%);top:-4px;bottom:-4px;width:2px;background:var(--danger)}.bar-fill{height:100%;min-width:2px;max-width:100%;border-radius:7px;background:linear-gradient(90deg,var(--teal2),#22a4ad)}.bar-fill.over{background:linear-gradient(90deg,#ef9f28,#c54945)}.bar-value{text-align:right;font-weight:850}.risk-chart{display:grid;gap:10px}.risk-item{display:grid;grid-template-columns:110px 1fr 32px;align-items:center;gap:8px}.risk-track{height:12px;border-radius:8px;background:#edf1ef;overflow:hidden}.risk-fill{height:100%;border-radius:8px}.sector-list{display:grid;gap:10px}.sector-item{display:grid;grid-template-columns:1fr auto;gap:4px;padding:10px 0;border-bottom:1px solid #edf1ef}.sector-item strong{font-size:.88rem}.sector-item span{font-size:.78rem;color:var(--muted)}.sector-item b{grid-row:1/3;grid-column:2;align-self:center;font-size:1.1rem}.conclusion-list{display:grid;gap:10px}.conclusion-item{display:grid;grid-template-columns:110px 1fr;gap:12px;padding:12px;border-radius:10px;background:#f7faf9}.conclusion-item strong{font-size:.82rem}.conclusion-item p{margin:0;line-height:1.45;font-size:.84rem}.empty{padding:28px;text-align:center;color:var(--muted)}.forms-container{display:grid;gap:24px}.field-form-page{width:min(210mm,100%);min-height:285mm;margin:auto;padding:12mm;background:#fff;border:1px solid var(--line);box-shadow:var(--shadow);page-break-after:always}.form-header{display:flex;align-items:center;justify-content:space-between;border-bottom:3px solid var(--teal);padding-bottom:9px}.form-header img{width:120px}.form-header h2{margin:0;text-align:right;font-size:1.15rem}.form-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:0;border:1px solid #9db4b5;margin-top:10px}.form-cell{min-height:44px;padding:6px 8px;border-right:1px solid #b7c6c6;border-bottom:1px solid #b7c6c6}.form-cell.wide{grid-column:1/-1}.form-cell label{display:block;font-size:.67rem;text-transform:uppercase;color:#5d7477;font-weight:750}.form-cell span{display:block;margin-top:4px;font-size:.88rem;white-space:pre-wrap}.signature-grid{display:grid;grid-template-columns:1fr 1fr;gap:25px;margin-top:35px}.signature{padding-top:24px;border-top:1px solid #566;text-align:center;font-size:.75rem}dialog{width:min(940px,calc(100vw - 28px));max-height:92vh;border:0;border-radius:18px;padding:0;box-shadow:0 24px 70px rgba(0,0,0,.25)}dialog::backdrop{background:rgba(6,36,40,.58)}.dialog-panel{display:flex;flex-direction:column;max-height:92vh}.dialog-panel header,.dialog-panel footer{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:17px 20px;background:#fff}.dialog-panel header{border-bottom:1px solid var(--line)}.dialog-panel footer{border-top:1px solid var(--line)}.dialog-panel footer span{flex:1}.dialog-panel h2{margin:0}.dialog-content{overflow:auto;padding:18px 20px;background:#f8faf9}.field-section{margin-bottom:22px}.field-section h3{margin:0 0 10px;font-size:.92rem;color:var(--teal)}.field-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}.field-grid label.wide{grid-column:span 2}.field-grid textarea{min-height:84px;resize:vertical}.calculated-card{padding:12px;border-radius:10px;background:var(--blue);font-size:.82rem;line-height:1.55}.icon-close{border:0;background:transparent;font-size:1.8rem;color:var(--muted)}.login-card{display:flex;flex-direction:column;gap:12px;padding:26px}.login-card img{width:150px;align-self:center}.login-card h2,.login-card p{margin:0}.link-button{border:0;background:transparent;color:var(--teal2);text-decoration:underline}.message{min-height:18px;color:var(--danger);font-size:.82rem}.toast{position:fixed;right:20px;bottom:20px;z-index:50;max-width:390px;padding:12px 16px;border-radius:10px;background:#173b40;color:#fff;box-shadow:var(--shadow);opacity:0;transform:translateY(12px);pointer-events:none;transition:.2s}.toast.show{opacity:1;transform:translateY(0)}.site-footer{display:flex;justify-content:space-between;padding:18px clamp(16px,3vw,46px);background:#173b40;color:#dbe8e7;font-size:.78rem}
@media(max-width:900px){.topbar{align-items:flex-start}.top-actions{flex-wrap:wrap;justify-content:flex-end}.save-state{width:100%;text-align:right}.brand div{display:none}.company-grid,.metric-grid{grid-template-columns:repeat(2,1fr)}.dashboard-grid{grid-template-columns:1fr}.panel.wide{grid-column:auto}.bar-row{grid-template-columns:minmax(110px,180px) 1fr 54px}.field-grid{grid-template-columns:repeat(2,1fr)}}
@media(max-width:600px){.topbar{position:static;flex-direction:column;align-items:stretch}.top-actions{justify-content:stretch}.top-actions .button{flex:1}.save-state{text-align:left}.page-heading{align-items:stretch;flex-direction:column}.company-grid,.metric-grid{grid-template-columns:1fr 1fr}.table-tools{align-items:stretch;flex-direction:column}.table-tools label:first-child{min-width:0}.table-tools span{margin-left:0}.bar-row{grid-template-columns:1fr 48px}.bar-label{grid-column:1/-1}.field-grid{grid-template-columns:1fr}.field-grid label.wide{grid-column:auto}.conclusion-item{grid-template-columns:1fr}.site-footer{flex-direction:column;gap:5px}}
@media print{body{background:#fff}.topbar,.tabs,.page-heading,.site-footer,.toast,.lookup-status{display:none!important}main{padding:0}.view{display:none!important}#formView{display:block!important}.forms-container{gap:0}.field-form-page{width:210mm;min-height:297mm;box-shadow:none;border:0;margin:0;padding:10mm;break-after:page}@page{size:A4 portrait;margin:0}}

/* Planilha web editável */
.sheet-help{padding:9px 14px;background:#fff8cf;border-bottom:1px solid #eadb8b;color:#685b17;font-size:.82rem;font-weight:650}
.sheet-scroll{max-height:68vh;min-height:340px;overscroll-behavior:contain}
.sheet-table{width:max-content;min-width:100%;table-layout:auto}
.sheet-table th{max-width:260px;white-space:normal;line-height:1.25;vertical-align:bottom}
.sheet-table td{height:42px;min-width:125px;max-width:280px;padding:0}
.sheet-table td:first-child{min-width:64px}
.sheet-table .input-cell,.parameter-sheet .input-cell{background:#fff8ca}
.sheet-table .automatic-cell{background:#e5f2fb;color:#244d59;font-weight:650;padding:8px 10px;white-space:normal}
.sheet-table .formula-alert{background:#fbdede;color:#8f2f2f}
.sheet-table input,.sheet-table select,.parameter-sheet input{width:100%;min-width:124px;min-height:41px;border:0;border-radius:0;padding:7px 9px;background:transparent;color:var(--ink)}
.sheet-table input:focus,.sheet-table select:focus,.parameter-sheet input:focus{position:relative;z-index:6;outline:3px solid #1f8c98;outline-offset:-3px;background:#fff}
.sheet-table [data-grid-field="substance"]{min-width:310px}.sheet-table [data-grid-field="method"]{min-width:220px}.sheet-table [data-grid-field="activity"],.sheet-table [data-grid-field="fieldNotes"]{min-width:230px}
.sheet-table .sticky-sheet{position:sticky;z-index:3;box-shadow:2px 0 0 #c5d3d2}.sheet-table th.sticky-sheet{z-index:8}.sheet-table tr>*:first-child.sticky-sheet{left:0}.sheet-table tr>*:nth-child(2).sticky-sheet{left:64px}
.sheet-table .action-cell{padding:6px 8px;background:#fff;min-width:145px}.danger-text{color:var(--danger)!important}
.parameter-sheet{width:max-content;min-width:100%}.parameter-sheet td{padding:0;min-width:190px}.parameter-sheet th{white-space:normal;min-width:190px}.parameter-sheet td:first-child,.parameter-sheet th:first-child{min-width:60px;padding:8px}.parameter-sheet input{min-width:188px}
@media(max-width:600px){.sheet-scroll{max-height:62vh}.sheet-table .sticky-sheet{position:static}.sheet-table [data-grid-field="substance"]{min-width:260px}}
.document-actions{display:flex;align-items:end;justify-content:flex-end;gap:8px;flex-wrap:wrap}.lookup-status{display:none;margin:-4px 0 14px;padding:11px 14px;border-radius:10px;background:#e8f4f4;color:#31565a;font-size:.84rem}.lookup-status.show{display:block}.lookup-status.error{background:#fbe2e2;color:#8f3030}.lookup-status a{color:inherit;font-weight:750}.cnpj-field{position:relative}.cnpj-row{display:flex;gap:6px}.cnpj-row input{min-width:0;flex:1}.cnpj-row button{white-space:nowrap}.login-card textarea{width:100%;border:1px solid var(--line);border-radius:9px;padding:8px 10px;resize:vertical}.field-error{outline:2px solid #bd3c3c!important;background:#ffe8e8!important}.validation-note{display:block;margin-top:3px;color:#a33;font-size:.72rem;font-weight:650}
#reportView,#dashboardView,#summaryView{width:min(1040px,100%);margin-inline:auto}#reportView .report-table,#summaryView .report-table{min-width:1800px}#dashboardView .dashboard-grid{grid-template-columns:1fr}#dashboardView .panel.wide{grid-column:auto}#dashboardView .bar-row{grid-template-columns:minmax(190px,280px) 1fr 64px}
@media(max-width:600px){.document-actions{justify-content:stretch}.document-actions>.button,.document-actions>.sector-filter{flex:1}.cnpj-row{flex-direction:column}}

/* Visualizacao em pagina A4 retrato: somente apresentacao, sem alterar calculos. */
:root{--a4-width:210mm;--a4-height:297mm;--a4-padding:12mm}
#formView,#reportView,#dashboardView,#summaryView{width:min(var(--a4-width),100%);margin-inline:auto}
#reportView.active,#dashboardView.active,#summaryView.active{min-height:var(--a4-height);padding:var(--a4-padding);background:#fff;border:1px solid var(--line);border-radius:2px;box-shadow:var(--shadow)}
#formView .field-form-page{width:100%;min-height:var(--a4-height);padding:var(--a4-padding)}
#reportView .page-heading,#dashboardView .page-heading,#summaryView .page-heading{align-items:flex-start;flex-wrap:wrap}
#reportView .page-heading>div:first-child,#dashboardView .page-heading>div:first-child,#summaryView .page-heading>div:first-child{flex:1 1 330px}
#reportView .document-actions,#dashboardView .document-actions,#summaryView .document-actions{flex:1 1 260px}
#reportView .table-card,#summaryView .table-card{max-width:100%}
#reportView .report-scroll,#summaryView .report-scroll{max-height:none}
#dashboardView .metric-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
#dashboardView .dashboard-grid{grid-template-columns:1fr}
#dashboardView .panel.wide{grid-column:auto}

@media(max-width:850px){
  #reportView.active,#dashboardView.active,#summaryView.active{min-height:0;padding:clamp(16px,4vw,32px);border-inline:0;box-shadow:none}
  #formView .field-form-page{min-height:0;padding:clamp(16px,4vw,32px)}
}

@media(max-width:600px){
  #dashboardView .metric-grid{grid-template-columns:1fr 1fr}
  #reportView .document-actions,#dashboardView .document-actions,#summaryView .document-actions{flex-basis:100%;justify-content:stretch}
}

@media print{
  @page{size:210mm 297mm;margin:0}
  #formView{width:210mm;margin:0}
  #formView .field-form-page{width:210mm;min-height:297mm;padding:10mm;margin:0;border:0;border-radius:0;box-shadow:none;break-after:page;page-break-after:always}
  #formView .field-form-page:last-child{break-after:auto;page-break-after:auto}
}
