:root {
  --bg: #f4f7fb;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: #ffffff;
  --text: #13233f;
  --muted: #708099;
  --line: rgba(19, 35, 63, 0.1);
  --primary: #6d28d9;
  --primary-dark: #4c1d95;
  --accent: #f59e0b;
  --danger: #dc2626;
  --success: #0f766e;
  --shadow: 0 22px 60px rgba(19, 35, 63, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Tajawal", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(109, 40, 217, 0.12), transparent 22%),
    radial-gradient(circle at top left, rgba(245, 158, 11, 0.08), transparent 20%),
    linear-gradient(180deg, #fbfcff 0%, var(--bg) 100%);
  color: var(--text);
}
body { padding: 20px; }
button, input, select, textarea { font: inherit; }

.layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 18px;
  min-height: calc(100vh - 40px);
}

.sidebar, .panel, .modal-card, .login-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar {
  border-radius: 34px;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  border-radius: 28px;
  padding: 22px;
  background: linear-gradient(135deg, #140f2e 0%, #6d28d9 56%, #c026d3 100%);
  color: #fff;
}

.brand-logo, .login-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: #fff;
  border-radius: 18px;
  padding: 8px;
}

.brand h1, .brand p, .login-card h1, .login-card p { margin: 0; }
.brand h1 { margin-top: 12px; }
.brand p { margin-top: 8px; color: rgba(255,255,255,0.8); }

.nav-list { display: grid; gap: 10px; }
.nav-button {
  border: 0;
  background: transparent;
  border-radius: 18px;
  padding: 14px 16px;
  text-align: right;
  color: var(--text);
  cursor: pointer;
  transition: .2s ease;
}
.nav-button:hover, .nav-button.active {
  background: linear-gradient(135deg, rgba(109,40,217,.12), rgba(19,35,63,.05));
  color: var(--primary-dark);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-radius: 20px;
  background: rgba(109, 40, 217, 0.08);
  color: var(--muted);
}

.content { display: flex; flex-direction: column; gap: 16px; }
.topbar, .section-head, .hero-note {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.topbar h2, .topbar p, .section-head h3, .section-head p, .hero-note h3, .hero-note p { margin: 0; }
.topbar h2 { font-size: 1.95rem; }
.muted { color: var(--muted); }

.panel { border-radius: var(--radius-xl); padding: 22px; }
.soft-panel { background: rgba(248, 250, 252, 0.8); }

.hero-note {
  padding: 20px 22px;
  border-radius: 28px;
  color: #fff;
  background: linear-gradient(135deg, #0f172a 0%, #6d28d9 55%, #c026d3 100%);
}
.hero-note p { color: rgba(255,255,255,0.82); }

.stats-grid, .cards-grid, .report-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.chart-panel {
  padding: 20px;
}
.chart-shell {
  position: relative;
  height: 320px;
  margin-top: 14px;
}
.report-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.report-shell,
.report-stack,
.report-two-up,
.report-overview-grid,
.report-summary-grid,
.report-section-panel,
.report-table-wrap,
.content,
.panel {
  min-width: 0;
}
.report-hero-panel {
  padding-bottom: 18px;
}
.report-shell {
  padding: 24px;
}
.report-toolbar-clean {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.report-board {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: start;
}
.report-main,
.report-side {
  display: grid;
  gap: 16px;
  align-content: start;
}
.report-side-panel {
  padding: 20px;
}
.stat-card, .report-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
}
.report-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
}
.report-toolbar-copy h3,
.report-toolbar-copy p {
  margin: 0;
}
.report-toolbar-copy {
  max-width: 560px;
}
.report-toolbar-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.report-toolbar-actions .field {
  min-width: 240px;
  max-width: 280px;
}
.report-card h4 {
  margin: 12px 0 8px;
  font-size: 1.9rem;
}
.report-card p {
  margin: 0;
}
.report-kpis-clean .report-card {
  min-height: 148px;
}
.report-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.report-strip-card {
  background: linear-gradient(180deg, rgba(109, 40, 217, 0.06), rgba(255, 255, 255, 0.96));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px 18px;
  display: grid;
  gap: 10px;
}
.report-strip-card span {
  color: var(--muted);
  font-size: .92rem;
}
.report-strip-card strong {
  font-size: 1.2rem;
}
.report-stack {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}
.report-two-up {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.report-table-wrap {
  overflow-x: auto;
}
.report-screen-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}
.report-screen-table-narrow {
  table-layout: auto;
}
.report-screen-table th,
.report-screen-table td {
  word-break: break-word;
}
.report-savings-panel-clean {
  background: linear-gradient(180deg, rgba(217, 70, 239, 0.08), rgba(255, 255, 255, 0.98));
}
.label, .mini-title { color: var(--muted); font-size: .95rem; }
.value { font-size: 1.8rem; font-weight: 800; margin: 10px 0 6px; }
.delta { color: var(--success); font-weight: 700; }
.danger { color: var(--danger); }

.form-grid, .filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.wide-span { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field span { color: var(--muted); font-size: .92rem; }
.field input, .field select, .field textarea, .readonly-box {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  background: rgba(248, 250, 252, .9);
  color: var(--text);
}
.field textarea { min-height: 110px; resize: vertical; }
.readonly-box { min-height: 48px; display: flex; align-items: center; }
.customer-lookup-box {
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
  line-height: 1.5;
}
.customer-lookup-box small {
  color: var(--muted);
  font-size: .86rem;
}
.customer-miss-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.savings-grid {
  margin-bottom: 18px;
}
.savings-items-editor {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}
.savings-item-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
}
.savings-value {
  font-size: 1.5rem;
  overflow-wrap: anywhere;
}

.action-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%); color: #fff; }
.btn-secondary { background: rgba(19,35,63,.06); color: var(--text); }
.btn-accent { background: rgba(245,158,11,.14); color: #9a6700; }
.btn-danger { background: rgba(220,38,38,.12); color: var(--danger); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.list { display: grid; gap: 10px; }
.list-item {
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.list-item strong, .list-item span { display: block; }

.split { display: grid; grid-template-columns: 1.05fr .95fr; gap: 16px; }
.review-split { margin-top: 16px; }
.compact-head { margin-top: 12px; }

.customer-bank-shell {
  overflow: hidden;
}
.customer-ledger-shell {
  overflow: hidden;
}
.customer-ledger-top {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .95fr);
  gap: 16px;
}
.customer-ledger-form {
  padding: 18px;
}
.customer-ledger-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.customer-table-filters {
  grid-template-columns: minmax(280px, 1fr);
}
.document-center-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.85fr);
  gap: 16px;
  margin-top: 18px;
}
.document-type-grid {
  margin-top: 18px;
}
.document-type-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
  display: grid;
  gap: 8px;
  text-align: right;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.document-type-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.07);
}
.document-type-card.active {
  border-color: rgba(109, 40, 217, 0.28);
  box-shadow: 0 16px 32px rgba(109, 40, 217, 0.12);
  background: linear-gradient(180deg, rgba(109, 40, 217, 0.10), rgba(255,255,255,0.98));
}
.document-type-card strong {
  font-size: 1.1rem;
}
.document-type-card span {
  color: var(--muted);
  line-height: 1.7;
}
.document-preview-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(248,250,252,0.75);
}
.document-preview-card h4,
.document-preview-card p {
  margin: 8px 0 0;
}
.document-registry-table {
  min-width: 980px;
}
.settings-stack {
  display: grid;
  gap: 18px;
}
.settings-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0;
}
.settings-tab {
  border: 1px solid var(--line);
  background: rgba(248,250,252,.92);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  transition: .18s ease;
}
.settings-tab.active,
.settings-tab:hover {
  background: linear-gradient(135deg, rgba(109,40,217,.14), rgba(255,255,255,.98));
  border-color: rgba(109,40,217,.26);
  color: var(--primary-dark);
}
.settings-subsection {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,250,252,0.82));
}
.document-settings-hint {
  min-height: auto;
  display: grid;
  gap: 6px;
  align-items: start;
  background: linear-gradient(180deg, rgba(109,40,217,.06), rgba(255,255,255,.95));
}
.document-settings-hint strong {
  font-size: .98rem;
}
.document-settings-hint small {
  color: var(--muted);
  line-height: 1.7;
}
.document-invoice .invoice-meta-card {
  background: linear-gradient(135deg, #111827 0%, #5b21b6 100%);
}
.document-quote {
  border-top: 8px solid #c026d3;
  background: linear-gradient(180deg, rgba(255,255,255,1), rgba(253,244,255,0.92));
  position: relative;
  overflow: hidden;
}
.document-quote .invoice-meta-card {
  background: linear-gradient(135deg, #701a75 0%, #d946ef 100%);
}
.document-quote .eyebrow {
  background: rgba(217,70,239,.12);
  color: #a21caf;
}
.document-payment-request {
  border-top: 8px solid #0f766e;
  background: linear-gradient(180deg, rgba(255,255,255,1), rgba(240,253,250,0.94));
}
.document-payment-request .invoice-meta-card {
  background: linear-gradient(135deg, #0f172a 0%, #0f766e 100%);
}
.document-payment-request .eyebrow {
  background: rgba(15,118,110,.12);
  color: #0f766e;
}
.document-payment-request .totals-row.grand {
  background: #0f766e;
}
.quote-watermark {
  position: absolute;
  inset: 18% auto auto 50%;
  width: 320px;
  height: 360px;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0.18;
}
.quote-watermark-shape {
  position: absolute;
  display: block;
  border-radius: 44px;
  background: linear-gradient(180deg, rgba(192,38,211,0.18), rgba(109,40,217,0.08));
  filter: blur(0.2px);
}
.quote-watermark-shape-a {
  width: 108px;
  height: 280px;
  right: 48%;
  top: 34px;
  transform: rotate(32deg);
}
.quote-watermark-shape-b {
  width: 108px;
  height: 280px;
  left: 48%;
  top: 34px;
  transform: rotate(-32deg);
}
.quote-header-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 18px;
}
.quote-header-brand {
  display: flex;
  gap: 16px;
  align-items: center;
}
.quote-header-brand img {
  width: 76px;
  height: 76px;
  object-fit: contain;
}
.quote-main-title {
  margin: 10px 0 22px;
  text-align: center;
  font-size: 1.75rem;
}
.quote-meta-stack {
  display: grid;
  gap: 10px;
  min-width: 220px;
}
.quote-meta-pill {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(217,70,239,.18);
  background: rgba(255,255,255,.88);
  font-weight: 800;
  text-align: center;
  color: #111827;
}
.quote-intro-copy {
  margin: 0 0 20px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(253,244,255,.85), rgba(255,255,255,.9));
  border: 1px solid rgba(217,70,239,.14);
  line-height: 1.9;
  text-align: center;
}
.quote-party-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.quote-party-grid div {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(217,70,239,.18);
  background: rgba(255,255,255,.82);
  display: grid;
  gap: 8px;
}
.quote-party-grid div strong {
  color: #a21caf;
}
.quote-party-grid div span {
  font-weight: 700;
}
.quote-body-section {
  border-top: 2px solid rgba(17,24,39,.9);
  border-bottom: 2px solid rgba(17,24,39,.9);
  padding: 18px 0;
  margin: 18px 0;
}
.quote-body-section h3 {
  margin: 0 0 12px;
}
.quote-lines-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}
.quote-line-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 16px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,.84);
  border: 1px solid rgba(19,35,63,.08);
}
.quote-line-index {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #a21caf;
  background: rgba(217,70,239,.12);
}
.quote-line-copy {
  display: grid;
  gap: 8px;
}
.quote-line-copy strong {
  font-size: 1rem;
}
.quote-line-copy p {
  margin: 0;
  line-height: 1.95;
  color: #334155;
}
.quote-price-box {
  margin-top: 22px;
  padding: 18px 20px;
  border-radius: 22px;
  border: 2px solid rgba(217,70,239,.28);
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(253,244,255,.94));
}
.quote-price-label {
  color: #a21caf;
  font-weight: 900;
  margin-bottom: 8px;
}
.quote-price-value {
  font-size: 1.5rem;
  font-weight: 900;
  margin-bottom: 8px;
}
.quote-price-box p {
  margin: 8px 0 0;
  line-height: 1.9;
}
.quote-validity-note {
  color: #a21caf;
  font-weight: 800;
}
.quote-notes-block p {
  line-height: 1.9;
}
.customer-table-wrap {
  margin-top: 16px;
}
.customer-ledger-table {
  min-width: 1180px;
}
.customer-ledger-table td strong {
  font-size: 1rem;
}
.customer-bank-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.8fr);
  gap: 16px;
}
.customer-bank-summary {
  display: grid;
  gap: 14px;
}
.customer-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.customer-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  display: grid;
  gap: 16px;
}
.customer-card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}
.customer-card-head h4,
.customer-card-head p {
  margin: 0;
}
.customer-card-head h4 {
  margin-top: 10px;
  font-size: 1.25rem;
}
.customer-card-head p {
  margin-top: 6px;
  color: var(--muted);
}
.customer-chip {
  display: inline-flex;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(109,40,217,.08);
  color: var(--primary-dark);
  font-weight: 800;
}
.customer-card-balance {
  min-width: 140px;
  text-align: left;
  display: grid;
  gap: 6px;
}
.customer-card-balance span {
  color: var(--muted);
  font-size: .88rem;
}
.customer-card-balance strong {
  font-size: 1.2rem;
}
.customer-card-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.customer-card-meta div {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(248,250,252,.82);
}
.customer-card-meta span {
  display: block;
  color: var(--muted);
  font-size: .86rem;
  margin-bottom: 6px;
}
.customer-card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.customer-empty {
  grid-column: 1 / -1;
}

.invoice-item-list { display: grid; gap: 12px; }
.item-row {
  display: grid;
  grid-template-columns: 1.15fr 1.65fr .75fr .85fr .95fr auto;
  gap: 14px;
  align-items: end;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.04);
}
.item-row .btn { align-self: stretch; }
.invoice-item-list {
  display: grid;
  gap: 14px;
}
.invoice-list-kpis {
  margin: 18px 0 0;
}

.review-note {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  font-weight: 700;
}
.review-note.ok { background: rgba(15,118,110,.12); color: var(--success); }
.review-note.warn { background: rgba(245,158,11,.14); color: #9a6700; }

.table-wrap {
  overflow: auto;
  border-radius: 20px;
  border: 1px solid var(--line);
  margin-top: 12px;
  background: #fff;
}
table { width: 100%; border-collapse: collapse; min-width: 860px; background: #fff; }
th, td { padding: 14px; text-align: right; border-bottom: 1px solid var(--line); }
thead th { background: #f8fafc; color: var(--muted); }
.table-empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 16px;
}

.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.invoices-filters {
  grid-template-columns: minmax(280px, 1.35fr) repeat(3, minmax(160px, .7fr));
  align-items: end;
}
.invoices-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
}
.invoices-table-wrap {
  margin-top: 16px;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.06);
}
.invoices-table {
  min-width: 1120px;
}
.invoices-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-top: 18px;
  padding-bottom: 18px;
  font-size: 1rem;
  font-weight: 800;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}
.invoices-table tbody td {
  vertical-align: middle;
  padding-top: 18px;
  padding-bottom: 18px;
}
.invoice-row {
  transition: background .18s ease;
}
.invoice-row:hover {
  background: rgba(109, 40, 217, 0.035);
}
.invoice-row-cancelled {
  background: rgba(248, 113, 113, 0.05);
}
.invoice-id-cell strong {
  display: inline-block;
  font-size: 1rem;
  line-height: 1.45;
}
.invoice-service-cell {
  min-width: 220px;
  max-width: 320px;
  color: var(--ink-soft);
  line-height: 1.7;
}
.invoice-actions {
  min-width: 180px;
}
.invoice-actions .btn {
  min-width: 72px;
}
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
}
.pagination-meta {
  color: var(--muted);
  font-weight: 700;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 700;
}
.status-paid { background: rgba(15,118,110,.12); color: var(--success); }
.status-pending { background: rgba(245,158,11,.14); color: #9a6700; }
.status-overdue { background: rgba(220,38,38,.12); color: var(--danger); }

.totals {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
}
.totals-row.grand {
  background: #111827;
  color: #fff;
  font-weight: 800;
}

.statement-footer {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(109, 40, 217, 0.08);
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 40;
}
.modal-card {
  width: min(1180px, 100%);
  max-height: 92vh;
  overflow: auto;
  border-radius: 28px;
  padding: 24px;
}
.modal-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.pdf-modal { background: #f8fafc; }
.invoice-doc {
  background: #fff;
  color: #111827;
  border-radius: 24px;
  padding: 28px;
  border: 1px solid #e5e7eb;
}
.expense-doc {
  background: linear-gradient(180deg, rgba(255,255,255,1), rgba(248,250,252,0.98));
}
.withdrawal-doc {
  background: linear-gradient(180deg, rgba(255,255,255,1), rgba(255,251,235,0.98));
}
.expense-meta-card {
  background: linear-gradient(135deg, #0f172a 0%, #7c3aed 100%);
}
.withdrawal-meta-card {
  background: linear-gradient(135deg, #0f172a 0%, #f59e0b 100%);
}
.invoice-doc-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 22px;
}
.invoice-branding { display: flex; gap: 16px; align-items: center; }
.invoice-branding img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  border-radius: 18px;
  background: #fff;
  padding: 8px;
  border: 1px solid #ede9fe;
}
.eyebrow {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(109,40,217,.08);
  color: var(--primary);
  font-size: .8rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.invoice-branding h2, .invoice-branding p { margin: 0; }
.invoice-meta-card {
  min-width: 290px;
  padding: 16px 18px;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(135deg, #111827 0%, #5b21b6 100%);
  display: grid;
  gap: 10px;
}
.invoice-meta-card span { color: rgba(255,255,255,.74); font-size: .82rem; display: block; }
.invoice-meta-card strong { display: block; margin-top: 3px; }
.invoice-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.invoice-barcode-block {
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.invoice-barcode {
  width: 100%;
  max-height: 92px;
}
.info-card, .invoice-notes {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid #e5e7eb;
  background: #fff;
}
.info-card h4, .invoice-notes strong { margin: 0 0 10px; display: block; }
.info-card p, .invoice-notes p { margin: 6px 0; }
.invoice-table { min-width: 0; margin-top: 0; }
.invoice-footer-line {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: space-between;
  color: #475569;
  font-size: .92rem;
}
.link-button {
  background: transparent;
  border: 0;
  color: var(--primary-dark);
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}
.report-doc {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  overflow: hidden;
  color: #111827;
}
.report-doc-header {
  position: relative;
  padding: 0 24px 16px;
}
.report-header-band {
  height: 46px;
  background: linear-gradient(90deg, #c026d3 0%, #111827 50%, #c026d3 100%);
}
.report-brand-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding-top: 18px;
}
.report-brand-side {
  text-align: center;
  font-weight: 800;
  border-bottom: 3px solid #e5e7eb;
  padding-bottom: 8px;
}
.report-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
}
.report-doc-body {
  padding: 8px 36px 24px;
}
.report-basmala,
.report-title,
.report-period {
  text-align: center;
  margin: 0 0 12px;
}
.report-title {
  font-size: 1.8rem;
  font-weight: 900;
}
.report-period {
  font-weight: 700;
}
.report-section {
  border-top: 2px solid #1f2937;
  padding-top: 18px;
  margin-top: 18px;
}
.report-section h3,
.report-savings-box h3 {
  margin: 0 0 14px;
}
.report-bullets {
  margin: 0;
  display: grid;
  gap: 10px;
  padding-right: 20px;
}
.report-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
.report-table th,
.report-table td {
  border: 1px solid #cbd5e1;
  padding: 11px 12px;
  text-align: right;
}
.report-table th {
  background: #f3f4f6;
}
.report-total-row {
  font-weight: 800;
}
.report-savings-box {
  margin-top: 24px;
  border: 3px solid #d946ef;
  padding: 18px 20px;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(217,70,239,.08), rgba(255,255,255,.9));
}
.report-savings-box h3 {
  background: linear-gradient(90deg, #d946ef, #c026d3);
  color: #fff;
  padding: 10px 14px;
  margin: -18px -20px 16px;
  text-align: center;
}
.report-footer-line {
  padding: 18px 24px 22px;
  margin-top: 0;
}

.login-shell {
  min-height: calc(100vh - 40px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: min(520px, 100%);
  border-radius: 30px;
  padding: 28px;
  text-align: center;
}
.login-grid {
  display: grid;
  gap: 14px;
  margin: 18px 0;
}
.alert {
  padding: 12px 14px;
  border-radius: 16px;
  margin-bottom: 14px;
  font-weight: 700;
}
.alert.danger { background: rgba(220,38,38,.12); color: var(--danger); }
.print-body { margin: 0; padding: 24px; background: #fff; }

@media (max-width: 1200px) {
  .stats-grid, .report-grid, .report-kpis, .report-summary-strip, .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .invoice-columns { grid-template-columns: 1fr; }
  .document-center-grid,
  .customer-ledger-top,
  .customer-bank-grid,
  .customer-cards-grid { grid-template-columns: 1fr; }
  .customer-ledger-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-board { grid-template-columns: 1fr; }
  .report-two-up,
  .report-summary-grid { grid-template-columns: 1fr; }
  .form-grid, .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invoices-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invoices-toolbar,
  .pagination-bar { flex-direction: column; align-items: stretch; }
}

@media (max-width: 900px) {
  body { padding: 12px; }
  .layout { grid-template-columns: 1fr; }
  .topbar, .section-head, .hero-note, .invoice-doc-header { flex-direction: column; align-items: stretch; }
  .report-toolbar { flex-direction: column; align-items: stretch; }
}

@media (max-width: 640px) {
  .stats-grid, .report-grid, .report-kpis, .report-summary-strip, .chart-grid, .form-grid, .filters, .invoice-columns { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr; }
  .document-type-grid { grid-template-columns: 1fr; }
  .customer-ledger-kpis { grid-template-columns: 1fr; }
  .quote-party-grid { grid-template-columns: 1fr; }
  .quote-line-card { grid-template-columns: 1fr; }
  .quote-line-index { width: 48px; height: 48px; }
  .customer-card-head,
  .customer-card-meta { grid-template-columns: 1fr; }
  .customer-card-head { flex-direction: column; }
  .customer-card-balance { text-align: right; }
  .savings-item-row { grid-template-columns: 1fr; }
  .invoice-footer-line { flex-direction: column; gap: 8px; }
  .customer-miss-note { flex-direction: column; align-items: stretch; }
  .report-toolbar-actions { flex-direction: column; align-items: stretch; }
  .report-toolbar-actions .field { min-width: 0; }
  .invoices-filters { grid-template-columns: 1fr; }
  .invoices-toolbar,
  .pagination-bar { padding: 12px 14px; }
  .invoice-actions { min-width: 0; }
}
