/* Novalar Invoicing — module stylesheet.
   Visual language follows Client Operations (portal/design-tokens.css): soft
   elevation, large radii, a dense type scale and pill status chips. The brand
   palette is unchanged — navy and blue are the same values the Tracker uses.

   The invoice document itself (.inv-preview and below) is deliberately NOT
   restyled: it is a printed business record, not app chrome. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Aliases for the Tracker variable names the generated markup still emits
     inline (color:var(--muted) etc.), remapped onto the Portal tokens. */
  --navy:      #1a2744;
  --blue:      #2a5298;
  --text:      #1c2940;
  --text-mid:  #44557a;
  --muted:     #6f7f99;
  --muted2:    #98a5b8;
  --border:    #dce3e7;
  --border2:   #b9c7d9;
  --surface:   #ffffff;
  --surface2:  #f4f7fc;
  --blue-soft: #eaf0fa;
  --green:     #2e7d52;
  --green-bg:  #eaf4ef;
  --red:       #b43a32;
  --red-bg:    #fdf0ee;
  --amber:     #99610e;
  --amber-bg:  #fff5df;

  --bg:            #f5f6f2;
  --shadow:        0 14px 36px rgba(26, 39, 68, 0.07);
  --shadow-soft:   0 7px 22px rgba(26, 39, 68, 0.035);
  --radius:        13px;
  --radius-lg:     20px;
  --radius-sm:     9px;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── Shell ──────────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar { background: var(--navy); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 26px 22px 22px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.brand-logo { display: flex; align-items: center; gap: 11px; }
.brand-fsuss { background: #fff; border-radius: var(--radius-sm); padding: 11px 13px; }
.brand-fsuss img { width: 100%; display: block; }
.brand-n { width: 34px; height: 34px; background: #fff; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; color: var(--navy); flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 12.5px; color: #fff; letter-spacing: 0.05em; text-transform: uppercase; line-height: 1.2; }
.brand-sub { font-size: 9.5px; color: rgba(255,255,255,0.38); letter-spacing: 0.1em; text-transform: uppercase; }

nav { padding: 18px 13px; flex: 1; }
.nav-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.16em; color: rgba(255,255,255,0.3); padding: 0 10px; margin: 18px 0 7px; font-weight: 700; }
.nav-label:first-child { margin-top: 0; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.62); cursor: pointer; transition: background 0.15s, color 0.15s; border: none; background: none; width: 100%; font-family: inherit; text-align: left; text-decoration: none; }
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.13); color: #fff; }
.nav-icon { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; width: 20px; text-align: center; opacity: 0.85; }

.sidebar-bottom { padding: 16px; border-top: 1px solid rgba(255,255,255,0.07); }
.user-info { display: flex; flex-direction: column; gap: 9px; }
.user-email { font-size: 11px; color: rgba(255,255,255,0.45); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-signout { width: 100%; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: rgba(255,255,255,0.66); font-family: inherit; font-size: 12px; font-weight: 600; padding: 8px; border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s; }
.btn-signout:hover { background: rgba(180,58,50,0.28); border-color: rgba(180,58,50,0.4); color: #fca5a5; }

main { padding: 40px 44px 64px; max-width: 1560px; }
.page { display: none; }
.page.active { display: block; }

/* ── Page heading ───────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; flex-wrap: wrap; margin-bottom: 30px; }
.page-title { color: var(--navy); font-size: clamp(1.9rem, 4vw, 2.7rem); line-height: 1.06; letter-spacing: -0.05em; font-weight: 700; }
.page-title span { font-weight: 400; color: var(--muted); }

/* ── Stat cards ─────────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(212px, 1fr)); gap: 15px; margin-bottom: 30px; }
/* The accent is a top border because renderInvoiceStats sets border-top-color
   inline per card. Keep it a border, not a pseudo-element, or that breaks. */
.stat-card { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--navy); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow); }
.stat-card:nth-child(2) { border-top-color: #2e3f6e; }
.stat-card:nth-child(3) { border-top-color: #4a6eb5; }
.stat-card:nth-child(4) { border-top-color: #6a8fd0; }
.stat-label { font-size: 0.63rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 9px; }
.stat-value { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.035em; color: var(--navy); line-height: 1.1; }
.stat-sub { font-size: 0.7rem; color: var(--muted); margin-top: 6px; line-height: 1.45; }

/* ── Filters ────────────────────────────────────────────────────────────── */
.filter-tabs { display: inline-flex; gap: 3px; padding: 4px; background: rgba(255,255,255,0.85); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow-soft); flex-wrap: wrap; }
.filter-tab { border: none; background: none; font-family: inherit; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; color: var(--muted); padding: 8px 15px; border-radius: 999px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.filter-tab:hover { color: var(--navy); background: var(--surface2); }
.filter-tab.active { background: var(--navy); color: #fff; }

.view-tabs { display: inline-flex; gap: 3px; padding: 3px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.view-tab { border: none; background: none; font-family: inherit; font-size: 0.7rem; font-weight: 700; color: var(--muted); padding: 7px 13px; border-radius: 6px; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.view-tab:hover { color: var(--navy); }
.view-tab.active { background: var(--navy); color: #fff; }

.log-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; padding: 14px 16px; background: rgba(255,255,255,0.9); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.search-input, .filter-select {
  font-family: inherit; font-size: 0.76rem; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 12px; min-height: 38px; transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input { flex: 1; }
.search-input::placeholder { color: var(--muted2); }
.search-input:focus, .filter-select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42,82,152,0.1); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.73rem; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: #27395f; }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--border2); background: var(--surface2); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.48; cursor: default; }

.icon-btn { border: 1px solid transparent; background: none; color: var(--muted); font-family: inherit; font-size: 12px; padding: 5px 7px; border-radius: 6px; cursor: pointer; transition: all 0.15s; }
.icon-btn:hover { background: var(--surface2); border-color: var(--border); color: var(--navy); }
.icon-btn.del:hover { background: var(--red-bg); border-color: rgba(180,58,50,0.25); color: var(--red); }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card, .settings-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-title { font-size: 0.95rem; font-weight: 700; letter-spacing: -0.02em; color: var(--navy); }
.settings-section-title { font-size: 0.63rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--blue); margin-bottom: 14px; }
.badge { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 999px; background: var(--surface2); color: var(--muted); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

.entity-profiles-heading { max-width: 760px; margin: 28px 0 14px; }
.entity-profiles-heading h2 { margin: 0 0 4px; color: var(--navy); font-size: 1rem; }
.entity-profiles-heading p { margin: 0; color: var(--muted); font-size: 0.76rem; }
.entity-profile-card { max-width: 760px; }
.entity-profile-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.entity-profile-head .settings-section-title { margin-bottom: 5px; }
.entity-profile-legal, .entity-profile-hint { color: var(--muted); font-size: 0.7rem; line-height: 1.5; }
.entity-profile-logo { width: 190px; height: 72px; display: flex; align-items: center; justify-content: flex-end; flex-shrink: 0; }
.entity-profile-logo img { max-width: 100%; max-height: 72px; object-fit: contain; }
.entity-profile-logo span { color: var(--navy); font-size: 1rem; font-weight: 700; text-align: right; }
.entity-logo-actions { display: flex; gap: 8px; margin-bottom: 6px; }
.entity-logo-upload { position: relative; overflow: hidden; }
.entity-logo-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.entity-payment-details[readonly] { background: var(--surface2); color: var(--text-mid); }
.entity-profile-schema-hint { max-width: 640px; color: var(--muted); font-size: 0.76rem; }
.rate-impact-options { display: grid; gap: 10px; }
.rate-impact-option { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.rate-impact-option input { width: auto; min-height: auto; margin-top: 3px; }
.rate-impact-option strong { display: block; color: var(--navy); font-size: 12px; }
.rate-impact-option span span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.45; }

.empty-state { background: var(--surface); border: 1px dashed var(--border2); border-radius: var(--radius-lg); padding: 44px; color: var(--muted); font-size: 0.82rem; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.inv-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
/* Column template matches the Tracker's so the generated rows still line up.
   The By Client view overrides it inline with its own seven-column layout. */
.inv-table-head {
  display: grid; grid-template-columns: 130px 1fr 100px 110px 100px 140px;
  padding: 13px 22px; background: var(--surface2); border-bottom: 1px solid var(--border);
  font-size: 0.61rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.inv-row {
  display: grid; grid-template-columns: 130px 1fr 100px 110px 100px 140px;
  padding: 15px 22px; align-items: center; border-bottom: 1px solid var(--border);
  font-size: 0.8rem; transition: background 0.12s;
}
.inv-table-head > *, .inv-row > * { padding: 0 6px; min-width: 0; }
.inv-row:last-child { border-bottom: none; }
.inv-row:hover { background: var(--surface2); }
.inv-num { font-weight: 700; color: var(--blue); cursor: pointer; font-variant-numeric: tabular-nums; }
.inv-num:hover { text-decoration: underline; }
.log-client { font-weight: 600; color: var(--navy); }
.log-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Three-column template inherited from the Tracker — the receivables and
   payment rows override it inline; the fees/expenses rows rely on this. */
.task-client-line { display: grid; grid-template-columns: 1fr auto auto; gap: 9px; align-items: center; padding: 11px 0; border-top: 1px solid var(--border); font-size: 0.76rem; }
.task-client-line:first-child { border-top: none; }
.task-client-name { font-weight: 700; color: var(--navy); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cat-chip { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em; }

/* ── Status pills ───────────────────────────────────────────────────────── */
.status-pill-inv {
  display: inline-flex; align-items: center; width: fit-content; padding: 4px 10px;
  border-radius: 999px; font-size: 0.61rem; font-weight: 700; letter-spacing: 0.07em;
  line-height: 1; text-transform: uppercase;
}
.status-pill-inv.draft   { background: var(--surface2); color: var(--muted); }
.status-pill-inv.sent    { background: var(--amber-bg); color: var(--amber); }
.status-pill-inv.partial { background: var(--blue-soft); color: var(--blue); }
.status-pill-inv.paid    { background: var(--green-bg); color: var(--green); }
.status-pill-inv.overdue { background: var(--red-bg); color: var(--red); }
.muted { color: var(--muted); }

/* ── Modals ─────────────────────────────────────────────────────────────── */
/* Structure matches the Tracker's: padding lives on .modal itself (there is no
   body wrapper) and widths are set per-modal, sometimes inline. Only the
   surface treatment is modernised. */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(17, 28, 51, 0.44); backdrop-filter: blur(4px);
  z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity 0.16s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 30px; width: 500px; max-width: 92vw; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 28px 70px rgba(17,28,51,0.26);
  transform: translateY(12px) scale(0.985); transition: transform 0.18s ease;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-lg { width: 760px; max-width: 96vw; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.03em; color: var(--navy); }
.modal-close { background: var(--surface2); border: 1px solid var(--border); color: var(--muted); border-radius: var(--radius-sm); padding: 6px 10px; font-size: 13px; line-height: 1; font-family: inherit; cursor: pointer; transition: all 0.15s; flex-shrink: 0; }
.modal-close:hover { background: var(--red-bg); border-color: rgba(180,58,50,0.25); color: var(--red); }
.modal-footer { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

.invoice-group-editor-help { padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--blue-soft); color: var(--text-mid); font-size: 0.72rem; line-height: 1.5; }
.invoice-group-card { margin-bottom: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface2); }
.invoice-group-card-head { display: grid; grid-template-columns: minmax(0,1fr) 112px 34px; gap: 8px; align-items: center; margin-bottom: 10px; }
.invoice-group-card-head .invoice-group-name { color: var(--navy); font-weight: 700; background: #fff; }
.invoice-group-columns, .invoice-group-line { display: grid; grid-template-columns: minmax(180px,1fr) 72px 92px 106px 32px; gap: 7px; align-items: start; }
.invoice-group-columns { padding: 0 3px 5px; color: var(--muted); font-size: 0.57rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.invoice-group-line { margin-bottom: 7px; }
.invoice-group-line textarea { min-height: 42px; resize: vertical; }
.invoice-group-line input, .invoice-group-line select, .invoice-group-line textarea { padding: 8px 9px; font-size: 0.72rem; }
.invoice-line-kind { align-self: center; color: var(--muted2); font-size: 0.58rem; font-weight: 700; letter-spacing: 0.08em; text-align: center; text-transform: uppercase; }
.invoice-line-move { align-self: center; }
.invoice-group-actions { display: flex; gap: 7px; padding-top: 2px; }
.invoice-group-actions .btn-secondary { padding: 5px 9px; font-size: 0.65rem; }
.invoice-editor-total { margin-top: 14px; color: var(--navy); font-weight: 700; text-align: right; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { margin-bottom: 15px; display: flex; flex-direction: column; }
.form-label { font-size: 0.61rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.form-field input, .form-field select, .form-field textarea, .modal input, .modal select, .modal textarea {
  font-family: inherit; font-size: 0.8rem; color: var(--text); background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus,
.modal input:focus, .modal select:focus, .modal textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42,82,152,0.1);
}
.form-field textarea { resize: vertical; min-height: 70px; line-height: 1.5; }

/* ── Invoice builder rows ───────────────────────────────────────────────── */
.inv-extra-row, .invoice-line-row { display: grid; gap: 8px; align-items: center; margin-bottom: 8px; }
.inv-extra-row { grid-template-columns: minmax(0,1fr) 120px 36px; }
.invoice-line-row { grid-template-columns: minmax(0,1fr) 78px 92px 100px 36px; }
.inv-expense-check { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 6px; font-size: 0.78rem; background: #fff; transition: border-color 0.15s; }
.inv-expense-check:hover { border-color: var(--border2); }

/* ── Per-client billing view ────────────────────────────────────────────── */
.billing-back { display: inline-flex; align-items: center; gap: 6px; border: none; background: none; font-family: inherit; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; color: var(--muted); cursor: pointer; padding: 0 0 14px; transition: color 0.15s; }
.billing-back:hover { color: var(--navy); }

.billing-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 26px; }
.billing-subtitle { font-size: 0.76rem; color: var(--muted); margin-top: 6px; }

.billing-row { display: grid; grid-template-columns: 74px minmax(0,1fr) 88px 104px 118px; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--border); font-size: 0.78rem; }
.billing-row:first-of-type { border-top: none; }
/* Wider first column so invoice numbers do not wrap. */
.billing-row--invoice { grid-template-columns: 116px minmax(0,1fr) 88px 104px 118px; }
.billing-row--invoice .billing-desc { color: var(--text-mid); }

.billing-date { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.billing-desc { min-width: 0; display: flex; flex-direction: column; gap: 3px; color: var(--navy); font-weight: 600; overflow-wrap: anywhere; }
.billing-meta { font-size: 0.68rem; font-weight: 500; color: var(--muted); }
.billing-qty { font-variant-numeric: tabular-nums; color: var(--text-mid); font-weight: 600; }
.billing-rate { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.billing-amt { text-align: right; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.billing-warn { color: var(--red); font-weight: 700; }

.billing-total { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; padding-top: 13px; border-top: 2px solid var(--border); font-size: 0.8rem; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.billing-empty { padding: 6px 0 2px; font-size: 0.78rem; color: var(--muted); }

/* Configuration, not a pending item — styled as a note so it never reads as a
   row that should be included in the totals above. */
.billing-recurring { margin-top: 14px; padding: 11px 14px; border: 1px dashed var(--border2); border-radius: var(--radius-sm); background: var(--surface2); font-size: 0.73rem; line-height: 1.5; color: var(--text-mid); }

/* ── Reports ────────────────────────────────────────────────────────────── */
/* Left rail doubles as the overview: every report shows its headline figure,
   so picking one is a drill-down rather than the only way to see anything. */
.reports-layout { display: grid; grid-template-columns: 264px minmax(0,1fr); gap: 20px; align-items: start; }

.report-nav { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 24px; }
.report-nav-item {
  display: grid; gap: 3px; text-align: left; width: 100%; font-family: inherit; cursor: pointer;
  padding: 13px 15px; border: 1px solid var(--border); border-radius: var(--radius);
  background: rgba(255,255,255,0.75); transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.report-nav-item:hover { border-color: var(--border2); background: var(--surface); }
.report-nav-item.active { border-color: var(--navy); background: var(--surface); box-shadow: var(--shadow); }

.report-nav-name { font-size: 0.78rem; font-weight: 700; color: var(--navy); letter-spacing: -0.01em; }
.report-nav-figure { font-size: 0.92rem; font-weight: 700; color: var(--navy); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.report-nav-figure--alert { color: var(--red); }
.report-nav-blurb { font-size: 0.68rem; color: var(--muted); line-height: 1.4; }

.badge--alert { background: var(--red-bg); color: var(--red); }

@media (max-width: 1080px) {
  .reports-layout { grid-template-columns: minmax(0,1fr); }
  .report-nav { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .report-nav-item { flex: 0 0 auto; min-width: 190px; }
}

.report-bar-row { display: grid; grid-template-columns: 168px minmax(0,1fr) 148px; gap: 14px; align-items: center; padding: 7px 0; font-size: 0.76rem; }
.report-bar-label { color: var(--text-mid); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-bar-track { height: 20px; background: var(--surface2); border-radius: 5px; overflow: hidden; }
.report-bar-fill { display: block; height: 100%; border-radius: 5px; transition: width 0.5s cubic-bezier(0.4,0,0.2,1); }
.report-bar-value { text-align: right; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .report-bar-row { grid-template-columns: 118px minmax(0,1fr) 112px; gap: 9px; font-size: 0.72rem; }
}

/* ── Invoice document — preserved verbatim; a printed record, not app chrome ─ */
.inv-preview { font-family: Arial, Helvetica, sans-serif; color: #232e38; background: #fff; }
.inv-preview-document { min-height: 880px; padding: 8px 6px 20px; }
.inv-preview-header { display: grid; grid-template-columns: minmax(0,1fr) 305px; gap: 54px; align-items: start; }
.inv-preview-logo { width: 200px; max-width: 72%; margin-bottom: 22px; }
.inv-preview-logo img { display: block; width: 100%; height: auto; }
.inv-preview-logo-upload { height: 78px; display: flex; align-items: flex-start; }
.inv-preview-logo-upload img { width: auto; max-width: 100%; max-height: 78px; object-fit: contain; }
.inv-preview-logo-text { font-size: 22px; line-height: 1.15; font-weight: 700; color: #232e38; margin-bottom: 20px; }
.inv-issuer-name { font-size: 12px; line-height: 1.45; font-weight: 700; margin-bottom: 2px; }
.inv-issuer-detail { font-size: 12px; color: #232e38; line-height: 1.45; }
.inv-title { margin: 0 0 2px; font-size: 32px; line-height: 1; font-weight: 400; letter-spacing: .01em; text-align: right; color: #232e38; }
.inv-number { margin-bottom: 40px; font-size: 14px; line-height: 1.3; text-align: right; color: #87909a; }
.inv-meta-row { display: grid; grid-template-columns: 116px minmax(0,1fr); gap: 10px; align-items: baseline; margin-bottom: 13px; font-size: 12px; }
.inv-meta-label { color: #87909a; text-align: right; }
.inv-meta-val { color: #232e38; text-align: right; font-weight: 400; }
.inv-balance { display: grid; grid-template-columns: 116px minmax(0,1fr); gap: 10px; margin-top: 6px; padding: 9px 12px; border-radius: 4px; background: #f5f6f9; font-size: 14px; font-weight: 700; }
.inv-balance span:last-child { text-align: right; }
.inv-bill-to { margin-top: 26px; }
.inv-party-label { margin-bottom: 7px; font-size: 12px; color: #87909a; }
.inv-party-name { margin-bottom: 3px; font-size: 12px; font-weight: 700; }
.inv-party-detail { font-size: 12px; color: #232e38; line-height: 1.45; white-space: pre-line; }
.inv-intro { margin: 28px 0 -20px; font-size: 12px; color: #485461; line-height: 1.55; white-space: pre-line; }
.inv-items-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-top: 48px; margin-bottom: 24px; }
.inv-items-table th { padding: 8px 10px; background: #232e38; color: #fff; text-align: left; font-size: 11px; font-weight: 400; }
.inv-items-table th:first-child { width: 60%; border-radius: 4px 0 0 4px; }
.inv-items-table th:nth-child(2), .inv-items-table th:nth-child(3) { width: 13%; text-align: center; }
.inv-items-table th:last-child { width: 14%; border-radius: 0 4px 4px 0; }
.inv-items-table th:last-child, .inv-items-table td:last-child { text-align: right; }
.inv-items-table td { padding: 10px; border-bottom: 0; vertical-align: top; font-size: 12px; line-height: 1.45; }
.inv-items-table td:first-child { font-weight: 600; overflow-wrap: anywhere; }
.inv-items-table td:nth-child(2), .inv-items-table td:nth-child(3) { text-align: center; }
.inv-items-table td:last-child { font-weight: 400; white-space: nowrap; }
.inv-items-table .inv-muted-cell { color: #9aa2aa; }
.inv-items-table .inv-group-row td { padding-top: 13px; padding-bottom: 7px; border-top: 1px solid #dfe3e8; font-weight: 700; }
.inv-items-table .inv-group-row:first-child td { border-top: 0; }
.inv-items-table .inv-detail-row td { padding-top: 5px; padding-bottom: 6px; color: #485461; font-size: 11px; }
.inv-items-table .inv-detail-row td:first-child { padding-left: 25px; font-weight: 400; }
.inv-totals { margin: 6px 0 0 auto; width: 265px; break-inside: avoid; }
.inv-total-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 5px 0; font-size: 12px; }
.inv-total-row span:first-child { color: #87909a; text-align: right; }
.inv-total-row span:last-child { min-width: 88px; text-align: right; }
.inv-total-row.grand { margin-top: 2px; padding-top: 7px; border-top: 1px solid #dfe3e8; font-size: 14px; font-weight: 700; }
.inv-total-row.grand span:first-child { color: #232e38; }
.inv-footer-note { margin-top: 36px; break-inside: avoid; font-size: 11px; color: #232e38; line-height: 1.55; }
.inv-payment-details { width: min(390px, 100%); margin-top: 34px; padding: 13px 15px; break-inside: avoid; border-left: 3px solid #232e38; background: #f5f6f9; font-size: 11px; color: #232e38; line-height: 1.55; }
.inv-payment-details p { margin: 0; }
.inv-footer-title { margin-bottom: 7px; font-weight: 700; }
.inv-footer-note p { margin: 0 0 5px; }

/* Print — preserved verbatim */
@media print {
  @page { size: Letter; margin: .38in .4in .35in; }
  body > * { display: none !important; }
  #invoicePrintFrame { display: block !important; }
  #invoicePrintFrame { position: static; inset: auto; padding: 0; overflow: visible; }
  #invoicePrintFrame .inv-preview { max-width: none !important; }
  .inv-preview-document { min-height: 0; padding: 0; }
  .inv-preview-header, .inv-items-table tr, .inv-totals, .inv-payment-details, .inv-footer-note { break-inside: avoid; }
  .inv-items-table .inv-group-row { break-after: avoid; }
  .inv-items-table thead { display: table-header-group; }
  .inv-items-table { margin-top: 42px; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
#invoicePrintFrame { display: none; position: fixed; inset: 0; background: white; z-index: 9999; padding: 40px 60px; overflow: auto; }
