/* ═══════════════════════════════════════════════════════════════
   NijHisaab — Design System & Component Styles
   Font: Inter (body) + Outfit (headings) via Google Fonts
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@600;700;800&display=swap');

/* ── 1. CSS Variables / Design Tokens ──────────────────────────── */
:root {
  --brand-teal:   #0e7490;
  --brand-blue:   #1d4ed8;
  --brand-grad:   linear-gradient(135deg, #0e7490, #1d4ed8);
  --brand-grad-v: linear-gradient(180deg, #0e7490, #1d4ed8);

  --sidebar-bg:   #0b1120;
  --sidebar-w:    260px;
  --header-h:     64px;

  --surface:      #f0f5fc;
  --card:         #ffffff;
  --card-border:  rgba(0,0,0,0.06);
  --ink:          #0f172a;
  --ink-2:        #334155;
  --muted:        #64748b;
  --border:       #e2e8f0;

  --green:        #10b981;
  --green-light:  #d1fae5;
  --red:          #ef4444;
  --red-light:    #fee2e2;
  --amber:        #f59e0b;
  --amber-light:  #fef3c7;
  --blue:         #3b82f6;
  --blue-light:   #dbeafe;

  --radius:       14px;
  --radius-sm:    8px;
  --shadow:       0 4px 24px rgba(15,23,42,0.08);
  --shadow-sm:    0 2px 8px rgba(15,23,42,0.05);
  --transition:   all 0.22s cubic-bezier(0.4,0,0.2,1);
}

/* ── 2. Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--surface);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5 { font-family: 'Outfit', sans-serif; font-weight: 700; }
a { text-decoration: none; color: inherit; }
button { font: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font: inherit; }
img { max-width: 100%; }

/* ── 3. Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }

/* ── 4. Utility ─────────────────────────────────────────────────── */
.text-green  { color: var(--green) !important; }
.text-red    { color: var(--red) !important; }
.text-amber  { color: var(--amber) !important; }
.text-muted  { color: var(--muted) !important; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.bold        { font-weight: 600; }
.hidden      { display: none !important; }
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2       { gap: 0.5rem; }
.gap-3       { gap: 0.75rem; }
.mt-1        { margin-top: 0.25rem; }
.mt-2        { margin-top: 0.5rem; }
.mt-3        { margin-top: 0.75rem; }

/* ── 5. Login Page ──────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, #0b1120 0%, #0f2952 40%, #0e7490 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

#login-screen::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(14,116,144,0.35) 0%, transparent 70%);
  top: -100px; right: -100px;
  border-radius: 50%;
  animation: floatBlob 8s ease-in-out infinite;
}
#login-screen::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(29,78,216,0.3) 0%, transparent 70%);
  bottom: -80px; left: -80px;
  border-radius: 50%;
  animation: floatBlob 10s ease-in-out infinite reverse;
}

@keyframes floatBlob {
  0%, 100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(30px,-30px) scale(1.08); }
}

.login-card {
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 24px;
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.login-logo-icon {
  width: 44px; height: 44px;
  background: var(--brand-grad);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 4px 16px rgba(14,116,144,0.5);
}

.login-logo h1 {
  font-size: 1.6rem;
  color: #fff;
  letter-spacing: -0.5px;
}

.login-tagline {
  color: rgba(255,255,255,0.55);
  font-size: 0.875rem;
  margin-bottom: 2.5rem;
  padding-left: 56px;
}

.login-label {
  display: block;
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.login-input {
  width: 100%;
  padding: 0.85rem 1.1rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
  margin-bottom: 1.25rem;
}
.login-input::placeholder { color: rgba(255,255,255,0.35); }
.login-input:focus {
  border-color: var(--brand-teal);
  background: rgba(255,255,255,0.12);
  box-shadow: 0 0 0 3px rgba(14,116,144,0.3);
}

.login-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(14,116,144,0.2);
  border: 1px solid rgba(14,116,144,0.4);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  color: rgba(255,255,255,0.75);
  font-size: 0.8rem;
  margin-bottom: 1.5rem;
}

.login-btn {
  width: 100%;
  padding: 0.95rem;
  background: var(--brand-grad);
  color: #fff;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(14,116,144,0.5);
  letter-spacing: 0.01em;
}
.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(14,116,144,0.6);
}
.login-btn:active { transform: translateY(0); }

.login-error {
  color: #fca5a5;
  font-size: 0.85rem;
  margin-top: 0.75rem;
  text-align: center;
}

/* ── 6. Business Selector ────────────────────────────────────────── */
#business-selector {
  min-height: 100vh;
  background: var(--surface);
  padding: 2.5rem 2rem;
}

.selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.selector-header-left { display: flex; align-items: center; gap: 0.75rem; }

.selector-logo {
  width: 40px; height: 40px;
  background: var(--brand-grad);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}

.selector-header h2 { font-size: 1.4rem; color: var(--ink); }
.selector-header p  { color: var(--muted); font-size: 0.9rem; }

.selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.biz-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.75rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.biz-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--biz-accent, var(--brand-grad));
}

.biz-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--biz-border, #e2e8f0);
}

.biz-card-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 1rem;
  background: var(--biz-light, #f0f9ff);
}

.biz-card h3 { font-size: 1.15rem; margin-bottom: 0.25rem; }
.biz-card p  { color: var(--muted); font-size: 0.83rem; margin-bottom: 1.25rem; }

.biz-card-stats { display: flex; gap: 1.5rem; margin-bottom: 1.25rem; }

.biz-stat-item label { display: block; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.biz-stat-item .stat-val { font-size: 1rem; font-weight: 700; font-family: 'Outfit', sans-serif; }

.biz-card canvas { width: 100%; height: 48px; display: block; margin-top: 0.5rem; }

.biz-card-action {
  width: 100%;
  padding: 0.65rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  color: #fff;
  text-align: center;
  background: var(--biz-grad, var(--brand-grad));
  transition: var(--transition);
  margin-top: 0.75rem;
}
.biz-card:hover .biz-card-action { opacity: 0.9; }

.biz-overdue-badge {
  position: absolute;
  top: 1rem; right: 1rem;
  background: var(--red);
  color: #fff;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  display: flex; align-items: center; gap: 0.25rem;
}

/* ── 7. App Shell (Sidebar + Content) ─────────────────────────── */
#app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── 8. Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.3s ease;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: var(--brand-grad);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-brand-text h2 {
  font-size: 1.1rem;
  color: #fff;
  letter-spacing: -0.3px;
}
.sidebar-brand-text p {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.4);
  margin-top: 1px;
}

/* Business selector in sidebar */
.sidebar-biz-selector {
  margin: 1rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}

.sidebar-biz-selector-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  padding: 0.6rem 0.9rem 0.3rem;
}

.sidebar-biz-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  width: 100%;
  color: rgba(255,255,255,0.6);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border-radius: 0;
}
.sidebar-biz-btn:hover { background: rgba(255,255,255,0.07); color: #fff; }
.sidebar-biz-btn.active {
  background: rgba(14,116,144,0.25);
  color: #fff;
}
.sidebar-biz-btn .biz-icon { font-size: 1rem; flex-shrink: 0; }
.sidebar-biz-btn .biz-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--biz-col, #0e7490);
  flex-shrink: 0;
  margin-left: auto;
}

/* Nav */
.sidebar-nav { padding: 0.75rem 0; flex: 1; }

.nav-section-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.3);
  padding: 0.75rem 1.25rem 0.35rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  color: rgba(255,255,255,0.55);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.nav-link:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }

.nav-link.active {
  color: #fff;
  background: rgba(14,116,144,0.18);
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand-teal);
  border-radius: 0 3px 3px 0;
}

.nav-link .nav-icon { font-size: 1.1rem; flex-shrink: 0; width: 20px; text-align: center; }
.nav-link .nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  border-radius: 99px;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 1rem;
}

.sidebar-logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  color: rgba(255,255,255,0.45);
  font-size: 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}
.sidebar-logout-btn:hover { background: rgba(255,0,0,0.1); color: #fca5a5; }

/* ── 9. Main Content Area ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── 10. Header Bar ──────────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 1rem;
}

.topbar-left h2 {
  font-size: 1.05rem;
  color: var(--ink);
}
.topbar-left p {
  font-size: 0.78rem;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-lang-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-2);
  transition: var(--transition);
}
.topbar-lang-btn:hover { border-color: var(--brand-teal); color: var(--brand-teal); }

.topbar-report-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: var(--brand-grad);
  color: #fff;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 600;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(14,116,144,0.35);
}
.topbar-report-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(14,116,144,0.45);
}

.topbar-biz-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
}

/* ── 11. Page Content ────────────────────────────────────────────── */
.page-content { padding: 1.75rem; flex: 1; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h2 { font-size: 1.4rem; color: var(--ink); margin-bottom: 0.2rem; }
.page-header p  { color: var(--muted); font-size: 0.875rem; }

/* ── 12. KPI Cards ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--kpi-glow, rgba(14,116,144,0.07));
  transform: translate(30px, -30px);
}

.kpi-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.kpi-value {
  font-size: 1.55rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.5px;
  margin-bottom: 0.35rem;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
}
.kpi-trend.up   { background: var(--green-light); color: var(--green); }
.kpi-trend.down { background: var(--red-light); color: var(--red); }

/* ── 13. Cards / Sections ───────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
}

.card-header h3 { font-size: 1rem; color: var(--ink); }
.card-header p  { font-size: 0.78rem; color: var(--muted); margin-top: 1px; }
.card-header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.card-body { padding: 1.25rem 1.4rem; }

/* Chart inside a card */
.chart-wrap { padding: 1.25rem 1.4rem 0.75rem; }
.chart-wrap canvas { width: 100%; height: 220px; display: block; }
.chart-legend {
  display: flex;
  gap: 1.25rem;
  padding: 0.75rem 1.4rem 1rem;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--ink-2);
}
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Two-column chart row */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 900px) { .charts-row { grid-template-columns: 1fr; } }

/* ── 14. Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 9px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 2px 8px rgba(14,116,144,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(14,116,144,0.45); }

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--ink-2);
}
.btn-ghost:hover { border-color: var(--brand-teal); color: var(--brand-teal); background: var(--brand-teal)10; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #059669; }

.btn-amber { background: var(--amber); color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; border-radius: 7px; }
.btn-icon { padding: 0.45rem; border-radius: 8px; }

/* ── 15. Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.865rem;
}

.data-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafbff; }

.data-table td .amount { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 0.92rem; }

/* ── 16. Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-green   { background: var(--green-light); color: var(--green); }
.badge-red     { background: var(--red-light); color: var(--red); }
.badge-amber   { background: var(--amber-light); color: #92400e; }
.badge-blue    { background: var(--blue-light); color: var(--blue); }
.badge-gray    { background: #f1f5f9; color: var(--muted); }
.badge-income  { background: #d1fae5; color: #065f46; }
.badge-expense { background: #fee2e2; color: #991b1b; }

/* ── 17. Progress Bar ────────────────────────────────────────────── */
.progress-wrap { display: flex; align-items: center; gap: 0.75rem; }
.progress-bar {
  flex: 1;
  height: 8px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--brand-grad);
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}
.progress-pct { font-size: 0.78rem; font-weight: 700; color: var(--ink-2); min-width: 36px; text-align: right; }

/* ── 18. Advance Cards ───────────────────────────────────────────── */
.advance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
  padding: 1.25rem 1.4rem;
}

.advance-card {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem;
  background: #fff;
  transition: var(--transition);
}
.advance-card:hover { box-shadow: var(--shadow); }

.advance-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.advance-card-header h4 { font-size: 0.95rem; margin-bottom: 0.15rem; }
.advance-card-header p  { font-size: 0.78rem; color: var(--muted); }

.advance-amounts {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.advance-amount-item { text-align: center; }
.advance-amount-item label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 3px;
}
.advance-amount-item .val {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
}

.advance-card-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

/* ── 19. Loan Cards ──────────────────────────────────────────────── */
.loan-card {
  padding: 1.25rem 1.4rem;
  border-bottom: 1px solid var(--border);
}
.loan-card:last-child { border-bottom: none; }

.loan-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 0.75rem; gap: 0.75rem; }
.loan-card-header h4 { font-size: 1rem; }
.loan-card-header p  { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

.loan-stats-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}
.loan-stat label { display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 2px; }
.loan-stat span  { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 0.95rem; }

/* ── 20. Invoice ─────────────────────────────────────────────────── */
.invoice-list { padding: 0.5rem 1.4rem 1.25rem; }

.invoice-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
}
.invoice-item:last-child { border-bottom: none; }

.invoice-item-info { flex: 1; min-width: 160px; }
.invoice-item-info h4 { font-size: 0.9rem; margin-bottom: 2px; }
.invoice-item-info p  { font-size: 0.78rem; color: var(--muted); }

.invoice-item-amount { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 1rem; text-align: right; }
.invoice-item-actions { display: flex; gap: 0.4rem; }

/* Invoice print view */
.invoice-print-view {
  background: #fff;
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem;
  font-size: 0.9rem;
}

.invoice-print-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--brand-teal);
}

.invoice-print-title { font-size: 2rem; font-family: 'Outfit', sans-serif; font-weight: 800; letter-spacing: -1px; }
.invoice-print-title span { display: block; font-size: 0.8rem; color: var(--muted); font-family: 'Inter', sans-serif; font-weight: 400; letter-spacing: 0; margin-top: 4px; }

.invoice-biz-name { font-size: 1.1rem; font-weight: 700; }

.invoice-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.75rem; }
.invoice-meta-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 4px; }
.invoice-meta-value { font-weight: 600; }

.invoice-items-table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
.invoice-items-table th { background: #f8fafc; padding: 0.65rem 0.9rem; text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.invoice-items-table td { padding: 0.75rem 0.9rem; border-bottom: 1px solid #f1f5f9; }
.invoice-items-table .text-right { text-align: right; }
.invoice-total-row { font-weight: 700; background: #f0f9ff; }
.invoice-grand-total { font-size: 1.1rem; color: var(--brand-teal); font-family: 'Outfit', sans-serif; }

/* ── 21. Filter Bar ──────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: #fafbff;
}

.filter-select, .filter-input {
  padding: 0.45rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: var(--transition);
}
.filter-select:focus, .filter-input:focus { border-color: var(--brand-teal); }
.filter-input { min-width: 160px; }

/* ── 22. Modals ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 64px rgba(15,23,42,0.25);
  animation: slideUp 0.22s cubic-bezier(0.4,0,0.2,1);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 840px; }

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--card); z-index: 1;
}
.modal-header h3 { font-size: 1.1rem; }
.modal-header p  { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }

.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: var(--transition);
  cursor: pointer;
}
.modal-close:hover { background: var(--red-light); color: var(--red); }

.modal-body { padding: 1.25rem 1.5rem; flex: 1; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 0.6rem; justify-content: flex-end; flex-wrap: wrap; }

/* ── 23. Forms ───────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

.form-full { grid-column: 1 / -1; }

.form-field { display: flex; flex-direction: column; gap: 0.35rem; }
.form-field label { font-size: 0.8rem; font-weight: 500; color: var(--ink-2); }
.form-field input, .form-field select, .form-field textarea {
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: var(--transition);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 3px rgba(14,116,144,0.12);
}
.form-field textarea { resize: vertical; min-height: 80px; }

/* ── 24. Email Preview Modal ─────────────────────────────────────── */
.email-preview {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.875rem;
}

.email-preview-bar {
  background: var(--sidebar-bg);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.email-preview-dot { width: 10px; height: 10px; border-radius: 50%; }

.email-preview-meta {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.email-preview-meta p { font-size: 0.8rem; }
.email-preview-meta p strong { color: var(--ink); }
.email-preview-meta p span   { color: var(--muted); }

.email-preview-body { padding: 1rem 1.1rem; background: #fff; line-height: 1.7; }
.email-preview-body h4 { color: var(--brand-teal); margin-bottom: 0.5rem; }
.email-preview-body .email-row { display: flex; justify-content: space-between; padding: 0.35rem 0; border-bottom: 1px solid #f1f5f9; }
.email-preview-body .email-total { font-weight: 700; color: var(--brand-teal); }

/* ── 25. Daily Report Modal ──────────────────────────────────────── */
.report-preview {
  background: linear-gradient(135deg, #0e7490, #1d4ed8);
  border-radius: 10px;
  padding: 1.5rem;
  color: #fff;
  margin-bottom: 1rem;
}
.report-preview h3 { font-size: 1.15rem; margin-bottom: 0.25rem; }
.report-preview p  { opacity: 0.7; font-size: 0.82rem; margin-bottom: 1.25rem; }

.report-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.report-stat-box {
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 0.85rem 0.75rem;
  text-align: center;
}
.report-stat-box label { display: block; font-size: 0.68rem; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.report-stat-box .val { font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 1.05rem; }

.report-alerts { margin-top: 0.5rem; }
.report-alert-item { display: flex; align-items: center; gap: 0.5rem; background: rgba(239,68,68,0.2); border-radius: 8px; padding: 0.5rem 0.75rem; font-size: 0.8rem; margin-bottom: 0.4rem; }

/* ── 26. Insights Panel ──────────────────────────────────────────── */
.insight-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.4rem;
}

.insight-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.insight-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.insight-text h4 { font-size: 0.875rem; margin-bottom: 2px; }
.insight-text p  { font-size: 0.78rem; color: var(--muted); }

/* ── 27. Recent Transactions ────────────────────────────────────── */
.recent-tx-list { padding: 0 1.4rem 0.75rem; }

.recent-tx-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.recent-tx-item:last-child { border-bottom: none; }

.recent-tx-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.recent-tx-info { flex: 1; min-width: 0; }
.recent-tx-info h4 { font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-tx-info p  { font-size: 0.75rem; color: var(--muted); }

.recent-tx-amount { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 0.95rem; text-align: right; }

/* ── 28. Payment History Timeline ────────────────────────────────── */
.payment-timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid #f1f5f9;
  position: relative;
}
.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--brand-teal);
  margin-top: 4px;
  flex-shrink: 0;
}

.timeline-info { flex: 1; }
.timeline-info p { font-size: 0.82rem; font-weight: 500; }
.timeline-info span { font-size: 0.75rem; color: var(--muted); }

.timeline-amount { font-family: 'Outfit', sans-serif; font-weight: 700; color: var(--green); font-size: 0.88rem; }

/* ── 29. Toast ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.8rem 1.1rem;
  background: var(--ink);
  color: #fff;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: slideInRight 0.25s ease;
  min-width: 260px;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast.info    { background: var(--brand-teal); }

@keyframes slideInRight {
  from { transform: translateX(30px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── 30. Empty States ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--muted);
  text-align: center;
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state h4 { font-size: 1rem; margin-bottom: 0.35rem; color: var(--ink-2); }
.empty-state p  { font-size: 0.83rem; }

/* ── 31. Reports page specific ───────────────────────────────────── */
.report-period-select { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 1.4rem 1.25rem;
}
.donut-wrap canvas { width: 140px; height: 140px; flex-shrink: 0; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.donut-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
}
.donut-legend-item-left { display: flex; align-items: center; gap: 0.5rem; }
.donut-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.donut-legend-item .pct { font-weight: 700; color: var(--ink); }

/* ── 32. Settings page ───────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; }
.settings-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--border); }
.settings-item:last-child { border-bottom: none; }
.settings-label h4 { font-size: 0.9rem; }
.settings-label p  { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

.toggle-switch {
  position: relative;
  width: 44px; height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #cbd5e1;
  border-radius: 99px;
  cursor: pointer;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  left: 3px; top: 3px;
  transition: var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
input:checked + .toggle-slider { background: var(--brand-teal); }
input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── 33. Print ───────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .modal-backdrop, #toast-container,
  .btn, .filter-bar, .page-header .topbar-right { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #e2e8f0 !important; }
  body { background: #fff !important; }
}

/* ── 34. Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .advance-grid { grid-template-columns: 1fr; }
  .report-stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-content { padding: 1rem; }
  .report-stats-grid { grid-template-columns: 1fr; }
  .invoice-meta-grid { grid-template-columns: 1fr; }
}

/* ── 35. Animations & Micro-interactions ─────────────────────────── */
.fade-in { animation: fadeIn 0.3s ease; }
.slide-up { animation: slideUp 0.3s cubic-bezier(0.4,0,0.2,1); }

.kpi-card .kpi-value { transition: all 0.5s ease; }

/* Overdue pulse */
.pulse-badge {
  animation: pulse-red 2s ease-in-out infinite;
}
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 5px rgba(239,68,68,0); }
}
