:root {
  --color-bg: #f3f2f2;
  --color-surface: #eae9e9;
  --color-text: #201e1d;
  --color-accent: #ec3013;
  --color-divider: color-mix(in srgb, #201e1d 40%, transparent);
  --color-neutral-100: #f8f4f4;
  --color-neutral-200: #eae7e7;
  --color-neutral-300: #d7d3d3;
  --color-neutral-400: #bab6b6;
  --color-neutral-500: #9b9797;
  --color-neutral-600: #7d7979;
  --color-neutral-700: #605d5d;
  --color-neutral-800: #444141;
  --color-neutral-900: #2d2b2b;
  --color-accent-100: #fff2ef;
  --color-accent-200: #ffe0d9;
  --color-accent-300: #ffc4b8;
  --color-accent-400: #ff9783;
  --color-accent-500: #ff563c;
  --color-accent-600: #dd2b0f;
  --color-accent-700: #ae1800;
  --color-accent-800: #7c1405;
  --font-heading: "Archivo", system-ui, sans-serif;
  --font-body: "Archivo", system-ui, sans-serif;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --shadow-sm: 0 1px 2px color-mix(in srgb, #2d2b2b 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #2d2b2b 16%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #2d2b2b 22%, transparent);
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--color-bg); color: var(--color-text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.55;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading); font-weight: 800;
  line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 var(--space-2);
}
h1 { font-size: 42px; } h3 { font-size: 25px; } h4 { font-size: 20px; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
.text-muted { color: var(--color-neutral-600); }
.card-kicker {
  color: var(--color-accent); font-size: 10px; font-weight: 800;
  letter-spacing: .16em; text-transform: uppercase;
}
.tag {
  display: inline-block; padding: 4px 9px; font-size: 10px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--color-divider);
}
.tag-accent { color: var(--color-accent-700); border-color: var(--color-accent-300); background: var(--color-accent-100); }
.tag-neutral { color: var(--color-neutral-700); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; font: inherit; font-size: 13px; font-weight: 800;
  border: 1px solid var(--color-text); cursor: pointer; background: transparent;
  color: var(--color-text); text-decoration: none; transition: background 150ms ease, color 150ms ease;
}
.btn-primary { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-700); border-color: var(--color-accent-700); }
.btn-secondary:hover { background: var(--color-text); color: #fff; }
.input {
  width: 100%; padding: 12px 14px; font: inherit; font-size: 14px;
  border: 1px solid var(--color-neutral-400); background: #fff; color: var(--color-text);
}
.input:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }

/* ── Login (redesigned: vermilion-spine dark entry) ───────── */
.login-shell {
  min-height: 100vh; display: grid; place-items: center;
  padding: clamp(16px, 4vw, 64px); color: #f5f2ef;
  background: radial-gradient(130% 100% at 100% 0%, #2c1714 0%, transparent 55%), #141110;
}
.login-panel {
  width: min(100%, 960px); display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(340px, 1.05fr);
  border: 1px solid #322c29; background: #1b1715; overflow: hidden;
  box-shadow: 0 40px 120px rgba(0,0,0,.6);
}
.login-brand {
  position: relative; min-height: 520px; display: flex; flex-direction: column;
  justify-content: space-between; gap: 32px; padding: 52px 44px;
  border-right: 1px solid #322c29;
  background: linear-gradient(160deg, #241b19 0%, #171211 100%);
}
.login-brand::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--color-accent); }
.login-brand-top { display: flex; flex-direction: column; gap: 26px; }
.login-logo { width: min(100%, 188px); height: auto; }
.login-tagline {
  margin: 0; font-family: var(--font-heading); font-weight: 800;
  font-size: clamp(22px, 2.5vw, 31px); line-height: 1.06; letter-spacing: -.02em;
  color: #fff; text-wrap: balance;
}
.login-tagline em { color: var(--color-accent); font-style: normal; }
.login-brand-note {
  margin: 0; color: #8a807b; font-size: 10px; font-weight: 800;
  letter-spacing: .2em; text-transform: uppercase;
}
.login-brand-foot {
  display: flex; align-items: center; gap: 10px; color: #6f6763;
  font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
}
.login-brand-foot::before { content: ""; width: 20px; height: 2px; background: var(--color-accent); }
.login-access { display: flex; flex-direction: column; justify-content: center; padding: clamp(34px, 4vw, 52px); background: #1b1715; }
.login-kicker {
  display: block; margin-bottom: 12px; color: var(--color-accent-500);
  font-size: 10px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase;
}
.login-title { margin: 0; color: #fff; font-size: clamp(30px, 3.6vw, 44px); letter-spacing: -.035em; line-height: 1; }
.login-intro { max-width: 360px; margin: 12px 0 26px; color: #9a908b; font-size: 13.5px; line-height: 1.5; }
.login-field label { display: block; margin-bottom: 7px; color: #b7ada8; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.login-field .input { color: #fff; border-color: #3a332f; background: #120f0e; }
.login-field .input:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; border-color: var(--color-accent); }
.login-actions { margin-top: 20px; }
.login-msg { margin: 16px 0 0; font-size: 13px; color: #9a908b; }
.login-msg a { color: var(--color-accent-400); font-weight: 700; }
.login-msg.is-error { color: #ff8c7a; }
.login-msg.is-ok { color: #7fd18f; }
.login-security-note {
  margin: 26px 0 0; color: #5f5752; font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
}

/* ── App shell ───────────────────────────────────────────── */
.nav {
  display: flex; align-items: center; gap: var(--space-4);
  padding: 10px var(--space-6); border-bottom: 1px solid var(--color-divider); background: var(--color-bg);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.nav-brand { display: flex; align-items: center; gap: 8px; background: var(--color-neutral-900); padding: 4px 10px; }
.nav-brand img { height: 26px; width: auto; }
.nav a {
  color: var(--color-text); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 6px 2px; border-bottom: 2px solid transparent; cursor: pointer;
}
.nav a.is-active { color: var(--color-accent); border-bottom-color: var(--color-accent); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }
main { flex: 1; padding: var(--space-6); max-width: 1280px; width: 100%; margin: 0 auto; }

.md-dashboard { display: grid; gap: var(--space-6); }
.md-dashboard-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4);
  padding-bottom: var(--space-4); border-bottom: 2px solid var(--color-text);
}
.md-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: var(--space-3); }
.md-kpi {
  min-height: 120px; display: flex; flex-direction: column; justify-content: space-between;
  padding: var(--space-4); border-top: 3px solid var(--color-text); background: var(--color-surface);
}
.md-kpi.is-accent { border-top-color: var(--color-accent); }
.md-kpi-value { display: block; font-size: clamp(25px,3vw,36px); font-weight: 800; line-height: 1; letter-spacing: -.035em; }
.md-kpi-detail { display: block; margin-top: 10px; color: var(--color-neutral-600); font-size: 11px; }
.md-section { padding: var(--space-4); border: 1px solid var(--color-divider); background: var(--color-neutral-100); }
.md-section-header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.md-section-header h3 { margin: 0; }
.md-empty { padding: 26px; border: 1px dashed var(--color-neutral-400); color: var(--color-neutral-600); font-size: 13px; text-align: center; }
.md-attention-list { display: grid; gap: var(--space-2); }
.md-attention-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 12px 0; border-bottom: 1px solid var(--color-divider);
}
.md-attention-item:last-child { border-bottom: 0; }
.md-attention-count { min-width: 36px; font-size: 22px; font-weight: 800; text-align: right; }

.fin-strip { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--space-4); }
.cash-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3);
  padding: 9px 0; border-bottom: 1px solid var(--color-divider); font-size: 13px;
}
.cash-row:last-child { border-bottom: 0; }
.cash-row strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cash-row.is-total { border-top: 2px solid var(--color-text); font-weight: 800; }
.cash-row.is-remaining { background: var(--color-accent-100); padding: 9px 8px; font-weight: 800; }

/* ── Tables / register ───────────────────────────────────── */
.tx-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.tx-toolbar .input { max-width: 340px; }
.tabs { display: flex; border-bottom: 2px solid var(--color-text); }
.tab {
  padding: 9px 14px; border: 0; border-right: 1px solid var(--color-neutral-300);
  background: transparent; color: var(--color-neutral-600); font: inherit; font-size: 12px; font-weight: 800; cursor: pointer;
}
.tab.is-active { background: var(--color-text); color: #fff; }
.sheet { background: var(--color-neutral-100); border: 1px solid var(--color-neutral-400); box-shadow: var(--shadow-sm); }
.sheet-hint {
  padding: 7px 14px; border-bottom: 1px solid var(--color-neutral-400); background: var(--color-neutral-200);
  color: var(--color-neutral-700); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
}
.table-wrap { overflow-x: auto; background: #fff; }
table.grid { border-collapse: collapse; margin: 0; font-variant-numeric: tabular-nums; width: 100%; }
table.grid.wide { min-width: 1560px; font-size: 11px; }
table.grid.wide th { padding: 8px 7px; font-size: 9.5px; }
table.grid.wide td { padding: 7px 7px; font-size: 10.5px; }
.ledger-teamband { margin-bottom: var(--space-4); }
.ledger-teamband-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.ledger-teamband-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.grid th {
  padding: 10px 8px; border-right: 1px solid var(--color-neutral-500); border-bottom: 2px solid var(--color-text);
  background: var(--color-neutral-200); color: var(--color-neutral-900); font-size: 10px; line-height: 1.25;
  text-align: left; vertical-align: bottom; white-space: normal;
}
.grid td { padding: 10px 8px; border-right: 1px solid var(--color-neutral-300); border-bottom: 1px solid var(--color-neutral-300); font-size: 11px; line-height: 1.3; vertical-align: top; }
.grid .numeric { text-align: right; white-space: nowrap; }
.grid .unit-cell { background: #fff8a8; text-align: center; font-weight: 800; }
.grid .tp-cell { background: #eef6e9; }
.grid .total-row td { background: var(--color-neutral-900); color: #fff; font-weight: 800; border-color: var(--color-neutral-700); }
.expiry-days { font-weight: 800; white-space: nowrap; }
.expiry-days.is-overdue { color: var(--color-accent-700); }
.expiry-tier { margin-bottom: var(--space-4); }
.expiry-tier h4 { margin: 0 0 var(--space-2); }

/* ── Ledger ──────────────────────────────────────────────── */
.ledger-layout { display: grid; grid-template-columns: 250px minmax(0,1fr); gap: var(--space-5); align-items: start; }
.ledger-panel { max-height: calc(100vh - 120px); overflow: auto; }
.ledger-agent {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px;
  border: 1px solid transparent; background: var(--color-neutral-100); cursor: pointer; margin-bottom: 6px;
}
.ledger-agent.is-active { border-color: var(--color-accent); }
.ledger-agent-amt { flex: none; font-weight: 800; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--color-text); }
.ledger-agent-amt.is-zero { color: var(--color-neutral-500); font-weight: 600; }
.ledger-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--color-accent-100); color: var(--color-accent-800);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; flex: none;
}
.ledger-metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1px; background: var(--color-neutral-400); margin-bottom: var(--space-4); }
.ledger-metric { padding: 14px; background: #fff; }
.ledger-metric.is-accent { background: var(--color-accent-100); }
.ledger-metric-label { display: block; color: var(--color-neutral-700); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.ledger-metric-value { display: block; margin-top: 6px; font-size: 20px; font-weight: 800; }

.spinner { padding: 60px; text-align: center; color: var(--color-neutral-600); }

/* ── Modal / deal form ───────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(20,18,17,.55);
  display: grid; place-items: center; padding: 16px; overflow: auto;
}
.modal {
  width: min(860px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--color-bg); border: 1px solid var(--color-neutral-400); box-shadow: var(--shadow-lg);
}
.modal-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px; background: var(--color-neutral-900); color: #fff;
}
.modal-head h3 { margin: 0; color: #fff; font-size: 18px; }
.modal-body { padding: 18px; }
.modal-close { background: none; border: 0; color: #fff; font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.form-grid .field label {
  display: block; margin-bottom: 5px; color: var(--color-neutral-700);
  font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.form-grid .input { padding: 9px 11px; font-size: 13px; }
.form-section {
  grid-column: 1 / -1; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--color-neutral-300);
  color: var(--color-accent); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
}
.form-note { grid-column: 1 / -1; color: var(--color-neutral-600); font-size: 11px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.form-msg { color: var(--color-accent-700); font-size: 12px; margin-right: auto; align-self: center; }
.row-actions { display: flex; gap: 6px; }
.btn-mini { padding: 5px 9px; font-size: 11px; }
.contract-modal { width: min(1100px, 100%); }
.contract-form-section { margin-bottom: 18px; padding: 14px; border: 1px solid var(--color-neutral-300); background: #fff; }
.contract-form-section h4 { margin: 0 0 12px; color: var(--color-accent-700); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.compact-field { min-width: 120px; margin: 0; font-size: 10px; }
.compact-field .input { min-width: 110px; padding: 6px 8px; }
.contract-print-shell { position: fixed; inset: 0; z-index: 100; overflow: auto; padding: 24px; background: #292929; }
.contract-print-toolbar { position: sticky; top: 0; z-index: 4; width: min(210mm,100%); margin: 0 auto 16px; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; color: #fff; background: #171717; box-shadow: var(--shadow-lg); }
.contract-print-toolbar .btn-secondary { color: #fff; border-color: #666; }
.contract-draft-watermark { position: fixed; z-index: 3; left: 50%; top: 50%; transform: translate(-50%,-50%) rotate(-28deg); color: rgba(185,28,28,.18); font-size: 110px; font-weight: 800; pointer-events: none; }
.dld-print-page { position: relative; width: min(210mm,100%); aspect-ratio: 210 / 297; margin: 0 auto 18px; overflow: hidden; background: #fff; box-shadow: 0 12px 32px rgba(0,0,0,.35); }
.dld-print-page > img { position: absolute; inset: 0; width: 100%; height: 100%; }
.dld-fill, .addendum-fill { position: absolute; z-index: 1; overflow: hidden; color: #111a42; font-family: Arial,sans-serif; font-size: clamp(8px,.92vw,11px); font-weight: 700; line-height: 1.15; }
.addendum-fill { color: #111; }
.dld-terms-fill { line-height: 1.65; }
.addendum-custom { white-space: pre-line; border: 1px solid #d5d5d5; background: #fff; }

@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr 1fr; } .contract-print-shell { padding: 8px; } .contract-print-toolbar { align-items: flex-start; } }

@media (max-width: 960px) {
  .md-kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .fin-strip { grid-template-columns: 1fr; }
  .ledger-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .login-panel { grid-template-columns: 1fr; }
  .login-brand { min-height: auto; padding: 40px 28px 24px; border-right: 0; border-bottom: 1px solid #262626; }
  .md-kpi-grid { grid-template-columns: 1fr; }
}

/* ── daily-control department progress bars ── */
.dept-progress { margin-bottom: 12px; }
.dept-progress:last-child { margin-bottom: 0; }
.dept-progress-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin-bottom: 5px; }
.dept-progress-head strong { font-size: 15px; }
.dept-progress-track { height: 8px; border-radius: 999px; background: var(--color-neutral-300); overflow: hidden; }
.dept-progress-fill { height: 100%; border-radius: 999px; background: var(--color-accent); transition: width .3s ease; min-width: 2px; }

/* ── daily activity feed ── */
.activity-feed { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.activity-item { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.activity-item .tag { flex: 0 0 auto; }

/* ── team activity (owner) ── */
.activity-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--space-4); }

/* ── dashboard global search ── */
.dash-search { position: relative; margin-bottom: 20px; max-width: 560px; }
.dash-search-results { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; background: var(--color-neutral-100); border: 1px solid var(--color-neutral-300); border-radius: 10px; padding: 8px; box-shadow: var(--shadow-sm); }
.dash-search-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font: inherit; }
.dash-search-item:hover { background: var(--color-neutral-200); }
.dash-search-item strong { font-size: 13px; }
.dash-search-item span { font-size: 12px; }

/* ── expiry / reminder rows (dashboard cards, renewal reminders) ── */
.expiry-list { display: grid; gap: 4px; }
.expiry-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--color-divider); }
.expiry-row:last-child { border-bottom: 0; }

/* invoice print — bill-to and details columns (companions to .inv-meta) */
.inv-billto { display: grid; gap: 6px; align-content: start; }
.inv-fields { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-content: start; align-items: center; }

/* ── receipt print (companion to the tax-invoice styles) ── */
.rcpt-band { width: 340px; margin: 8px 0 26px auto; padding: 8px 4px; display: flex; justify-content: space-between; gap: 12px; border-top: 1.5px solid #1a1a1a; border-bottom: 1.5px solid #1a1a1a; font-size: 14px; }
.rcpt-total td { border-top: 1.5px solid #1a1a1a; padding: 8px 4px; }

/* ── addendum clause removal ── */
.clause-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 4px 14px; margin-top: 6px; }
.clause-check { display: flex; align-items: flex-start; gap: 7px; font-size: 12px; font-weight: 400; cursor: pointer; }
.clause-check input { margin-top: 2px; flex: 0 0 auto; }
.clause-whiteout { position: absolute; left: 1.5%; width: 96.5%; background: #fff; }

/* ── official commission statement print ── */
.ls-shell { position: fixed; inset: 0; z-index: 100; overflow: auto; padding: 20px; background: #292929; }
.ls-toolbar { position: sticky; top: 0; }
.ls-sheet { width: 297mm; min-height: 210mm; margin: 16px auto; background: #fff; color: #111; padding: 12mm; box-shadow: var(--shadow-lg); font-size: 9px; }
.ls-head { margin-bottom: 6px; }
.ls-logo { height: 34px; width: auto; }
.ls-title { border-collapse: collapse; margin-bottom: 8px; }
.ls-title td { border: 1px solid #111; padding: 2px 8px; font-size: 10px; }
.ls-t1 { font-weight: 800; } .ls-t2 { font-weight: 800; text-align: center; }
.ls-lbl { font-weight: 700; width: 120px; } .ls-val { font-weight: 700; min-width: 200px; }
.ls-grid { width: 100%; border-collapse: collapse; }
.ls-grid th, .ls-grid td { border: 1px solid #111; padding: 3px 4px; vertical-align: middle; }
.ls-grid th { font-size: 8px; font-weight: 800; text-align: center; background: #f2f2f2; }
.ls-num { text-align: right; white-space: nowrap; }
.ls-total td { font-weight: 800; text-align: right; }
.ls-total td:first-child { text-align: center; }
.ls-lower { display: flex; justify-content: center; margin-top: 18px; }
.ls-summary { border-collapse: collapse; width: 340px; }
.ls-summary td { border: 1px solid #111; padding: 4px 8px; font-size: 10px; }
.ls-sum-label { font-weight: 700; }
.ls-incl { font-weight: 800; background: #eef3e7; }
.ls-sign { display: flex; gap: 120px; margin-top: 40px; padding-left: 8px; }
.ls-sign-name { font-weight: 800; font-size: 11px; }
.ls-sign-role { font-weight: 700; font-size: 10px; }

@media print {
  body:has(.ls-shell) * { visibility: hidden !important; }
  body:has(.ls-shell) .ls-shell, body:has(.ls-shell) .ls-shell * { visibility: visible !important; }
  body:has(.ls-shell) .ls-toolbar { display: none !important; }
  body:has(.ls-shell) .ls-shell { position: absolute; inset: 0; background: #fff; padding: 0; overflow: visible; }
  body:has(.ls-shell) .ls-sheet { width: 297mm; margin: 0; box-shadow: none; }
  @page { size: A4 landscape; }

  @page { size: A4; margin: 0; }
  body { background: #fff; }
  body:has(.contract-print-shell) * { visibility: hidden !important; }
  body:has(.contract-print-shell) .contract-print-shell,
  body:has(.contract-print-shell) .contract-print-shell * { visibility: visible !important; }
  body:has(.contract-print-shell) .contract-print-toolbar { display: none !important; }
  body:has(.contract-print-shell) .contract-print-shell { position: absolute; inset: 0; overflow: visible; padding: 0; background: #fff; }
  body:has(.contract-print-shell) .dld-print-page { width: 210mm; height: 297mm; margin: 0; box-shadow: none; break-after: page; page-break-after: always; }
  body:has(.contract-print-shell) .dld-print-page:last-child { break-after: auto; page-break-after: auto; }
  body:has(.contract-print-shell) .dld-print-page,
  body:has(.contract-print-shell) .dld-print-page * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .nav, .ledger-panel, .tabs, .btn { display: none !important; }
  main { padding: 0; max-width: none; }
  .ledger-layout { display: block; }
  .sheet, .ledger-metrics { break-inside: avoid; box-shadow: none; }
  .table-wrap { overflow: visible; }
  .grid { font-size: 9px; }
}

/* ── Tax invoice draft + print ────────────────────────────── */
.inv-print-shell { position: fixed; inset: 0; z-index: 100; overflow: auto; padding: 24px; background: #292929; }
.inv-toolbar { position: sticky; top: 0; z-index: 4; width: min(210mm,100%); margin: 0 auto 16px; }
.inv-sheet { position: relative; width: min(210mm,100%); min-height: 297mm; margin: 0 auto; padding: 16mm 14mm; background: #fff; color: #1a1a1a; box-shadow: 0 12px 32px rgba(0,0,0,.35); font-size: 12px; line-height: 1.4; }
.inv-watermark { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 120px; font-weight: 800; color: rgba(236,48,19,.06); letter-spacing: .1em; pointer-events: none; }
.inv-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.inv-title { margin: 0; font-size: 34px; letter-spacing: -.01em; }
.inv-logo { width: 92px; height: auto; filter: invert(1); print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.inv-meta { display: grid; grid-template-columns: 1.1fr .9fr 1fr; gap: 18px; margin-bottom: 26px; }
.inv-lbl { display: block; font-weight: 700; font-size: 11px; margin: 6px 0 2px; }
.inv-company strong { display: block; margin-bottom: 2px; }
.inv-company div { color: #333; }
.inv-in { width: 100%; border: 1px dashed #cfcfcf; background: #fbfbfb; font: inherit; color: inherit; padding: 2px 4px; }
.inv-in:focus { outline: 2px solid var(--color-accent); background: #fff; }
.inv-ta { resize: vertical; }
.inv-items { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.inv-items th { text-align: left; border-bottom: 1.5px solid #1a1a1a; padding: 6px 4px; font-size: 11px; }
.inv-items th.num, .inv-items td.num { text-align: right; }
.inv-items td { padding: 8px 4px; vertical-align: top; border-bottom: 1px solid #e5e5e5; }
.inv-buyer { margin-top: 4px; color: #333; }
.inv-totals { width: 300px; margin-left: auto; margin-bottom: 40px; }
.inv-total-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 4px; }
.inv-total-row.is-grand { border-top: 1.5px solid #1a1a1a; font-weight: 800; font-size: 14px; }
.inv-foot { margin-top: 20px; }
.inv-due { margin-bottom: 10px; }
.inv-bank div { line-height: 1.5; }
.inv-sign { margin-top: 30px; position: relative; height: 130px; }
.inv-sign-img { position: absolute; top: 6px; left: 10px; width: 150px; height: auto; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.inv-stamp-img { position: absolute; top: 0; left: 120px; width: 120px; height: auto; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.inv-sign-label { position: absolute; top: 116px; left: 10px; font-size: 10px; color: #666; }
.inv-registered { margin-top: 40px; padding-top: 8px; border-top: 1px solid #ddd; font-size: 10px; color: #666; }
@media (max-width: 720px) { .inv-meta { grid-template-columns: 1fr; } .inv-print-shell { padding: 8px; } }
@media print {
  body:has(.inv-print-shell) * { visibility: hidden !important; }
  body:has(.inv-print-shell) .inv-print-shell,
  body:has(.inv-print-shell) .inv-print-shell * { visibility: visible !important; }
  body:has(.inv-print-shell) .inv-toolbar { display: none !important; }
  body:has(.inv-print-shell) .inv-print-shell { position: absolute; inset: 0; overflow: visible; padding: 0; background: #fff; }
  body:has(.inv-print-shell) .inv-sheet { width: 210mm; min-height: 297mm; margin: 0; box-shadow: none; }
  body:has(.inv-print-shell) .inv-in { border: none !important; background: transparent !important; padding: 0 !important; }
  body:has(.inv-print-shell) .inv-watermark { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ── dashboard redesign: collection-rate hero + severity ladder ──────────── */
:root { --sev-crit:#c22110; --sev-warn:#b17516; --sev-ok:#3f7549; }
.md-dashboard-header.has-collect { align-items: stretch; flex-wrap: wrap; }
.md-dashboard-header.has-collect > div:first-child { align-self: flex-end; }
.md-collect { min-width: 340px; flex: 1 1 340px; padding: var(--space-5); background: var(--color-neutral-900); color: #fff; }
.md-collect-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.md-collect-top .card-kicker { color: #ff9d88; }
.md-collect-pct { font-size: clamp(38px,6vw,54px); font-weight: 800; line-height: .85; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.md-meter { height: 14px; background: #4a4747; overflow: hidden; }
.md-meter-fill { height: 100%; background: var(--color-accent); position: relative; min-width: 2px; }
.md-meter-fill::after { content: ""; position: absolute; inset: 0 0 0 auto; width: 2px; background: #fff; opacity: .85; }
.md-collect-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); margin-top: var(--space-4); }
.md-collect-legend .lg-label { display: block; margin-bottom: 3px; color: #a9a5a5; font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.md-collect-legend strong { font-size: 15px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.md-collect-legend .lg-out strong { color: #ff9d88; }

.md-ladder { display: grid; gap: var(--space-2); }
.md-rung { display: grid; grid-template-columns: 4px auto 1fr auto; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--color-divider); }
.md-rung:last-child { border-bottom: 0; }
.md-rung .stripe { align-self: stretch; min-height: 34px; }
.md-rung.crit .stripe { background: var(--sev-crit); }
.md-rung.warn .stripe { background: var(--sev-warn); }
.md-rung.watch .stripe { background: var(--color-neutral-400); }
.md-rung-label strong { display: block; font-size: 14px; font-weight: 800; }
.md-rung-label span { font-size: 11px; color: var(--color-neutral-600); }
.md-rung-eg { min-width: 0; overflow: hidden; font-size: 11px; color: var(--color-neutral-600); text-overflow: ellipsis; white-space: nowrap; }
.md-rung-count { min-width: 40px; font-size: 26px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.md-rung.crit .md-rung-count { color: var(--sev-crit); }

@media (max-width: 820px) {
  .md-dashboard-header.has-collect { flex-direction: column; align-items: stretch; }
  .md-collect { min-width: 0; }
}
