:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-alt: #f8faf9;
  --ink: #18201f;
  --muted: #65706e;
  --line: #d9dfdd;
  --line-strong: #bdc8c5;
  --brand: #087667;
  --brand-dark: #075e53;
  --sidebar: #172522;
  --sidebar-muted: #aebfba;
  --amber: #9a5b06;
  --amber-bg: #fff7e7;
  --danger: #a92c27;
  --danger-bg: #fff0ef;
  --success: #176b47;
  --success-bg: #edf8f2;
  --shadow: 0 1px 2px rgba(24, 32, 31, .06);
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: Inter, "Segoe UI", Arial, sans-serif; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 26px; line-height: 1.25; letter-spacing: 0; }
h2 { margin-bottom: 5px; font-size: 17px; line-height: 1.3; letter-spacing: 0; }
p { margin-bottom: 12px; }
small { color: var(--muted); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 13px; color: #f6fbf9; background: var(--sidebar); z-index: 30; }
.brand-block { display: flex; align-items: center; gap: 11px; padding: 2px 8px 21px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-block strong, .brand-block small { display: block; }
.brand-block strong { font-size: 16px; }
.brand-block small { margin-top: 1px; color: var(--sidebar-muted); font-size: 11px; text-transform: uppercase; }
.brand-mark { width: 35px; height: 35px; display: grid; place-items: center; border: 1px solid #5f8c82; border-radius: 7px; color: white; background: #245a50; font-weight: 800; }
.nav { flex: 1; overflow-y: auto; padding: 15px 0; }
.nav a { display: block; min-height: 39px; margin: 2px 0; padding: 9px 11px; border-radius: 6px; color: #d3dfdc; font-size: 14px; font-weight: 600; }
.nav a:hover { color: white; background: rgba(255,255,255,.06); }
.nav a.active { color: white; background: #26594f; box-shadow: inset 3px 0 0 #6fd0bd; }
.sidebar-user { padding: 14px 8px 2px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user strong { font-size: 13px; }
.sidebar-user small { margin: 2px 0 9px; color: var(--sidebar-muted); font-size: 11px; }
.sidebar-user a, .sidebar-user button { color: #d9e6e3; font-size: 12px; text-decoration: underline; }
.sidebar-user form { margin-top: 4px; }
.sidebar-user button { padding: 0; border: 0; background: none; cursor: pointer; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 68px; display: flex; align-items: center; gap: 15px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); }
.company-context { display: flex; align-items: center; gap: 10px; min-width: 0; }
.company-context > span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.company-context form { min-width: 0; }
.company-context select { min-width: 230px; max-width: 380px; border-color: transparent; background-color: var(--surface-alt); font-weight: 700; }
.company-context form + form select { min-width: 130px; max-width: 150px; }
.year-lock { min-height: 28px; display: inline-flex; align-items: center; padding: 4px 8px; border: 1px solid #ead19b; border-radius: 5px; color: var(--amber); background: var(--amber-bg); font-size: 11px; font-weight: 800; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.menu-toggle { display: none !important; }
.content { width: 100%; max-width: 1440px; margin: 0 auto; padding: 25px 28px 50px; }

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.back-link { display: inline-block; margin-bottom: 8px; color: var(--brand-dark); font-size: 13px; font-weight: 700; }
.profile-chip { display: inline-flex; align-items: center; min-height: 30px; padding: 5px 9px; border: 1px solid #b9d7d1; border-radius: 6px; color: var(--brand-dark); background: #f0f8f6; font-size: 12px; font-weight: 800; white-space: nowrap; }

.btn { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: var(--surface); box-shadow: var(--shadow); cursor: pointer; font-weight: 700; font-size: 13px; line-height: 1.2; }
.btn:hover { border-color: #94a39f; background: var(--surface-alt); }
.btn.primary { color: white; border-color: var(--brand); background: var(--brand); }
.btn.primary:hover { border-color: var(--brand-dark); background: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #dfaaa7; background: white; }
.btn.small { min-height: 32px; padding: 6px 9px; font-size: 12px; }
.btn:disabled { opacity: .48; cursor: not-allowed; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; flex: 0 0 36px; padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; background: white; cursor: pointer; font-size: 20px; line-height: 1; }
.icon-btn.danger { color: var(--danger); }

.alert { margin-bottom: 18px; padding: 11px 13px; border: 1px solid #acd5c6; border-radius: 6px; color: #125b3d; background: var(--success-bg); font-size: 13px; }
.alert.warning { color: #754603; border-color: #e3c17c; background: var(--amber-bg); }
.alert.error { color: var(--danger); border-color: #e5aaa6; background: var(--danger-bg); }
.inline-alert { margin: 16px 0 0; }

.form-section, .data-section { margin-bottom: 18px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
.form-section { padding: 18px; }
.data-section { overflow: hidden; }
.section-heading { min-height: 34px; display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.data-section > .section-heading { margin: 0; padding: 16px 17px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin-bottom: 3px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.section-heading > span, .section-heading > a { color: var(--muted); font-size: 12px; font-weight: 700; }
.section-heading > a { color: var(--brand-dark); }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset:disabled { opacity: .78; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
label { display: block; margin-bottom: 6px; color: #37413f; font-size: 12px; font-weight: 750; }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: white; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(8,118,103,.11); }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--danger); background: var(--danger-bg); }
input.is-invalid:focus, select.is-invalid:focus, textarea.is-invalid:focus { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(169,44,39,.12); }
input::placeholder, textarea::placeholder { color: #99a3a1; }
textarea { min-height: 88px; resize: vertical; }
input[type="checkbox"] { width: 17px; min-height: 17px; accent-color: var(--brand); }
input[type="file"] { padding: 7px; font-size: 12px; }
.form-grid small, .field-help { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.field-error small { color: var(--danger); font-weight: 700; }
.checkbox-field { display: flex; flex-direction: column; justify-content: center; min-height: 40px; }
.checkbox-field label { display: flex; align-items: center; gap: 8px; margin: 0; }
.field-note { align-self: end; min-height: 40px; display: flex; align-items: center; padding: 9px 11px; border-left: 3px solid #c6d1ce; color: var(--muted); background: var(--surface-alt); font-size: 12px; }
.calculated-field { min-height: 66px; display: flex; flex-direction: column; justify-content: center; padding: 8px 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-alt); }
.calculated-field span { color: var(--muted); font-size: 11px; }
.calculated-field strong { font-size: 17px; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 9px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; padding: 13px; border: 1px solid var(--line); background: rgba(255,255,255,.96); }
.profile-summary { display: flex; gap: 10px; margin-top: 14px; padding: 10px 12px; border-left: 3px solid var(--brand); background: #f2f8f6; font-size: 13px; }
.profile-summary span { color: var(--muted); }
.asset-preview { width: 120px; height: 60px; display: block; margin-top: 8px; padding: 4px; border: 1px solid var(--line); object-fit: contain; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.cols-3-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { min-height: 126px; padding: 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
.stat > span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.stat > strong { display: block; margin: 9px 0 5px; font-size: 23px; line-height: 1.2; }
.stat small { display: block; font-size: 11px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .75fr); gap: 18px; }
.threshold-section, .deadline-section { padding: 0; }
.threshold-section .threshold-row { padding: 14px 17px; border-bottom: 1px solid var(--line); }
.threshold-section .threshold-row:last-child { border-bottom: 0; }
.threshold-row > div:first-child { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.threshold-row p, .threshold-row small { display: block; margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.progress { height: 7px; margin-top: 9px; overflow: hidden; border-radius: 4px; background: #e3e8e6; }
.progress span { height: 100%; display: block; border-radius: inherit; background: var(--brand); }
.deadline-section { padding-bottom: 17px; }
.deadline-section > :not(.section-heading) { margin-left: 17px; margin-right: 17px; }
.deadline-section time { display: block; margin-bottom: 5px; font-size: 28px; font-weight: 800; }
.deadline-section > strong { display: block; font-size: 14px; }
.deadline-section p { margin-top: 8px; color: var(--muted); font-size: 12px; }

.table-toolbar { min-height: 59px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.search-field { width: min(360px, 100%); margin: 0; }
.search-field input { min-height: 36px; }
.record-count { color: var(--muted); font-size: 12px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 12px; }
th { color: #4d5956; background: #f6f8f7; font-size: 11px; font-weight: 800; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfc; }
td small, td strong { display: block; }
td small { margin-top: 3px; font-size: 10px; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong-link { color: var(--brand-dark); font-weight: 800; }
.strong-link:hover { text-decoration: underline; }
.table-actions { min-width: 140px; text-align: right; white-space: nowrap; }
.table-actions .btn + .btn { margin-left: 4px; }
.table-actions form { display: flex; justify-content: flex-end; gap: 6px; }
.table-actions .inline-form { display: inline-flex; margin-left: 4px; vertical-align: middle; }
.table-actions input { width: 190px; min-height: 32px; padding: 5px 7px; font-size: 12px; }
.empty-state { padding: 28px; color: var(--muted); text-align: center; }
.badge { min-height: 24px; display: inline-flex; align-items: center; padding: 3px 7px; border: 1px solid #cbd8d4; border-radius: 5px; color: #3d5b54; background: #f2f7f5; font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge.ok { color: var(--success); border-color: #b5dac8; background: var(--success-bg); }
.badge.warn { color: var(--amber); border-color: #ead19b; background: var(--amber-bg); }
.badge.danger { color: var(--danger); border-color: #e6b2ae; background: var(--danger-bg); }

.filter-bar { display: flex; align-items: end; gap: 12px; margin-bottom: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.filter-bar > div { width: 190px; }
.definition-list { margin: 0; }
.definition-list > div { display: grid; grid-template-columns: 210px 1fr; gap: 15px; padding: 11px 17px; border-bottom: 1px solid var(--line); }
.definition-list > div:last-child { border-bottom: 0; }
.definition-list dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.definition-list dd { margin: 0; font-size: 13px; }
.calculation-line { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 15px 17px; border-top: 1px solid var(--line); background: var(--surface-alt); }
.calculation-line strong { font-size: 18px; }
.text-danger { color: var(--danger); }

.export-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.export-tool .btn { width: 100%; }
.compliance-note .source-links { display: flex; flex-wrap: wrap; gap: 15px; margin: 0; padding: 13px 17px; border-top: 1px solid var(--line); }
.source-links a { color: var(--brand-dark); font-size: 12px; font-weight: 700; text-decoration: underline; }
.accounting-footer { margin-top: 28px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
.accounting-footer summary { min-height: 46px; display: flex; align-items: center; padding: 12px 15px; cursor: pointer; color: var(--brand-dark); font-size: 13px; font-weight: 800; }
.accounting-footer details[open] summary { border-bottom: 1px solid var(--line); }
.accounting-footer div { padding: 15px 17px; }
.accounting-footer ul { margin: 0 0 12px 18px; padding: 0; color: #33413e; font-size: 13px; }
.accounting-footer li + li { margin-top: 7px; }
.accounting-footer p { margin: 0; color: var(--muted); font-size: 12px; }

.document-form { padding-bottom: 76px; }
.line-section { padding: 0; overflow: hidden; }
.line-section > .section-heading { margin: 0; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.line-table { min-width: 940px; table-layout: fixed; }
.line-table th:first-child { width: auto; }
.line-table .w-qty { width: 90px; }
.line-table .w-unit { width: 95px; }
.line-table .w-price { width: 145px; }
.line-table .w-vat { width: 90px; }
.line-table .w-total { width: 130px; }
.line-table .w-action { width: 52px; }
.line-table td { padding: 7px 5px; }
.line-table td:first-child { padding-left: 12px; }
.line-table td:last-child { padding-right: 12px; }
.line-table input, .line-table select { min-height: 35px; padding: 6px 7px; }
.line-total { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.document-summary { display: flex; justify-content: flex-end; padding: 17px; border-top: 1px solid var(--line); background: var(--surface-alt); }
.document-summary dl { width: min(370px, 100%); margin: 0; }
.document-summary dl > div { display: flex; justify-content: space-between; gap: 20px; padding: 5px 0; }
.document-summary dt { color: var(--muted); font-size: 12px; }
.document-summary dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.document-summary .grand-total { margin-top: 5px; padding-top: 10px; border-top: 1px solid var(--line-strong); }
.document-summary .grand-total dt, .document-summary .grand-total dd { color: var(--ink); font-size: 18px; font-weight: 800; }
.payment-fields { display: none; grid-template-columns: 1fr 1fr 2fr; gap: 14px; align-items: end; padding: 13px; border: 1px solid #e3c17c; border-radius: 6px; background: var(--amber-bg); }
.payment-fields.visible { display: grid; }
.payment-fields p { margin: 0 0 9px; color: #754603; font-size: 12px; }

.document-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.invoice-paper { width: 100%; max-width: 210mm; min-height: 297mm; display: flex; flex-direction: column; margin: 0 auto 20px; padding: 12mm 14mm 10mm; border: 1px solid var(--line); border-top: 4px solid var(--brand); background: white; box-shadow: 0 10px 32px rgba(24,32,31,.09); color: #17201f; font-family: "Segoe UI", Arial, sans-serif; font-size: 10.25pt; line-height: 1.42; }
.invoice-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12mm; padding-bottom: 5mm; border-bottom: 2px solid #172522; }
.invoice-brand { min-width: 0; display: flex; align-items: flex-start; gap: 5mm; }
.invoice-brand.no-logo { gap: 0; }
.invoice-brand img { width: 25mm; height: 18mm; flex: 0 0 auto; object-fit: contain; object-position: left top; }
.invoice-brand-copy { min-width: 0; }
.invoice-brand-copy > strong, .invoice-brand-copy > span, .invoice-brand-copy p > span { display: block; }
.invoice-brand-copy > strong { font-size: 15pt; line-height: 1.2; }
.invoice-brand-copy > span { margin-top: 1mm; color: #596461; font-size: 9pt; }
.invoice-brand-copy p { margin: 2mm 0 0; color: #53605d; font-size: 8.75pt; line-height: 1.45; overflow-wrap: anywhere; }
.invoice-monogram { width: 18mm; height: 18mm; display: grid; place-items: center; flex: 0 0 18mm; color: white; background: var(--sidebar); font-size: 15pt; font-weight: 800; }
.invoice-identity { min-width: 62mm; padding-top: 0; text-align: right; }
.invoice-identity .invoice-title { margin: 0 0 3mm; color: #17201f; font-size: 20pt; font-weight: 800; line-height: 1; text-transform: uppercase; }
.invoice-identity > span { display: block; color: #69736f; font-size: 8pt; font-weight: 700; text-transform: uppercase; }
.invoice-identity > strong { display: block; margin-top: 1mm; font-size: 11.5pt; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.invoice-overview { margin-top: 6mm; border-left: 4px solid var(--brand); background: #f1f6f4; }
.invoice-buyer { padding: 4.5mm 6mm; }
.invoice-buyer h2, .invoice-payment h2, .invoice-notes h2 { margin: 0 0 2.5mm; color: #5b6764; font-size: 8pt; font-weight: 800; text-transform: uppercase; }
.invoice-buyer > strong { display: block; font-size: 12pt; line-height: 1.3; }
.invoice-buyer p { margin: 2mm 0 0; color: #4d5956; font-size: 9.5pt; line-height: 1.5; }
.invoice-buyer p > span { display: block; }
.invoice-meta-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8mm; margin: 0 0 6mm; padding: 3.5mm 6mm; border-bottom: 1px solid #cfd8d5; }
.invoice-meta-row.has-supply-date { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.invoice-meta-row dt { color: #68736f; font-size: 8pt; font-weight: 700; text-transform: uppercase; }
.invoice-meta-row dd { margin: 1mm 0 0; font-size: 10pt; font-weight: 700; font-variant-numeric: tabular-nums; }
.correction-reference { margin: 0 0 6mm; padding: 3mm 4mm; border-left: 3px solid var(--amber); background: var(--amber-bg); font-size: 9pt; }
.correction-reference a { color: var(--brand-dark); text-decoration: underline; }
.invoice-lines { overflow: visible; }
.invoice-lines table { border: 0; table-layout: fixed; }
.invoice-lines th { padding: 2.6mm 2.4mm; color: white; border: 0; background: #172522; font-size: 8pt; font-weight: 700; letter-spacing: 0; }
.invoice-lines td { padding: 3.2mm 2.4mm; border-bottom-color: #dfe4e2; font-size: 9.5pt; vertical-align: top; }
.invoice-lines tbody tr:nth-child(even) td { background: #fafbfb; }
.invoice-lines td:first-child, .invoice-lines th:first-child { width: 5%; text-align: center; }
.invoice-lines .without-vat th:nth-child(2) { width: 43%; }
.invoice-lines .without-vat th:nth-child(3) { width: 9%; }
.invoice-lines .without-vat th:nth-child(4) { width: 10%; }
.invoice-lines .without-vat th:nth-child(5) { width: 16%; }
.invoice-lines .without-vat th:nth-child(6) { width: 17%; }
.invoice-lines .with-vat th:nth-child(2) { width: 34%; }
.invoice-lines .with-vat th:nth-child(3) { width: 8%; }
.invoice-lines .with-vat th:nth-child(4) { width: 9%; }
.invoice-lines .with-vat th:nth-child(5) { width: 16%; }
.invoice-lines .with-vat th:nth-child(6) { width: 12%; }
.invoice-lines .with-vat th:nth-child(7) { width: 16%; }
.invoice-lines td small { margin-top: .5mm; font-size: 8pt; }
.invoice-item-description { line-height: 1.45; }
.invoice-closing { display: grid; grid-template-columns: minmax(0, 1fr) 66mm; gap: 12mm; padding-top: 6mm; }
.invoice-payment { padding: 3.5mm 0 3.5mm 5mm; border-left: 3px solid #cad5d1; }
.invoice-payment p, .invoice-notes p { margin: 0; color: #3f4c49; font-size: 9.5pt; line-height: 1.65; overflow-wrap: anywhere; }
.invoice-payment p strong { color: #17201f; }
.exchange-note { padding: 7px 8px; border-left: 2px solid var(--line-strong); background: var(--surface-alt); }
.invoice-totals { margin: 0; }
.invoice-totals > div { display: flex; justify-content: space-between; gap: 5mm; padding: 2.5mm 0; border-bottom: 1px solid var(--line); font-size: 9.75pt; }
.invoice-totals dd { margin: 0; font-weight: 700; }
.invoice-totals .total { margin-top: 1mm; padding: 3.5mm; border: 0; background: #edf5f2; color: #102a25; font-size: 13pt; font-weight: 800; }
.invoice-closing, .invoice-notes, .invoice-footer { break-inside: avoid; }
.invoice-notes { margin-top: 6mm; padding: 3.5mm 5mm; border: 1px solid var(--line); }
.invoice-footer { display: grid; grid-template-columns: minmax(0, 1fr) 64mm; gap: 12mm; align-items: end; margin-top: auto; padding-top: 10mm; }
.invoice-generated { color: #56625e; font-size: 8pt; line-height: 1.45; }
.invoice-generated p { max-width: 96mm; margin: 0; }
.invoice-generated strong { color: #17201f; }
.signature-area { min-height: 22mm; display: flex; align-items: flex-end; justify-content: center; gap: 2mm; position: relative; padding-bottom: 4mm; border-bottom: 1px solid #8d9995; }
.signature-area img { max-width: 30mm; max-height: 17mm; object-fit: contain; }
.signature-area span { position: absolute; bottom: -5mm; color: #65716d; font-size: 8pt; }
.print-without-auth .signature-area img { display: none; }
.related-documents, .correction-tool { max-width: 1000px; margin-left: auto; margin-right: auto; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 22px; background: #e9eeec; }
.auth-card { width: min(430px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 7px; background: white; box-shadow: 0 14px 45px rgba(24,32,31,.11); }
.auth-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 25px; }
.auth-brand > span { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 7px; color: white; background: var(--sidebar); font-weight: 800; }
.auth-brand h1 { margin: 0; font-size: 20px; }
.auth-brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.auth-card .btn { width: 100%; }
.account-form { max-width: 720px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.no-print { print-color-adjust: exact; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .export-grid { grid-template-columns: 1fr; }
  .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.cols-4 .span-3, .form-grid.cols-4 .span-4 { grid-column: span 2; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 244px; transition: transform .2s ease; box-shadow: 10px 0 30px rgba(0,0,0,.2); }
  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open::after { content: ""; position: fixed; inset: 0; z-index: 25; background: rgba(10,20,18,.42); }
  .menu-toggle { display: inline-grid !important; }
  .topbar { padding: 9px 14px; }
  .company-context { flex: 1; }
  .company-context > span { display: none; }
  .company-context select { width: 100%; min-width: 0; }
  .top-actions .btn:first-child { display: none; }
  .content { padding: 19px 14px 40px; }
  .page-heading { align-items: stretch; }
  .page-heading > .btn { align-self: flex-start; }
  .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.cols-3 .span-3, .form-grid.cols-4 .span-3, .form-grid.cols-4 .span-4 { grid-column: span 2; }
  .invoice-paper { min-height: 0; padding: 26px 24px; }
  .invoice-meta-row, .invoice-meta-row.has-supply-date { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invoice-closing { grid-template-columns: 1fr; gap: 20px; }
  .invoice-footer { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  h1 { font-size: 22px; }
  .top-actions .btn { padding-left: 9px; padding-right: 9px; }
  .page-heading { flex-direction: column; gap: 12px; }
  .stats-grid, .cols-3-stats { grid-template-columns: 1fr; }
  .stat { min-height: 105px; }
  .form-grid, .form-grid.cols-2, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .span-2, .span-3, .span-4, .form-grid.cols-3 .span-3, .form-grid.cols-4 .span-3, .form-grid.cols-4 .span-4 { grid-column: span 1; }
  .form-section { padding: 14px; }
  .form-actions { justify-content: stretch; }
  .form-actions .btn { flex: 1; }
  .payment-fields.visible { grid-template-columns: 1fr; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar > div { width: 100%; }
  .definition-list > div { grid-template-columns: 1fr; gap: 4px; }
  .table-toolbar { align-items: stretch; flex-direction: column; }
  .invoice-paper { padding: 20px 16px; }
  .invoice-header { flex-direction: column; }
  .invoice-identity { width: 100%; min-width: 0; text-align: left; }
  .invoice-footer { grid-template-columns: 1fr; gap: 20px; }
  .invoice-lines { overflow-x: auto; }
  .invoice-lines table { min-width: 720px; }
  .invoice-footer { margin-top: 30px; }
}

@page { size: A4; margin: 0; }
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }
  html, body { width: 210mm; min-height: 297mm; background: white; }
  .sidebar, .topbar, .no-print { display: none !important; }
  .app-shell, .main { display: block; min-height: 0; }
  .content { max-width: none; padding: 0; }
  .invoice-paper { width: 210mm; max-width: none; min-height: 297mm; display: flex; margin: 0; padding: 12mm 14mm 10mm; border: 0; border-top: 4px solid var(--brand); box-shadow: none; }
  .invoice-header { display: flex !important; flex-direction: row !important; align-items: flex-start !important; justify-content: space-between !important; gap: 12mm; padding-bottom: 5mm; border-bottom: 2px solid #172522; }
  .invoice-brand { display: flex !important; align-items: flex-start !important; gap: 5mm; }
  .invoice-brand.no-logo { gap: 0 !important; }
  .invoice-brand img { width: 25mm; height: 18mm; }
  .invoice-identity { width: auto !important; min-width: 62mm; text-align: right !important; }
  .invoice-overview { display: block !important; margin-top: 6mm; background: #f1f6f4 !important; }
  .invoice-meta-row { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 8mm; }
  .invoice-meta-row.has-supply-date { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .invoice-lines { overflow: visible !important; }
  .invoice-lines table { width: 100% !important; min-width: 0 !important; table-layout: fixed; }
  .invoice-lines thead { display: table-header-group; }
  .invoice-lines th { color: white !important; background: #172522 !important; border-top: 0; border-bottom: 0; }
  .invoice-lines tbody tr:nth-child(even) td { background: #fafbfb !important; }
  .invoice-lines tr { break-inside: avoid; }
  .invoice-closing { display: grid !important; grid-template-columns: minmax(0, 1fr) 66mm !important; gap: 12mm; padding-top: 6mm; }
  .invoice-totals .total { background: #edf5f2 !important; }
  .invoice-footer { display: grid !important; grid-template-columns: 1fr 64mm !important; gap: 12mm; margin-top: auto; padding-top: 10mm; }
  .signature-area img { display: none; }
  .print-with-auth .signature-area img { display: block !important; visibility: visible !important; opacity: 1 !important; }
  a { text-decoration: none !important; }
}
