/* invoicing.css — Invoicing, quotes, recurring, subscriptions, dunning UI
   All styles use --kat-* CSS variables from the Katalyst theme.
   Classes: .inv-* for invoices, .quote-* for quotes, .rec-* for recurring,
            .sub-* for subscriptions, .dun-* for dunning.
*/

/* ── Live connection indicator ───────────────────────────────────────── */
.inv-conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(74,222,128,.08);
  border: 1px solid rgba(74,222,128,.2);
  border-radius: 20px;
  font-size: .74rem;
  color: #15803d;
}
.inv-conn--offline {
  background: rgba(248,113,113,.08);
  border-color: rgba(248,113,113,.2);
  color: #dc2626;
}
.inv-conn__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: connPulse 2s ease-in-out infinite;
}
.inv-conn--offline .inv-conn__dot {
  background: #f87171;
  animation: none;
}
@keyframes connPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ── KPI strip ───────────────────────────────────────────────────────── */
.inv-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.inv-kpi {
  background: var(--kat-bg-elevated);
  border: 1px solid var(--kat-border);
  border-radius: 12px;
  padding: 16px 18px;
}
.inv-kpi__label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--kat-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.inv-kpi__metric {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--kat-text-strong);
  line-height: 1.2;
}
.inv-kpi__sub {
  font-size: .73rem;
  color: var(--kat-text-muted);
  margin-top: 4px;
}

/* ── Status chips ────────────────────────────────────────────────────── */
.inv-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.inv-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  font-size: .76rem;
  font-weight: 600;
  color: var(--kat-text-muted);
  background: var(--kat-bg-hover);
  border: 1px solid var(--kat-border);
  border-radius: 20px;
  cursor: pointer;
  transition: all .15s;
}
.inv-chip:hover { border-color: var(--kat-text-muted); color: var(--kat-text-strong); }
.inv-chip--active {
  background: var(--kat-gold);
  border-color: var(--kat-gold);
  color: var(--kat-on-gold, #ffffff);
}

/* ── Status pill (inline status badge) ──────────────────────────────── */
.inv-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.inv-pill[data-status="draft"]          { background: rgba(100,116,139,.15); color: #94a3b8; border-color: rgba(100,116,139,.2); }
.inv-pill[data-status="sent"]           { background: rgba(99,102,241,.12);  color: #818cf8; border-color: rgba(99,102,241,.2); }
.inv-pill[data-status="viewed"]         { background: rgba(139,92,246,.12);  color: #7c3aed; border-color: rgba(139,92,246,.2); }
.inv-pill[data-status="partially_paid"] { background: rgba(245,158,11,.12);  color: #b45309; border-color: rgba(245,158,11,.2); }
.inv-pill[data-status="paid"]           { background: rgba(34,197,94,.12);   color: #15803d; border-color: rgba(34,197,94,.2); }
.inv-pill[data-status="overdue"]        { background: rgba(248,113,113,.12); color: #dc2626; border-color: rgba(248,113,113,.2); }
.inv-pill[data-status="void"]           { background: rgba(100,116,139,.1);  color: #64748b; border-color: rgba(100,116,139,.15); }
.inv-pill[data-status="active"]         { background: rgba(34,197,94,.12);   color: #15803d; border-color: rgba(34,197,94,.2); }
.inv-pill[data-status="paused"]         { background: rgba(245,158,11,.12);  color: #b45309; border-color: rgba(245,158,11,.2); }
.inv-pill[data-status="cancelled"]      { background: rgba(248,113,113,.12); color: #dc2626; border-color: rgba(248,113,113,.2); }
.inv-pill[data-status="pending"]        { background: rgba(99,102,241,.12);  color: #818cf8; border-color: rgba(99,102,241,.2); }
.inv-pill[data-status="accepted"]       { background: rgba(34,197,94,.12);   color: #15803d; border-color: rgba(34,197,94,.2); }
.inv-pill[data-status="rejected"]       { background: rgba(248,113,113,.12); color: #dc2626; border-color: rgba(248,113,113,.2); }
.inv-pill[data-status="expired"]        { background: rgba(100,116,139,.1);  color: #64748b; border-color: rgba(100,116,139,.15); }

/* ── Date range ──────────────────────────────────────────────────────── */
.inv-date-range {
  display: flex;
  align-items: center;
  gap: 6px;
}
.inv-date-range__sep {
  color: var(--kat-text-muted);
  flex-shrink: 0;
}

/* ── Invoice table ───────────────────────────────────────────────────── */
.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
}
.inv-table thead th {
  padding: 9px 12px;
  font-size: .72rem;
  font-weight: 700;
  color: var(--kat-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--kat-border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.inv-table thead th:hover { color: var(--kat-text-strong); }
.inv-table tbody tr {
  border-bottom: 1px solid var(--kat-border);
  transition: background .12s;
  cursor: pointer;
}
.inv-table tbody tr:hover { background: var(--kat-bg-hover); }
.inv-table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  color: var(--kat-text);
}

/* ── Invoice number ──────────────────────────────────────────────────── */
.inv-num {
  font-family: ui-monospace, monospace;
  font-size: .82rem;
  font-weight: 700;
  color: var(--kat-gold);
}

/* ── Money display ───────────────────────────────────────────────────── */
.inv-money {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--kat-text-strong);
}
.inv-money--red { color: #dc2626; }
.inv-money--green { color: #15803d; }

/* ── Pagination ──────────────────────────────────────────────────────── */
.inv-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
  font-size: .8rem;
  color: var(--kat-text-muted);
}
.inv-pager__btns { display: flex; gap: 4px; }
.inv-pager__btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--kat-border);
  background: var(--kat-bg-hover);
  color: var(--kat-text);
  font-size: .78rem;
  cursor: pointer;
  transition: background .12s;
}
.inv-pager__btn:hover { border-color: var(--kat-gold); }
.inv-pager__btn--active { background: var(--kat-gold); color: var(--kat-on-gold, #ffffff); border-color: var(--kat-gold); font-weight: 600; }
.inv-pager__btn:disabled { opacity: .4; cursor: default; }

/* ── Tab nav (invoice detail) ────────────────────────────────────────── */
.inv-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--kat-border);
  margin-bottom: 18px;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.inv-tabs::-webkit-scrollbar { height: 0; }
.inv-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--kat-text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.inv-tab:hover { color: var(--kat-text-strong); }
.inv-tab--active {
  color: var(--kat-gold);
  border-bottom-color: var(--kat-gold);
  font-weight: 600;
}
.inv-tab__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--kat-bg-hover);
  border: 1px solid var(--kat-border);
  border-radius: 9px;
  font-size: .68rem;
  font-weight: 700;
  color: var(--kat-text-muted);
}

/* ── Content pane ────────────────────────────────────────────────────
   `.inv-pane` is the card that holds the editor form / preview on the
   invoice, quote, recurring and reconciliation pages. (It used to be a
   hidden-by-default tab pane, which made all of those pages render blank.) */
.inv-pane {
  display: block;
  background: var(--kat-bg-elevated);
  border: 1px solid var(--kat-border);
  border-radius: 14px;
  padding: 20px;
  min-width: 0;
}
.inv-pane > h6 {
  font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--kat-text-muted); margin: 18px 0 10px;
}
.inv-pane > h6:first-child { margin-top: 0; }

/* ── Invoice editor (2-column layout) ───────────────────────────────── */
.inv-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) { .inv-grid-2 { grid-template-columns: 1fr; } }

/* Editor = form pane (left) + sticky live preview (right). */
.inv-edit-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.inv-edit-wrap > .inv-pane:last-child { position: sticky; top: 86px; }
@media (max-width: 1199.98px) {
  .inv-edit-wrap { grid-template-columns: 1fr; }
  .inv-edit-wrap > .inv-pane:last-child { position: static; }
}

/* ── Invoice / quote preview container ───────────────────────────────
   The A4 pages themselves are drawn by doc-preview.js (.nxdp-*). */
.inv-preview {
  position: relative;
  min-height: 200px;
  border-radius: 10px;
  max-height: calc(100vh - 190px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 2px 6px;
  scrollbar-width: thin;
}
@media (max-width: 1199.98px) { .inv-preview { max-height: none; } }
.inv-preview-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.inv-preview-bar h6 { margin: 0 !important; }
.inv-preview-bar__meta { font-size: .72rem; color: var(--kat-text-muted); display: flex; align-items: center; gap: 6px; }
.inv-preview-bar__meta a { color: var(--kat-gold); text-decoration: none; }
.inv-preview-bar__meta a:hover { text-decoration: underline; }

/* ── Line items ──────────────────────────────────────────────────────── */
.inv-lines {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.inv-lines th {
  padding: 7px 10px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--kat-text-muted);
  border-bottom: 1px solid var(--kat-border);
  text-align: left;
}
.inv-lines td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--kat-border);
  color: var(--kat-text);
  vertical-align: middle;
}
.inv-lines tr:last-child td { border-bottom: none; }

/* ── Modal ───────────────────────────────────────────────────────────── */
.inv-modal .modal-content {
  background: var(--kat-bg-elevated);
  border: 1px solid var(--kat-border);
  border-radius: 16px;
  color: var(--kat-text);
}
.inv-modal .modal-header {
  border-bottom: 1px solid var(--kat-border);
  padding: 16px 20px;
  color: var(--kat-text-strong);
}
.inv-modal .modal-footer {
  border-top: 1px solid var(--kat-border);
  padding: 12px 20px;
}

/* ── Public invoice shell (client-facing page) ───────────────────────── */
.inv-public-shell {
  min-height: 100vh;
  background: var(--kat-bg-base, #12261a);
  padding: 32px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.inv-public-card {
  background: var(--kat-bg-elevated, #15151f);
  border: 1px solid var(--kat-border, rgba(var(--kat-ink-rgb), .07));
  border-radius: 18px;
  padding: 32px;
  width: 100%;
  max-width: 700px;
  color: var(--kat-text, #e2e8f0);
}
.inv-public-doc {
  background: #fff;
  color: #0f172a;
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
}
/* The dark theme colours bare div/td/strong light — on the white document
   that made client names, lines and totals near-invisible. */
.inv-public-doc div, .inv-public-doc span, .inv-public-doc p, .inv-public-doc strong,
.inv-public-doc b, .inv-public-doc td, .inv-public-doc th, .inv-public-doc li { color: inherit; }
.inv-public-doc table { width: 100%; border-collapse: collapse; }
.inv-public-doc th { color: #64748b; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; padding: 8px 6px; border-bottom: 1px solid #e2e8f0; }
.inv-public-doc td { padding: 8px 6px; border-bottom: 1px solid #f1f5f9; vertical-align: top; overflow-wrap: anywhere; }
.inv-public-doc td[style*="text-align:right"], .inv-public-doc th[style*="text-align:right"] { white-space: nowrap; overflow-wrap: normal; }
@media (max-width: 560px) {
  .inv-public-shell { padding: 16px 8px; }
  .inv-public-card { padding: 16px; border-radius: 14px; }
  .inv-public-doc { padding: 14px; font-size: .82rem; }
  .inv-public-doc th[style*="width"] { width: auto !important; }
  .inv-public-doc th, .inv-public-doc td { padding: 6px 4px; }
  .inv-public-doc table[style*="min-width"] { min-width: 0 !important; width: 100%; }
}
.inv-public-pay {
  padding: 16px 18px;
  border: 1px solid var(--kat-border, rgba(var(--kat-ink-rgb), .07));
  border-radius: 12px;
  overflow: hidden;
}
.inv-public-pay__tabs {
  display: flex;
  border-bottom: 1px solid var(--kat-border, rgba(var(--kat-ink-rgb), .07));
}
.inv-public-pay-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: .8rem;
  font-weight: 600;
  color: var(--kat-text-muted, #64748b);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .15s;
}
.inv-public-pay-tab--active {
  color: var(--kat-gold, #4e7d2d);
  border-bottom-color: var(--kat-gold, #4e7d2d);
}
.inv-public-pay-pane {
  padding: 20px;
  display: none;
}
.inv-public-pay-pane--active { display: block; }
.inv-public-payNowBtn {
  width: 100%;
  padding: 12px;
  font-size: .9rem;
  font-weight: 700;
  background: var(--kat-gold, #4e7d2d);
  color: var(--kat-on-gold, #ffffff);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity .15s;
}
.inv-public-payNowBtn:hover { opacity: .88; }
.inv-public-payNowBtn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Recurring / subscription cards ──────────────────────────────────── */
.rec-card,
.sub-card {
  background: var(--kat-bg-elevated);
  border: 1px solid var(--kat-border);
  border-radius: 12px;
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color .15s;
}
.rec-card:hover,
.sub-card:hover { border-color: var(--kat-gold); }
.rec-card__title,
.sub-card__title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--kat-text-strong);
  margin: 0 0 6px;
}
.rec-card__meta,
.sub-card__meta {
  font-size: .76rem;
  color: var(--kat-text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Dunning timeline ────────────────────────────────────────────────── */
.dun-step {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--kat-border);
  font-size: .82rem;
}
.dun-step:last-child { border-bottom: none; }
.dun-step__day {
  font-weight: 700;
  color: var(--kat-gold);
  min-width: 60px;
  flex-shrink: 0;
}
.dun-step__body { flex: 1; color: var(--kat-text); }
.dun-step__meta { font-size: .74rem; color: var(--kat-text-muted); }

/* ── Payment row ─────────────────────────────────────────────────────── */
.pay-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--kat-border);
  font-size: .83rem;
  gap: 10px;
  flex-wrap: wrap;
}
.pay-row:last-child { border-bottom: none; }
.pay-row__amount {
  font-weight: 700;
  color: #15803d;
}
.pay-row__meta { font-size: .74rem; color: var(--kat-text-muted); }

/* ── Totals summary ──────────────────────────────────────────────────── */
.inv-totals {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 0;
}
.inv-totals__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .83rem;
  padding: 4px 0;
}
.inv-totals__row--total {
  border-top: 2px solid var(--kat-border);
  padding-top: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--kat-text-strong);
}
.inv-totals__row--due {
  color: var(--kat-gold);
  font-weight: 700;
  font-size: 1.1rem;
}

/* ── Quote actions bar ───────────────────────────────────────────────── */
.quote-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid var(--kat-border);
  margin-bottom: 18px;
}

/* ── Vendor costs table ──────────────────────────────────────────────── */
.vendor-costs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
}
.vendor-costs-table th {
  padding: 8px 12px;
  font-size: .72rem;
  font-weight: 700;
  color: var(--kat-text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--kat-border);
  text-align: left;
}
.vendor-costs-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--kat-border);
  color: var(--kat-text);
  vertical-align: middle;
}

/* ── Reminder plan ───────────────────────────────────────────────────── */
.rplan-card {
  background: var(--kat-bg-elevated);
  border: 1px solid var(--kat-border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 10px;
}
.rplan-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.rplan-card__name {
  font-weight: 600;
  color: var(--kat-text-strong);
  font-size: .88rem;
}

/* ════════════════════════════════════════════════════════════════════
   Document preview (doc-preview.js) — A4 pages at 595 x 842 px (1px=1pt),
   scaled to the container. Mirrors utils/pdfTemplate.js.
   ════════════════════════════════════════════════════════════════════ */
.nxdp { --nxdp-accent: #b8925a; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.nxdp-frame { position: relative; flex: none; border-radius: 4px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(var(--kat-shadow-rgb), 0.14), 0 14px 34px rgba(var(--kat-shadow-rgb), 0.152); background: #fff; }
.nxdp-page { position: absolute; top: 0; left: 0; width: 595.28px; height: 841.89px; transform-origin: 0 0;
  background: #fff no-repeat 0 0 / 100% 100%; color: #2b2f36; overflow: hidden;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 9px; line-height: 1.38;
  -webkit-font-smoothing: antialiased; }
/* The dark theme colours every div/span (body span { color: var(--kat-text) });
   inside the white page everything inherits instead. Same specificity as a
   single class, so the .nxdp-* rules below (declared later) still win. */
.nxdp-page :where(div, span, p, small, strong, b, label, td, th, li) { color: inherit; font-family: inherit; }
.nxdp-wm { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-35deg);
  font-weight: 800; letter-spacing: .08em; white-space: nowrap; pointer-events: none; user-select: none; line-height: 1; }
.nxdp-guide { position: absolute; border: 1px dashed rgba(78, 125, 45,.9); pointer-events: none; z-index: 3; }
.nxdp-content { position: absolute; overflow: hidden; z-index: 2; }
.nxdp-footer { position: absolute; height: 18px; border-top: .5px solid #e5e7eb; z-index: 2;
  display: flex; justify-content: space-between; gap: 12px; padding-top: 6px; font-size: 7.5px; color: #9ca3af; }
.nxdp-footer__l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nxdp-footer__r { white-space: nowrap; }

.nxdp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 10px; }
.nxdp-brand { min-width: 0; max-width: 55%; }
.nxdp-logo { display: block; max-width: 150px; max-height: 46px; object-fit: contain; margin-bottom: 7px; }
.nxdp-company { font-size: 17px; font-weight: 700; color: #16181d; line-height: 1.2; margin-bottom: 4px; }
.nxdp-company--small { font-size: 10.5px; margin-bottom: 3px; }
.nxdp-sender { font-size: 8.5px; color: #6b7280; line-height: 1.32; }
.nxdp-titleblock { text-align: right; flex: none; }
.nxdp-title { font-size: 24px; font-weight: 700; letter-spacing: 1.5px; color: var(--nxdp-accent); line-height: 1.15; }
.nxdp-number { font-size: 10.5px; font-weight: 700; color: #16181d; margin-top: 6px; }
.nxdp-status { display: inline-block; margin-top: 5px; padding: 2.5px 8px; border-radius: 8px; color: #fff;
  font-size: 7.5px; font-weight: 700; letter-spacing: .8px; }
.nxdp-rule { height: 2px; background: var(--nxdp-accent); margin-bottom: 16px; }

.nxdp-parties { display: flex; justify-content: space-between; gap: 18px; padding-bottom: 14px; }
.nxdp-party { min-width: 0; max-width: 50%; }
.nxdp-label { font-size: 7.5px; font-weight: 700; letter-spacing: 1px; color: #9ca3af; text-transform: uppercase; margin-bottom: 4px; }
.nxdp-party__name { font-size: 11px; font-weight: 700; color: #16181d; margin-bottom: 2px; }
.nxdp-party__line { font-size: 9px; color: #2b2f36; word-break: break-word; }
.nxdp-muted { color: #9ca3af; }
.nxdp-meta { width: min(230px, 46%); flex: none; }
.nxdp-meta__row { display: flex; justify-content: space-between; gap: 8px; font-size: 9px; padding: 1.5px 0; }
.nxdp-meta__row span:first-child { color: #6b7280; font-size: 8.5px; }
.nxdp-meta__row--strong span:last-child { font-weight: 700; font-size: 10px; color: #16181d; }
.nxdp-subtitle { font-size: 12.5px; font-weight: 700; color: #16181d; padding-bottom: 10px; }

.nxdp-tr { display: grid; align-items: start; border-bottom: .5px solid #e5e7eb; }
.nxdp-tr > span { padding: 6.5px 6px; min-width: 0; }
.nxdp-tr .r { text-align: right; }
.nxdp-tr--head { background: var(--nxdp-accent); border-bottom: 0; }
.nxdp-tr--head > span { color: #fff; font-weight: 700; font-size: 8px; letter-spacing: .6px; text-transform: uppercase; padding: 7px 6px; }
.nxdp-tr--zebra { background: rgba(246,246,248,.75); }
.nxdp-n { color: #9ca3af; font-size: 8.5px; }
.nxdp-desc { word-break: break-word; }
.nxdp-amt { font-weight: 700; color: #16181d; }
.nxdp-empty { padding: 10px 6px; color: #9ca3af; border-bottom: .5px solid #e5e7eb; }

.nxdp-totals { width: min(250px, 50%); margin: 14px 0 8px auto; }
.nxdp-tot { display: flex; justify-content: space-between; padding: 3px 10px; font-size: 9.5px; color: #6b7280; }
.nxdp-tot span:last-child { color: #2b2f36; }
.nxdp-tot--strong, .nxdp-tot--strong span:last-child { color: #16181d; font-weight: 700; font-size: 10px; }
.nxdp-tot--grand { background: var(--nxdp-accent); color: #fff; font-weight: 700; padding: 7px 10px; margin-top: 6px; align-items: center; }
.nxdp-tot--grand span:first-child { font-size: 10px; color: #fff; }
.nxdp-tot--grand span:last-child { font-size: 12px; color: #fff; }

.nxdp-sec { padding-top: 6px; }
.nxdp-sec__title { font-size: 8px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--nxdp-accent);
  padding-bottom: 5px; margin-bottom: 6px; position: relative; }
.nxdp-sec__title::after { content: ""; position: absolute; left: 0; bottom: 0; width: 28px; height: 1px; background: var(--nxdp-accent); }
.nxdp-sec__body { font-size: 9px; color: #2b2f36; line-height: 1.39; word-break: break-word; padding-bottom: 4px; }
/* ── Studio layout (doc-preview.js renderStudio) — mirrors utils/pdfStudio.js ── */
@font-face { font-family: "NxPoppins"; font-weight: 400; font-style: normal; font-display: swap; src: url("/assets/fonts/pdf/Poppins-Regular.ttf") format("truetype"); }
@font-face { font-family: "NxPoppins"; font-weight: 500; font-style: normal; font-display: swap; src: url("/assets/fonts/pdf/Poppins-Medium.ttf") format("truetype"); }
@font-face { font-family: "NxPoppins"; font-weight: 600; font-style: normal; font-display: swap; src: url("/assets/fonts/pdf/Poppins-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "NxPoppins"; font-weight: 700; font-style: normal; font-display: swap; src: url("/assets/fonts/pdf/Poppins-Bold.ttf") format("truetype"); }
.nxs-page { background-color: #ffffff; color: #3b3d42; font-family: "NxPoppins", "Poppins", "Helvetica Neue", Arial, sans-serif; font-size: 8.2px; line-height: 1.6; }
.nxs-mark { position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%); opacity: .11; pointer-events: none; user-select: none; z-index: 1; }
.nxs-topbar { position: absolute; top: 0; width: .8px; background: #4b4d52; z-index: 2; }
.nxs-content { padding-left: 16px; }
.nxs-bar { position: relative; }
.nxs-bar::before { content: ""; position: absolute; left: -14px; top: -3px; bottom: -2px; width: .8px; background: #4b4d52; }
.nxs-logo { display: block; max-width: 150px; max-height: 38px; object-fit: contain; }
.nxs-logo-text { font-size: 18px; font-weight: 700; color: #232427; line-height: 1.3; }
.nxs-head { padding-bottom: 30px; }
.nxs-co { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 18px; }
.nxs-co__name { font-size: 8.5px; font-weight: 700; color: #232427; margin-bottom: 3px; }
.nxs-co__line { font-size: 7.2px; color: #6c6f75; letter-spacing: .3px; line-height: 13px; }
.nxs-co__line b { font-weight: 500; color: #232427; letter-spacing: 0; }
.nxs-badgewrap { text-align: right; flex: none; margin-left: auto; }
.nxs-badge { display: inline-block; padding: 0 17px; height: 25px; line-height: 25px; border-radius: 5px; border: .9px solid var(--nxdp-accent);
  font-size: 9.5px; font-weight: 600; color: #232427; white-space: nowrap; }
.nxs-status { font-size: 6.5px; font-weight: 600; letter-spacing: .9px; text-transform: uppercase; margin-top: 4px; }
.nxs-num { font-size: 9px; font-weight: 600; color: #232427; margin-bottom: 30px; line-height: 15px; }
.nxs-num span { font-weight: 500; color: #3b3d42; }
.nxs-details { display: flex; gap: 0; padding-bottom: 22px; }
.nxs-det { width: 52%; flex: none; }
.nxs-billto { margin-left: 8%; flex: 1; min-width: 0; }
.nxs-kv { font-size: 8.2px; line-height: 13.5px; margin-bottom: 1.5px; word-break: break-word; }
.nxs-kv b { font-weight: 600; color: #232427; }
.nxs-billto__label { font-size: 8.4px; font-weight: 600; color: #232427; margin-bottom: 8px; line-height: 14px; }
.nxs-billto__name { font-size: 8.4px; font-weight: 600; color: #232427; line-height: 14px; margin-bottom: 1px; }
.nxs-subtitle { font-size: 11px; font-weight: 600; color: #232427; line-height: 15px; padding-bottom: 10px; }
.nxs-box { border: .9px solid var(--nxdp-accent); border-radius: 7px; padding: 14px 13px 6px; position: relative; z-index: 2; }
.nxs-box + .nxs-box { margin-top: 0; }
.nxs-box__title { text-align: center; font-size: 9.5px; font-weight: 600; color: #232427; line-height: 17px; }
.nxs-box__rule { width: 120px; height: .9px; background: var(--nxdp-accent); margin: 0 auto 20px; }
.nxs-tr { display: grid; align-items: center; border-bottom: .7px solid var(--nxdp-accent); }
.nxs-tr > span { padding: 8px 5px; min-width: 0; word-break: break-word; line-height: 10.2px; font-size: 7.2px; }
.nxs-tr--head { min-height: 26px; border-bottom-width: .9px; }
.nxs-tr--head > span { font-size: 7px; font-weight: 600; color: #232427; padding: 3px 5px; white-space: pre-line; }
.nxs-tr .c { text-align: center; }
.nxs-tr .nxs-item { font-weight: 500; color: #232427; }
.nxs-tr .nxs-tot { font-weight: 600; color: #232427; }
.nxs-row { min-height: 30px; }
.nxs-tr > span.nxs-num7 { font-size: 7.4px; }
.nxs-empty { padding: 10px 5px; color: #9a9ca1; font-size: 7.6px; }
.nxs-totals { padding: 12px 0 0; }
.nxs-trow { display: grid; grid-template-columns: 1fr 120px 96px; font-size: 7.4px; line-height: 15px; }
.nxs-trow span:nth-child(2) { text-align: right; font-weight: 500; color: #6c6f75; }
.nxs-trow span:nth-child(3) { text-align: right; padding-right: 5px; }
.nxs-trow--strong span:nth-child(2), .nxs-trow--strong span:nth-child(3) { font-weight: 600; color: #232427; }
.nxs-trow--grand { margin-top: 3px; padding-top: 5px; font-size: 8.4px; line-height: 16px; position: relative; }
.nxs-trow--grand::before { content: ""; position: absolute; top: -2px; right: 0; width: 176px; height: .7px; background: var(--nxdp-accent); }
.nxs-trow--grand span:nth-child(2) { font-weight: 600; color: #232427; }
.nxs-trow--grand span:nth-child(3) { font-weight: 700; color: #232427; font-size: 8.6px; }
.nxs-sec { padding-top: 20px; }
.nxs-sec + .nxs-sec { padding-top: 12px; }
.nxs-sec__title { font-size: 8.4px; font-weight: 600; color: #232427; line-height: 13px; }
.nxs-sec__rule { width: 26px; height: .9px; background: var(--nxdp-accent); margin-bottom: 7px; }
.nxs-sec__body { font-size: 7.8px; line-height: 12px; color: #3b3d42; word-break: break-word; }
.nxs-footer { position: absolute; z-index: 2; display: flex; gap: 8px; font-size: 7.4px; font-weight: 500; color: #232427; line-height: 13px; }
.nxs-footer::before { content: ""; position: absolute; left: -14px; top: -4px; width: .8px; height: var(--nxs-bar-h, 80px); background: #4b4d52; }
.nxs-footer__l { min-width: 0; }
.nxs-footer__m { letter-spacing: .4px; white-space: nowrap; }
.nxs-footer__r { margin-left: auto; text-align: right; font-weight: 600; letter-spacing: 1px; position: relative; white-space: nowrap; }
.nxs-footer__r::before { content: ""; position: absolute; right: 0; top: -10px; width: 66px; height: .7px; background: #4b4d52; }
.nxs-footer__pg { position: absolute; left: 0; right: 0; top: 40px; text-align: center; font-size: 6.4px; font-weight: 400; color: #6c6f75; letter-spacing: 0; }
/* The app shell forces Satoshi + letter-spacing:normal on every element with
   !important (head-css.ejs). Document pages must render in their own fonts
   so the preview matches the PDF. */
.nxdp-page:not(.nxs-page), .nxdp-page:not(.nxs-page) :is(div, span, p, small, strong, b, label, td, th, li) {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important; }
.nxdp-page :is(div, span, p, small, strong, b, label, td, th, li) { letter-spacing: inherit !important; }
.nxs-page, .nxs-page :is(div, span, p, small, strong, b, label, td, th, li) {
  font-family: "NxPoppins", "Poppins", "Helvetica Neue", Arial, sans-serif !important; }
.nxs-page { letter-spacing: 0 !important; }
.nxs-page .nxs-co__line { letter-spacing: .3px !important; }
.nxs-page .nxs-co__line b { letter-spacing: 0 !important; }
.nxs-page .nxs-status { letter-spacing: .9px !important; }
.nxs-page .nxs-footer__m { letter-spacing: .4px !important; }
.nxs-page .nxs-footer__r { letter-spacing: 1px !important; }
.nxs-page .nxs-footer__pg { letter-spacing: 0 !important; }
.nxdp-page:not(.nxs-page) .nxdp-title { letter-spacing: 1.5px !important; }
.nxdp-page:not(.nxs-page) .nxdp-status { letter-spacing: .8px !important; }
.nxdp-page:not(.nxs-page) .nxdp-label, .nxdp-page:not(.nxs-page) .nxdp-sec__title { letter-spacing: 1px !important; }
.nxdp-page:not(.nxs-page) .nxdp-tr--head > span { letter-spacing: .6px !important; }
.nxdp-wm { letter-spacing: .08em !important; }

/* ── Editor: client picker, line rows, banners ─────────────────────── */
.inv-client-picker { position: relative; margin-bottom: 14px; }
.inv-client-picker__input { width: 100%; padding-left: 34px !important; }
.inv-client-picker__icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--kat-text-muted); pointer-events: none; }
.inv-client-picker__menu {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--kat-bg-elevated); border: 1px solid var(--kat-border); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(var(--kat-shadow-rgb), 0.18); max-height: 300px; overflow-y: auto; padding: 4px; display: none;
}
.inv-client-picker__menu.is-open { display: block; }
.inv-client-opt { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 8px 10px;
  border: 0; background: transparent; color: var(--kat-text); border-radius: 8px; cursor: pointer; }
.inv-client-opt:hover, .inv-client-opt.is-active { background: var(--kat-bg-hover, rgba(var(--kat-ink-rgb), .05)); }
.inv-client-opt__av { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: rgba(var(--kat-gold-rgb, 78, 125, 45), .16); color: var(--kat-gold, #4e7d2d); font-weight: 700; font-size: .78rem; }
.inv-client-opt__name { font-size: .84rem; font-weight: 600; color: var(--kat-text-strong, #fff); }
.inv-client-opt__sub { font-size: .74rem; color: var(--kat-text-muted); }
.inv-client-picker__empty { padding: 12px; font-size: .8rem; color: var(--kat-text-muted); }
.inv-client-chip { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; padding: 3px 10px; border-radius: 999px;
  background: rgba(var(--kat-gold-rgb, 78, 125, 45), .12); color: var(--kat-gold, #4e7d2d); border: 1px solid rgba(var(--kat-gold-rgb, 78, 125, 45), .25); margin-top: 6px; }
.inv-client-chip button { border: 0; background: none; color: inherit; padding: 0; line-height: 1; cursor: pointer; }

.inv-lines .inv-line-input { width: 100%; min-width: 0; }
.inv-lines .inv-line-input.num { text-align: right; }
.inv-lines td.inv-line-cell { padding: 0; }
.inv-line { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 6px; padding: 12px 2px; }
.inv-line__handle { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 8px; }
.inv-line__n { font-size: .68rem; font-weight: 700; color: var(--kat-text-muted); font-variant-numeric: tabular-nums; }
.inv-line__nums { display: grid; grid-template-columns: 74px 116px 74px 74px minmax(96px, 1fr) auto; gap: 8px; align-items: end; margin-top: 8px; }
.inv-line__nums label { margin: 0; min-width: 0; }
.inv-line__nums label > span, .inv-line__amt > span { display: block; font-size: .64rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--kat-text-muted); margin-bottom: 3px; }
.inv-line__amt { text-align: right; min-width: 0; padding-bottom: 7px; }
.inv-line__amt strong { font-size: .92rem; color: var(--kat-text-strong, #fff); white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-line .inv-line-tools { padding-bottom: 4px; }
@media (max-width: 640px) {
  .inv-line__nums { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inv-line__amt { text-align: left; }
}
.inv-lines tr.is-dragging { opacity: .45; }
.inv-lines tr.is-drop-target td { border-top: 2px solid var(--kat-gold, #4e7d2d); }
.inv-line-tools { display: flex; gap: 2px; justify-content: flex-end; }
.inv-icon-btn { border: 1px solid transparent; background: transparent; color: var(--kat-text-muted); border-radius: 7px;
  width: 26px; height: 26px; display: inline-grid; place-items: center; cursor: pointer; transition: all .15s; }
.inv-icon-btn:hover { color: var(--kat-text-strong, #fff); background: var(--kat-bg-hover, rgba(var(--kat-ink-rgb), .06)); border-color: var(--kat-border); }
.inv-icon-btn--danger:hover { color: #dc2626; border-color: rgba(239,68,68,.3); background: rgba(239,68,68,.08); }
.inv-icon-btn:disabled { opacity: .3; cursor: default; }
.inv-drag { cursor: grab; color: var(--kat-text-muted); }
.inv-lines-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.inv-bulk { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inv-bulk .proj-input { width: 90px; }
.inv-sumbox { min-width: 230px; margin-left: auto; font-size: .84rem; }
.inv-sumbox__row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; color: var(--kat-text-muted); }
.inv-sumbox__row span:last-child { color: var(--kat-text); font-variant-numeric: tabular-nums; }
.inv-sumbox__row--total { border-top: 1px solid var(--kat-border); margin-top: 6px; padding-top: 8px; font-weight: 700; }
.inv-sumbox__row--total span { color: var(--kat-gold, #4e7d2d) !important; font-size: .98rem; }
.inv-banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 10px; font-size: .82rem; margin-bottom: 14px;
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.25); color: #b45309; }
.inv-banner i { font-size: 1.05rem; line-height: 1.2; }
.inv-dirty-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--kat-gold, #4e7d2d); margin-left: 6px; vertical-align: middle; opacity: 0; transition: opacity .2s; }
.inv-dirty-dot.is-on { opacity: 1; }
.inv-field-error { border-color: rgba(239,68,68,.6) !important; box-shadow: 0 0 0 3px rgba(239,68,68,.12) !important; }
/* ── Invoice editor — organised layout (views/invoices.ejs, .ive) ───── */
.ive-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--kat-bg-elevated); border: 1px solid var(--kat-border); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.ive-head__id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ive-head__icon { width: 42px; height: 42px; border-radius: 12px; flex: none; display: grid; place-items: center; font-size: 1.3rem;
  background: rgba(var(--kat-gold-rgb, 78, 125, 45), .12); color: var(--kat-gold, #4e7d2d); border: 1px solid rgba(var(--kat-gold-rgb, 78, 125, 45), .22); }
.ive-head__title { margin: 0 0 4px; font-size: 1.05rem; font-weight: 700; color: var(--kat-text-strong, #fff); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ive-head__meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .78rem; color: var(--kat-text-muted); }
.ive-head__total strong { color: var(--kat-gold, #4e7d2d); font-size: .9rem; font-variant-numeric: tabular-nums; margin-left: 4px; }
.ive-chip { --chip: #6b7280; display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .7rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: var(--chip); background: color-mix(in srgb, var(--chip) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--chip) 35%, transparent); }
.ive-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--chip); }
.ive-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.ive-steps { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.ive-steps::-webkit-scrollbar { display: none; }
.ive-steps a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--kat-border); background: var(--kat-bg-elevated); color: var(--kat-text-muted); font-size: .8rem; font-weight: 600;
  text-decoration: none; transition: border-color .15s, color .15s; }
.ive-steps a:hover { color: var(--kat-text-strong, #fff); border-color: rgba(var(--kat-gold-rgb, 78, 125, 45), .4); }
.ive-steps em { font-style: normal; font-weight: 500; font-size: .68rem; opacity: .7; }
.ive-steps__n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; font-weight: 700;
  background: rgba(var(--kat-ink-rgb), .06); color: var(--kat-text-muted); }
.ive-steps a.is-done { color: var(--kat-text-strong, #fff); border-color: rgba(16,185,129,.35); }
.ive-steps a.is-done .ive-steps__n { background: rgba(16,185,129,.18); color: #059669; font-size: 0; }
.ive-steps a.is-done .ive-steps__n::before { content: "\2713"; font-size: .78rem; }

.ive-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ive-form > .inv-banner { margin-bottom: 0; }
.ive-card { background: var(--kat-bg-elevated); border: 1px solid var(--kat-border); border-radius: 14px; padding: 18px 20px 20px; scroll-margin-top: 90px; min-width: 0; }
.ive-card__head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--kat-border); }
.ive-card__n { width: 28px; height: 28px; border-radius: 9px; flex: none; display: grid; place-items: center; font-weight: 700; font-size: .82rem;
  background: rgba(var(--kat-gold-rgb, 78, 125, 45), .14); color: var(--kat-gold, #4e7d2d); }
.ive-card__head h6 { margin: 2px 0 3px; font-size: .95rem; font-weight: 700; color: var(--kat-text-strong, #fff); letter-spacing: 0; text-transform: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ive-card__head p { margin: 0; font-size: .76rem; color: var(--kat-text-muted); line-height: 1.45; }
.ive-count { font-size: .68rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: rgba(var(--kat-ink-rgb), .06); color: var(--kat-text-muted); }
.ive-grid { display: grid; gap: 14px 16px; }
.ive-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ive-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ive-span { grid-column: 1 / -1; }
.ive-field { min-width: 0; }
.ive-field .proj-label, .ive-internal .proj-label { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ive-field .proj-input, .ive-field .proj-select, .ive-internal .proj-input { width: 100%; }
.ive-field textarea, .ive-internal textarea { resize: vertical; }
.ive-req { color: var(--kat-gold, #4e7d2d); }
.ive-hint { font-size: .68rem; font-weight: 500; color: var(--kat-text-muted); opacity: .8; text-transform: none; letter-spacing: 0; }
.ive .inv-client-picker { margin-bottom: 16px; }

/* Line items as tidy tiles */
.ive-lines { border-collapse: separate; border-spacing: 0; }
.ive-lines > tbody > tr > td { padding: 0 0 10px; border: 0; }
.ive .inv-line { border: 1px solid var(--kat-border); border-radius: 12px; background: rgba(var(--kat-ink-rgb), .015); padding: 12px 12px 10px 6px; transition: border-color .15s; }
.ive .inv-line:focus-within { border-color: rgba(var(--kat-gold-rgb, 78, 125, 45), .45); }
.ive .inv-line__nums { margin-top: 10px; }
.ive-items-actions { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.ive-bulk { border: 1px dashed var(--kat-border); border-radius: 10px; padding: 0 12px; }
.ive-bulk > summary { cursor: pointer; list-style: none; font-size: .8rem; font-weight: 600; color: var(--kat-text-muted); padding: 8px 0; }
.ive-bulk > summary::-webkit-details-marker { display: none; }
.ive-bulk[open] { padding-bottom: 12px; }
.ive-bulk[open] > summary { color: var(--kat-text-strong, #fff); }
.ive-totals { display: flex; justify-content: flex-end; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--kat-border); }
.ive-totals .inv-sumbox { min-width: 260px; margin-left: 0; background: rgba(var(--kat-gold-rgb, 78, 125, 45), .05); border: 1px solid rgba(var(--kat-gold-rgb, 78, 125, 45), .16); border-radius: 12px; padding: 10px 14px; }

.ive-internal { margin-top: 16px; padding: 12px 14px 14px; border-radius: 12px; background: rgba(245,158,11,.05); border: 1px dashed rgba(245,158,11,.28); }
.ive-internal .proj-label i { color: #b45309; }

.ive-preview .inv-preview-bar h6 { display: flex; align-items: center; gap: 6px; }
.ive .inv-line__nums { grid-template-columns: minmax(48px, .7fr) minmax(78px, 1.25fr) minmax(48px, .7fr) minmax(48px, .7fr) minmax(86px, 1.3fr) auto; gap: 8px; }
.ive .inv-line__amt strong { font-size: .88rem; }
.ive .inv-line-tools { flex-wrap: wrap; max-width: 56px; }
.ive textarea[data-f="desc"] { overflow: hidden; resize: none !important; line-height: 1.45; }
@media (max-width: 640px) {
  .ive .inv-line__nums { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ive .inv-line-tools { max-width: none; grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 1399.98px) { .ive-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .ive-grid--2, .ive-grid--3 { grid-template-columns: 1fr; }
  .ive-card { padding: 16px 14px; }
  .ive-actions { width: 100%; }
  .ive-actions > * { flex: 1 1 auto; justify-content: center; }
  .ive-totals .inv-sumbox { min-width: 0; width: 100%; }
}

/* ── Settings → Document templates ─────────────────────────────────── */
.dt-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr) minmax(0, 400px); gap: 18px; align-items: start; }
@media (max-width: 1399.98px) { .dt-layout { grid-template-columns: 230px minmax(0, 1fr); } .dt-preview-col { grid-column: 1 / -1; } }
@media (max-width: 991.98px) { .dt-layout { grid-template-columns: 1fr; } }
.dt-list { display: flex; flex-direction: column; gap: 8px; }
.dt-item { text-align: left; width: 100%; padding: 12px 14px; border-radius: 12px; cursor: pointer;
  background: var(--kat-bg-elevated); border: 1px solid var(--kat-border); color: var(--kat-text); transition: border-color .15s, background .15s; }
.dt-item:hover { border-color: rgba(var(--kat-gold-rgb, 78, 125, 45), .45); }
.dt-item.is-active { border-color: var(--kat-gold, #4e7d2d); background: rgba(var(--kat-gold-rgb, 78, 125, 45), .07); }
.dt-item__name { font-weight: 600; font-size: .88rem; color: var(--kat-text-strong, #fff); display: block; }
.dt-item__tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.dt-tag { font-size: .66rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px;
  background: rgba(var(--kat-ink-rgb), .05); color: var(--kat-text-muted); border: 1px solid var(--kat-border); }
.dt-tag--gold { color: var(--kat-gold, #4e7d2d); border-color: rgba(var(--kat-gold-rgb, 78, 125, 45), .3); background: rgba(var(--kat-gold-rgb, 78, 125, 45), .1); }
.dt-margins { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .dt-margins { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dt-unit { position: relative; }
.dt-unit .proj-input { width: 100%; padding-right: 34px; }
.dt-unit::after { content: "mm"; position: absolute; right: 10px; bottom: 9px; font-size: .72rem; color: var(--kat-text-muted); pointer-events: none; }
.dt-drop { border: 1.5px dashed var(--kat-border); border-radius: 12px; padding: 16px; display: flex; gap: 14px; align-items: center;
  transition: border-color .15s, background .15s; }
.dt-drop.is-over { border-color: var(--kat-gold, #4e7d2d); background: rgba(var(--kat-gold-rgb, 78, 125, 45), .06); }
.dt-drop__thumb { width: 64px; height: 90px; border-radius: 4px; flex: none; background: #fff center / 100% 100% no-repeat;
  box-shadow: 0 2px 10px rgba(var(--kat-shadow-rgb), 0.14); display: grid; place-items: center; color: #475569; font-size: 1.4rem; }
.dt-drop__body { flex: 1; min-width: 0; font-size: .8rem; color: var(--kat-text-muted); }
.dt-drop__body strong { color: var(--kat-text-strong, #fff); font-size: .86rem; }
.dt-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .85rem; color: var(--kat-text); }
.dt-switch input { width: 16px; height: 16px; accent-color: var(--kat-gold, #4e7d2d); }
.dt-color { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dt-color input[type=color] { width: 40px; height: 36px; padding: 2px; border-radius: 8px; border: 1px solid var(--kat-border); background: transparent; cursor: pointer; }
.dt-swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.dt-swatch.is-active { border-color: #fff; }
.dt-assign { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dt-assign label { display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 10px; border: 1px solid var(--kat-border); cursor: pointer; font-size: .84rem; }
.dt-assign input { accent-color: var(--kat-gold, #4e7d2d); width: 16px; height: 16px; }
.dt-assign label.is-on { border-color: rgba(var(--kat-gold-rgb, 78, 125, 45), .55); background: rgba(var(--kat-gold-rgb, 78, 125, 45), .07); }
.dt-preview-col .inv-pane { position: sticky; top: 86px; }
.dt-kind-toggle { display: inline-flex; border: 1px solid var(--kat-border); border-radius: 9px; padding: 2px; }
.dt-kind-toggle button { border: 0; background: transparent; color: var(--kat-text-muted); padding: 4px 10px; font-size: .74rem; border-radius: 7px; cursor: pointer; }
.dt-kind-toggle button.is-active { background: rgba(var(--kat-gold-rgb, 78, 125, 45), .15); color: var(--kat-gold, #4e7d2d); }
