:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #182d29;
  background: #f5f5ef;
  --ink: #182d29;
  --muted: #4c6059;
  --accent: #155348;
  --glow: #e3efde;
  --paper: #fffefa;
  --line: #daddd2;
  --error: #8c302d;
  --focus: #a34815;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 290px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
button, input, select, textarea, a {
  outline-offset: 3px;
}
:focus-visible { outline: 2px solid var(--focus); }
[hidden] { display: none !important; }

.skip {
  position: absolute;
  top: -5rem;
  left: 1rem;
  padding: .5rem;
  background: var(--paper);
  color: var(--ink);
  z-index: 2;
}
.skip:focus { top: .5rem; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  min-height: 5.25rem;
  padding: .9rem clamp(1rem, 4vw, 3rem);
  color: #f4f5ea;
  background: #193b32;
}
.brand { display: flex; align-items: center; gap: .85rem; font-size: 1.12rem; font-weight: 650; }
.brand-mark {
  flex: 0 0 1.2rem;
  height: 1.2rem;
  border: 1px solid #e8f1b2;
  border-radius: 2px;
  box-shadow: inset 0 4px 0 #193b32, inset 0 5px 0 #e8f1b2;
  transform: rotate(-10deg);
}
.context { display: flex; gap: .8rem; }
.context label { font-size: .75rem; color: #e0ebdf; }
.context select {
  width: 100%;
  max-width: 16rem;
  min-height: 2.15rem;
  padding-block: .22rem;
  color: #f9fff9;
  background: #254c41;
  border-color: #7c998b;
}
.context select:disabled { opacity: 1; }
.layout {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  max-width: 96rem;
  margin-inline: auto;
  padding: 2.6rem clamp(1rem, 4vw, 3rem) 3.75rem;
}
.sidebar nav { display: grid; gap: .18rem; padding-top: .85rem; }
.sidebar button {
  text-align: left;
  font-size: .91rem;
  padding: .65rem .75rem;
  border: 0;
  border-radius: .35rem;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}
.sidebar button:hover { background: #eaece3; }
.sidebar [aria-current] {
  color: #144a41;
  background: #e7efe0;
  box-shadow: inset 3px 0 var(--accent);
  font-weight: 650;
}
main { min-width: 0; }
.page-heading, .panel-heading, .dialog-heading, .actions, .dialog-actions, .filters, .row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .6rem;
}
.page-heading {
  justify-content: space-between;
  align-items: end;
  gap: .8rem 1.5rem;
  margin-bottom: 1.6rem;
}
.page-context, .muted { color: var(--muted); font-size: .87rem; }
.page-context:empty { display: none; }
h1, h2, p { margin: 0; }
h1, .dialog-heading h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -.035em;
}
h1 { font-size: clamp(2.3rem, 5vw, 3.65rem); line-height: 1.04; margin-top: .15rem; }
h2 { font-size: 1.12rem; font-weight: 650; }
.primary, .secondary, .small-btn, .icon-button {
  font-weight: 650;
  font-size: .88rem;
  border: 1px solid var(--line);
  border-radius: .36rem;
  background: var(--paper);
  padding: .55rem .82rem;
  min-height: 2.35rem;
  line-height: 1.2;
}
.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.download { display: inline-flex; align-items: center; text-decoration: none; color: var(--ink); }
.primary:hover { background: #10463c; }
.secondary:hover, .small-btn:hover, .icon-button:hover { background: #e8efe5; }
.small-btn { padding: .38rem .53rem; min-height: 2rem; font-size: .79rem; }
.icon-button { min-width: 2.38rem; font-size: 1.2rem; padding: .3rem; }

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr));
  gap: 1px;
  margin-bottom: 1.12rem;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: .55rem;
  overflow: hidden;
}
.stat {
  display: grid;
  gap: .35rem;
  padding: 1rem 1.15rem 1.05rem;
  background: var(--paper);
  margin: 0;
}
.stat dt { font-size: .8rem; color: var(--muted); }
.stat dd {
  margin: 0;
  font-size: 1.42rem;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: .55rem;
  overflow: hidden;
}
.panel + .panel, .bank-results:not(:empty) { margin-top: 1rem; }
.panel-heading {
  justify-content: space-between;
  padding: .85rem 1.05rem;
  border-bottom: 1px solid var(--line);
}
.panel-body { padding: 1rem; }
.panel-body > p + *, .panel-body > h2 + * { margin-top: .8rem; }
.bank-form { display: grid; gap: .8rem; }
.bank-form > button { justify-self: start; }
.bank-form > p + * { margin-top: 0; }
.facturae-party { min-width: 0; margin: 0; padding: .65rem; border: 1px solid var(--line); border-radius: .35rem; }
.facturae-party legend { padding: 0 .25rem; font-weight: 650; }
.facturae-digest { margin: 0; overflow-wrap: anywhere; }
.facturae-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.facturae-choice { display: flex; align-items: center; gap: .5rem; }
.facturae-choice input { order: -1; margin: 0; accent-color: var(--accent); }
.labor-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: .28rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.labor-calendar-weekday {
  padding: .25rem 0;
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 650;
}
.labor-calendar-day {
  min-height: 2.45rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .22rem;
  padding: .18rem;
  border: 1px solid var(--line);
  border-radius: .3rem;
  font-variant-numeric: tabular-nums;
}
.labor-calendar-day.has-incident { background: var(--glow); color: var(--accent); }
.labor-calendar-count { font-size: .7rem; font-weight: 700; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; text-align: left; width: 100%; font-size: .88rem; }
th, td { padding: .74rem .9rem; vertical-align: top; }
thead th {
  color: var(--muted);
  background: #f0f2e9;
  font-size: .76rem;
  font-weight: 650;
  white-space: nowrap;
}
tbody tr + tr { border-top: 1px solid #e6e9e0; }
tfoot { border-top: 1px solid var(--line); font-weight: 650; }
.cell-main { font-weight: 630; }
.cell-sub { display: block; margin-top: .18rem; color: var(--muted); font-size: .76rem; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.no-wrap { white-space: nowrap; }
.pill {
  display: inline-block;
  border-radius: 1rem;
  padding: .16rem .45rem;
  font-size: .75rem;
  white-space: nowrap;
  background: #f0ebd9;
  color: #684a17;
  font-weight: 640;
}
.pill.is-posted { background: var(--glow); color: #245445; }
.pill.is-reversed { background: #edece6; color: #4c6059; }
.empty { padding: 1.4rem 1.02rem; color: var(--muted); }
.filters { align-items: end; padding: .9rem 1.05rem; border-bottom: 1px solid var(--line); }
.filters label { margin: 0; }
label { display: grid; gap: .35rem; font-size: .81rem; font-weight: 650; }
input, select, textarea {
  border: 1px solid #adb7aa;
  border-radius: .32rem;
  padding: .48rem .57rem;
  background: #fffffc;
  font-weight: 450;
  min-width: 0;
}
textarea { width: 100%; min-height: 7.5rem; resize: vertical; }
.memory-note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.invoice-observation-text, .invoice-printed-comments { white-space: pre-wrap; overflow-wrap: anywhere; }
input:read-only { background: #f0f2e9; }
.feedback, #feedback {
  margin-bottom: .8rem;
  padding: .7rem .85rem;
  border-radius: .35rem;
  border: 1px solid #9eaa99;
  background: var(--glow);
  color: #234a3c;
  font-size: .88rem;
}
.feedback.is-error, #feedback.is-error {
  border-color: #c5918a;
  background: #faeee9;
  color: var(--error);
}
dialog {
  max-height: 91vh;
  width: min(calc(100% - 1.25rem), 36rem);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: .6rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1rem 3rem #182d2940;
}
dialog.wide { width: min(calc(100% - 1.25rem), 56rem); }
dialog::backdrop { background: #172a24a6; }
#dialog-form { padding: 1.1rem 1.3rem 1.2rem; }
.dialog-heading { justify-content: space-between; margin-bottom: 1rem; }
.dialog-heading h2 { font-size: 1.75rem; }
#dialog-body { display: grid; gap: .8rem; }
.dialog-actions { justify-content: end; margin-top: 1rem; }
#dialog-error { margin: .8rem 0 0; }
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(11rem, 100%), 1fr));
  gap: .7rem;
}
.entry-lines { overflow: auto; border: 1px solid var(--line); border-radius: .32rem; }
.entry-lines input, .entry-lines select { width: 100%; }
.entry-lines th, .entry-lines td { padding: .37rem; }
.entry-lines .line-amount { min-width: 6.2rem; }
.entry-lines .line-account { min-width: 9rem; }
.entry-lines .line-description { min-width: 8rem; }
.entry-lines .line-cost-center { min-width: 11rem; }
.entry-totals { justify-content: space-between; gap: .5rem; display: flex; align-items: center; flex-wrap: wrap; }
.entry-totals p { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 800px) {
  .topbar { align-items: start; flex-direction: column; gap: .55rem; }
  .context { width: 100%; }
  .context label { flex: 1; min-width: 0; }
  .context select { max-width: none; }
  .layout { display: block; padding-top: .85rem; }
  .sidebar nav {
    display: flex;
    overflow-x: auto;
    padding: .2rem .2rem .65rem;
    margin: 0 -.2rem 1.2rem;
  }
  .sidebar button { flex: 0 0 auto; }
  .sidebar [aria-current] { box-shadow: inset 0 -2px var(--accent); }
  .page-heading { margin-bottom: 1rem; }
}
@media (max-width: 450px) {
  .entry-lines td { padding: .3rem; }
  #dialog-form { padding: .85rem; }
  th, td { padding: .6rem; }
}

.portal-entry {
  width: min(30rem, calc(100% - 2rem));
  margin: clamp(2rem, 10vh, 8rem) auto;
}

.portal-entry h1 { margin: 0 0 1rem; }
.portal-entry fieldset {
  min-width: 0;
  margin: 0;
  padding: .8rem;
  border: 1px solid var(--border);
  border-radius: .5rem;
  display: grid;
  gap: .5rem;
}
.portal-entry fieldset p { margin: 0 0 .35rem; }
.portal-user { max-width: 13rem; overflow-wrap: anywhere; font-size: .83rem; color: #f8f8f1; }
.portal-logout {
  align-self: end;
  padding: .4rem .7rem;
  border: 1px solid currentColor;
  border-radius: .45rem;
  color: #f8f8f1;
  background: transparent;
  white-space: nowrap;
}
.portal-logout:hover { background: #ffffff1c; }

.invoice-statistics {
  display: grid;
  gap: .8rem;
  min-inline-size: 0;
}
.invoice-statistics > div, .invoice-statistics fieldset { min-inline-size: 0; }
.invoice-statistics fieldset {
  margin: 0;
  padding: .65rem;
  border: 1px solid var(--line);
  border-radius: .4rem;
}
.invoice-statistics legend { padding-inline: .25rem; }
.invoice-statistics .invoice-statistics-results { display: grid; gap: .55rem; }
.invoice-statistics .invoice-statistics-bar { white-space: nowrap; }
.invoice-statistics .invoice-statistics-bar meter { inline-size: 5rem; vertical-align: middle; }
.invoice-statistics details { padding-block: .45rem; }


.commission-credit-details {
  grid-template-columns: minmax(0, 1fr);
  min-inline-size: 0;
}
.commission-credit-details summary { overflow-wrap: anywhere; }
