/* ── style.css ───────────────────────────────────────────────────────────────
   FinanceLedger — Premium Monochrome Design System
   Inspired by: Arc, Linear, Vercel, Phantom
   ─────────────────────────────────────────────────────────────────────────── */

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

/* ── Design Tokens ────────────────────────────────────────────────────────── */
:root {
  /* ── Light Mode Palette (Khatabook Style) ── */
  --brand-blue:     #0b57cf;
  --brand-blue-dark:#094ab2;

  --black:          #f1f5f9; /* Body background */
  --black-1:        #f8fafc;
  --black-2:        #ffffff; /* Cards */
  --black-3:        #f8fafc; /* Modals/Headers if not brand */
  --black-4:        #f1f5f9;
  --black-5:        #e2e8f0;

  --white:          #000000;
  --white-1:        #0f172a;
  --white-2:        #1e293b;
  --white-3:        #334155;
  --white-4:        #475569;
  --white-5:        #64748b;
  --white-6:        #94a3b8;

  /* Semantic */
  --green:          #15803d;
  --green-dim:      #f0fdf4;
  --red:            #b91c1c;
  --red-dim:        #fef2f2;
  --amber:          #d97706;
  --amber-dim:      #fffbeb;

  /* Borders */
  --border:         #e2e8f0;
  --border-hover:   #cbd5e1;
  --border-active:  #94a3b8;
  --border-strong:  #64748b;

  /* Text */
  --text-1:         #0f172a;
  --text-2:         #334155;
  --text-3:         #475569;
  --text-4:         #64748b;

  /* Spacing */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.25rem;
  --s-6: 1.5rem;
  --s-8: 2rem;
  --s-10: 2.5rem;
  --s-12: 3rem;

  /* Radius */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   20px;
  --r-2xl:  28px;
  --r-full: 9999px;

  /* Shadow */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --shadow-xl:  0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);

  /* Motion */
  --ease:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --t-fast:  120ms;
  --t-mid:   240ms;
  --t-slow:  360ms;

  /* Layout */
  --nav-h:    64px;
  --header-h: 120px;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--black);
  color: var(--text-1);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Subtle noise texture overlay for depth */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}
#app { position: relative; z-index: 1; }

/* ── Typography ───────────────────────────────────────────────────────────── */
h1 { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-1); }
h2 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; color: var(--text-1); }
h3 { font-size: 0.9375rem; font-weight: 600; color: var(--text-1); }
p  { color: var(--text-2); font-size: 0.875rem; line-height: 1.6; }

/* All SVGs: consistent premium style */
svg {
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Loading Screen ───────────────────────────────────────────────────────── */
.loading-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--black);
  transition: opacity var(--t-slow) var(--ease);
}
.loading-screen.fade-out { opacity: 0; pointer-events: none; }

.loading-logo { text-align: center; animation: fade-up 0.5s var(--ease) both; }

.loading-icon {
  width: 68px; height: 68px;
  background: var(--white);
  border-radius: var(--r-xl);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.75rem; font-weight: 800;
  color: var(--black);
  margin: 0 auto var(--s-4);
  box-shadow: 0 0 0 1px var(--border), var(--shadow-lg);
  animation: icon-pulse 2.5s var(--ease) infinite;
}
.loading-logo h1 { color: var(--text-1); margin-bottom: var(--s-1); font-size: 1.25rem; }
.loading-logo p  { color: var(--text-3); font-size: 0.8125rem; }

/* ── Bottom Navigation ────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  padding: 0 var(--s-4) env(safe-area-inset-bottom, 0);
  z-index: 100;
}
.bottom-nav.hidden { display: none; }

.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: var(--s-2) var(--s-4);
  background: none; border: none; cursor: pointer;
  color: var(--text-4);
  font-family: inherit; font-size: 0.6rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  border-radius: var(--r-md);
  transition: color var(--t-fast);
  position: relative;
}
.nav-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.nav-btn:hover { color: var(--white-2); }
.nav-btn.active { color: var(--white); }

/* Active indicator dot */
.nav-btn.active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%; transform: translateX(-50%);
  width: 20px; height: 2px;
  background: var(--white);
  border-radius: 0 0 var(--r-full) var(--r-full);
}

/* Centre Add Customer button */
#nav-add-customer {
  width: auto; height: 48px;
  padding: 0 20px;
  background: #9b0f49; /* Magenta from Khatabook */
  border-radius: var(--r-full);
  color: #fff;
  box-shadow: 0 4px 12px rgba(155,15,73,0.3);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  flex-direction: row;
  gap: 8px;
}
#nav-add-customer::before { display: none; }
#nav-add-customer svg { width: 20px; height: 20px; stroke-width: 2.5; }
#nav-add-customer span { display: inline-block; font-size: 0.9rem; font-weight: 700; letter-spacing: 0.05em; }
#nav-add-customer:hover {
  transform: scale(1.03);
  box-shadow: 0 6px 16px rgba(155,15,73,0.4);
}
#nav-add-customer:active { transform: scale(0.96); }

/* ── Page Layout ──────────────────────────────────────────────────────────── */
.page {
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + var(--s-8));
}

/* ── Page Header ──────────────────────────────────────────────────────────── */
.page-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  padding: var(--s-4) var(--s-4) 0;
}
.header-content { display: flex; align-items: center; padding-bottom: var(--s-4); }
.header-brand { display: flex; align-items: center; gap: var(--s-3); flex: 1; }

.brand-icon {
  width: 38px; height: 38px;
  background: var(--white);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 800;
  color: var(--black);
  flex-shrink: 0;
  box-shadow: 0 0 0 1px var(--border-strong);
}

.header-title { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.02em; }
.header-sub   { font-size: 0.7rem; color: var(--text-3); letter-spacing: 0.03em; }

/* Search */
.search-bar-wrapper { padding-bottom: var(--s-4); }
.search-bar { 
  position: relative; display: flex; align-items: center; 
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.search-icon {
  position: absolute; left: 12px;
  width: 18px; height: 18px;
  color: var(--brand-blue); pointer-events: none;
  stroke-width: 2.5;
}
.search-bar input {
  width: 100%;
  padding: 12px 40px 12px 40px;
  background: transparent;
  border: none;
  color: var(--text-1);
  font-family: inherit; font-size: 0.95rem; font-weight: 500;
  outline: none;
}
.search-bar input::placeholder { color: var(--text-4); font-weight: 400; }
.search-filter-icon {
  position: absolute; right: 12px;
  width: 18px; height: 18px;
  color: var(--brand-blue); pointer-events: none;
}

/* ── Page Main ────────────────────────────────────────────────────────────── */
.page-main {
  padding: var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-4);
}

/* ── Dashboard Stats ──────────────────────────────────────────────────────── */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
}
.stat-card {
  background: var(--black-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-2);
  text-align: center;
}
.stat-label {
  font-size: 0.6rem;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 4px;
}
.stat-value { font-size: 0.8rem; font-weight: 700; color: var(--text-1); word-break: break-all; }
.stat-positive .stat-value { color: var(--green); }
.stat-negative .stat-value { color: var(--red); }

/* ── Customer Cards ───────────────────────────────────────────────────────── */
.customers-grid { display: flex; flex-direction: column; gap: 0; background: #fff; }

.customer-card {
  display: flex; align-items: stretch;
  background: #fff;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t-fast);
}
.customer-card:active { background: var(--black-1); }

.card-left { 
  display: flex; align-items: center; gap: 14px; 
  flex: 1; min-width: 0; padding: 16px; 
}

.customer-avatar {
  width: 44px; height: 44px;
  background: var(--black-1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; font-weight: 700;
  color: var(--text-2);
  flex-shrink: 0;
}
.customer-info { min-width: 0; }
.customer-name  { font-weight: 600; font-size: 1rem; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.customer-meta  { font-size: 0.8rem; color: var(--text-4); margin-top: 2px; }

.card-right { 
  display: flex; flex-direction: column; justify-content: center; align-items: flex-end; 
  min-width: 120px; padding: 16px;
  flex-shrink: 0; 
}
.kb-list-got-bg { background: rgba(21,128,61,0.03); }
.kb-list-gave-bg { background: rgba(220,38,38,0.03); }

.balance-amount { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.balance-positive { color: var(--green); }
.balance-negative { color: var(--red); }

.remind-link {
  font-size: 0.7rem; font-weight: 700; color: var(--brand-blue);
  text-transform: uppercase; display: flex; align-items: center; gap: 2px;
}

/* ── Customer Header ──────────────────────────────────────────────────────── */
.customer-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  min-height: 60px;
}

.back-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--black-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer; color: var(--text-1);
  transition: border-color var(--t-fast), background var(--t-fast);
  flex-shrink: 0;
}
.back-btn svg { width: 18px; height: 18px; stroke-width: 1.5; }
.back-btn:hover { border-color: var(--border-hover); background: var(--black-4); }

.customer-header-info { flex: 1; min-width: 0; }
.ch-name  { font-weight: 700; font-size: 0.9375rem; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-phone { font-size: 0.7rem; color: var(--text-3); }

.customer-header-actions { display: flex; gap: var(--s-1); flex-shrink: 0; }

.icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--black-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer; color: var(--text-3);
  transition: all var(--t-fast);
}
.icon-btn svg { width: 16px; height: 16px; stroke-width: 1.5; }
.icon-btn:hover { border-color: var(--border-active); color: var(--text-1); background: var(--black-4); }
#wa-summary-btn:hover { background: #075E54; border-color: #128C7E; color: #25D366; }

/* ── KB Layout (Khatabook Style) ──────────────────────────────────────────── */

.kb-page {
  background: var(--black-1);
  min-height: 100dvh;
  padding-bottom: 80px; /* Space for bottom buttons */
}

/* Header */
.kb-header {
  background: var(--brand-blue);
  color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 16px;
  position: sticky; top: 0; z-index: 50;
}
.kb-back-btn {
  background: transparent; border: none; color: #fff; cursor: pointer;
  padding: 4px; display: flex;
}
.kb-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: #fff; color: var(--brand-blue);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; flex-shrink: 0;
}
.kb-header-info { flex: 1; }
.kb-name { font-weight: 600; font-size: 1.05rem; display: flex; align-items: center; gap: 6px; }
.kb-tag { background: rgba(255,255,255,0.2); font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; font-weight: 500; }
.kb-subtitle { font-size: 0.75rem; opacity: 0.85; margin-top: 2px; }
.kb-icon-btn { background: transparent; border: none; color: #fff; padding: 8px; cursor: pointer; }

/* Floating Balance */
.kb-hero-wrapper {
  background: var(--brand-blue);
  padding: 0 16px 16px;
}
.kb-hero-card {
  background: #fff; border-radius: 8px;
  padding: 16px; display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.kb-hero-label { font-size: 0.95rem; font-weight: 500; color: var(--text-2); }
.kb-hero-value { font-size: 1.25rem; font-weight: 700; }
.kb-green { color: var(--green); }
.kb-red { color: var(--red); }

/* Action Bar */
.kb-action-bar {
  display: flex; justify-content: space-around;
  background: #fff; padding: 12px 0;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.kb-action-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 0.75rem; font-weight: 500; color: var(--text-3);
  cursor: pointer;
}
.kb-action-item svg { color: var(--brand-blue); }

/* Ledger Headers */
.kb-ledger-header {
  display: flex; background: #fff; border-bottom: 1px solid var(--border);
  position: sticky; top: 72px; z-index: 40; /* Approximate offset */
}
.kb-col { flex: 1; padding: 12px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-align: right; }
.kb-col1 { flex: 1.2; text-align: left; }
.kb-col-entries { flex: 1.2; color: var(--text-4); text-align: left; }
.kb-col-gave { color: var(--red); }
.kb-col-got { color: var(--green); }

/* Ledger Main */
.kb-ledger-main { padding-bottom: 24px; }
.kb-date-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 8px;
}
.kb-date-line { flex: 1; height: 1px; background: var(--border); }
.kb-date-text { font-size: 0.7rem; color: var(--text-4); font-weight: 500; text-transform: uppercase; }

.kb-tx-row {
  display: flex; background: #fff; margin-bottom: 4px;
  cursor: pointer; position: relative;
}
.kb-tx-row:active { background: var(--black-1); }
.kb-col2, .kb-col3 { display: flex; align-items: center; justify-content: flex-end; }
.kb-gave-bg { background: rgba(220,38,38,0.03); }
.kb-got-bg { background: rgba(21,128,61,0.03); }

.kb-tx-time { font-size: 0.75rem; color: var(--text-2); margin-bottom: 4px; font-weight: 500; }
.kb-tx-bal { display: inline-block; font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
.kb-bal-green { background: var(--green-dim); color: var(--green); }
.kb-bal-red { background: var(--red-dim); color: var(--red); }
.kb-bal-neutral { background: var(--black-5); color: var(--text-3); }

.kb-amt { font-size: 1rem; font-weight: 700; }
.kb-gave-text { color: var(--red); }
.kb-got-text { color: var(--green); }

.kb-live-row { opacity: 0.7; }
.kb-tx-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 600; color: var(--text-3); background: rgba(255,255,255,0.5);
  pointer-events: none;
}

/* Bottom Bar */
.kb-bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; gap: 8px; padding: 12px 16px;
  background: #fff; border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
  z-index: 100;
}
.kb-btn {
  flex: 1; padding: 14px; border: none; border-radius: 6px;
  font-size: 0.95rem; font-weight: 700; color: #fff; cursor: pointer;
}
.kb-btn-gave { background: var(--red); }
.kb-btn-got { background: var(--green); }
.kb-btn:active { filter: brightness(0.9); }

/* Tx actions */
.tx-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.tx-action-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: var(--r-sm);
  cursor: pointer; color: var(--text-4);
  transition: background var(--t-fast), color var(--t-fast);
}
.tx-action-btn svg { stroke-width: 1.5; }
.tx-action-btn:hover { color: var(--text-1); }
.btn-edit-tx:hover   { background: rgba(255,255,255,0.07); }
.btn-delete-tx:hover { background: var(--red-dim); color: var(--red); }
.btn-share-tx:hover  { background: rgba(37,211,102,0.1); color: #25D366; }

@media (hover: hover) {
  .tx-actions { opacity: 0; }
  .tx-row:hover .tx-actions,
  .tx-row.row-selected .tx-actions { opacity: 1; }
}

/* ── FAB ──────────────────────────────────────────────────────────────────── */
.fab-group {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--s-4));
  right: var(--s-4);
  display: flex; gap: var(--s-2);
  z-index: 80;
}

.fab {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 13px 20px;
  background: var(--white); color: var(--black);
  border: none; border-radius: var(--r-full);
  font-family: inherit; font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em;
  box-shadow: 0 4px 16px rgba(255,255,255,0.1), var(--shadow-lg);
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}

.fab-credit { background: var(--green); color: var(--black); box-shadow: 0 4px 16px rgba(74,222,128,0.2); }
.fab-debit  { background: var(--red); color: var(--black); box-shadow: 0 4px 16px rgba(248,113,113,0.2); }

.fab svg { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; }
.fab:hover {
  transform: translateY(-2px);
  background: var(--white-1);
  box-shadow: 0 8px 28px rgba(255,255,255,0.18), var(--shadow-xl);
}
.fab-credit:hover { background: #5df094; box-shadow: 0 8px 28px rgba(74,222,128,0.3); }
.fab-debit:hover  { background: #ff8a8a; box-shadow: 0 8px 28px rgba(248,113,113,0.3); }

.fab:active { transform: scale(0.97); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 9px 18px;
  border-radius: var(--r-md);
  font-family: inherit; font-size: 0.875rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  transition: all var(--t-fast);
  white-space: nowrap; letter-spacing: -0.01em;
}
.btn-sm { padding: 6px 13px; font-size: 0.8125rem; gap: var(--s-1); }
.btn svg { stroke-width: 1.5; }

.btn-primary {
  background: var(--white);
  color: var(--black);
  border-color: var(--white);
}
.btn-primary:hover { background: var(--white-2); border-color: var(--white-2); }

.btn-ghost {
  background: transparent;
  color: var(--text-1);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--border-hover); background: rgba(255,255,255,0.04); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(248,113,113,0.25);
}
.btn-danger:hover { background: var(--red); color: var(--black); border-color: var(--red); }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: transparent;
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: background var(--t-mid), backdrop-filter var(--t-mid);
}
.modal-overlay.modal-overlay-visible {
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
}
.modal-overlay.hidden { display: none; }

#modal-container {
  position: fixed; inset: 0; z-index: 201;
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: none;
}
#modal-container.hidden { display: none; }

.modal {
  width: 100%; max-width: 480px;
  background: var(--black-3);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.04);
  pointer-events: all;
  transform: translateY(100%);
  transition: transform var(--t-mid) var(--ease);
  max-height: 92dvh;
  overflow-y: auto;
}
.modal.modal-visible { transform: translateY(0); }

/* Drag handle */
.modal::before {
  content: '';
  display: block;
  width: 36px; height: 4px;
  background: var(--border-hover);
  border-radius: var(--r-full);
  margin: var(--s-3) auto 0;
}

.modal-sm { max-width: 360px; }

@media (min-width: 600px) {
  #modal-container { align-items: center; }
  .modal {
    border: 1px solid var(--border);
    border-radius: var(--r-2xl);
    transform: scale(0.94) translateY(8px);
    opacity: 0;
    transition: transform var(--t-mid) var(--ease), opacity var(--t-mid);
    max-height: 88dvh;
  }
  .modal.modal-visible { transform: scale(1) translateY(0); opacity: 1; }
  .modal::before { display: none; }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-4) var(--s-5) var(--s-3);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
  background: var(--black-3);
}

.modal-close-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--black-5); border: 1px solid var(--border);
  border-radius: var(--r-sm); cursor: pointer;
  color: var(--text-3); font-size: 1.1rem; line-height: 1;
  transition: all var(--t-fast);
}
.modal-close-btn:hover { color: var(--text-1); border-color: var(--border-hover); }

.modal-body   { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); }
.modal-footer {
  display: flex; gap: var(--s-2);
  padding: var(--s-3) var(--s-5) var(--s-5);
  border-top: 1px solid var(--border);
}
.modal-footer .btn { flex: 1; justify-content: center; }

/* ── Transaction Type Footer (Credit / Debit quick-tap) ─────────────────── */
.tx-type-footer {
  display: flex;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5) var(--s-5);
  border-top: 1px solid var(--border);
}

.btn-tx-credit,
.btn-tx-debit {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 15px var(--s-4);
  border-radius: var(--r-md);
  font-family: inherit; font-size: 1rem; font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.btn-tx-credit:active,
.btn-tx-debit:active { transform: scale(0.97); }

.btn-tx-credit {
  background: rgba(74,222,128,0.08);
  border-color: rgba(74,222,128,0.35);
  color: var(--green);
}
.btn-tx-credit:hover {
  background: var(--green);
  border-color: var(--green);
  color: var(--black);
}

.btn-tx-debit {
  background: rgba(248,113,113,0.08);
  border-color: rgba(248,113,113,0.35);
  color: var(--red);
}
.btn-tx-debit:hover {
  background: var(--red);
  border-color: var(--red);
  color: var(--black);
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--s-1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }

label {
  font-size: 0.7rem; font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.input-hint { font-size: 0.7rem; color: var(--text-4); }

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="search"] {
  padding: 9px 11px;
  background: var(--black-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-1);
  font-family: inherit; font-size: 0.875rem;
  outline: none; width: 100%;
  transition: border-color var(--t-fast), background var(--t-fast);
}
input:focus { border-color: var(--border-active); background: var(--black-3); }
input::placeholder { color: var(--text-4); }
input.input-error { border-color: var(--red); animation: shake 0.25s ease; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.6); cursor: pointer; }

.confirm-msg { font-size: 0.9rem; color: var(--text-2); line-height: 1.7; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge-positive {
  display: inline-block; padding: 1px 5px;
  background: var(--green-dim); color: var(--green);
  border-radius: var(--r-sm); font-size: 0.7rem; font-weight: 700;
}
.badge-negative {
  display: inline-block; padding: 1px 5px;
  background: var(--red-dim); color: var(--red);
  border-radius: var(--r-sm); font-size: 0.7rem; font-weight: 700;
}
.badge-warning {
  display: inline-block; padding: 2px 7px;
  background: var(--amber-dim); color: var(--amber);
  border-radius: var(--r-sm); font-size: 0.7rem; font-weight: 600;
}

/* ── Settings ─────────────────────────────────────────────────────────────── */
.settings-main { gap: var(--s-5); }
.settings-section { display: flex; flex-direction: column; gap: var(--s-2); }

.settings-section-title {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-4); padding: 0 var(--s-1);
}
.settings-section-title svg { stroke-width: 1.5; }
.danger-title { color: var(--red); }

.settings-card {
  background: var(--black-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.settings-card-danger { border-color: rgba(248,113,113,0.18); }

.settings-item {
  display: flex; align-items: center;
  padding: var(--s-4);
  gap: var(--s-4);
}
.settings-item-info { flex: 1; min-width: 0; }
.settings-item-title { font-weight: 600; font-size: 0.9rem; color: var(--text-1); letter-spacing: -0.01em; }
.settings-item-desc  { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; line-height: 1.5; }
.settings-divider    { height: 1px; background: var(--border); margin: 0; }
.settings-badge {
  padding: 2px 9px;
  background: rgba(255,255,255,0.07);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em;
}

.settings-tip {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--black-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 0.78rem; color: var(--text-3); line-height: 1.6;
}
.settings-tip svg { flex-shrink: 0; color: var(--text-2); margin-top: 1px; stroke-width: 1.5; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: var(--s-4); left: 50%; transform: translateX(-50%);
  z-index: 9000;
  display: flex; flex-direction: column; gap: var(--s-2);
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 11px 14px;
  background: var(--black-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  transform: translateY(-14px) scale(0.96);
  opacity: 0;
  transition: transform var(--t-mid) var(--ease), opacity var(--t-mid);
  pointer-events: all;
}
.toast.toast-visible { transform: translateY(0) scale(1); opacity: 1; }

.toast-success { border-left: 2px solid var(--green); }
.toast-error   { border-left: 2px solid var(--red);   }
.toast-info    { border-left: 2px solid var(--white-3); }
.toast-warning { border-left: 2px solid var(--amber);  }

.toast-icon { width: 16px; height: 16px; flex-shrink: 0; }
.toast-icon svg { width: 100%; height: 100%; stroke-width: 2; }
.toast-success .toast-icon { color: var(--green); }
.toast-error   .toast-icon { color: var(--red); }
.toast-info    .toast-icon { color: var(--text-2); }
.toast-warning .toast-icon { color: var(--amber); }

.toast-msg { font-size: 0.8125rem; color: var(--text-1); flex: 1; line-height: 1.4; }
.toast-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-4); font-size: 1rem;
  padding: 0 0 0 var(--s-2); line-height: 1;
  transition: color var(--t-fast);
}
.toast-close:hover { color: var(--text-1); }

/* ── Empty & Error States ─────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: var(--s-12) var(--s-8); animation: fade-up 0.35s var(--ease); }
.empty-icon  { font-size: 2.5rem; margin-bottom: var(--s-4); display: block; opacity: 0.5; }
.empty-state h3 { font-size: 1rem; margin-bottom: var(--s-1); }
.empty-state p  { font-size: 0.8125rem; max-width: 260px; margin: 0 auto; line-height: 1.7; }
.error-state    { padding: var(--s-8); color: var(--red); text-align: center; font-size: 0.875rem; }

/* ── Loading Spinner ──────────────────────────────────────────────────────── */
.loading-spinner {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  padding: var(--s-12);
  color: var(--text-4); font-size: 0.8125rem;
}
.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes icon-pulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--border-strong); }
  50%       { box-shadow: 0 0 0 1px var(--white), 0 0 20px rgba(255,255,255,0.1); }
}
@keyframes live-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  30%       { transform: translateX(-5px); }
  70%       { transform: translateX(5px); }
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--white-5); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--white-4); }

/* ── Selection ────────────────────────────────────────────────────────────── */
::selection { background: rgba(255,255,255,0.12); color: var(--white); }

/* ── Focus ────────────────────────────────────────────────────────────────── */
:focus-visible { outline: 1.5px solid var(--white-3); outline-offset: 2px; border-radius: var(--r-sm); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 380px) {
  .dashboard-stats { grid-template-columns: repeat(3, 1fr); }
  .stat-value { font-size: 0.68rem; }
  .form-row { grid-template-columns: 1fr; }
  
  .fab-group { gap: var(--s-1); right: var(--s-3); bottom: calc(var(--nav-h) + var(--s-3)); }
  .fab span { display: none; }
  .fab { padding: 14px; border-radius: 50%; }
}

@media (min-width: 768px) {
  .page-main { max-width: 680px; margin: 0 auto; padding: var(--s-5); }
  .customers-grid { gap: var(--s-3); }
  .ledger-table th, .ledger-table td { padding: 11px 12px; }
  .ledger-table { font-size: 0.8125rem; }
  .ledger-wrapper { padding: 0 var(--s-4); }
}
