/* —— Design tokens —— */
:root {
  --brand: #e31e24;
  --brand-dark: #b9151a;
  --accent-orange: #f7941d;
  --brand-soft: rgba(227, 30, 36, 0.08);
  --ink: #0f1419;
  --ink-muted: #5c6570;
  --ink-light: #8b949e;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eceef2;
  --border: #e2e5eb;
  --border-strong: #c8cdd6;
  --shadow-sm: 0 1px 2px rgba(15, 20, 25, 0.04);
  --shadow-md: 0 8px 30px rgba(15, 20, 25, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 20, 25, 0.12);
  --radius: 10px;
  --radius-lg: 14px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --font-ar: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}

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

html {
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: linear-gradient(160deg, #eef0f4 0%, #e4e7ed 100%);
  line-height: 1.5;
}

/* —— App layout —— */
.app {
  display: grid;
  grid-template-columns: minmax(360px, 400px) 1fr;
  min-height: 100vh;
}

/* —— Editor sidebar —— */
.editor {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  max-height: 100vh;
  position: sticky;
  top: 0;
  box-shadow: var(--shadow-sm);
}

.editor-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px;
  background: linear-gradient(145deg, #0f1419 0%, #1c2128 100%);
  color: #fff;
}

.editor-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  padding: 4px;
}

.editor-brand-text h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.editor-brand-text p {
  margin: 2px 0 0;
  font-size: 0.75rem;
  opacity: 0.65;
}

.editor-nav {
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
}

.nav-pill {
  display: inline-block;
  padding: 6px 12px;
  margin-right: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  text-decoration: none;
}

.nav-pill.active {
  background: var(--brand);
  color: #fff;
}

.db-status {
  margin: 0 22px 12px;
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-muted);
}

.db-status.ok {
  background: #e8f8ef;
  color: #1a7f4c;
}

.db-status.checking {
  background: #eef4ff;
  color: #3b5998;
}

.db-status.error {
  background: #fdecea;
  color: var(--brand-dark);
}

.btn-whatsapp {
  color: #fff;
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
}

.btn-whatsapp:hover {
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45);
}

.panel {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.panel h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

.panel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 0.65rem;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 6px;
}

.badge {
  margin-left: auto;
  padding: 2px 8px;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--ink-light);
  background: var(--surface-2);
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0;
}

.panel-hint {
  margin: -8px 0 12px;
  font-size: 0.8rem;
  color: var(--ink-light);
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field-label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.ar-inline {
  font-family: var(--font-ar);
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink-light);
}

.lh-ar,
.inv-ar-label,
.th-ar,
.t-ar,
.meta-label-ar {
  font-feature-settings: "liga" 1, "kern" 1;
  text-rendering: optimizeLegibility;
}

input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--border-strong);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-grid .field {
  margin-bottom: 0;
}

.field-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.line-items-header {
  display: grid;
  grid-template-columns: 24px 1fr 44px 56px 48px;
  gap: 6px;
  padding: 0 8px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-light);
}

.line-items-editor {
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
}

.line-items-editor::-webkit-scrollbar {
  width: 5px;
}

.line-items-editor::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.line-item-row {
  display: grid;
  grid-template-columns: 24px 1fr 44px 56px 48px;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s;
}

.line-item-row:focus-within {
  border-color: var(--brand);
  background: var(--surface);
}

.line-item-row input {
  margin: 0;
  padding: 7px 8px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.desc-input,
.work-name-input {
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.items-table .col-desc,
.work-name-cell {
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.row-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-light);
  text-align: center;
}

.row-total {
  font-size: 0.75rem;
  font-weight: 700;
  text-align: right;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
}

.work-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.work-mode-tab {
  padding: 10px 12px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.work-mode-tab:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.work-mode-tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  border-color: var(--brand-dark);
  box-shadow: 0 2px 8px rgba(227, 30, 36, 0.25);
}

.work-auto-panel,
.work-manual-panel {
  margin-bottom: 12px;
}

.work-package-hint {
  margin: 0 0 12px;
  padding: 10px 12px;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink-muted);
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.field-hint {
  margin: -6px 0 12px;
  font-size: 0.72rem;
  color: var(--ink-muted);
  line-height: 1.45;
}

.btn-danger-text {
  color: var(--brand-dark) !important;
  border-color: rgba(227, 30, 36, 0.35) !important;
}

.btn-danger-text:hover {
  background: #fdecea !important;
}

.line-item-row .desc-select {
  min-width: 0;
}

.collapse-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
}

.collapse-toggle .chevron {
  color: var(--ink-light);
  transition: transform 0.2s;
}

.collapse-toggle[aria-expanded="true"] .chevron {
  transform: rotate(90deg);
}

.collapse-body {
  margin-top: 12px;
}

#priceListEditor {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  margin-bottom: 8px;
}

.panel-catalog {
  border-top: 1px solid var(--border);
}

.panel-catalog .collapse-toggle {
  margin: 0;
}

.catalog-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.catalog-tab {
  padding: 8px 10px;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.catalog-tab.active {
  color: var(--brand-dark);
  background: #fff;
  border-color: var(--brand);
}

.catalog-panel.hidden {
  display: none;
}

.catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.btn-sm {
  padding: 8px 12px !important;
  font-size: 0.74rem !important;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  margin: 0;
}

.catalog-table-wrap {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.catalog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.catalog-table th,
.catalog-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.catalog-table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.catalog-input {
  width: 100%;
  padding: 7px 8px !important;
  font-size: 0.78rem !important;
}

.catalog-input-price {
  max-width: 100px;
}

.btn-icon-del {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--brand);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.btn-icon-del:hover {
  background: #fdecea;
  border-color: var(--brand);
}

.catalog-status {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.catalog-status.ok {
  color: #166534;
}

.catalog-status.warn {
  color: #b45309;
}

.catalog-meta {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
}

.panel-compact {
  padding-top: 12px;
  padding-bottom: 12px;
}

.editor-actions {
  padding: 20px 22px 28px;
  background: var(--surface-2);
}

.action-hint {
  margin: 8px 0 14px;
  font-size: 0.72rem;
  color: var(--ink-light);
  text-align: center;
}

.action-hint.subtle {
  margin: 4px 0 10px;
  font-size: 0.68rem;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 8px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  box-shadow: 0 4px 14px rgba(227, 30, 36, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(227, 30, 36, 0.4);
}

.btn-secondary {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-outline {
  color: var(--brand);
  background: transparent;
  border: 1px dashed var(--brand);
  width: auto;
}

.btn-outline:hover {
  background: var(--brand-soft);
}

.btn-ghost {
  color: var(--ink-muted);
  background: transparent;
  font-size: 0.82rem;
  padding: 8px;
}

.btn-ghost:hover {
  color: var(--brand);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.8rem;
  margin-top: 4px;
}

.hidden {
  display: none !important;
}

/* —— Preview area —— */
.preview-wrap {
  padding: 28px 32px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: auto;
}

.preview-label {
  margin: 0 0 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-light);
}

/* —— Professional invoice document (screen + PDF) —— */
.invoice.pro-invoice {
  --inv-pad: 26px;
  --inv-border: #d4d9e1;
  width: 100%;
  max-width: 210mm;
  min-height: auto;
  background: #fff;
  border: 1px solid var(--inv-border);
  border-radius: 2px;
  box-shadow: 0 2px 16px rgba(15, 20, 25, 0.06);
  overflow: visible;
  position: relative;
  font-size: 11px;
  color: var(--ink);
  display: block;
}

.invoice.pro-invoice.fit-a4 {
  width: 210mm;
  max-width: 210mm;
  min-width: 210mm;
}

.invoice.density-tight .inv-hero-inner {
  padding: 14px 22px 12px;
}

.invoice.density-tight .inv-logo-wrap .logo {
  width: 110px;
}

.invoice.density-tight .inv-title-pro {
  font-size: 1.5rem;
}

.invoice.density-tight .inv-info-block {
  margin-left: var(--inv-pad);
  margin-right: var(--inv-pad);
}

.invoice.density-tight .meta-card {
  padding: 8px 10px 10px;
}

.invoice.density-tight .table-container {
  margin-top: 10px;
}

.invoice.density-tight .items-table th {
  padding: 6px 8px;
}

.invoice.density-tight .items-table td {
  padding: 5px 8px;
  height: auto;
  font-size: 0.72rem;
}

.invoice.density-compact .inv-hero-inner {
  padding: 18px 26px 14px;
}

.invoice.density-compact .items-table td {
  padding: 6px 10px;
  height: auto;
}

.invoice.density-compact .inv-summary,
.invoice.density-compact .inv-verification {
  margin-top: 14px;
}

.invoice.density-tight .inv-summary {
  margin-top: 10px;
}

.invoice.density-tight .inv-verification {
  margin-top: 10px;
  padding-top: 10px;
}

.invoice.density-tight .stamp-seal {
  width: 84px;
  height: 84px;
}

.invoice.density-tight .qr-box img {
  width: 72px !important;
  height: 72px !important;
}

.invoice.density-tight .inv-footer {
  padding-top: 12px;
  padding-bottom: 14px;
}

.invoice.density-tight .footer-grid {
  gap: 12px;
}

.invoice.density-tight .footer-block p,
.invoice.density-tight .bank-text {
  font-size: 0.6rem !important;
}

.items-table .row-placeholder td {
  text-align: center;
  color: var(--ink-light);
  font-style: italic;
  padding: 12px;
}

/* ═══════════════════════════════════════════
   CLASSIC SHEET INVOICE (matches your Excel layout)
   ═══════════════════════════════════════════ */
.sheet-invoice {
  --inv-pad: 22px;
  font-family: var(--font);
  border: 1px solid #c5cad3 !important;
  box-shadow: 0 4px 24px rgba(15, 20, 25, 0.08) !important;
}

.sheet-invoice .ar {
  font-family: var(--font-ar);
  font-weight: 600;
}

/* Top: INVOICE left · Logo right */
.inv-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px var(--inv-pad) 14px;
  border-bottom: 2px solid var(--brand);
}

.inv-title-classic {
  margin: 0;
  font-size: 2.15rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--ink);
  line-height: 1;
}

.inv-no-classic {
  margin: 10px 0 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}

.inv-no-classic span {
  color: var(--brand);
  font-weight: 800;
  font-size: 1.05rem;
}

.logo-classic {
  width: 168px;
  height: auto;
  display: block;
  object-fit: contain;
}

/* Bill to row */
.inv-billto {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 11px var(--inv-pad);
  border-bottom: 1px solid #c5cad3;
  background: #fafbfc;
}

.inv-billto-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inv-billto-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Ref · Date · Mob strip */
.inv-info-strip {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 0.9fr;
  border-bottom: 1px solid #c5cad3;
}

.inv-info-cell {
  padding: 9px 14px;
  border-right: 1px solid #c5cad3;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inv-info-cell:last-child {
  border-right: none;
}

.inv-info-lbl {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-light);
}

.inv-info-val {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Table — connected grid like spreadsheet */
.sheet-invoice .sheet-table-wrap {
  margin: 0 !important;
  border: none !important;
  border-bottom: 1px solid #c5cad3 !important;
}

.sheet-invoice .sheet-table {
  border-collapse: collapse;
}

.sheet-invoice .sheet-table th,
.sheet-invoice .sheet-table td {
  border: 1px solid #b8bec8 !important;
  padding: 6px 9px !important;
}

.sheet-invoice .sheet-table thead {
  background: var(--brand) !important;
}

.sheet-invoice .sheet-table tbody tr.row-empty td {
  height: 22px;
  background: #fff;
}

.sheet-invoice .sheet-table .col-desc {
  font-size: 0.72rem;
  line-height: 1.35;
  word-break: break-word;
}

/* Summary */
.sheet-invoice .sheet-summary {
  margin: 0 !important;
  padding: 0 var(--inv-pad) 12px;
  border-bottom: 1px solid #c5cad3;
  grid-template-columns: 1fr 240px;
}

.sheet-invoice .sheet-totals {
  border: 1px solid #b8bec8 !important;
}

.sheet-invoice .sheet-totals td {
  border-bottom: 1px solid #b8bec8 !important;
  padding: 6px 10px !important;
  font-size: 0.74rem !important;
}

.sheet-invoice .sheet-thanks {
  margin-top: 10px !important;
  font-size: 0.72rem !important;
  font-style: italic;
  background: transparent !important;
  border: none !important;
  border-left: 3px solid var(--brand) !important;
  padding-left: 10px !important;
}

.balance-words-inline {
  margin-top: 12px;
  padding: 8px 10px;
  background: #f8f9fb;
  border: 1px dashed #c5cad3;
  border-radius: 4px;
}

.balance-words-inline .bw-label {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-light);
  margin-bottom: 3px;
}

.balance-words-inline .bw-value {
  font-size: 0.7rem;
  font-weight: 600;
  font-style: italic;
  color: var(--ink-muted);
  line-height: 1.4;
}

/* QR + Signature */
.sheet-invoice .sheet-verify {
  margin: 14px var(--inv-pad) 0 !important;
  padding: 12px 0 !important;
  border-top: none !important;
}

.sheet-invoice .verify-text {
  min-width: 0;
}

.sheet-invoice .verify-title {
  font-size: 0.78rem !important;
  font-weight: 800 !important;
  color: var(--brand) !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sheet-invoice .verify-sub {
  font-family: var(--font-ar);
  font-size: 0.65rem !important;
  color: var(--ink-light) !important;
}

.sheet-invoice .verify-thanks {
  margin: 8px 0 0;
  font-size: 0.68rem;
  line-height: 1.5;
  color: var(--ink-muted);
  font-style: italic;
}

.sig-heading {
  margin: 0 0 10px;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-light);
  text-align: center;
}

.sheet-invoice .stamp-seal {
  width: 100px;
  height: 100px;
}

/* Footer contact band */
.sheet-invoice .sheet-footer {
  margin-top: 0 !important;
  padding: 0 !important;
  background: #fff !important;
  border-top: 3px solid var(--brand) !important;
}

.footer-contact-band {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 14px var(--inv-pad);
  background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.contact-icon-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contact-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(227, 30, 36, 0.3);
}

.ci-loc::before { content: "⌖"; font-size: 0.9rem; }
.ci-tel::before { content: "☎"; font-size: 0.8rem; }
.ci-mail::before { content: "@"; font-size: 0.85rem; }

.contact-details {
  font-size: 0.72rem;
  line-height: 1.55;
  color: var(--ink-muted);
}

.contact-details p {
  margin: 0 0 3px;
}

.contact-title {
  font-size: 0.78rem !important;
  font-weight: 800 !important;
  color: var(--brand) !important;
  letter-spacing: 0.08em;
  margin-bottom: 4px !important;
}

.footer-bank-strip {
  padding: 8px var(--inv-pad) 12px;
  background: #f3f4f6;
  border-top: 1px solid #e2e5eb;
}

.footer-bank-strip .bank-text {
  margin: 0;
  font-size: 0.58rem !important;
  line-height: 1.5 !important;
  color: var(--ink-muted) !important;
  text-align: center;
}

/* Compact density for 12-row sheet */
.sheet-invoice.density-normal .sheet-table td,
.sheet-invoice.density-compact .sheet-table td,
.sheet-invoice.density-tight .sheet-table td {
  padding: 5px 8px !important;
  font-size: 0.7rem !important;
}

.sheet-invoice.density-tight .inv-top {
  padding-top: 14px;
  padding-bottom: 10px;
}

.sheet-invoice.density-tight .logo-classic {
  width: 140px;
}

.sheet-invoice.density-tight .inv-title-classic {
  font-size: 1.75rem;
}

.inv-accent-bar {
  height: 4px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--accent-orange) 55%, var(--brand) 100%);
}

/* —— Letterhead header (Rashid-style · Tasleem branding) —— */
.inv-letterhead {
  position: relative;
  margin: 14px var(--inv-pad) 0;
  border: 1px solid #cfd4dc;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 20, 25, 0.04);
}

.lh-accent-curve {
  position: absolute;
  left: -28px;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 120px;
  background: linear-gradient(160deg, var(--accent-orange) 0%, var(--brand) 100%);
  border-radius: 50%;
  z-index: 1;
}

.lh-inner {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 14px 28px;
  z-index: 2;
}

.lh-logo {
  flex-shrink: 0;
  width: 118px;
  max-width: 118px;
  padding: 4px 6px;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
}

.lh-logo .logo {
  display: block;
  width: 118px;
  max-width: 118px;
  height: auto;
  max-height: 80px;
  object-fit: contain;
  object-position: left center;
}

.lh-company {
  min-width: 0;
  padding-right: 8px;
}

.lh-ar {
  margin: 0 0 4px;
  font-family: var(--font-ar);
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.5;
  letter-spacing: 0.01em;
}

.lh-en {
  margin: 0 0 4px;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #1a2744;
  line-height: 1.25;
}

.lh-tagline {
  margin: 0 0 5px;
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--brand);
  letter-spacing: 0.02em;
  line-height: 1.35;
}

.lh-address {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--ink-muted);
  line-height: 1.4;
}

.lh-contact-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 12px 18px 12px 14px;
  background: linear-gradient(135deg, #1a1a1a 0%, #5c1218 55%, var(--brand-dark) 100%);
  border-radius: 999px 10px 10px 999px;
  color: #fff;
  min-width: 188px;
}

.lh-phone-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  color: #fff;
}

.lh-contact-text {
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.02em;
}

.lh-contact-text p {
  margin: 0;
}

.lh-divider {
  display: block;
  height: 1px;
  margin: 6px 0;
  background: rgba(255, 255, 255, 0.35);
}

.lh-email {
  font-size: 0.62rem !important;
  font-weight: 500 !important;
  word-break: break-all;
}

/* Invoice title strip below letterhead */
.inv-doc-strip {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 12px var(--inv-pad) 0;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--brand);
}

/* —— Classic invoice info block (reference layout) —— */
.inv-info-block {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  align-items: start;
  gap: 20px 28px;
  margin: 14px var(--inv-pad) 0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--brand);
  font-family: Georgia, "Times New Roman", Times, serif;
}

.inv-info-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inv-ar-label {
  margin: 0;
  font-family: var(--font-ar);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.5;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.inv-title-classic {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--brand);
  line-height: 1.1;
}

.inv-no-box {
  display: inline-block;
  margin-top: 4px;
  padding: 6px 12px;
  background: #eceef2;
  border: 1px solid #b8bec8;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.inv-no-label {
  font-weight: 700;
}

.inv-no-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.inv-date-line {
  margin: 4px 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}

.inv-customer-box {
  padding: 12px 16px;
  border: 1.5px solid var(--brand);
  border-radius: 6px;
  background: #fff;
}

.inv-info-row {
  margin: 0 0 7px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ink);
}

.inv-info-row:last-child {
  margin-bottom: 0;
}

.inv-info-row strong {
  font-weight: 700;
  color: var(--ink);
}

.inv-info-row span {
  font-weight: 400;
}

.invoice.density-tight .inv-info-block {
  margin-top: 10px;
  gap: 14px 20px;
  padding-bottom: 10px;
}

.invoice.density-tight .inv-title-classic {
  font-size: 1.45rem;
}

.invoice.density-tight .inv-no-box,
.invoice.density-tight .inv-date-line,
.invoice.density-tight .inv-info-row {
  font-size: 0.75rem;
}

.invoice.density-tight .inv-customer-box {
  padding: 10px 12px;
}

.inv-doc-strip-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inv-doc-strip .inv-title-pro {
  margin: 0;
  font-size: 1.65rem;
}

.footer-grid-bank {
  grid-template-columns: 1fr !important;
}

.footer-bank-full {
  text-align: center;
}

.footer-bank-full .bank-text {
  font-size: 0.68rem !important;
}

.invoice.density-tight .lh-logo .logo {
  width: 100px;
}

.invoice.density-tight .lh-en {
  font-size: 0.78rem;
}

.invoice.density-tight .lh-contact-pill {
  padding: 10px 14px 10px 12px;
  min-width: 170px;
}

.invoice.density-tight .lh-inner {
  padding: 10px 12px 10px 24px;
  gap: 10px;
}

/* —— Professional invoice hero header (legacy) —— */
.inv-hero {
  padding: 0;
  background: #fff;
}

.inv-hero-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px var(--inv-pad) 18px;
}

.inv-brand-block {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 1;
}

.inv-logo-wrap {
  flex-shrink: 0;
  padding: 6px 8px;
  background: #ffffff;
  border: 1px solid #e8ebf0;
  border-radius: 8px;
  box-shadow: none;
}

.inv-logo-wrap .logo {
  display: block;
  width: 150px;
  height: auto;
  object-fit: contain;
  background: #ffffff;
}

.inv-brand-copy {
  min-width: 0;
}

.inv-company-name {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1.3;
}

.inv-company-loc {
  margin: 5px 0 0;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--ink-light);
  letter-spacing: 0.02em;
}

.inv-doc-block {
  flex-shrink: 0;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.inv-doc-badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-orange);
  background: rgba(247, 148, 29, 0.1);
  border: 1px solid rgba(247, 148, 29, 0.35);
  border-radius: 999px;
}

.inv-title-pro {
  margin: 2px 0 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  line-height: 1;
  color: var(--brand);
}

.inv-number-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 7px 14px;
  background: linear-gradient(135deg, #fafbfc 0%, #f3f5f8 100%);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 20, 25, 0.04);
}

.inv-num-label {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-light);
}

.inv-num-value {
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.inv-hero-rule {
  height: 3px;
  margin: 0 var(--inv-pad);
  background: linear-gradient(90deg, var(--brand) 0%, var(--accent-orange) 50%, transparent 100%);
  border-radius: 2px;
}

/* —— Meta info cards —— */
.inv-meta-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.9fr 0.9fr;
  gap: 10px;
  margin: 16px var(--inv-pad) 0;
  padding: 0;
}

.meta-card {
  position: relative;
  padding: 12px 14px 14px;
  background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
  border: 1px solid #e8ebf0;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(15, 20, 25, 0.03);
  overflow: hidden;
}

.meta-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--accent-orange) 100%);
  opacity: 0.35;
}

.meta-card-primary {
  background: linear-gradient(135deg, #fff 0%, #fff8f8 100%);
  border-color: rgba(227, 30, 36, 0.15);
  box-shadow: 0 2px 8px rgba(227, 30, 36, 0.06);
}

.meta-card-primary::before {
  opacity: 1;
  height: 3px;
}

.meta-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 8px;
  margin-bottom: 8px;
}

.meta-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
}

.meta-card-primary .meta-dot {
  background: var(--accent-orange);
}

.meta-label-en {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}

.meta-label-ar {
  font-family: var(--font-ar);
  font-size: 0.56rem;
  font-weight: 600;
  color: var(--ink-light);
  margin-right: auto;
}

.meta-card-value {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  word-break: break-word;
  min-height: 1.2em;
}

.meta-card-primary .meta-card-value {
  font-size: 0.95rem;
  color: var(--brand-dark);
}

.inv-header {
  display: grid;
  grid-template-columns: 1fr 200px;
  grid-template-areas: "main brand";
  align-items: start;
  gap: 16px;
  padding: 22px var(--inv-pad) 18px;
  border-bottom: 2px solid var(--brand);
}

.inv-header-main {
  grid-area: main;
  min-width: 0;
}

.inv-header-brand {
  grid-area: brand;
}

.inv-doc-type {
  margin: 0 0 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--brand);
}

.inv-title {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.1;
  color: var(--ink);
}

.inv-meta-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 12px;
  padding: 6px 12px;
  background: #fafbfc;
  border: 1px solid var(--inv-border);
  border-radius: 4px;
}

.inv-meta-chip .meta-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-light);
}

.inv-meta-chip .meta-value {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.inv-header-brand {
  text-align: right;
  justify-self: end;
  width: 100%;
  max-width: 220px;
}

.inv-header-brand .logo {
  max-width: 200px;
  height: auto;
  display: block;
  margin-left: auto;
}

.brand-tagline {
  margin: 8px 0 0;
  max-width: 200px;
  margin-left: auto;
  font-size: 0.65rem;
  line-height: 1.4;
  color: var(--ink-light);
  text-align: right;
}

/* Customer details band */
.inv-parties {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr 0.85fr 0.85fr;
  margin: 16px var(--inv-pad) 0;
  border: 1px solid var(--inv-border);
  background: #fff;
}

.party-card {
  padding: 10px 12px;
  border-right: 1px solid var(--inv-border);
  background: #fff;
}

.party-card:last-child {
  border-right: none;
}

.party-bill {
  background: #f8f9fb;
}

.party-heading {
  margin: 0 0 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.party-heading .en {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-light);
}

.party-heading .ar {
  font-family: var(--font-ar);
  font-size: 0.58rem;
  color: var(--ink-light);
}

.party-value {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  min-height: 1.2em;
  word-break: break-word;
}

/* Services table — red header (Tasleem brand) */
.table-container {
  margin: 14px var(--inv-pad) 0;
  border: 1px solid var(--inv-border);
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.items-table thead {
  background: var(--brand);
  color: #fff;
}

.items-table th {
  padding: 9px 10px;
  font-size: 0.6rem;
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
  border: 1px solid var(--brand-dark);
}

.items-table th .th-en {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.items-table th .th-ar {
  display: block;
  font-family: var(--font-ar);
  font-size: 0.58rem;
  font-weight: 500;
  opacity: 0.85;
  margin-top: 2px;
}

.items-table tbody tr {
  background: #fff;
}

.items-table tbody tr:nth-child(even) {
  background: #fcfcfd;
}

.items-table td {
  padding: 8px 10px;
  font-size: 0.78rem;
  vertical-align: middle;
  border: 1px solid var(--inv-border);
  min-height: 26px;
}

.items-table .col-no {
  width: 36px;
  text-align: center;
  font-weight: 600;
  color: var(--ink-light);
  font-size: 0.72rem;
}

.items-table .col-desc {
  text-align: left;
  font-weight: 500;
}

.items-table .col-qty {
  width: 48px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.items-table .col-price,
.items-table .col-total {
  width: 88px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.items-table .col-total {
  font-weight: 600;
}

/* Totals + note */
.inv-summary {
  display: grid;
  grid-template-columns: 1fr 248px;
  align-items: start;
  gap: 16px;
  margin: 14px var(--inv-pad) 0;
}

.summary-note {
  min-width: 0;
}

.other-note {
  margin: 0;
  padding: 10px 14px;
  font-size: 0.76rem;
  font-style: italic;
  color: #4a5560;
  background: #f8f9fb;
  border-left: 3px solid var(--brand);
  line-height: 1.5;
}

.other-note:empty {
  display: none;
}

.summary-totals {
  width: 248px;
  justify-self: end;
}

.totals-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--inv-border);
  table-layout: fixed;
}

.totals-table td {
  padding: 7px 12px;
  font-size: 0.76rem;
  border-bottom: 1px solid var(--inv-border);
}

.totals-table tr:last-child td {
  border-bottom: none;
}

.totals-table td:first-child {
  background: var(--surface-2);
}

.totals-table .t-en {
  display: block;
  font-weight: 600;
  color: var(--ink-muted);
}

.totals-table .t-ar {
  display: block;
  font-family: var(--font-ar);
  font-size: 0.62rem;
  color: var(--ink-light);
  margin-top: 1px;
}

.totals-table td:last-child {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

.balance-row td {
  background: var(--brand) !important;
  color: #fff !important;
  padding: 10px 12px !important;
  border-color: var(--brand-dark) !important;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.balance-row .t-en,
.balance-row .t-ar {
  color: rgba(255, 255, 255, 0.9) !important;
}

.balance-row td:last-child {
  font-size: 1.05rem !important;
}

.balance-row .currency {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.9;
  margin-right: 4px;
}

.balance-words-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: #fff8f0;
  border: 1px solid var(--accent-orange);
  border-left: 4px solid var(--accent-orange);
  border-radius: 4px;
}

.bw-label {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-light);
  margin-bottom: 4px;
}

.bw-value {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  font-style: italic;
  color: var(--ink);
  line-height: 1.45;
}

.payment-note-block {
  margin-bottom: 10px;
}

.note-label {
  margin: 0 0 4px;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand);
}

.payment-note {
  margin: 0;
  padding: 8px 12px;
  font-size: 0.74rem;
  background: #fff5f5;
  border-left: 3px solid var(--brand);
  line-height: 1.45;
  color: var(--ink-muted);
}

.qr-box {
  border: 2px solid var(--brand) !important;
  border-radius: 6px;
}

/* Verification */
.inv-verification {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 18px var(--inv-pad) 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--inv-border);
}

.verify-qr {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 16px;
}

.qr-box {
  padding: 6px;
  background: #fff;
  border: 1px solid var(--inv-border);
}

.qr-box img {
  display: block;
}

.verify-title {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink);
}

.verify-sub {
  margin: 4px 0 0;
  font-size: 0.68rem;
  color: var(--ink-light);
}

.verify-stamp {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stamp-seal {
  width: 108px;
  height: 108px;
  padding: 4px;
  border: 2px solid #1a4d8c;
  border-radius: 50%;
  transform: rotate(-12deg);
}

.stamp-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed #1a4d8c;
  border-radius: 50%;
  color: #1a4d8c;
  text-align: center;
  line-height: 1.25;
}

.stamp-name {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.stamp-type {
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
}

.stamp-loc {
  font-size: 0.5rem;
  margin-top: 2px;
  opacity: 0.85;
}

.signature-line {
  margin: 16px 0 0;
  width: 160px;
  padding-top: 32px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-light);
  text-align: center;
  border-top: 1px solid var(--ink);
}

/* Footer */
.inv-footer {
  margin-top: 16px;
  padding: 16px var(--inv-pad) 18px;
  background: #f3f4f6;
  border-top: 3px solid var(--brand);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 20px;
}

.footer-block h4 {
  margin: 0 0 6px;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
}

.footer-block p {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.55;
  color: var(--ink-muted);
}

.contact-line {
  display: block;
}

.bank-text {
  font-size: 0.65rem !important;
  line-height: 1.45 !important;
}

.footer-legal {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.62rem;
  color: var(--ink-light);
  text-align: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 22px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 10000;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.toast.error {
  background: var(--brand-dark);
}

.toast.warn {
  background: #b45309;
}

.toast.ok {
  background: #166534;
}

/* Off-screen clone for PDF — fixed A4 width, same as preview */
.pdf-capture-host {
  position: fixed;
  left: -12000px;
  top: 0;
  width: 794px;
  background: #fff;
  z-index: -1;
  pointer-events: none;
}

.pdf-capture-host .invoice.pro-invoice {
  width: 794px !important;
  min-width: 794px !important;
  max-width: 794px !important;
  overflow: visible !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

/* Screen-only print reminder */
.print-tip {
  margin: 0 0 10px;
  padding: 10px 12px;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--ink-muted);
  background: #fff8e6;
  border: 1px solid #f0d78c;
  border-radius: 8px;
}

.print-tip.highlight {
  border-color: var(--brand);
  background: var(--brand-soft);
}

@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* Search page */
.search-page {
  min-height: 100vh;
}

.search-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.search-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-header h1 {
  margin: 0;
  font-size: 1.35rem;
}

.search-header p {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.search-header .btn {
  margin-left: auto;
  width: auto;
  margin-bottom: 0;
}

.search-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}

.search-form {
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.search-form .field {
  margin-bottom: 0;
}

.search-form .btn {
  width: auto;
  margin-bottom: 0;
  white-space: nowrap;
}

.search-status {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 12px;
}

.results-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
}

.results-table th {
  padding: 12px 14px;
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--brand);
  color: #fff;
}

.results-table td {
  padding: 12px 14px;
  font-size: 0.84rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.results-table tr:hover td {
  background: var(--surface-2);
}

.work-cell {
  max-width: 220px;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.empty-row {
  text-align: center;
  color: var(--ink-light);
  padding: 32px !important;
}

.results-table .btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
  margin-bottom: 0;
  width: auto;
}

/* View page */
.view-page {
  background: #eef0f4;
}

.view-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
}

.view-toolbar .btn {
  width: auto;
  margin-bottom: 0;
}

.view-preview-wrap {
  padding-top: 24px;
}

.load-error {
  max-width: 600px;
  margin: 24px auto;
  padding: 16px 20px;
  background: #fdecea;
  color: var(--brand-dark);
  border-radius: var(--radius);
  text-align: center;
  font-weight: 600;
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 1fr;
  }

  .editor {
    position: static;
    max-height: none;
  }

  .field-grid-3 {
    grid-template-columns: 1fr;
  }

  .inv-meta-grid {
    grid-template-columns: 1fr 1fr;
    margin: 0 20px;
  }

  .meta-card-primary {
    grid-column: span 2;
  }

  .inv-hero-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
  }

  .lh-inner {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
  }

  .lh-accent-curve {
    left: -20px;
    width: 44px;
    height: 90px;
  }

  .lh-contact-pill {
    width: 100%;
    min-width: 0;
    border-radius: 12px;
  }

  .inv-info-block {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .inv-customer-box {
    width: 100%;
  }

  .inv-doc-strip {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .inv-doc-block {
    align-items: flex-start;
    text-align: left;
    width: 100%;
  }

  .inv-title-pro {
    font-size: 1.6rem;
  }

  .inv-summary {
    grid-template-columns: 1fr;
  }

  .summary-totals {
    width: 100%;
    justify-self: stretch;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }

  .search-form {
    grid-template-columns: 1fr 1fr;
  }

  .search-header .btn {
    margin-left: 0;
    width: 100%;
  }
}
