/* ===================================================
   HisabPlus - Professional Responsive Accounting Design System
   Optimized for Mobile, Tablet, and Desktop (100% Responsive)
   =================================================== */

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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-glow: rgba(37, 99, 235, 0.18);

  --emerald: #059669;
  --emerald-dark: #047857;
  --emerald-light: #ecfdf5;
  --emerald-glow: rgba(5, 150, 105, 0.18);

  --crimson: #e11d48;
  --crimson-dark: #be123c;
  --crimson-light: #fff1f2;
  --crimson-glow: rgba(225, 29, 72, 0.18);

  --amber: #d97706;
  --amber-light: #fffbeb;

  --bg-app: #0f172a;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-white: #ffffff;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 10px -2px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 20px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-float: 0 20px 30px -10px rgba(15, 23, 42, 0.25);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="dark"] {
  --bg-app: #070b14;
  --bg-surface: #111a2e;
  --bg-subtle: #0a1120;
  --bg-card: #162238;
  --border-color: #1f304d;
  --border-light: #16243b;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;

  --primary-light: rgba(37, 99, 235, 0.22);
  --emerald-light: rgba(5, 150, 105, 0.22);
  --crimson-light: rgba(225, 29, 72, 0.22);
  --amber-light: rgba(217, 119, 6, 0.22);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.6);
  --shadow-float: 0 20px 35px rgba(0, 0, 0, 0.7);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  background: #090d16;
  color: var(--text-main);
  overflow-x: hidden;
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
  background-image: 
    radial-gradient(at 15% 15%, rgba(37, 99, 235, 0.2) 0px, transparent 50%),
    radial-gradient(at 85% 85%, rgba(5, 150, 105, 0.18) 0px, transparent 50%);
  background-attachment: fixed;
}

/* ===================================================
   RESPONSIVE VIEWPORT SHELL & CONTAINER
   =================================================== */
.app-viewport-wrapper {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  overflow: hidden;
}

/* The Main App Canvas (Fixed Frame, Only Middle Scrolls) */
.device-frame {
  width: 100%;
  max-width: 920px;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  margin: 0 auto;
  overflow: hidden;
}

/* Desktop & Laptop Screen Enhancements */
@media (min-width: 769px) {
  .app-viewport-wrapper {
    padding: 20px 16px 28px 16px;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  .device-frame {
    height: calc(100vh - 48px);
    max-height: calc(100vh - 48px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    overflow: hidden;
  }
}

/* Mobile Devices (Under 768px): 100% Fullscreen Mobile App */
@media (max-width: 768px) {
  .app-viewport-wrapper {
    padding: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden !important;
  }
  .device-frame {
    max-width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    overflow: hidden !important;
  }
}

/* Top App Header */
.app-header {
  background: var(--bg-surface);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 20;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-logo-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
  flex-shrink: 0;
  overflow: hidden;
}

.app-brand-info {
  min-width: 0;
}

.app-brand-info h1 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.app-brand-info .app-role-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.role-tag-admin {
  background: #dbeafe;
  color: #1d4ed8;
}

.role-tag-superadmin {
  background: #fdf2f8;
  color: #db2777;
  border: 1px solid #fbcfe8;
}

.role-tag-customer {
  background: #fef3c7;
  color: #b45309;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.user-avatar-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.18s ease;
}

.user-avatar-badge:hover {
  transform: scale(1.05);
}

.profile-avatar-preview {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #2563eb;
  background: #f1f5f9;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #2563eb;
  font-weight: 800;
  overflow: hidden;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--text-muted);
}

/* Main Content Area (Only This Slides / Scrolls - "बीचको मात्रै स्लाइड हुनु पर्यो") */
.app-content {
  flex: 1 1 0%;
  height: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-subtle);
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
.app-content::-webkit-scrollbar {
  width: 5px;
}
.app-content::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Tab Screens */
.tab-pane {
  display: none;
  animation: fadeIn 0.2s ease-out;
}

.tab-pane.active {
  display: block;
}

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

/* ===================================================
   HERO BALANCE DASHBOARD CARD
   =================================================== */
.hero-balance-card {
  background: linear-gradient(145deg, #0f172a, #1e293b);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  color: white;
  box-shadow: 0 12px 30px -6px rgba(15, 23, 42, 0.4);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-balance-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.3), transparent 70%);
  pointer-events: none;
}

.hero-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-meta-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #94a3b8;
}

.hero-status-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hero-status-pill.positive {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.hero-status-pill.negative {
  background: rgba(244, 63, 94, 0.2);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.hero-status-pill.settled {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.hero-badge-live {
  font-size: 10px;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
}

.hero-main-balance {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.hero-net-amount {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-family: var(--font-sans);
  color: #ffffff;
  line-height: 1.1;
  white-space: nowrap;
  word-break: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-net-amount.positive {
  color: #34d399;
  text-shadow: 0 0 20px rgba(52, 211, 153, 0.25);
}

.hero-net-amount.negative {
  color: #f87171;
  text-shadow: 0 0 20px rgba(248, 113, 113, 0.25);
}

.hero-customer-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hero-tag-item {
  font-size: 11px;
  font-weight: 700;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Twin Stat Grid (You Will Get / You Will Pay) */
.twin-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.twin-stat-item {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
}

.twin-stat-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.twin-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.dot-green { background: #34d399; box-shadow: 0 0 6px #34d399; }
.dot-red { background: #f87171; box-shadow: 0 0 6px #f87171; }

.twin-stat-label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
}

.twin-stat-val {
  font-size: 17px;
  font-weight: 800;
  margin-top: 4px;
  white-space: nowrap;
  word-break: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

.twin-stat-sub {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 2px;
}

.val-green {
  color: #34d399;
}

.val-red {
  color: #f87171;
}

/* Lifetime Investment vs Recovery Strip */
.hero-metrics-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  flex-wrap: wrap;
  gap: 8px;
}

.strip-stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.strip-stat-label {
  color: #94a3b8;
  font-weight: 600;
}

.strip-stat-val {
  font-weight: 800;
  color: #f1f5f9;
  white-space: nowrap;
}

.strip-stat-val.val-emerald {
  color: #34d399;
}

.strip-divider {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.15);
}

/* Today's Activity Banner */
.hero-today-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.15), rgba(5, 150, 105, 0.15));
  border-radius: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.today-banner-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.today-banner-info {
  flex: 1;
  min-width: 0;
}

.today-banner-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #93c5fd;
}

.today-banner-desc {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 1px;
  line-height: 1.3;
}

.today-banner-desc strong {
  color: #ffffff;
}

/* Quick Action Buttons */
.quick-actions-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-quick-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-md);
}

.btn-quick-action:active {
  transform: scale(0.97);
}

.btn-credit-give {
  background: linear-gradient(135deg, #e11d48, #be123c);
  color: #ffffff;
}
.btn-credit-give:hover {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  box-shadow: 0 6px 16px var(--crimson-glow);
}

.btn-payment-get {
  background: linear-gradient(135deg, #059669, #047857);
  color: #ffffff;
}
.btn-payment-get:hover {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 6px 16px var(--emerald-glow);
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 2px;
}

.section-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-link {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}

/* Search and Filter Box */
.search-filter-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-surface);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.search-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 44px;
  padding: 8px 12px 8px 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.filter-chips-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.filter-chips-row::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  user-select: none;
}

.filter-chip.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Customer Cards */
.customer-list, .transaction-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.customer-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.customer-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.customer-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.avatar-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}

.customer-meta {
  min-width: 0;
  flex: 1;
}

.customer-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.customer-subtext {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.customer-balance-block {
  text-align: right;
  flex-shrink: 0;
}

.customer-balance-amount {
  font-size: 15px;
  font-weight: 800;
  font-family: var(--font-sans);
}

.customer-balance-amount.receivable {
  color: var(--emerald);
}

.customer-balance-amount.payable {
  color: var(--crimson);
}

.customer-balance-amount.settled {
  color: var(--text-light);
}

.customer-balance-status {
  font-size: 10px;
  font-weight: 700;
  margin-top: 2px;
  text-transform: uppercase;
}

.customer-balance-status.receivable {
  color: var(--emerald);
}
.customer-balance-status.payable {
  color: var(--crimson);
}
.customer-balance-status.settled {
  color: var(--text-muted);
}

/* Transaction List Item */
.tx-item-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tx-item-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.tx-item-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.icon-credit {
  background: var(--crimson-light);
  color: var(--crimson);
}

.icon-payment {
  background: var(--emerald-light);
  color: var(--emerald);
}

.tx-item-info {
  flex: 1;
  min-width: 0;
}

.tx-item-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-item-reason {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.tx-item-project-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: #f1f5f9;
  color: #475569;
  padding: 2px 7px;
  border-radius: 6px;
  margin-top: 3px;
}

.tx-item-amount-block {
  text-align: right;
  flex-shrink: 0;
}

.tx-item-amount {
  font-size: 15px;
  font-weight: 800;
}

.tx-item-amount.credit {
  color: var(--crimson);
}

.tx-item-amount.payment {
  color: var(--emerald);
}

.tx-item-date {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 10px;
  opacity: 0.8;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 280px;
  margin: 0 auto;
}

/* ===================================================
   BOTTOM NAVIGATION BAR (Strictly Fixed at Bottom)
   =================================================== */
.bottom-nav {
  height: 64px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 6px;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.06);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  flex: 1;
  height: 100%;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
}

/* ===================================================
   TRULY RESPONSIVE MODALS (CENTERED ON DESKTOP, BOTTOM SHEET ON MOBILE)
   =================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: overlayFadeIn 0.2s ease-out forwards;
}

.modal-overlay.active {
  display: flex;
}

/* Specific Modal Stacking Hierarchy - Guarantees transaction modals open in front immediately */
#customerDetailModal { z-index: 10000 !important; }
#statementModal { z-index: 10020 !important; }
#newCustomerModal { z-index: 10040 !important; }
#transactionModal { z-index: 10060 !important; }
#triActionModal { z-index: 10080 !important; }
#deleteCustomerPinModal { z-index: 10100 !important; }
#setPinModal, #resetPinModal { z-index: 10110 !important; }
#superStatementModal { z-index: 10020 !important; }

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

/* Desktop & Tablet: Centered Modal Dialog */
@media (min-width: 640px) {
  .modal-overlay {
    align-items: center !important;
    justify-content: center !important;
    padding: 24px 16px !important;
  }
  .bottom-sheet {
    width: 100%;
    max-width: 580px;
    max-height: 88vh;
    max-height: 88dvh;
    background: var(--bg-surface);
    border-radius: 20px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.15) !important;
    display: flex;
    flex-direction: column;
    margin: auto;
    overflow: hidden;
    animation: modalCenterPop 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
  }
  .sheet-handle-bar {
    display: none !important;
  }
}

@keyframes modalCenterPop {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Mobile (Under 640px): Bottom Sheet */
@media (max-width: 639px) {
  .modal-overlay {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }
  .bottom-sheet {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    background: var(--bg-surface);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: var(--shadow-float);
    display: flex;
    flex-direction: column;
    margin: 0;
    overflow: hidden;
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }
  .sheet-handle-bar {
    display: block;
    width: 44px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 10px auto 4px auto;
    flex-shrink: 0;
  }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  background: var(--bg-surface);
}

.sheet-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overscroll-behavior: contain;
}

.sheet-footer {
  padding: 14px 20px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-color);
  background: #ffffff;
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

/* Forms & Input Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  height: 44px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea.form-control {
  height: 68px;
  resize: vertical;
}

/* Amount Input with Fixed RM Badge */
.amount-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.amount-prefix {
  position: absolute;
  left: 14px;
  font-size: 18px;
  font-weight: 800;
  color: #2563eb;
  pointer-events: none;
}

.form-control.amount-field {
  padding-left: 54px;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
  height: 52px;
}

/* Mode selector 2x2 Grid */
.mode-selector-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.mode-pill {
  padding: 10px;
  text-align: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.mode-pill.active {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #3b82f6;
}

/* Specific Action Buttons */
.btn-danger-action {
  background: linear-gradient(135deg, #e11d48, #be123c);
  color: #ffffff !important;
  border: none;
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.25);
}
.btn-danger-action:hover {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #ffffff !important;
}

.btn-success-action {
  background: linear-gradient(135deg, #059669, #047857);
  color: #ffffff !important;
  border: none;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.25);
}
.btn-success-action:hover {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff !important;
}

/* Chips Row in Forms */
.tx-chips-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 2px 0;
}

/* Super Admin Settings Responsive Grid */
.admin-settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 14px;
}

@media (min-width: 680px) {
  .admin-settings-grid {
    grid-template-columns: 1fr 1fr;
  }
  .admin-grid-full {
    grid-column: 1 / -1;
  }
}

/* Swipe Hint for mobile tables */
.swipe-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #64748b;
  margin-bottom: 6px;
}

/* Buttons */
.btn {
  height: 46px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.btn-whatsapp {
  background: #25d366;
  color: #ffffff;
  font-weight: 800;
}

.btn-whatsapp:hover {
  background: #1eb956;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
}

.btn-block {
  width: 100%;
}

/* Tri-Action Success Card */
.tri-action-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid #cbd5e1;
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tri-action-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
}

.success-check-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #10b981;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.wa-preview-box {
  background: #e5ddd5;
  border-radius: 10px;
  padding: 12px;
}

.wa-bubble {
  background: #ffffff;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
  color: #111827;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 360px;
}

.toast-msg {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastPop 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastPop {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Customer Portal View Header */
.customer-portal-hero {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
}

/* Printable Card Base */
.printable-receipt-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-sans);
}

@media (min-width: 640px) {
  .printable-receipt-card {
    padding: 22px;
  }
}

.printable-statement-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  padding: 16px;
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-sans);
}

@media (min-width: 640px) {
  .printable-statement-card {
    padding: 24px;
  }
}

/* Responsive Table Wrapper for Statement & Receipts */
.statement-table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
}

/* Print Styles */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-viewport-wrapper, .bottom-nav, .app-header, .sheet-footer, .btn, .sheet-handle-bar, .modal-overlay:not(.active), #triBalanceBanner, #btnTabVoucher, #btnTabWhatsApp, .wa-preview-box {
    display: none !important;
  }
  .modal-overlay.active {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    display: block !important;
  }
  .bottom-sheet {
    max-width: 100% !important;
    max-height: none !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    animation: none !important;
    margin: 0 !important;
  }
  .sheet-header, .sheet-footer {
    display: none !important;
  }
  .sheet-body {
    padding: 0 !important;
    overflow: visible !important;
  }
  .printable-receipt-card, .printable-statement-card {
    display: block !important;
    width: 100% !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
}

/* ================= SUPER ADMIN & RECOVERY HUB STYLES ================= */
.super-top-nav {
  display: flex;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  padding: 0 12px;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.super-nav-tab {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.super-nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.recovery-card {
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.2s;
}

.recovery-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.recovery-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.recovery-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.pin-display-wrap {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 18px 0;
}

.pin-input-large {
  letter-spacing: 14px;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  height: 52px;
  border: 2px solid #94a3b8;
  border-radius: 12px;
}

.pin-input-large:focus {
  border-color: var(--primary);
}

/* ===================================================
   DARK MODE COMPONENT REFINEMENTS
   =================================================== */
[data-theme="dark"] body {
  background: #070b14 !important;
  color: #f1f5f9;
}

[data-theme="dark"] .device-frame {
  background: var(--bg-surface);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .app-header {
  background: var(--bg-surface);
  border-bottom-color: var(--border-color);
}

[data-theme="dark"] .bottom-nav {
  background: var(--bg-surface);
  border-top-color: var(--border-color);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .sheet-header,
[data-theme="dark"] .sheet-footer {
  background: var(--bg-surface);
  border-color: var(--border-color);
}

[data-theme="dark"] .form-control {
  background: var(--bg-card);
  color: #f1f5f9;
  border-color: var(--border-color);
}

[data-theme="dark"] .form-control:focus {
  background: var(--bg-surface);
}

[data-theme="dark"] .tri-action-card,
[data-theme="dark"] .recovery-card {
  background: var(--bg-card);
  border-color: var(--border-color);
}

[data-theme="dark"] .printable-receipt-card,
[data-theme="dark"] .printable-statement-card {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}

[data-theme="dark"] .statement-table-responsive {
  background: var(--bg-card);
  border-color: var(--border-color);
}

[data-theme="dark"] .statement-table-responsive th {
  background: var(--bg-surface) !important;
  color: #94a3b8 !important;
}

[data-theme="dark"] .statement-table-responsive td {
  border-bottom-color: var(--border-color) !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] .wa-bubble {
  background: #1e293b;
  color: #f8fafc;
}

[data-theme="dark"] .wa-preview-box {
  background: #0b1329;
}

[data-theme="dark"] .tx-item-project-tag {
  background: #1e293b;
  color: #94a3b8;
}

[data-theme="dark"] .btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: #cbd5e1;
}

[data-theme="dark"] .btn-secondary:hover {
  background: #1e293b;
  color: #ffffff;
}

/* ===================================================
   SPLASH SCREEN & ONBOARDING WALKTHROUGH
   =================================================== */
#appSplashScreen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #090d16 0%, #0f172a 50%, #1e1b4b 100%);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#appSplashScreen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-logo-box {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  background: linear-gradient(135deg, #2563eb, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 900;
  box-shadow: 0 12px 35px rgba(37, 99, 235, 0.45);
  margin-bottom: 20px;
  animation: splashPulse 2s infinite ease-in-out;
}

@keyframes splashPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 12px 35px rgba(37, 99, 235, 0.45); }
  50% { transform: scale(1.05); box-shadow: 0 16px 42px rgba(5, 150, 105, 0.55); }
}

.splash-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.splash-tagline {
  font-size: 13px;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.splash-spinner {
  margin-top: 36px;
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Onboarding Modal & Carousel */
#appOnboardingModal {
  z-index: 999990 !important;
}

.onboarding-card {
  max-width: 480px !important;
  text-align: center;
  padding: 28px 24px !important;
  border-radius: 24px !important;
}

.onboarding-slides-container {
  position: relative;
  overflow: hidden;
  min-height: 260px;
}

.onboarding-slide {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: fadeIn 0.3s ease-out;
}

.onboarding-slide.active {
  display: flex;
}

.onboarding-icon-circle {
  width: 80px;
  height: 80px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  margin-bottom: 18px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.onboarding-slide h3 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 10px;
}

.onboarding-slide p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 360px;
}

.onboarding-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 20px 0 18px 0;
}

.onboarding-dot {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--border-color);
  transition: all 0.3s ease;
  cursor: pointer;
}

.onboarding-dot.active {
  width: 24px;
  background: var(--primary);
}

.onboarding-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

/* ===================================================
   SETTINGS & PREFERENCES ROW / CARDS
   =================================================== */
.settings-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.settings-option-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-option-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.settings-option-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
}

.settings-option-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.toggle-pills {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}

.toggle-pill-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s ease;
}

.toggle-pill-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}


