:root {
  --color-primary: #1E3A8A;
  --color-secondary: #2563EB;
  --color-success: #16A34A;
  --color-danger: #DC2626;
  --color-warning: #F59E0B;
  --color-bg: #F8FAFC;
  --color-card: #FFFFFF;
  --color-border: #E7EBF3;
  --color-text: #0F172A;
  --color-text-muted: #64748B;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 4px 10px rgba(15, 23, 42, 0.06), 0 16px 32px rgba(15, 23, 42, 0.09);
}

.pricing-strip {
  background: var(--color-primary);
  color: #fff;
  font-size: .82rem;
  font-weight: 500;
  text-align: center;
  padding: 7px 12px;
}
.pricing-strip strong { color: #FDE68A; }

[data-bs-theme="dark"] {
  --color-bg: #0B1220;
  --color-card: #121A2B;
  --color-border: #22304A;
  --color-text: #E8EDF7;
  --color-text-muted: #94A3B8;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

/* ---------- App Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--color-primary), #16296B);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: transform .25s ease;
  z-index: 40;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px; font-weight: 800; font-size: 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand i { font-size: 1.4rem; }

.sidebar-nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 12px;
  color: rgba(255,255,255,.78);
  padding: 11px 14px; border-radius: var(--radius-sm);
  font-weight: 500; margin-bottom: 4px; transition: all .18s ease;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav .nav-link.active { background: #fff; color: var(--color-primary); box-shadow: var(--shadow-soft); }

.sidebar-section-title { padding: 14px 14px 6px; margin-top: 6px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-section-title span { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.5); font-weight: 700; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.12); }
.badge-role { background: rgba(255,255,255,.14); padding: 5px 12px; border-radius: 20px; font-size: .75rem; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
  height: 68px; display: flex; align-items: center; gap: 16px;
  padding: 0 28px; background: var(--color-card); border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-size: 1.2rem; font-weight: 700; margin: 0; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn-icon {
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--color-border); background: var(--color-card); color: var(--color-text);
}
.btn-icon:hover { background: var(--color-bg); }

.btn-user {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--color-border);
  border-radius: 10px; padding: 6px 12px; background: var(--color-card);
}
.avatar, .avatar-sm {
  width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}
.avatar-sm { width: 38px; height: 38px; flex-shrink: 0; }

.app-content { padding: 28px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ---------- Cards ---------- */
.card-panel {
  background: var(--color-card); border-radius: var(--radius-lg); border: 1px solid var(--color-border);
  box-shadow: var(--shadow-soft); padding: 24px; margin-bottom: 0;
}
.panel-title { font-weight: 700; margin-bottom: 16px; font-size: 1rem; }

/* ---------- Stats ---------- */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px;
}
@media (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 576px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--color-card); border-radius: var(--radius-lg); border: 1px solid var(--color-border);
  box-shadow: var(--shadow-soft); padding: 20px; display: flex; align-items: center; gap: 14px;
  transition: box-shadow .2s ease, transform .2s ease;
}
.stat-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-label { color: var(--color-text-muted); font-size: .8rem; margin: 0 0 2px; font-weight: 500; }
.stat-card h3 { margin: 0; font-size: 1.35rem; font-weight: 800; }

.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }

/* ---------- Buttons ---------- */
.btn { border-radius: 10px; font-weight: 600; padding: 9px 18px; }
.btn-lg { padding: 12px 24px; border-radius: 12px; }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-secondary); border-color: var(--color-secondary); }
.btn-sm.btn-icon { width: 32px; height: 32px; padding: 0; }

/* ---------- Tables ---------- */
.table { margin-bottom: 0; }
.table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-border); font-weight: 700; white-space: nowrap;
}
.table td { vertical-align: middle; border-color: var(--color-border); }
.table-hover tbody tr:hover { background: rgba(37, 99, 235, .05); }

/* ---------- Auth ---------- */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at top left, #1E3A8A, #0B1739 65%);
  font-family: 'Inter', sans-serif; padding: 20px;
}
.auth-card {
  background: #fff; border-radius: 20px; padding: 40px; width: 100%; max-width: 420px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand i { font-size: 2.4rem; color: var(--color-primary); }
.auth-brand h1 { font-size: 1.4rem; font-weight: 800; margin: 10px 0 2px; }
.auth-brand p { color: var(--color-text-muted); margin: 0; font-size: .9rem; }
.auth-hint { text-align: center; color: var(--color-text-muted); font-size: .8rem; margin-top: 16px; }

/* ---------- Totals / Invoice Form ---------- */
.totals-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: .92rem; }
.totals-row.grand-total { font-size: 1.2rem; font-weight: 800; color: var(--color-primary); padding-top: 10px; }

.recent-customers li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.recent-customers li:last-child { border-bottom: none; }

.payment-history li { padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.payment-history li:last-child { border-bottom: none; }

.settings-thumb { max-height: 60px; border-radius: 8px; border: 1px solid var(--color-border); }

/* ---------- Invoice document (shared by view/print) ---------- */
.invoice-doc {
  font-size: .92rem; color: #1e293b; line-height: 1.5;
  /* Theme variables - these defaults reproduce the original look exactly.
  --doc-accent: var(--color-primary);
  --doc-accent-soft: #EEF2FF;
  --doc-heading-bg: none;
  --doc-heading-color: var(--doc-accent);
  --doc-heading-radius: 0;
  --doc-heading-padding: 0 0 22px;
  --doc-body-font: 'Inter', sans-serif;
  --doc-radius: 10px;
  --doc-item-header-style: soft; /* soft | line | dark */
  --doc-item-th-bg: transparent;
}
.invoice-doc { font-family: var(--doc-body-font); max-width: 900px; margin: 0 auto; }
.invoice-doc-header {
  display: flex; justify-content: space-between; gap: 24px;
  border-bottom: 3px solid var(--doc-accent);
  padding: var(--doc-heading-padding); margin-bottom: 26px;
  background: var(--doc-heading-bg); border-radius: var(--doc-heading-radius);
}
.invoice-doc-brand { display: flex; gap: 16px; }
.invoice-logo { max-height: 56px; max-width: 160px; object-fit: contain; }
.invoice-doc-brand h2 { font-size: 1.25rem; font-weight: 800; margin: 0 0 8px; color: var(--doc-heading-color); letter-spacing: -.01em; }
.invoice-doc-brand p { margin: 0 0 3px; font-size: .82rem; color: #64748B; line-height: 1.55; }
.invoice-doc-meta { text-align: right; min-width: 240px; }
.invoice-doc-meta h1 { font-size: 1.45rem; font-weight: 800; letter-spacing: .08em; color: var(--doc-heading-color); margin: 0 0 14px; }
.invoice-doc-meta table { margin-left: auto; font-size: .82rem; border-collapse: collapse; }
.invoice-doc-meta td { padding: 3px 0 3px 16px; text-align: right; white-space: nowrap; }
.invoice-doc-meta td:first-child { color: #94A3B8; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; }

.invoice-doc-proforma-note {
  background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E;
  border-radius: var(--doc-radius); padding: 10px 14px; font-size: .8rem;
  margin-bottom: 20px; display: flex; align-items: center; gap: 8px;
}

.invoice-doc-parties { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 26px; }
.invoice-doc-parties .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #94A3B8; font-weight: 700; }
.invoice-doc-parties h3 { margin: 6px 0 6px; font-size: 1.02rem; font-weight: 700; }
.invoice-doc-parties p { margin: 0 0 3px; color: #64748B; font-size: .83rem; }

.invoice-doc-items { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.invoice-doc-items th {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
  padding: 11px 10px; text-align: left; color: var(--doc-accent);
  background: var(--doc-item-th-bg);
}
.invoice-doc-items td { padding: 11px 10px; border-bottom: 1px solid var(--color-border); font-size: .85rem; font-variant-numeric: tabular-nums; }
.invoice-doc-items .text-end { text-align: right; }
.invoice-doc-items tbody tr:last-child td { border-bottom: 2px solid var(--doc-accent); }

.invoice-doc-summary { display: flex; justify-content: space-between; gap: 40px; margin-bottom: 26px; }
.invoice-doc-words { flex: 1; }
.invoice-doc-words .label, .invoice-doc-terms .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #94A3B8; font-weight: 700; }
.invoice-doc-words p, .invoice-doc-terms p { font-size: .84rem; color: #475569; margin: 5px 0 0; }
.invoice-doc-totals { min-width: 290px; border-collapse: collapse; }
.invoice-doc-totals td { padding: 5px 4px; font-size: .85rem; color: #64748B; font-variant-numeric: tabular-nums; }
.invoice-doc-totals td:last-child { text-align: right; font-weight: 600; color: #1e293b; }
.invoice-doc-totals tr.grand td {
  font-size: 1.2rem; font-weight: 800; color: var(--doc-accent);
  border-top: 2px solid var(--doc-accent); padding-top: 12px; margin-top: 6px;
}
.invoice-doc-totals tr.grand td:first-child { color: var(--doc-accent); }

.invoice-doc-footer { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 34px; gap: 24px; padding-top: 20px; border-top: 1px solid var(--color-border); }
.invoice-doc-bank { flex: 1; }
.invoice-doc-bank .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #94A3B8; font-weight: 700; }
.invoice-doc-bank p { font-size: .83rem; color: #475569; margin: 5px 0 0; }
.invoice-doc-qr { margin-top: 14px; display: flex; align-items: center; gap: 10px; }
.invoice-doc-qr img { width: 64px; height: 64px; object-fit: contain; border: 1px solid var(--color-border); border-radius: 8px; padding: 4px; background: #fff; }
.invoice-doc-qr span { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: #94A3B8; font-weight: 700; }
.invoice-doc-sign { text-align: center; min-width: 200px; display: flex; flex-direction: column; align-items: center; }
.invoice-doc-sign p { margin: 0; font-size: .8rem; color: #64748B; }
.invoice-doc-sign span { font-size: .78rem; font-weight: 600; }
.stamp-img { max-height: 72px; max-width: 150px; object-fit: contain; opacity: .82; margin-bottom: -22px; }
.sign-img { max-height: 46px; position: relative; }
.invoice-doc-terms { margin-top: 22px; border-top: 1px solid var(--color-border); padding-top: 16px; }
.invoice-doc-thankyou { text-align: center; margin-top: 30px; color: var(--doc-accent); font-weight: 700; font-size: .9rem; letter-spacing: .02em; }

/* ---------- Misc ---------- */
.status-chip { text-align: right; }
@media (max-width: 992px) {
  .app-sidebar { position: fixed; left: 0; transform: translateX(-100%); }
  .app-sidebar.show { transform: translateX(0); }
}
