/* ================================================================
   udhar.css — Khata Wallah Udhar Ledger
   Mobile-First, Premium UI
================================================================ */

:root {
  --bg-color: #f8fafc;
  --surface: #ffffff;
  --text-dark: #0f172a;
  --text-muted: #64748b;

  --primary: #3b82f6;
  --primary-light: #eff6ff;
  --primary-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);

  --success: #10b981;
  --success-gradient: linear-gradient(135deg, #059669 0%, #047857 100%);
  --success-light: #ecfdf5;

  --danger: #ef4444;
  --danger-gradient: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  --danger-light: #fef2f2;

  --warning: #f59e0b;
  --warning-gradient: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  --warning-light: #fffbeb;

  --premium-dark: linear-gradient(135deg, #020617 0%, #0f172a 100%);

  --border: #e2e8f0;
  --shadow-sm: 0 4px 6px -1px rgba(0,0,0,.05), 0 2px 4px -1px rgba(0,0,0,.03);
  --shadow-md: 0 10px 25px -5px rgba(0,0,0,.08), 0 8px 10px -6px rgba(0,0,0,.04);
  --shadow-lg: 0 25px 50px -12px rgba(0,0,0,.15);
}

/* ─── RESET & BASE ─── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  background: var(--bg-color);
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
}

/* ─── ANIMATIONS ─── */
@keyframes slideUpFade  { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
@keyframes popIn        { 0%  { opacity:0; transform:scale(0.95); }       100%{ opacity:1; transform:scale(1); } }
@keyframes shimmer      { 0%  { background-position:200% 0; }              100%{ background-position:-200% 0; } }
@keyframes slideInRight { from{ transform:translateX(100%); }              to  { transform:translateX(0); } }
@keyframes fadeIn       { from{ opacity:0; }                               to  { opacity:1; } }

/* ─── DESKTOP / MOBILE HELPERS ─── */
.desk-topbar, .desk-footer, .desk-only, .desk-page-header, .desktop-empty { display: none; }

/* ================================================================
   MOBILE TOPBAR
================================================================ */
.mob-topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  height: 58px; background: #fff;
  border-bottom: 1px solid #f1f5f9;
  padding: 0 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.mob-back {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 12px; background: #f8fafc; color: var(--text-dark);
  text-decoration: none; border: 1px solid var(--border); font-size: 1.05rem;
  transition: background 0.2s;
}
.mob-back:hover { background: #f1f5f9; }
.mob-title {
  flex: 1; text-align: center; font-size: 1.1rem; font-weight: 800;
  letter-spacing: -0.01em; background: var(--primary-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.mob-action-btn {
  background: transparent; border: none; font-size: 1.25rem; color: var(--text-dark);
  width: 40px; height: 40px; cursor: pointer; border-radius: 12px;
  transition: background 0.2s;
}
.mob-action-btn:hover { background: #f1f5f9; }

/* ================================================================
   MAIN WRAPPER
================================================================ */
.udhar-page { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.dashboard-panel { width: 100%; display: flex; flex-direction: column; }

/* ================================================================
   BENTO GRID / SUMMARY CARD (Mobile)
================================================================ */
.bento-grid { padding: 12px 14px 10px; display: grid; gap: 12px; }

.summary-card {
  background: var(--premium-dark);
  color: #fff; border-radius: 22px; padding: 22px 20px 18px;
  box-shadow: 0 14px 28px -14px rgba(15,23,42,.58);
  position: relative; overflow: hidden;
  animation: popIn 0.45s cubic-bezier(0.16,1,0.3,1);
  border: 1px solid rgba(255,255,255,.08);
}
.summary-card.positive {
  background: var(--success-gradient);
  box-shadow: 0 20px 40px -12px rgba(5,150,105,.4);
}
.summary-card::before, .summary-card::after {
  content: ''; position: absolute; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.12) 0%, transparent 70%);
  pointer-events: none;
}
.summary-card::before { top: -40%; right: -15%; width: 240px; height: 240px; }
.summary-card::after  { bottom: -30%; left: -10%; width: 160px; height: 160px; }

.summary-title {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: #94a3b8; margin-bottom: 8px;
}
.summary-amount {
  font-size: clamp(2.2rem, 10vw, 2.75rem); font-weight: 900; margin: 0; line-height: 1;
  letter-spacing: -0.03em; text-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.summary-subtitle {
  font-size: 0.78rem; opacity: 0.9; margin-top: 14px;
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-weight: 500;
}
.summary-progress-bg {
  background: rgba(255,255,255,.08); height: 4px; border-radius: 4px;
  margin-top: 14px; overflow: hidden;
}
.summary-progress-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #3b82f6, #a855f7);
  transition: width 1.2s cubic-bezier(0.16,1,0.3,1);
  width: 0%;
}

/* ================================================================
   AI STRIP
================================================================ */
.ai-strip {
  display: flex; gap: 12px; overflow-x: auto;
  padding: 0 14px 10px; scrollbar-width: none;
}
.ai-strip[hidden] { display: none !important; }
.ai-strip::-webkit-scrollbar { display: none; }
.ai-card {
  min-width: 260px; border-radius: 18px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,.03); flex-shrink: 0;
  border: 1px solid transparent;
}
.ai-card.danger  { background: #fef2f2; border-color: #fee2e2; }
.ai-card.warning { background: #fffbeb; border-color: #fef3c7; }
.ai-card-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; flex-shrink: 0;
  background: #fff;
}
.ai-card.danger  .ai-card-icon { color: var(--danger); }
.ai-card.warning .ai-card-icon { color: var(--warning); }
.ai-card-title { font-weight: 800; font-size: 0.9rem; margin: 0 0 3px; color: var(--text-dark); }
.ai-card-desc  { font-size: 0.78rem; color: var(--text-muted); margin: 0; line-height: 1.4; }

/* ================================================================
   SEARCH, FILTER & SORT
================================================================ */
.search-filter-section {
  padding: 8px 14px 6px; margin-bottom: 2px;
  position: sticky; top: 58px; background: var(--bg-color);
  z-index: 90; border-bottom: 1px solid transparent;
  transition: box-shadow 0.2s;
}
.search-container { position: relative; margin-bottom: 8px; }
.search-input {
  width: 100%; padding: 11px 14px 11px 42px; border-radius: 14px;
  border: 1.5px solid transparent; font-family: inherit;
  font-size: 0.95rem; font-weight: 500; background: #f1f5f9;
  transition: all 0.2s; color: var(--text-dark);
}
.search-input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 4px 12px rgba(59,130,246,.1); }
.search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 0.95rem; pointer-events: none; }

/* Filter + Sort Row */
.filter-sort-row {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
}
.filter-sort-row::-webkit-scrollbar { display: none; }
.filter-chips { display: flex; gap: 6px; flex-shrink: 0; }
.filter-chip {
  background: #f1f5f9; border: none;
  color: var(--text-muted); padding: 8px 16px;
  border-radius: 20px; font-size: 0.82rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: all 0.18s;
  font-family: inherit;
}
.filter-chip:hover { background: #e2e8f0; color: var(--text-dark); }
.filter-chip.active { background: var(--text-dark); color: #fff; }

.sort-select {
  flex-shrink: 0; padding: 8px 12px; border: 1.5px solid var(--border);
  border-radius: 20px; font-family: inherit; font-size: 0.82rem;
  font-weight: 700; background: #fff; color: var(--text-muted);
  cursor: pointer; appearance: none; outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 28px;
}

/* Bulk Remind Button */
#btn-bulk-remind {
  display: none; align-items: center; justify-content: center; gap: 8px;
  background: #25D366; color: #fff; border: none;
  padding: 11px 16px; border-radius: 12px;
  font-weight: 700; cursor: pointer; font-size: 0.85rem;
  margin-top: 10px; width: 100%; font-family: inherit;
  box-shadow: 0 4px 12px rgba(37,211,102,.3);
  transition: transform 0.2s, box-shadow 0.2s;
}
#btn-bulk-remind:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37,211,102,.4); }

/* ================================================================
   CUSTOMER LIST
================================================================ */
.customer-list { padding: 10px 14px 20px; display: flex; flex-direction: column; gap: 9px; }

.customer-item {
  display: flex; align-items: center; gap: 0;
  background: #fff; padding: 14px; border-radius: 16px;
  box-shadow: var(--shadow-sm); cursor: pointer;
  border: 1.5px solid var(--border);
  animation: slideUpFade 0.35s cubic-bezier(0.16,1,0.3,1);
  transition: all 0.22s cubic-bezier(0.16,1,0.3,1);
}
.customer-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #cbd5e1; }
.customer-item:active { transform: scale(0.99); }

.c-avatar {
  width: 46px; height: 46px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1.2rem;
  margin-right: 14px; flex-shrink: 0;
}
.c-info { flex: 1; min-width: 0; }
.c-name {
  font-weight: 800; font-size: 1.05rem; margin: 0 0 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-dark); letter-spacing: -0.01em;
}
.c-meta {
  font-size: 0.8rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 10px; font-weight: 500;
  flex-wrap: wrap;
}
.c-meta i { font-size: 0.75rem; }

/* Overdue badges */
.overdue-badge {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 5px; padding: 3px 8px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 800;
  background: #fef2f2; color: var(--danger); border: 1px solid #fecaca;
  animation: fadeIn 0.3s ease;
}
.overdue-badge.warning { background: #fffbeb; color: var(--warning); border-color: #fde68a; }

/* Right section (amount + quick remind) */
.c-right {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.c-amount-box { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.c-amount { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; }
.c-amount.due     { color: var(--danger); }
.c-amount.settled { color: var(--text-muted); }
.c-amount.advance { color: var(--success); }
.badge { font-size: 0.62rem; font-weight: 800; padding: 3px 8px; border-radius: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.badge.due     { background: #fef2f2; color: var(--danger); border: 1px solid #fee2e2; }
.badge.settled { background: #f8fafc; color: var(--text-muted); border: 1px solid #f1f5f9; }

/* Quick Remind Button (on card) */
.quick-remind-btn {
  background: transparent; color: #10b981; border: none;
  border-radius: 12px; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.15rem; flex-shrink: 0;
  transition: all 0.18s;
}
.quick-remind-btn:hover { background: #ecfdf5; transform: scale(1.08); }
.quick-remind-btn:active { transform: scale(0.95); }

/* ─── SKELETON ─── */
.skeleton { background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 8px; }
.skel-item { display: flex; align-items: center; background: #fff; padding: 16px; border-radius: 20px; margin-bottom: 10px; }
.skel-avatar { width: 50px; height: 50px; border-radius: 15px; margin-right: 14px; flex-shrink: 0; }
.skel-line { height: 13px; margin-bottom: 8px; width: 60%; }
.skel-line.short { width: 38%; }

/* ─── EMPTY STATE ─── */
.empty-state { padding: 30px 20px 18px; text-align: center; color: var(--text-muted); }
.loading-state { padding: 48px 20px; text-align: center; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ─── FAB (Mobile) ─── */
.fab-container { position: fixed; bottom: 92px; right: 20px; z-index: 20; }
.fab-container[hidden] { display: none !important; }
.fab-btn {
  background: var(--text-dark); color: #fff; border: none; height: 54px;
  padding: 0 22px; border-radius: 28px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 0.95rem; font-weight: 800; font-family: inherit;
  box-shadow: 0 8px 24px rgba(15,23,42,.45);
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
}
.fab-btn:hover  { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(15,23,42,.5); }
.fab-btn:active { transform: scale(0.96); }

/* ================================================================
   LEDGER OVERLAY (Full-screen on mobile, side panel on desktop)
================================================================ */
.ledger-overlay {
  position: fixed; inset: 0; background: var(--bg-color); z-index: 2000;
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.35s cubic-bezier(0.16,1,0.3,1);
}
.ledger-overlay.active { transform: translateX(0); }

.lo-header {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
  position: sticky; top: 0; z-index: 10;
}
.lo-back {
  background: #f8fafc; border: 1.5px solid var(--border);
  font-size: 1rem; color: var(--text-dark);
  width: 42px; height: 42px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.2s;
}
.lo-back:hover { background: #f1f5f9; }
.lo-header h2 { font-size: 1.05rem; font-weight: 800; margin: 0; flex: 1; text-align: center; }
.lo-btn-icon {
  width: 42px; height: 42px; border: none; background: transparent;
  font-size: 1.3rem; cursor: pointer; border-radius: 12px;
  transition: background 0.2s; display: flex; align-items: center; justify-content: center;
}
.lo-btn-icon:hover { background: #f0fdf4; }
.lo-btn-whatsapp { color: #16a34a; }

.lo-scroll-content { flex: 1; overflow-y: auto; padding-bottom: 24px; }

/* Profile Card */
.lo-profile-card {
  background: #fff; margin: 16px; border-radius: 24px;
  box-shadow: var(--shadow-sm); position: relative;
  overflow: hidden; border: 1px solid var(--border);
}
.lo-profile-bg {
  height: 96px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 50%, #312e81 100%);
  border-radius: 24px 24px 0 0;
}
.lo-profile-top {
  padding: 14px 20px 12px;
  display: flex; align-items: flex-start; gap: 14px;
  position: relative; margin-top: -48px;
}
.lo-avatar.large {
  width: 72px; height: 72px; font-size: 2rem; border-radius: 20px;
  border: 4px solid #fff; box-shadow: 0 8px 20px rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-weight: 900;
}
.lo-profile-info { flex: 1; padding-top: 48px; }
.lo-name-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.lo-name { font-size: 1.25rem; margin: 0; font-weight: 800; color: var(--text-dark); letter-spacing: -0.02em; }
.lo-ai-badge {
  background: var(--warning-gradient); color: #fff;
  padding: 4px 10px; font-size: 0.68rem; font-weight: 800;
  border-radius: 10px; display: flex; align-items: center; gap: 4px;
  text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; flex-shrink: 0;
}
.lo-phone { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; margin: 0; }

.lo-actions-row { display: flex; gap: 10px; padding: 0 20px 18px; }
.lo-action-chip {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px; border-radius: 14px; font-weight: 700; font-size: 0.88rem;
  cursor: pointer; text-decoration: none; border: 1.5px solid transparent;
  transition: all 0.18s; font-family: inherit;
}
.lo-action-chip.call { background: #eff6ff; color: var(--primary); border-color: #bfdbfe; }
.lo-action-chip.call:hover { background: #dbeafe; }
.lo-action-chip.wa { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; }
.lo-action-chip.wa:hover { background: #dcfce7; }
.lo-action-chip.danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.lo-action-chip.danger:hover { background: #fee2e2; }
.lo-action-chip.danger.active { background: var(--danger); color: #fff; border-color: var(--danger); }
.lo-whatsapp-status { margin: -6px 20px 14px; padding: 10px 12px; border: 1px solid; border-radius: 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lo-whatsapp-status.is-off { background: #fff7ed; border-color: #fed7aa; }
.lo-whatsapp-status.is-on { background: #f0fdf4; border-color: #bbf7d0; }
.lo-wa-state { min-width: 0; display: flex; align-items: center; gap: 9px; }
.lo-wa-state > i { font-size: 1.05rem; color: #16a34a; }
.lo-wa-state span { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lo-wa-state strong { color: #1e293b; font-size: .76rem; }
.lo-wa-state small { color: #64748b; font-size: .66rem; line-height: 1.25; }
#lo-manage-whatsapp { min-height: 34px; padding: 0 11px; border: 1px solid #86efac; border-radius: 9px; background: #fff; color: #15803d; font: inherit; font-size: .7rem; font-weight: 800; cursor: pointer; }

.lo-profile-stats { display: flex; gap: 12px; padding: 0 20px 20px; }
.stat-glass-box {
  flex: 1; background: #f8fafc; padding: 16px; border-radius: 16px;
  display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--border);
}
.stat-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.stat-icon.danger-tint  { background: var(--danger-light);  color: var(--danger); }
.stat-icon.warning-tint { background: var(--warning-light); color: var(--warning); }
.stat-content p  { font-size: 0.7rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; margin: 0; }
.stat-content h2 { font-size: 1.4rem; font-weight: 800; margin: 0; line-height: 1; letter-spacing: -0.02em; }
.stat-content h2.danger  { color: var(--danger); }
.stat-content h2.success { color: var(--success); }

/* ─── TIMELINE ─── */
.lo-timeline {
  padding: 0 16px 8px;
  display: flex; flex-direction: column;
  position: relative;
}
.lo-timeline::before {
  content: ''; position: absolute; top: 0; bottom: 0;
  left: 34px; width: 2px; background: #e2e8f0; z-index: 1;
}
.tl-date-badge {
  align-self: flex-start; background: #fff; border: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.72rem; font-weight: 700;
  padding: 5px 14px; border-radius: 20px;
  margin: 16px 0 12px 48px; z-index: 2;
  box-shadow: var(--shadow-sm); text-transform: uppercase; letter-spacing: 0.5px;
}
.tl-entry-wrapper {
  display: flex; align-items: flex-start;
  margin-bottom: 14px; position: relative; z-index: 2;
}
.tl-dot {
  width: 36px; height: 36px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; margin-right: 12px; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.gave .tl-dot { border-color: #fda4af; color: var(--danger); background: #fff1f2; }
.penalty .tl-dot { border-color: #fdba74; color: #c2410c; background: #fff7ed; }
.got  .tl-dot { border-color: #86efac; color: var(--success); background: #f0fdf4; }
.advance .tl-dot { border-color: #c4b5fd; color: #7c3aed; background: #f5f3ff; }
.advance-use .tl-dot { border-color: #93c5fd; color: #2563eb; background: #eff6ff; }
.split .tl-dot { border-color: #60a5fa; color: #1d4ed8; background: #eff6ff; }
.tl-entry {
  flex: 1; background: #fff; padding: 14px 16px; border-radius: 0 16px 16px 0;
  border: 1px solid var(--border); border-left: 4px solid transparent;
  box-shadow: var(--shadow-sm);
}
.gave .tl-entry { border-left-color: var(--danger); }
.penalty .tl-entry { border-left-color: #ea580c; }
.got  .tl-entry { border-left-color: var(--success); }
.advance .tl-entry { border-left-color: #7c3aed; }
.advance-use .tl-entry { border-left-color: #2563eb; }
.split .tl-entry { border-left-color: #2563eb; background: linear-gradient(145deg,#fff,#f8fbff); }
.tl-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; gap: 10px; }
.tl-title  { font-weight: 700; font-size: 0.9rem; color: var(--text-dark); margin: 0; line-height: 1.3; flex: 1; }
.tl-amount { font-weight: 800; font-size: 1.1rem; flex-shrink: 0; }
.gave .tl-amount { color: var(--danger); }
.got  .tl-amount { color: var(--success); }
.bill-reference { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 4px 8px; border-radius: 7px; background: #f8fafc; color: var(--text-muted); font-size: .75rem; font-weight: 700; }
.tl-meta { font-size: 0.75rem; color: var(--text-muted); display: flex; justify-content: space-between; font-weight: 600; }
.tl-balance { background: #f1f5f9; padding: 3px 8px; border-radius: 8px; color: var(--text-dark); font-weight: 700; }
.tl-meta-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.tl-share-btn {
  min-height: 34px; padding: 6px 10px; border: 1px solid #bbf7d0; border-radius: 10px;
  background: #f0fdf4; color: #15803d; font: inherit; font-size: .72rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.tl-share-btn:hover { background: #dcfce7; border-color: #86efac; transform: translateY(-1px); }
.tl-share-btn:active { transform: scale(.97); }
.tl-share-btn:disabled { cursor: wait; opacity: .65; transform: none; }
.tl-share-btn i { font-size: .9rem; }
.tl-allocation-math { margin: 10px 0; padding: 10px 12px; border: 1px solid #dbeafe; border-radius: 12px; background: #f8fbff; display: grid; gap: 7px; }
.tl-allocation-math > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #64748b; font-size: .76rem; }
.tl-allocation-math strong { color: #0f172a; font-size: .8rem; white-space: nowrap; }
.tl-allocation-math .advance-row strong { color: #7c3aed; }
.tl-allocation-math .due-row strong { color: #dc2626; }
.tl-allocation-math .math-result { padding-top: 7px; border-top: 1px dashed #bfdbfe; font-weight: 800; }
.tl-allocation-math .math-result strong { color: #1d4ed8; }
.tl-allocation-math .tl-ledger-review { border-top: 1px dashed #f59e0b; padding-top: 7px; }
.tl-allocation-math .tl-ledger-review strong { color: #b45309; }
.tl-ledger-review-note { color: #92400e; background: #fffbeb; border-radius: 7px; padding: 8px 10px; font-size: .72rem; line-height: 1.4; }

@media (max-width: 420px) {
  .tl-meta { align-items: flex-end; gap: 8px; }
  .tl-meta-actions { flex-direction: column; align-items: flex-end; gap: 6px; }
  .tl-share-btn { min-width: 82px; }
}

/* ─── BOTTOM ACTION BAR ─── */
.lo-bottom-bar {
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  display: flex; gap: 12px; background: #fff;
  border-top: 1px solid var(--border);
  position: sticky; bottom: 0; z-index: 10;
  box-shadow: 0 -4px 20px rgba(0,0,0,.06);
}
.lo-action-btn {
  flex: 1; padding: 16px; border: none; border-radius: 16px;
  font-size: 0.95rem; font-weight: 800; font-family: inherit;
  color: #fff; cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 8px;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: 0 4px 14px rgba(0,0,0,.1);
}
.lo-action-btn:hover  { transform: translateY(-2px); }
.lo-action-btn:active { transform: scale(0.97); }
.lo-action-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.lo-btn-gave { background: var(--danger-gradient); }
.lo-btn-advance { background: linear-gradient(135deg, #7c3aed, #4f46e5); color: #fff; }
.lo-btn-got  { background: var(--success-gradient); }

/* ================================================================
   MODALS (Bottom Sheet on mobile, Centered on desktop)
================================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.65);
  backdrop-filter: blur(6px);
  z-index: 2500; display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  background: #fff; width: 100%; max-width: 520px;
  border-radius: 28px 28px 0 0;
  padding: 8px 20px calc(28px + env(safe-area-inset-bottom));
  animation: slideUpFade 0.3s ease-out; position: relative;
}
.modal-drag-handle { width: 44px; height: 5px; background: #e2e8f0; border-radius: 3px; margin: 8px auto 18px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px;
}
.modal-header h3 { margin: 0; font-size: 1.25rem; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.modal-close-btn {
  background: #f1f5f9; border: none; width: 38px; height: 38px;
  border-radius: 12px; font-size: 1.05rem; color: var(--text-muted); cursor: pointer;
  transition: background 0.2s;
}
.modal-close-btn:hover { background: #e2e8f0; }

.entry-input-group { margin-bottom: 18px; }
.entry-input-group label {
  display: block; font-size: 0.78rem; font-weight: 700;
  color: var(--text-muted); margin-bottom: 7px; text-transform: uppercase; letter-spacing: 0.5px;
}
.entry-input {
  width: 100%; padding: 14px 16px; font-size: 1rem; font-weight: 600;
  border: 2px solid var(--border); border-radius: 14px;
  background: #f8fafc; font-family: inherit; color: var(--text-dark);
  transition: border-color 0.2s, background 0.2s;
}
.entry-input:focus { outline: none; border-color: var(--primary); background: #fff; }
.amount-input { font-size: 1.75rem; text-align: center; font-weight: 800; letter-spacing: -0.02em; }
.danger-input:focus  { border-color: var(--danger); }
.success-input:focus { border-color: var(--success); }
textarea.entry-input { resize: none; font-size: 0.95rem; }
.field-help { display: block; margin-top: 6px; color: var(--text-muted); font-size: .76rem; line-height: 1.4; }
.link-button { padding: 2px 6px; border: 0; background: transparent; color: var(--primary); font: inherit; font-size: .75rem; cursor: pointer; }

.quick-amounts { display: flex; gap: 8px; margin-top: 8px; }
.qa-chip {
  flex: 1; background: #fff; border: 1.5px solid var(--border);
  padding: 9px 0; border-radius: 12px; font-size: 0.88rem;
  font-weight: 700; color: var(--text-muted); cursor: pointer;
  font-family: inherit; transition: all 0.18s;
}
.qa-chip:hover  { border-color: var(--primary); color: var(--primary); }
.qa-chip:active { background: #f8fafc; transform: scale(0.97); }

.consent-box {
  background: #f8fafc; padding: 14px 16px; border-radius: 14px;
  margin-bottom: 20px; border: 1px solid var(--border);
}
.consent-title { font-size: 0.72rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; margin: 0 0 10px; }
.consent-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.consent-row:last-child { margin-bottom: 0; }
.consent-row label { font-size: 0.88rem; font-weight: 600; color: var(--text-dark); cursor: pointer; }
.custom-checkbox { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.wa-check { accent-color: #16a34a; }

.btn-action {
  width: 100%; padding: 17px; border: none; border-radius: 16px;
  font-size: 1.05rem; font-weight: 800; font-family: inherit;
  color: #fff; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
}
.btn-action:hover  { transform: translateY(-1px); }
.btn-action:active { transform: scale(0.98); }
.btn-primary        { background: var(--text-dark); }
.btn-danger-action  { background: var(--danger-gradient); }
.btn-success-action { background: var(--success-gradient); }

/* ─── TOAST NOTIFICATION ─── */
#notification {
  position: fixed; bottom: 100px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-dark); color: #fff;
  padding: 12px 22px; border-radius: 24px;
  font-weight: 600; font-size: 0.9rem; z-index: 9999;
  display: flex; align-items: center; gap: 10px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  white-space: nowrap; max-width: 90vw;
}
#notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#notification.success { background: linear-gradient(135deg, #059669, #047857); }
#notification.error   { background: var(--danger-gradient); }
#notification.info    { background: var(--primary-gradient); }

/* ================================================================
   BOTTOM NAV (Mobile)
================================================================ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: 64px; background: #fff;
  display: flex; align-items: stretch;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,.07);
  padding-bottom: env(safe-area-inset-bottom);
}
.bnav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: #94a3b8;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.2px;
  transition: color 0.2s;
}
.bnav-icon { font-size: 1.25rem; transition: transform 0.2s; }
.bnav-item.active { color: var(--primary); }
.bnav-item.active .bnav-icon { transform: translateY(-2px); }
.bnav-item:hover  { color: var(--text-dark); }

/* ================================================================
   DESKTOP OVERRIDES (≥1024px)
================================================================ */
@media (min-width: 1024px) {

  /* Hide mobile-only elements */
  .mob-topbar, .mob-only, .bottom-nav { display: none !important; }
  .desk-only { display: flex !important; }

  body { background: #f1f5f9; padding-top: 64px; }

  /* ─── DESKTOP TOPBAR ─── */
  .desk-topbar {
    display: flex; position: fixed; top: 0; left: 0; right: 0; height: 64px;
    background: #0f172a; border-bottom: 1px solid rgba(255,255,255,.06);
    align-items: center; z-index: 500;
  }
  .desk-topbar-inner {
    max-width: 1400px; margin: 0 auto; width: 100%;
    padding: 0 40px; display: flex; align-items: center; justify-content: space-between;
  }
  .desk-brand {
    display: flex; align-items: center; gap: 10px;
    font-size: 1.05rem; font-weight: 800; color: #fff; text-decoration: none;
  }
  .desk-brand i { color: var(--primary); font-size: 1.2rem; }
  .desk-nav { display: flex; gap: 4px; }
  .desk-nav a {
    display: flex; align-items: center; gap: 7px;
    padding: 8px 14px; border-radius: 10px;
    color: #94a3b8; font-size: 0.88rem; font-weight: 600;
    text-decoration: none; transition: all .18s;
  }
  .desk-nav a:hover    { background: rgba(255,255,255,.07); color: #fff; }
  .desk-nav a.is-active{ background: rgba(59,130,246,.15); color: #60a5fa; }

  /* ─── PAGE LAYOUT ─── */
  .udhar-page {
    max-width: 1400px; margin: 0 auto;
    padding: 40px 40px 60px;
    display: flex; align-items: flex-start; gap: 32px;
  }
  .dashboard-panel { flex: 1; min-width: 0; }

  /* ─── DESKTOP PAGE HEADER ─── */
  .desk-page-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px;
  }
  .page-title {
    font-size: 2.4rem; font-weight: 900; margin: 0;
    color: var(--text-dark); letter-spacing: -0.04em;
  }
  .btn-refresh-desk {
    background: #fff; border: 1.5px solid var(--border);
    padding: 11px 22px; border-radius: 14px; font-weight: 700;
    color: var(--text-dark); cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    box-shadow: var(--shadow-sm); font-size: 0.9rem;
    font-family: inherit; transition: all 0.2s;
  }
  .btn-refresh-desk:hover { background: #f8fafc; transform: translateY(-2px); box-shadow: var(--shadow-md); }

  /* ─── BENTO GRID ─── */
  .bento-grid { padding: 0; grid-template-columns: 2.5fr 1fr; margin-bottom: 28px; gap: 20px; }
  .summary-card { padding: 36px; border-radius: 28px; }
  .summary-title { font-size: 0.88rem; margin-bottom: 14px; }
  .summary-amount { font-size: 4rem; }

  .b-add-cust {
    background: #fff; border-radius: 28px; padding: 36px;
    border: 2px dashed #cbd5e1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
    cursor: pointer; transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
  }
  .b-add-cust:hover { border-color: var(--primary); background: var(--primary-light); transform: translateY(-4px); box-shadow: var(--shadow-md); }
  .b-add-cust .bt-icon {
    width: 60px; height: 60px; background: var(--primary-light); color: var(--primary);
    border-radius: 18px; font-size: 1.7rem;
    display: flex; align-items: center; justify-content: center; margin-bottom: 16px;
  }
  .b-add-cust .bt-title { font-size: 1.2rem; font-weight: 800; margin: 0 0 6px; }
  .b-add-cust .bt-desc  { font-size: 0.9rem; color: var(--text-muted); margin: 0; }

  /* ─── SEARCH, FILTER & SORT (Desktop) ─── */
  .search-filter-section {
    position: static; padding: 0; background: transparent;
    display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-bottom: 24px;
    border-bottom: none;
  }
  .search-container { margin: 0; flex: 1; max-width: 420px; }
  .search-input { padding: 14px 18px 14px 48px; border-radius: 18px; font-size: 1rem; }
  .search-icon { left: 18px; font-size: 1rem; }

  .filter-sort-row { flex-shrink: 0; overflow: visible; }
  .filter-chip { padding: 10px 20px; font-size: 0.88rem; border-radius: 22px; }

  #btn-bulk-remind {
    width: auto; margin-top: 0; padding: 11px 20px; border-radius: 12px;
  }

  /* ─── CUSTOMER LIST (Desktop) ─── */
  .customer-list { padding: 0; gap: 12px; }
  .customer-item { padding: 20px 24px; border-radius: 22px; }
  .c-avatar { width: 56px; height: 56px; font-size: 1.4rem; border-radius: 16px; margin-right: 18px; }
  .c-name   { font-size: 1.15rem; margin-bottom: 6px; }
  .c-meta   { font-size: 0.85rem; }
  .c-amount { font-size: 1.15rem; }
  .badge    { font-size: 0.72rem; padding: 4px 10px; }
  .quick-remind-btn { width: 40px; height: 40px; font-size: 1.05rem; border-radius: 12px; }

  /* ─── LEDGER OVERLAY → SIDE PANEL on Desktop ─── */
  .ledger-overlay {
    position: sticky; top: 104px;
    width: 440px; flex-shrink: 0;
    background: #fff; border-radius: 28px;
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: none !important;
    display: none; flex-direction: column;
    height: calc(100vh - 140px); overflow: hidden;
  }
  .ledger-overlay.active {
    display: flex;
    animation: fadeIn 0.4s ease;
  }

  /* Desktop empty state (right panel) */
  .desktop-empty {
    display: flex; position: sticky; top: 104px;
    width: 440px; flex-shrink: 0;
    flex-direction: column; align-items: center; justify-content: center;
    background: transparent; border-radius: 28px;
    border: 2px dashed #cbd5e1; color: var(--text-muted);
    height: calc(100vh - 140px); text-align: center; padding: 40px;
  }
  .desktop-empty i { color: #94a3b8 !important; }
  .ledger-overlay.active + .desktop-empty { display: none; }

  .lo-header { padding: 24px 28px 18px; }
  .lo-back   { display: none; }
  .lo-header h2 { text-align: left; font-size: 1.3rem; letter-spacing: -0.02em; }
  .lo-btn-icon {
    width: 44px; height: 44px; background: #f0fdf4;
    border-radius: 14px; color: #16a34a;
  }
  .lo-btn-icon:hover { background: #dcfce7; }

  .lo-profile-card { margin: 20px 28px; border-radius: 22px; }
  .lo-profile-bg { height: 100px; border-radius: 22px 22px 0 0; }
  .lo-profile-top { padding: 18px 22px 14px; margin-top: -52px; }
  .lo-avatar.large { width: 78px; height: 78px; font-size: 2.2rem; }
  .lo-profile-info { padding-top: 52px; }
  .lo-name { font-size: 1.5rem; }

  .lo-timeline { padding: 0 28px 8px; }
  .lo-timeline::before { left: 46px; border-left: 2px dashed #e2e8f0; width: 0; background: transparent; }
  .tl-date-badge { margin: 20px 0 16px 62px; font-size: 0.8rem; padding: 6px 14px; }
  .tl-entry-wrapper { margin-bottom: 16px; }
  .tl-dot   { width: 40px; height: 40px; font-size: 1rem; margin-right: 18px; }
  .tl-entry { padding: 16px 18px; border-radius: 0 18px 18px 0; }

  .lo-bottom-bar  { padding: 20px 28px; gap: 14px; }
  .lo-action-btn  { padding: 18px; font-size: 1.05rem; border-radius: 16px; }

  /* ─── MODALS CENTERED on Desktop ─── */
  .modal-overlay { align-items: center; }
  .modal-sheet   { border-radius: 28px; padding: 32px 36px; }
  .modal-drag-handle { display: none; }

  /* ─── DESKTOP FOOTER ─── */
  .desk-footer { display: block; background: #0f172a; margin-top: 64px; }
  .desk-footer-inner {
    max-width: 1400px; margin: 0 auto;
    padding: 52px 40px 36px;
    display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 48px;
  }
  .df-brand { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 800; color: #fff; margin-bottom: 10px; }
  .df-brand i { color: var(--primary); font-size: 1.2rem; }
  .df-tagline { margin: 0 0 8px; color: #94a3b8; font-size: 0.85rem; font-style: italic; }
  .df-desc { margin: 0; color: #64748b; font-size: 0.83rem; line-height: 1.7; }
  .df-heading { margin: 0 0 16px; color: #fff; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700; }
  .df-nav { display: flex; flex-direction: column; gap: 10px; }
  .df-nav a { color: #64748b; text-decoration: none; font-size: 0.88rem; display: flex; align-items: center; gap: 8px; transition: color .2s; }
  .df-nav a:hover { color: #fff; }
  .df-info { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
  .df-info li { color: #64748b; font-size: 0.88rem; display: flex; align-items: center; gap: 8px; }
  .df-info li i { color: var(--primary); width: 14px; }
  .df-payments { display: flex; gap: 8px; flex-wrap: wrap; }
  .df-payments span { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); color: #94a3b8; padding: 5px 12px; border-radius: 20px; font-size: 0.78rem; font-weight: 700; display: flex; align-items: center; gap: 6px; }
  .df-bottom { max-width: 1400px; margin: 0 auto; padding: 20px 40px; border-top: 1px solid rgba(255,255,255,.06); display: flex; justify-content: space-between; align-items: center; }
  .df-bottom span { color: #475569; font-size: 0.82rem; display: flex; align-items: center; gap: 6px; }
}

/* ─── TABLET (768-1023px) ─── */
@media (min-width: 768px) and (max-width: 1023px) {
  .udhar-page { padding-bottom: 100px; }
  .bento-grid { grid-template-columns: 1fr; }
  .customer-list { padding: 8px 24px 20px; }
  .customer-item { padding: 18px 22px; border-radius: 22px; }
  .search-filter-section { padding: 10px 24px; }
  .customer-list { gap: 12px; }
}

/* ================================================================
   PROFESSIONAL LEDGER LAYOUT V2
================================================================ */
:root {
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --canvas: #f4f7fb;
  --surface-soft: #f8fafc;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --card-shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.06);
}

body { background: var(--canvas); color: var(--ink); }
.desk-footer, .desktop-empty { display: none !important; }
.udhar-page { width: 100%; padding: 0 0 calc(92px + env(safe-area-inset-bottom)); }
.dashboard-panel { width: 100%; }

.mob-topbar {
  height: 64px; padding: 0 14px; background: rgba(255,255,255,.96);
  backdrop-filter: blur(18px); border-bottom: 1px solid var(--line); box-shadow: none;
}
.mob-back, .mob-action-btn {
  width: 42px; height: 42px; border-radius: 12px; color: #344054;
  border: 1px solid var(--line); background: #fff;
}
.mob-title { color: var(--ink) !important; background: none; -webkit-text-fill-color: currentColor; font-size: 1rem; font-weight: 750; }
.mob-heading { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: flex-start; gap: 9px; padding-left: 12px; }
.mob-page-title { margin: 0; display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-size: .96rem; font-weight: 800; letter-spacing: -.025em; }
.mob-page-title i { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: linear-gradient(135deg,#dbeafe,#e0e7ff); color: var(--primary); font-size: .82rem; box-shadow: inset 0 0 0 1px rgba(37,99,235,.1); }
.mob-heading-icon { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; background: linear-gradient(135deg,#eff6ff,#e0e7ff); color: var(--primary); box-shadow: inset 0 0 0 1px rgba(37,99,235,.08); }
.mob-heading-copy { min-width: 0; display: grid; grid-template-rows: auto auto; align-items: start; line-height: 1.1; }
.mob-heading-copy strong, .mob-heading-copy small { display: block; white-space: nowrap; }
.mob-heading-copy strong { color: var(--ink); font-size: .9rem; letter-spacing: -.02em; }
.mob-heading-copy small { margin-top: 3px; color: #98a2b3; font-size: .56rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }

.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; padding: 12px 14px 10px; }
.summary-card {
  grid-column: 1 / -1; min-height: 158px; padding: 16px; border: 0; border-radius: 18px;
  background: linear-gradient(135deg,#0f3f9f 0%,#2563eb 50%,#6d28d9 100%);
  box-shadow: 0 18px 38px -18px rgba(79,70,229,.8); isolation: isolate;
}
.summary-card::before {
  top: -80px; right: -45px; width: 210px; height: 210px;
  background: radial-gradient(circle,rgba(103,232,249,.38),rgba(255,255,255,.08) 42%,transparent 70%);
}
.summary-card::after { display: block; width: 150px; height: 150px; left: auto; right: 22%; bottom: -105px; background: radial-gradient(circle,rgba(251,191,36,.72),rgba(244,114,182,.28) 42%,transparent 70%); }
.summary-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.summary-icon {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 11px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.16); color: #fff;
}
.summary-state { padding: 5px 9px; border-radius: 999px; background: rgba(255,255,255,.12); color: #dbeafe; font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.summary-title { margin: 0 0 5px; color: #bfdbfe; font-size: .7rem; letter-spacing: .09em; }
.summary-amount { color: #fff; font-size: clamp(2.15rem,10vw,2.65rem); letter-spacing: -.05em; text-shadow: none; }
.summary-progress-bg { height: 4px; margin-top: 12px; background: rgba(255,255,255,.15); }
.summary-progress-fill { background: #fff !important; }
.summary-helper { margin: 7px 0 0; color: #bfdbfe; font-size: .68rem; line-height: 1.35; }

.metric-card {
  min-height: 96px; padding: 12px; background: #fff; border: 1px solid var(--line);
  border-radius: 15px; box-shadow: 0 1px 2px rgba(16,24,40,.03); display: flex; flex-direction: row; align-items: flex-start; gap: 9px;
}
.metric-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 10px; flex: 0 0 auto; font-size: .82rem; }
.metric-pending { background: linear-gradient(145deg,#fff 55%,#fff7ed); border-color: #fed7aa; }
.metric-collected { background: linear-gradient(145deg,#fff 55%,#ecfdf3); border-color: #a6f4c5; }
.metric-pending .metric-icon { background: #ffedd5; color: #c2410c; }
.metric-collected .metric-icon { background: #d1fadf; color: #067647; }
.metric-copy { min-width: 0; display: flex; flex-direction: column; }
.metric-copy > span { color: var(--muted); font-size: .58rem; font-weight: 750; text-transform: uppercase; letter-spacing: .035em; line-height: 1.3; }
.metric-copy strong { margin-top: 4px; color: var(--ink); font-size: .78rem; line-height: 1.25; white-space: normal; }
.metric-copy small { display: none; }

.ai-strip { padding: 0 14px 12px; gap: 10px; }
.ai-card { min-width: min(310px,calc(100vw - 28px)); padding: 13px 14px; border-radius: 14px; box-shadow: none; }
.ai-card-icon { width: 38px; height: 38px; border-radius: 10px; }

.customers-panel { position: relative; margin: 0 14px; overflow: hidden; background: #fff; border: 1px solid #dbe3f0; border-top: 3px solid var(--primary); border-radius: 20px; box-shadow: var(--card-shadow); }
.customers-panel-head { padding: 14px 14px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-eyebrow, .page-eyebrow { display: block; color: var(--primary); font-size: .68rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.customers-panel-head h2 { margin: 3px 0 2px; color: var(--ink); font-size: 1.05rem; letter-spacing: -.025em; }
.customers-panel-head p, .page-heading-copy p { margin: 0; color: var(--muted); font-size: .79rem; line-height: 1.45; }
.panel-add-customer { min-width: 66px; height: 40px; padding: 0 12px; border: 0; border-radius: 11px; background: var(--primary); color: #fff; font: inherit; font-size: .76rem; font-weight: 750; align-items: center; justify-content: center; gap: 6px; cursor: pointer; box-shadow: 0 6px 14px -8px rgba(37,99,235,.8); }

.search-filter-section {
  position: static; top: auto; z-index: auto; padding: 0 14px 12px; margin: 0;
  background: #fff; border-bottom: 1px solid #f2f4f7;
}
.search-container { margin-bottom: 9px; }
.search-input { height: 46px; padding: 0 14px 0 42px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 12px; font-size: .88rem; }
.search-input:focus { border-color: #84adff; box-shadow: 0 0 0 4px #eff4ff; }
.filter-sort-row { justify-content: space-between; gap: 8px; overflow: visible; }
.filter-chips { min-width: 0; gap: 4px; padding: 3px; border-radius: 11px; background: #f2f4f7; }
.filter-chip { min-height: 34px; padding: 0 12px; border-radius: 8px; background: transparent; color: #667085; font-size: .76rem; }
.filter-chip.active { background: #fff; color: #1d2939; box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.sort-select { width: 104px; min-height: 40px; padding: 0 24px 0 8px; border: 0; border-radius: 10px; background-color: transparent; font-size: .75rem; }
.sort-control { min-height: 40px; display: flex; align-items: center; padding-left: 9px; border: 1px solid var(--line); border-radius: 11px; color: #667085; background: #fff; }
.sort-control i { font-size: .75rem; }
#btn-bulk-remind { margin-top: 9px; min-height: 42px; width: 100%; border-radius: 11px; box-shadow: none; }

.customer-list { padding: 4px 0 6px; gap: 0; }
.customer-item {
  position: relative; min-height: 82px; padding: 14px 16px 14px 18px; gap: 12px; border: 0; border-bottom: 1px solid #f2f4f7;
  border-radius: 0; box-shadow: none; animation: none; background: #fff;
}
.customer-item::before { content: ''; position: absolute; top: 17px; bottom: 17px; left: 0; width: 3px; border-radius: 0 3px 3px 0; background: #d0d5dd; }
.customer-item.is-due::before { background: linear-gradient(#f59e0b,#f97316); }
.customer-item.is-settled::before { background: linear-gradient(#12b76a,#039855); }
.customer-item.is-blocked::before { background: linear-gradient(#f04438,#d92d20); }
.customer-item:last-child { border-bottom: 0; }
.customer-item:hover { transform: none; box-shadow: none; background: #f9fafb; border-color: #f2f4f7; }
.customer-item:focus-visible { outline: 3px solid #bfdbfe; outline-offset: -3px; }
.c-avatar { width: 44px; height: 44px; margin: 0; border-radius: 13px; font-size: 1rem; }
.c-name { margin-bottom: 4px; font-size: .93rem; font-weight: 750; }
.c-meta { gap: 7px; font-size: .72rem; }
.c-right { gap: 7px; }
.c-amount-box { gap: 3px; }
.c-balance-label { display: none; color: #98a2b3; font-size: .52rem; font-weight: 750; letter-spacing: .035em; text-transform: uppercase; }
.c-amount { font-size: .93rem; }
.badge { padding: 2px 6px; border-radius: 5px; font-size: .55rem; }
.quick-remind-btn { width: 34px; height: 34px; border-radius: 10px; background: #ecfdf3; color: #079455; font-size: .95rem; }
.customer-open-indicator { color: #98a2b3; font-size: .7rem; }
.overdue-badge { margin-top: 4px; font-size: .62rem; }
.empty-state { padding: 44px 20px 48px; }
.empty-state-icon { width: 52px; height: 52px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; border-radius: 16px; background: #eff4ff; color: var(--primary); font-size: 1.15rem; }
.empty-state h3 { margin: 0 0 6px; color: var(--ink); font-size: 1rem; }
.empty-state p { max-width: 300px; margin: 0 auto 18px; font-size: .82rem; }
.empty-primary-action { min-height: 42px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--primary); color: #fff; font: inherit; font-size: .82rem; font-weight: 750; cursor: pointer; }

.fab-container { bottom: 82px; right: 16px; }
.fab-btn { height: 50px; padding: 0 17px; border-radius: 14px; background: var(--primary); font-size: .82rem; box-shadow: 0 10px 22px -8px rgba(37,99,235,.65); }

.ledger-overlay { background: var(--canvas); transition-duration: .25s; }
.lo-header { min-height: 64px; padding: 10px 14px; border-color: var(--line); box-shadow: none; }
.lo-back, .lo-btn-icon { width: 40px; height: 40px; border-radius: 11px; }
.lo-header-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lo-header-copy > span { color: var(--primary); font-size: .58rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.lo-header-copy h2 { margin: 2px 0 0; color: var(--ink); font-size: .98rem; line-height: 1.15; }
.lo-scroll-content { padding-bottom: 12px; }
.lo-profile-card { margin: 14px; border-radius: 20px; box-shadow: 0 12px 30px -18px rgba(16,24,40,.35); border-color: #dbe3f0; }
.lo-profile-bg { position: relative; height: 82px; overflow: hidden; border-radius: 20px 20px 0 0; background: linear-gradient(125deg,#1e3a8a 0%,#2563eb 52%,#7c3aed 100%); }
.lo-profile-bg::before { content: 'CUSTOMER PROFILE'; position: absolute; top: 16px; left: 16px; color: rgba(255,255,255,.82); font-size: .58rem; font-weight: 800; letter-spacing: .12em; }
.lo-profile-bg::after { content: ''; position: absolute; width: 150px; height: 150px; right: -35px; top: -85px; border-radius: 50%; background: radial-gradient(circle,rgba(103,232,249,.55),rgba(244,114,182,.22) 44%,transparent 70%); }
.lo-profile-top { margin-top: -36px; padding: 12px 16px 14px; }
.lo-avatar.large { width: 64px; height: 64px; border-radius: 17px; font-size: 1.5rem; box-shadow: 0 8px 18px rgba(16,24,40,.14); }
.lo-profile-info { padding-top: 37px; }
.lo-name { font-size: 1.08rem; }
.lo-ai-badge { padding: 4px 7px; border-radius: 7px; font-size: .58rem; }
.lo-actions-row { padding: 0 16px 14px; gap: 8px; }
.lo-action-chip { min-height: 42px; padding: 0 8px; border-width: 1px; border-radius: 12px; font-size: .72rem; white-space: nowrap; }
.lo-notes-box { margin: 0 16px 14px; padding: 11px 12px !important; border-radius: 11px; background: var(--surface-soft); border: 1px solid var(--line); }
.lo-profile-stats { padding: 0 16px 14px; gap: 10px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-glass-box { min-height: 118px; padding: 13px; border-radius: 14px; gap: 8px; justify-content: space-between; }
.stat-glass-box:first-child { background: linear-gradient(145deg,#fff,#fff1f2); border-color: #fecdd3; }
.stat-glass-box:nth-child(2) { background: linear-gradient(145deg,#fff,#ecfdf3); border-color: #a6f4c5; }
#advance-stat-card { grid-column: 1 / -1; min-height: auto; flex-direction: row; align-items: center; justify-content: flex-start; background: linear-gradient(145deg,#fff,#f5f3ff); border-color: #c4b5fd; }
#advance-stat-card .stat-content { flex: 1; }
.advance-adjust-btn { min-height: 36px; padding: 0 12px; border: 1px solid #c4b5fd; border-radius: 10px; background: #fff; color: #6d28d9; font: inherit; font-size: .72rem; font-weight: 800; cursor: pointer; white-space: nowrap; }
.advance-adjust-btn:hover { background: #ede9fe; }
.advance-adjust-summary { margin-bottom: 15px; padding: 14px; border: 1px solid #bfdbfe; border-radius: 12px; background: #eff6ff; color: #334155; line-height: 1.7; }
.stat-icon { width: 32px; height: 32px; border-radius: 9px; }
.stat-content h2 { font-size: 1.15rem; }
.lo-credit-limit-box { margin: 0 16px 16px; padding: 12px !important; border-radius: 12px; background: #f8fafc; border: 1px solid #e4e7ec; }
.lo-timeline { padding: 0 14px 6px; }
.tl-date-badge { margin-left: 50px; padding: 5px 12px; box-shadow: none; background: #fff; color: #475467; }
.tl-entry-wrapper { margin-bottom: 16px; }
.tl-entry { padding: 0; overflow: hidden; box-shadow: 0 8px 24px -18px rgba(16,24,40,.45); border-radius: 0 15px 15px 0; }
.gave .tl-entry { background: linear-gradient(145deg,#fff 58%,#fff1f2); border-color: #fecdd3; border-left-color: #f43f5e; }
.got .tl-entry { background: linear-gradient(145deg,#fff 58%,#ecfdf3); border-color: #a6f4c5; border-left-color: #12b76a; }
.advance .tl-entry { background: linear-gradient(145deg,#fff 58%,#f5f3ff); border-color: #c4b5fd; border-left-color: #7c3aed; }
.advance-use .tl-entry { background: linear-gradient(145deg,#fff 58%,#eff6ff); border-color: #bfdbfe; border-left-color: #2563eb; }
.penalty .tl-entry { background: linear-gradient(145deg,#fff 58%,#fff7ed); border-color: #fed7aa; border-left-color: #f97316; }
.tl-header { margin: 0; padding: 14px 14px 10px; align-items: center; }
.tl-title { font-size: .88rem; }
.tl-amount { padding: 5px 8px; border-radius: 8px; background: rgba(255,255,255,.72); font-size: 1rem; }
.tl-note { margin: 0 14px 9px; display: flex; align-items: flex-start; gap: 7px; color: #475467; font-size: .78rem; line-height: 1.4; }
.tl-note i { margin-top: 2px; color: #98a2b3; font-size: .72rem; }
.bill-reference { margin: 0 14px 10px; background: rgba(255,255,255,.76); border: 1px solid #eaecf0; }
.tl-meta { min-height: 47px; padding: 8px 12px 8px 14px; align-items: center; border-top: 1px solid rgba(208,213,221,.65); background: rgba(255,255,255,.58); }
.tl-time { display: inline-flex; align-items: center; gap: 5px; }
.tl-balance { padding: 0; display: flex; align-items: flex-end; flex-direction: column; gap: 1px; background: transparent; }
.tl-balance small { color: #98a2b3; font-size: .55rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.tl-balance strong { color: #344054; font-size: .76rem; }
.lo-bottom-bar { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); gap: 8px; box-shadow: 0 -8px 24px rgba(16,24,40,.06); }
.lo-action-btn { min-height: 48px; padding: 0 12px; border-radius: 12px; font-size: .86rem; box-shadow: none; }
.lo-btn-gave { background: #fff; color: #b42318; border: 1px solid #fecdca; }
.lo-btn-got { background: var(--primary); }

@media (max-width: 480px) {
  .lo-bottom-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lo-action-btn { min-width: 0; padding: 0 7px; font-size: .74rem; line-height: 1.15; }
  .lo-btn-advance { flex-direction: column; gap: 3px; }
  .lo-btn-advance i { font-size: .8rem; }
}

.modal-overlay { background: rgba(16,24,40,.58); backdrop-filter: blur(4px); }
.modal-sheet { border-radius: 22px 22px 0 0; padding: 8px 18px calc(22px + env(safe-area-inset-bottom)); }
.modal-header { margin-bottom: 18px; }
.modal-header h3 { font-size: 1.08rem; }
.entry-input-group { margin-bottom: 15px; }
.entry-input { min-height: 48px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.entry-input:focus { border-color: #84adff; box-shadow: 0 0 0 4px #eff4ff; }
.btn-action { min-height: 50px; padding: 0 16px; border-radius: 12px; font-size: .92rem; }
.btn-primary { background: var(--primary); }

@media (max-width: 767px) {
  .customers-panel-head p { display: none; }
  .customers-panel-head { min-height: 68px; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .c-balance-label { display: block; }
  .overview-grid { grid-template-columns: 1.5fr 1fr 1fr; padding: 24px; }
  .summary-card { grid-column: auto; }
  .customers-panel { margin: 0 24px; }
}

@media (min-width: 1024px) {
  .c-balance-label { display: block; }
  body { padding-top: 72px; background: var(--canvas); }
  .desk-topbar {
    height: 72px; background: #0f172a; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.06);
    box-shadow: 0 4px 15px rgba(0,0,0,.1);
  }
  .desk-topbar-inner {
    max-width: 1400px; padding: 0 36px;
    justify-content: flex-start; position: relative;
  }
  .desk-brand {
    gap: 12px; color: #fff; font-size: 1.35rem;
    font-weight: 800; letter-spacing: -.02em;
  }
  .desk-brand i { color: #3b82f6; font-size: 1.5rem; }
  .desk-nav {
    position: absolute; left: 50%; transform: translateX(-50%);
    align-items: center; gap: 8px;
  }
  .desk-nav a {
    padding: 10px 18px; border-radius: 12px;
    color: #cbd5e1; font-size: .95rem; font-weight: 600;
  }
  .desk-nav a:hover { color: #fff; background: rgba(255,255,255,.1); }
  .desk-nav a.is-active { color: #60a5fa; background: rgba(59,130,246,.15); }
  .udhar-page { max-width: 1280px; padding: 32px; gap: 24px; }
  .dashboard-panel { flex: 1; }
  .desk-page-header { margin: 0 0 22px; align-items: flex-end; }
  .page-title { margin: 4px 0 5px; font-size: 2rem; font-weight: 750; letter-spacing: -.04em; }
  .page-heading-copy p { font-size: .86rem; }
  .page-header-actions { display: flex; gap: 10px; }
  .btn-refresh-desk, .header-primary-action { min-height: 44px; padding: 0 15px; border-radius: 10px; font: inherit; font-size: .82rem; font-weight: 750; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
  .btn-refresh-desk { background: #fff; color: #344054; border: 1px solid var(--line); box-shadow: none; }
  .header-primary-action { background: var(--primary); color: #fff; border: 1px solid var(--primary); }
  .overview-grid { grid-template-columns: minmax(360px,1.55fr) repeat(2,minmax(190px,.72fr)); padding: 0; gap: 14px; margin-bottom: 16px; }
  .summary-card { grid-column: auto; min-height: 196px; padding: 22px; border-radius: 18px; }
  .summary-card-head { margin-bottom: 18px; }
  .summary-amount { font-size: 2.8rem; }
  .metric-card { min-height: 196px; padding: 20px; border-radius: 18px; justify-content: space-between; }
  .metric-icon { width: 42px; height: 42px; }
  .metric-copy > span { font-size: .7rem; }
  .metric-copy strong { font-size: 1.05rem; }
  .metric-copy small { display: block; margin-top: 6px; color: #98a2b3; font-size: .72rem; }
  .ai-strip { padding: 0 0 16px; }
  .customers-panel { margin: 0; border-radius: 18px; }
  .customers-panel-head { padding: 20px 22px 14px; }
  .customers-panel-head h2 { font-size: 1.2rem; }
  .search-filter-section { padding: 0 20px 14px; display: grid; grid-template-columns: minmax(260px,1fr) auto auto; gap: 10px; }
  .search-container { max-width: none; margin: 0; }
  .filter-chip { padding: 0 14px; }
  #btn-bulk-remind { width: auto; margin: 0; padding: 0 14px; }
  .customer-list { padding: 0 8px 8px; }
  .customer-item { min-height: 76px; margin: 0; padding: 13px 14px; border-radius: 12px; border-bottom: 0; }
  .customer-item + .customer-item { margin-top: 2px; }
  .c-avatar { width: 46px; height: 46px; }
  .ledger-overlay { position: sticky; top: 100px; width: 430px; height: calc(100vh - 124px); border-radius: 18px; border: 1px solid var(--line); box-shadow: var(--card-shadow); }
  .ledger-overlay.active { animation: none; }
  .lo-back { display: flex; }
  .lo-header { padding: 10px 14px; }
  .lo-header h2 { text-align: left; font-size: 1rem; }
  .lo-profile-card { margin: 14px; border-radius: 16px; }
  .lo-profile-bg { border-radius: 16px 16px 0 0; }
  .lo-timeline { padding: 0 14px 6px; }
  .lo-bottom-bar { padding: 12px 14px; }
  .modal-sheet { border-radius: 18px; padding: 24px; }
}

/* ─── PRINT ─── */
@media print {
  body * { visibility: hidden; }
  .ledger-overlay, .ledger-overlay * { visibility: visible; }
  .ledger-overlay {
    position: absolute; left: 0; top: 0; width: 100%;
    transform: none !important;
  }
  .lo-header .lo-back,
  .lo-header .lo-btn-icon,
  .lo-bottom-bar,
  .lo-actions-row { display: none !important; }
}
