:root { --ink: #162638; --muted: #546679; --accent: #116151; --line: #dbe5e9; }
body { background: #f2f6f7; color: var(--ink); }
a { color: #0d6154; text-underline-offset: .15em; }
a:hover { color: #084238; }
h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); font-weight: 730; letter-spacing: -.045em; margin: 0; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.workspace { max-width: 1160px; }
.brand { color: var(--ink); text-decoration: none; font-weight: 750; white-space: nowrap; display: inline-flex; gap: .6rem; align-items: center; }
.brand-mark { background: #133b36; color: #fff; border-radius: .65rem; width: 2.2rem; height: 2.2rem; display: inline-grid; place-items: center; font-size: .78rem; }
.menu a { color: var(--muted); padding: .4rem .65rem; border-radius: .45rem; text-decoration: none; font-weight: 550; }
.menu a[aria-current], .menu a:hover { color: #10443a; background: #e2f0ec; }
.heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.6rem; }
.heading p { color: var(--muted); margin: .35rem 0 0; }
.panel { background: #fff; padding: clamp(1rem, 3vw, 1.65rem); border: 1px solid var(--line); border-radius: .9rem; overflow-wrap: anywhere; }
.metric .amount { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 730; font-variant-numeric: tabular-nums; }
.metric h2 { color: #176455; font-weight: 700; }
.narrow { max-width: 720px; }
.login-panel { max-width: 425px; margin-top: min(9vh, 6rem); }
.back { display: inline-block; margin-bottom: .65rem; }
.search { max-width: 490px; }
.btn-primary { --bs-btn-bg: #116151; --bs-btn-border-color: #116151; --bs-btn-hover-bg: #0b4c3f; --bs-btn-hover-border-color: #0b4c3f; --bs-btn-active-bg: #0b4c3f; --bs-btn-active-border-color: #0b4c3f; }
.form-control:focus, .form-select:focus { border-color: #399886; box-shadow: 0 0 0 .2rem #11615124; }
.table { --bs-table-color: var(--ink); --bs-table-border-color: var(--line); }
.table th, .table td { padding: .8rem; }
.table thead th { color: #495d72; background: #f3f7f8; font-size: .9rem; white-space: nowrap; }
.status { display: inline-block; white-space: nowrap; border-radius: 2rem; padding: .25rem .6rem; background: #eaf0f5; color: #314a65; font-size: .875rem; }
.status[data-status="Paid"] { background: #dff3e8; color: #155638; }
.status[data-status="Overdue"] { background: #ffe7e2; color: #852d1e; }
.item-row { padding: .9rem 0 .25rem; border-top: 1px solid var(--line); }
.item-row input[type=checkbox] { width: 1rem; height: 1rem; margin-right: .4rem; }
.invoice-totals { max-width: 340px; }
.invoice-totals div { display: flex; justify-content: space-between; gap: 1rem; }
.invoice-totals dd { white-space: nowrap; }
.balance { border-top: 1px solid var(--line); padding-top: .65rem; }
@media print {
  @page { size: A4; margin: 15mm; }
  body { background: white; }
  .topbar, .alert { display: none; }
  main.workspace { padding: 0 !important; max-width: none; }
  .invoice-paper { padding: 0; border: 0; }
  .invoice-paper tr, .invoice-totals { break-inside: avoid; }
  .client-history { padding: 0; border: 0; }
  .client-history .table-responsive { overflow: visible; }
  .client-history th, .client-history td { padding: .4rem; }
  .client-history .table thead th, .client-history .status { white-space: normal; }
  .client-history tr { break-inside: avoid; }
  .client-history h2 { break-after: avoid; }
}

.invoice-signoff {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(11rem, .55fr);
  gap: 1.3rem;
  margin-top: 1.2rem;
  padding-top: .8rem;
  border-top: 1px solid var(--line);
}
.invoice-signoff p { margin-bottom: 0; }
.invoice-signature { font-size: .85rem; }
.invoice-signature-line { height: 1.55rem; border-bottom: 1px solid currentColor; }
.invoice-signature-date { display: flex; align-items: baseline; gap: .4rem; margin-top: .55rem; }
.invoice-signature-date span { width: 6.5rem; border-bottom: 1px solid currentColor; }
@media screen and (max-width: 520px) {
  .invoice-signoff { grid-template-columns: 1fr; }
}
@media print {
  .invoice-a4 { font-size: 9pt; line-height: 1.3; }
  .invoice-a4 h1 { font-size: 22pt; }
  .invoice-a4 h2 { font-size: 10pt; margin-bottom: 2mm; }
  .invoice-a4 .mb-4 { margin-bottom: 4mm !important; }
  .invoice-a4 .pb-3 { padding-bottom: 3mm !important; }
  .invoice-a4 .table-responsive { overflow: visible; }
  .invoice-a4 .table { margin-bottom: 0; }
  .invoice-a4 .table th, .invoice-a4 .table td { padding: 1.5mm 2mm; }
  .invoice-a4 .table thead th { font-size: 9pt; white-space: normal; }
  .invoice-a4 .table thead { display: table-header-group; }
  .invoice-a4 .invoice-totals { margin-top: 4mm !important; margin-bottom: 3mm; }
  .invoice-a4 .invoice-totals dd { margin-bottom: 1mm; }
  .invoice-a4 .balance { padding-top: 1.5mm; }
  .invoice-a4 p { margin-bottom: 2mm; }
  .invoice-a4 .invoice-signoff {
    margin-top: 3mm;
    padding-top: 3mm;
    gap: 6mm;
    break-inside: avoid;
  }
  .invoice-a4 .invoice-signoff p { margin: 0; }
  .invoice-a4 .invoice-signature { font-size: 8pt; }
  .invoice-a4 .invoice-signature-line { height: 7mm; }
}
