:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #172c24;
  background: #f5f5ef;
  --green: #143f31;
  --green-dark: #0b2d23;
  --paper: #fffefa;
  --muted: #56645b;
  --line: #dce1d7;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button, input, select, a, summary { outline-offset: 3px; }
:focus-visible { outline: 2px solid #9b6413; }

.header { background: var(--green-dark); color: white; }
.header-inner { max-width: 1280px; margin: auto; padding: 1rem 1.75rem; display: flex; align-items: center; gap: 1rem; min-height: 4.5rem; }
.brand { color: white; font-size: 1.27rem; font-weight: 650; text-decoration: none; }
.brand span { color: #edce8a; font-weight: 500; }
.environment { margin-left: auto; color: #e1e8df; font-size: .84rem; }
main { max-width: 1280px; margin: auto; padding: 1.3rem 1.75rem 3rem; }

.nav { display: flex; gap: .5rem; border-bottom: 1px solid var(--line); margin-bottom: 2rem; flex-wrap: wrap; }
.nav button { background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); border-radius: 0; padding: .9rem .85rem .8rem; }
.nav button[aria-current] { border-color: #b38a44; color: var(--green-dark); }
.heading { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.3rem; }
h1 { margin: 0; font-size: clamp(1.85rem, 4vw, 2.55rem); letter-spacing: -.035em; line-height: 1.13; }
h2 { margin: 0 0 1rem; font-size: 1.2rem; }
p { color: var(--muted); line-height: 1.5; margin: .55rem 0 0; }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.3rem; }
.summary div { display: grid; gap: .28rem; background: var(--paper); border: 1px solid var(--line); border-top: 3px solid #a77d37; border-radius: .65rem; padding: .95rem 1.1rem; }
.summary span { color: var(--muted); font-size: .9rem; }
.summary strong { color: var(--green); font-size: clamp(1.3rem, 3vw, 1.9rem); font-variant-numeric: tabular-nums; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: .75rem; padding: 1.15rem; }
.panel + .panel { margin-top: 1rem; }
.table-panel { padding: 0; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 760px; text-align: left; }
thead { color: var(--green-dark); background: #e9eee5; }
th, td { padding: .85rem .9rem; border-bottom: 1px solid var(--line); }
th { font-size: .85rem; font-weight: 650; }
td { font-size: .93rem; }
tr:last-child td { border-bottom: 0; }
td small { display: block; color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 1.25rem; color: var(--muted); }

.columns { display: grid; grid-template-columns: minmax(15rem, .8fr) minmax(20rem, 1.2fr); gap: 1rem; align-items: start; }
.columns > .panel + .panel { margin: 0; }
.login { max-width: 440px; margin: 9vh auto auto; padding: 1.6rem; }
.login h1 { margin: 0 0 1.25rem; font-size: 1.9rem; }
form { display: grid; gap: .85rem; }
.inline { display: flex; align-items: end; flex-wrap: wrap; gap: .6rem; }
.inline label { flex: 1 1 9rem; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.address-fields { display: grid; min-width: 0; gap: .75rem; border: 1px solid var(--line); border-radius: .4rem; padding: .8rem; margin: 0; }
.address-fields legend { padding: 0 .25rem; font-size: .88rem; font-weight: 650; }
label { display: grid; gap: .3rem; font-size: .88rem; font-weight: 650; min-width: 0; }
input, select { color: inherit; min-width: 0; width: 100%; padding: .57rem .67rem; background: #fff; border: 1px solid #aab8ad; border-radius: .4rem; font-weight: 400; }
button { min-height: 2.4rem; justify-self: start; border: 1px solid transparent; background: var(--green); color: white; border-radius: .4rem; padding: .5rem .85rem; font-weight: 650; cursor: pointer; }
button:hover { background: var(--green-dark); }
button:disabled { opacity: .55; cursor: wait; }
.secondary { background: transparent; color: var(--green); border-color: #aab8ad; }
.secondary:hover { background: #e9eee5; }
.header .secondary { color: white; border-color: #6c9080; }
.header .secondary:hover { background: var(--green); }
.message, .note { border-left: 3px solid #a77d37; color: #4e3b1e; background: #fbf2dd; padding: .65rem .8rem; }
.message { margin: 0 0 1rem; }
.message[data-error] { color: #6c271d; background: #ffebe3; border-color: #ae3e2b; }
.hint { color: var(--muted); font-size: .84rem; margin: 0; }
.results { display: grid; gap: .4rem; margin-top: .8rem; max-height: 16rem; overflow-y: auto; }
.results button { width: 100%; text-align: left; }
#contract-summary { margin: -.35rem 0 1rem; }
#contract-history, #closing-panel { margin-top: .95rem; }
.history-table table { min-width: 390px; }
.check-label { display: flex; gap: .5rem; align-items: center; }
.check-label input { width: 1rem; height: 1rem; accent-color: var(--green); }
.billing-filter-panel { margin-bottom: 1rem; }
.billing-filter { margin-bottom: .8rem; }
.billing-filter label:first-child { flex-grow: 2; }
.billing-actions { display: grid; gap: .65rem; margin-bottom: .9rem; }
.billing-selection { align-items: center; }
.billing-exports { align-items: end; column-gap: 1.25rem; }
.billing-export-group { flex: 0 0 auto; max-width: 100%; }
.billing-boleto-exports label { flex: 0 1 auto; }
#billing-boleto-kind { min-width: 10rem; }
#billing-boleto-format { min-width: 5rem; }
.selection-actions { margin: .6rem 0; align-items: center; }
#reports-view td input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--green); }
#occasional-customer-mode { margin: .3rem 0 .75rem; }
.billing-editor { margin-bottom: .9rem; }
.billing-editor li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
#billing-selection-count { color: var(--muted); font-size: .88rem; }
#billing-view table { min-width: 1060px; }
#billing-view td input[type=checkbox] { width: 1rem; height: 1rem; accent-color: var(--green); }
#billing-view td button { white-space: nowrap; font-size: .83rem; min-height: 2rem; }
.billing-row-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.contract-start { border-top: 1px solid var(--line); margin-top: .9rem; padding-top: .9rem; }
.service-filters { margin: 1rem 0; }
.service-results { max-height: 24rem; }
.service-results table { min-width: 560px; }
.service-results input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--green); }
.special-link, .adjustment-filter { margin-top: 1rem; }
.report-heading { justify-content: space-between; align-items: center; }
.report-heading h2 { margin: 0; }
.history-events { padding-left: 1.4rem; }
.history-events li { padding: .5rem 0; }
.history-events small { display: block; color: var(--muted); }
.boleto-fields { display: grid; gap: .8rem; }
#service-create-form, #department-create-form, #report-client-picker { margin-top: .75rem; }
.catalog-controls { display: grid; gap: .65rem; margin-bottom: 1rem; }
#report-count { margin: .7rem 0; }
#report-examples-label { margin-top: .7rem; }
#special-client-rows li { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
dialog { width: min(95vw, 680px); max-height: 92vh; padding: 1.3rem; border: 1px solid var(--line); border-radius: .7rem; color: inherit; background: var(--paper); }
dialog::backdrop { background: #0b2d2366; }
#subject-boleto-source, #subject-boleto-message { margin-bottom: .7rem; }
.selection-actions { margin: .75rem 0; }
.adjustment-preview { margin-top: 1rem; }
.adjustment-preview button { margin-top: .8rem; }
details { border: 1px solid var(--line); padding: .65rem .8rem; border-radius: .4rem; }
summary { cursor: pointer; font-weight: 600; }
details .field-pair { margin-top: .75rem; }
.reference-list { list-style: none; padding: 0; margin: 1rem 0 0; color: var(--muted); }
.reference-list li { padding: .4rem 0; border-top: 1px solid var(--line); }

@media (max-width: 720px) {
  main, .header-inner { padding-left: .8rem; padding-right: .8rem; }
  .columns { grid-template-columns: 1fr; }
  .summary { gap: .5rem; }
  .summary div { padding: .6rem; }
  .summary span { font-size: .77rem; }
}

#report-service-filter { margin: .8rem 0; }
.report-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 235px), 1fr)); gap: .25rem 1rem; max-height: 14rem; overflow: auto; }
.report-options label { margin: 0; }
.report-section { background: #e6eee7; color: #133f31; }
.report-detail td { color: #4b6255; background: #f3f6f1; }
#occasional-panel { margin-top: 1rem; }
#occasional-editor { margin: 1rem 0; }
#invoice-dialog { max-width: min(50rem, 95vw); }
#invoice-message, #occasional-receipt-message { color: #802e25; }

.billing-tab-nav { display:flex; flex-wrap:wrap; gap:.45rem; margin-bottom:1rem; }
.billing-tab-nav button[aria-current="page"] { background:var(--green); color:white; border-color:var(--green); box-shadow:inset 0 -3px #b38a44; }
#billing-origin form { margin-top:.85rem; }
#billing-consolidated summary { cursor:pointer; color:var(--green); }
#billing-consolidated details ul { padding-left:1.1rem; white-space:normal; min-width:9rem; }
@media (max-width:650px) {
  .billing-tab-nav { flex-wrap:nowrap; overflow-x:auto; padding-bottom:.35rem; }
  .billing-tab-nav button { flex:0 0 auto; }
}

.consolidated-documents { padding:.8rem; align-items:center; }
.consolidated-documents label { flex:0 0 auto; }
#consolidated-doc-count { font-size:.85rem; color:var(--muted); }

.xlsx-import { margin-bottom:1rem; }
.xlsx-import form { margin:.75rem 0; }

.treasury-panel form { margin-top:.75rem; }
#treasury-reconcile form { margin-bottom:.75rem; }

.finance-navigation { margin:.75rem 0; align-items:center; }
#payable-payment-items { width:100%; }
#payables-view td input[type=checkbox] { width:1rem; height:1rem; accent-color:var(--green); }

#card-plan, #card-confirm, #card-reports { margin:.8rem 0; }
#cards-view td input[type=checkbox] { width:1rem; height:1rem; accent-color:var(--green); }

.notice-box { position:relative; }
.notice-box summary { cursor:pointer; list-style:none; padding:.45rem; }
.notice-panel { position:absolute; z-index:5; right:0; top:100%; width:min(27rem,85vw); color:#172c24; max-height:65vh; overflow:auto; }
.notice-panel .inline { align-items:center; }
.notice-panel li button { margin:.2rem; }

.money-error { display: block; color: #9a2929; font-weight: 500; }

.finance-cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,15rem),1fr)); gap: 1rem; }
.finance-cards button { min-height: 7rem; text-align: left; padding: 1.2rem; border-bottom: 4px solid #b48338; }
.finance-cards span { display: block; font-size: 1.65rem; margin-bottom: .45rem; color: #efc375; }

#workspace > .nav { position: sticky; top: 0; z-index: 12; background: #f5f6f0; }
#billing-sticky { position: sticky; top: var(--workspace-nav-height, 0px); z-index: 10; background: #f5f6f0; }
#billing-sticky .heading { margin-bottom: .35rem; }
#billing-accounting > .billing-actions {
  position: sticky;
  top: calc(var(--workspace-nav-height, 0px) + var(--billing-sticky-height, 0px));
  z-index: 9;
  background: #f5f6f0;
  padding: .35rem 0;
}
#billing-view .table-scroll { max-height: min(62vh, 42rem); overflow: auto; }
#billing-view thead th { position: sticky; top: 0; z-index: 1; background: #e7ede3; }
.finance-indicators { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:.75rem; }
.finance-indicators article { display:grid; gap:.4rem; background:#eff4eb; border-left:3px solid #ab7f32; border-radius:.45rem; padding:.8rem; }
.finance-indicators strong { font-size:clamp(1rem,2vw,1.5rem); color:#143f31; }
.billing-column-sort,.billing-column-filter { background:transparent; color:#143f31; padding:.14rem .22rem; border:0; min-height:1.65rem; }
.billing-column-filter[aria-pressed=true] { outline:2px solid #9a6c25; }
th[aria-sort=ascending] .billing-column-sort::after { content:" ↑"; }
th[aria-sort=descending] .billing-column-sort::after { content:" ↓"; }
@media(max-width:660px){
 #workspace > .nav { flex-wrap:nowrap; overflow-x:auto; gap:.3rem; }
 #workspace > .nav button { white-space:nowrap; padding:.4rem .55rem; }
 #billing-sticky .heading { display:block; padding-top:.25rem; }
 #billing-sticky h1 { font-size:1.1rem; margin:0; }
 #billing-reference { display:none; }
 .finance-indicators { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
#process-billing-blockers { max-height: 12rem; overflow:auto; }

.workflow-group + .workflow-group { margin-top: 1rem; }
.workflow-group h3, .comparison-section h3 { margin: .5rem 0; }
.workflow-group .inline { margin-bottom: .3rem; }
.workflow-group button, #consolidated-document-toolbar button, .selection-actions button { min-height: 2rem; padding: .3rem .55rem; }
.workflow-group th, .workflow-group td { padding: .3rem .5rem; }
.comparison-section { margin-top: .7rem; min-width: 0; }
.monthly-comparison { min-width: max-content; }
.monthly-comparison th, .monthly-comparison td { padding: .3rem .55rem; white-space: nowrap; }
.monthly-comparison th:first-child { position: sticky; left: 0; z-index: 2; background: #edf0e6; }
.comparison-trend { color: #57674b; }
#workflow-results:empty { display: none; }

.table-scroll th, .table-scroll td { padding-block: .35rem; }
.table-scroll td button, .table-scroll th button { padding: .25rem .5rem; min-height: 1.75rem; }
.table-scroll thead th { position: sticky; top: 0; background-color: #e7ede3; }
.table-scroll :is(button, input, select):focus-visible { outline: 2px solid #856922; }

#workspace > .nav { flex-wrap: nowrap; overflow-x: auto; gap: .3rem; margin-bottom: 1.15rem; }
#workspace > .nav button { flex: 0 0 auto; white-space: nowrap; font-size: .8rem; padding: .55rem .55rem .48rem; min-height: 2.1rem; }
#billing-tabs { flex-wrap: nowrap; overflow-x: auto; gap: .3rem; margin-bottom: .7rem; }
#billing-tabs button { flex: 0 0 auto; white-space: nowrap; font-size: .79rem; padding: .33rem .55rem; min-height: 2rem; }
#monthly-overview { padding: .65rem .85rem; margin-bottom: .75rem; }
#monthly-overview:has(#financial-indicators:empty) { display: flex; flex-wrap: wrap; align-items: baseline; gap: .55rem; }
#monthly-overview:has(#financial-indicators:empty) p { margin: 0; font-size: .82rem; }
#overview-heading { font-size: 1rem; }
.compact-accounting-totals { display: flex; padding: .2rem 0 .65rem; gap: .3rem 1rem; flex-wrap: wrap; font-size: .82rem; }
#billing-accounting .table-scroll { max-height: none; }
.workflow-group { padding: .75rem; border: 1px solid #d6ded4; border-left: 4px solid #a77d37; border-radius: .45rem; background: #fffefa; }
.workflow-group + .workflow-group { margin-top: 1.4rem; }
.workflow-group h3 { margin: .1rem 0 .3rem; padding-bottom: .3rem; border-bottom: 1px solid #e2e8df; }
.comparison-tools { margin: .25rem 0 .5rem; }
.comparison-tools button, #workflow-pending, #workflow-due, #overview-xlsx, #overview-pdf { min-height: 1.85rem; padding: .25rem .55rem; font-size: .79rem; }
#workflow-pending-dialog { width: min(96vw, 950px); }
#workflow-pending-dialog table { min-width: 520px; }
#cash-statement-results input[type=checkbox], #workflow-cancellation-rows input[type=checkbox] { width: 1rem; height: 1rem; accent-color: var(--green); }
#cash-new-entry { margin-top: .65rem; }
.cash-row-provisional { color: var(--muted); }
#overview-composition:not([open]) .comparison-section { display: none; }


#workspace > .nav { margin-bottom: .55rem; }
#workspace > .nav button { padding: .35rem .42rem; min-height: 1.8rem; font-size: .77rem; }
#billing-sticky h1 { font-size: clamp(1.25rem, 2.25vw, 1.9rem); }
#billing-sticky .heading { gap: .45rem; }
#billing-reference { margin-top: .12rem; font-size: .82rem; }
#billing-tabs { gap: .2rem; margin-bottom: .4rem; }
#billing-tabs button { padding: .26rem .36rem; min-height: 1.65rem; font-size: .74rem; }
#monthly-overview { padding: .4rem .65rem; margin-bottom: .45rem; }
#monthly-overview > p { margin-top: .2rem; font-size: .8rem; }
#overview-composition { margin-top: .25rem; padding: .3rem .55rem; }
.finance-indicators { gap: .45rem; }
.finance-indicators article { padding: .38rem .55rem; gap: .18rem; font-size: .8rem; }
.finance-indicators strong { font-size: 1.1rem; }
#billing-filter-panel { padding: .5rem .65rem; margin-bottom: .45rem; }
#billing-filter-panel label { font-size: .77rem; gap: .15rem; }
#billing-filter-panel :is(form input,select,button), #preview-form :is(input,button) { padding: .3rem .4rem; min-height: 1.85rem; }
#billing-filter-panel form { margin-bottom: .32rem; gap: .35rem; }
#consolidated-document-toolbar { padding: .45rem; gap: .3rem; }
#consolidated-document-toolbar button, .workflow-group .inline button { padding: .25rem .38rem; min-height: 1.72rem; font-size: .76rem; }
#billing-view .workflow-group .table-scroll { max-height: none; }
.workflow-group { padding: .43rem; }
.workflow-group + .workflow-group { margin-top: .75rem; }
.workflow-group h3 { font-size: 1rem; }
.workflow-group td, .workflow-group th { padding: .28rem .38rem; }
.workflow-group td, .workflow-group td button { font-size: .8rem; }
.workflow-group :is(.billing-column-sort,.billing-column-filter) { min-height: 1.35rem; }
#workflow-pending-summary { margin-bottom: .5rem; }
.table-scroll:has(:is(#cash-statement-results,#card-lines,#card-payment-rows,#card-ledger-export-rows)) {
  max-height: min(72vh,42rem);
  overflow: auto;
}
@media(min-width:900px) {
  .table-scroll:has(:is(#cash-statement-results,#card-lines,#card-payment-rows,#card-ledger-export-rows)) {
    overflow: visible;
    max-height: none;
  }
  .table-scroll:has(:is(#cash-statement-results,#card-lines,#card-payment-rows,#card-ledger-export-rows)) table {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .table-scroll:has(:is(#cash-statement-results,#card-lines,#card-payment-rows,#card-ledger-export-rows)) thead th {
    top: var(--workspace-nav-height,0px);
    z-index: 4;
  }
}

input.competence-picker { width: 2.65rem; min-width: 0; padding-inline: .5rem; }
input.competence-picker::-webkit-datetime-edit { display: none; }
#accounting-fiscal-dialog { max-height: 85vh; overflow: auto; }
