/* ============================================
   LedgerRail - Mobile-First CSS
   ============================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #1a56db;
  --primary-dark: #1e40af;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --success: #16a34a;
  --warning: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
  --radius: 8px;
  --radius-lg: 12px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--gray-900);
  background: var(--gray-100);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  background: var(--white);
}

/* ============================================
   Header
   ============================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--primary);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: var(--white);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.sync-icon {
  display: inline-block;
}

.sync-icon.spinning {
  animation: spin 1s linear infinite;
}

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

/* ============================================
   Status Bar
   ============================================ */
.status-bar {
  padding: 10px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
}

.status-bar.success {
  background: #dcfce7;
  color: #166534;
}

.status-bar.error {
  background: #fee2e2;
  color: #991b1b;
}

.status-bar.info {
  background: #dbeafe;
  color: #1e40af;
}

/* ============================================
   Main Content
   ============================================ */
main {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 70px; /* Space for bottom nav */
}

.tab-content {
  display: none;
  padding: 16px;
}

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

/* ============================================
   Dashboard
   ============================================ */
.dashboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 12px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
}

.metric-count {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

.total-outstanding {
  border-left: 4px solid var(--primary);
}

.total-overdue {
  border-left: 4px solid var(--danger);
}

.total-overdue .metric-value {
  color: var(--danger);
}

.total-collected {
  border-left: 4px solid var(--success);
}

.customer-count {
  border-left: 4px solid var(--gray-500);
}

/* ============================================
   Section Headers
   ============================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
}

/* ============================================
   Activity List
   ============================================ */
.activity-list {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}

.activity-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 12px;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.activity-icon.payment {
  background: #dcfce7;
}

.activity-icon.invoice {
  background: #dbeafe;
}

.activity-icon.customer {
  background: #fef3c7;
}

.activity-details {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-meta {
  font-size: 12px;
  color: var(--gray-500);
}

.activity-amount {
  font-weight: 600;
  color: var(--success);
}

/* ============================================
   Customer List
   ============================================ */
.customer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.customer-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.customer-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
}

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

.customer-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.customer-phone {
  font-size: 13px;
  color: var(--gray-500);
}

.customer-stats {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

.customer-actions {
  display: flex;
  gap: 4px;
}

.customer-actions button {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--gray-100);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
}

.customer-actions button:hover {
  background: var(--gray-200);
}

/* ============================================
   Invoice List
   ============================================ */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-btn {
  padding: 6px 14px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  border-radius: 20px;
  font-size: 13px;
  color: var(--gray-700);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.invoice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.invoice-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.invoice-card:hover {
  box-shadow: var(--shadow-md);
}

.invoice-card.overdue {
  border-left: 4px solid var(--danger);
}

.invoice-card.paid {
  border-left: 4px solid var(--success);
}

.invoice-card.partial {
  border-left: 4px solid var(--warning);
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.invoice-number {
  font-weight: 700;
  font-size: 15px;
}

.invoice-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

.status-unpaid {
  background: #fee2e2;
  color: #991b1b;
}

.status-partial {
  background: #fef3c7;
  color: #92400e;
}

.status-paid {
  background: #dcfce7;
  color: #166534;
}

.status-overdue {
  background: #fee2e2;
  color: #991b1b;
}

.invoice-customer {
  font-size: 14px;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.invoice-amounts {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.invoice-total {
  font-size: 18px;
  font-weight: 700;
}

.invoice-balance {
  font-size: 13px;
  color: var(--gray-500);
}

.invoice-balance.has-balance {
  color: var(--danger);
  font-weight: 500;
}

.invoice-due {
  font-size: 12px;
  color: var(--gray-500);
}

.invoice-due.overdue {
  color: var(--danger);
  font-weight: 500;
}

.invoice-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
}

.invoice-actions button {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-pay {
  background: var(--success);
  color: var(--white);
}

.btn-share {
  background: #25D366;
  color: var(--white);
}

/* ============================================
   Bottom Navigation
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 100;
  max-width: 600px;
  margin: 0 auto;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--gray-500);
  transition: color 0.2s;
}

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

.nav-icon {
  font-size: 20px;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
}

/* ============================================
   Settings Page
   ============================================ */
.settings-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setting-group {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
}

.setting-group h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gray-700);
}

.setting-desc {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.merchant-id {
  font-size: 13px;
  color: var(--gray-500);
}

.merchant-id code {
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.version {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 8px;
}

/* ============================================
   Forms
   ============================================ */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--gray-700);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 16px;
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

/* ============================================
   Buttons
   ============================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: var(--gray-200);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  background: var(--danger);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

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

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

/* ============================================
   Modals
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  background: var(--white);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gray-100);
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
}

.modal form,
.modal > p,
.modal > div:not(.modal-header) {
  padding: 16px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  padding-top: 8px;
}

.modal-actions button {
  flex: 1;
}

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

.modal-lg {
  max-width: 600px;
}

.payment-summary {
  background: var(--gray-50);
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.payment-summary p {
  margin: 4px 0;
  font-size: 14px;
}

/* ============================================
   Invoice Detail
   ============================================ */
.invoice-detail {
  padding: 16px;
}

.invoice-detail-header {
  text-align: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 16px;
}

.invoice-detail-number {
  font-size: 24px;
  font-weight: 700;
}

.invoice-detail-status {
  margin-top: 8px;
}

.invoice-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}

.invoice-detail-label {
  color: var(--gray-500);
  font-size: 14px;
}

.invoice-detail-value {
  font-weight: 500;
  font-size: 14px;
}

.invoice-detail-total {
  font-size: 20px;
  font-weight: 700;
  text-align: right;
  padding: 16px 0;
  border-bottom: 2px solid var(--gray-900);
}

.payment-history {
  margin-top: 16px;
}

.payment-history h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.payment-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--gray-100);
}

.payment-item-amount {
  color: var(--success);
  font-weight: 500;
}

.invoice-detail-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.invoice-detail-actions button {
  flex: 1;
}

/* ============================================
   Receipt View
   ============================================ */
.receipt-view {
  position: fixed;
  inset: 0;
  background: var(--white);
  z-index: 200;
  overflow-y: auto;
}

.receipt {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px;
}

.receipt-header {
  text-align: center;
  padding-bottom: 20px;
  border-bottom: 2px dashed var(--gray-300);
  margin-bottom: 20px;
}

.receipt-merchant {
  font-size: 20px;
  font-weight: 700;
}

.receipt-invoice-num {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 4px;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
}

.receipt-total {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  padding: 20px 0;
  border-top: 2px dashed var(--gray-300);
  border-bottom: 2px dashed var(--gray-300);
  margin: 20px 0;
}

.receipt-payments h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.receipt-back {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 201;
}

/* ============================================
   Public Receipt (Conversion Surface)
   ============================================ */
.receipt-public {
  padding: 0;
  background: var(--gray-50);
  min-height: 100vh;
}

.receipt-authority-header {
  background: var(--white);
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid var(--gray-200);
}

.receipt-verified-badge {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

.receipt-verified-badge.verified {
  background: #dcfce7;
  color: #166534;
}

.receipt-verified-badge.unverified {
  background: #fee2e2;
  color: #991b1b;
}

.receipt-issuer {
  background: var(--white);
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid var(--gray-200);
}

.receipt-issuer-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
}

.receipt-issuer-age {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

.receipt-meta {
  background: var(--white);
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}

.receipt-meta .receipt-row {
  padding: 6px 0;
  font-size: 14px;
}

.receipt-id-value {
  font-family: monospace;
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.receipt-facts {
  background: var(--white);
  padding: 20px;
  margin: 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.receipt-fact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}

.receipt-fact-row:last-child {
  border-bottom: none;
}

.receipt-fact-label {
  font-size: 14px;
  color: var(--gray-500);
}

.receipt-fact-value {
  font-size: 18px;
  font-weight: 700;
}

.receipt-payment-history {
  background: var(--white);
  margin: 0 16px 16px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.receipt-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.receipt-payment-item {
  font-size: 13px;
  color: var(--gray-700);
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}

.receipt-payment-item:last-child {
  border-bottom: none;
}

.receipt-paid-badge {
  background: #dcfce7;
  color: #166534;
  text-align: center;
  padding: 16px;
  margin: 0 16px 16px;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 700;
}

.receipt-trust-proof {
  background: var(--white);
  margin: 0 16px 16px;
  padding: 20px;
  border-radius: var(--radius-lg);
  text-align: center;
  border: 1px solid var(--gray-200);
}

.receipt-trust-proof p {
  font-size: 13px;
  color: var(--gray-700);
  margin: 0;
}

.receipt-trust-detail {
  font-size: 11px !important;
  color: var(--gray-500) !important;
  margin-top: 4px !important;
}

.receipt-conversion {
  background: linear-gradient(135deg, #1a56db 0%, #1e40af 100%);
  margin: 0 16px 16px;
  padding: 24px 20px;
  border-radius: var(--radius-lg);
  text-align: center;
}

.receipt-conversion-copy {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
  margin: 0 0 16px;
  line-height: 1.5;
}

.receipt-cta {
  display: inline-block;
  background: var(--white);
  color: var(--primary);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
}

.receipt-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.receipt-social-proof {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--gray-500);
}

/* ============================================
   Debtors View
   ============================================ */
.debtors-summary {
  margin-bottom: 16px;
}

.debtors-summary-card {
  background: linear-gradient(135deg, var(--danger) 0%, #991b1b 100%);
  color: var(--white);
  padding: 20px;
  border-radius: var(--radius-lg);
  text-align: center;
}

.debtors-summary-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

.debtors-summary-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  margin: 4px 0;
}

.debtors-summary-count {
  font-size: 13px;
  opacity: 0.8;
}

.debtors-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debtor-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.debtor-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--gray-300);
}

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

.debtor-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.debtor-phone {
  font-size: 13px;
  color: var(--gray-500);
}

.debtor-meta {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

.debtor-amount-section {
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}

.debtor-amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--danger);
}

.debtor-bucket {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
  text-transform: uppercase;
}

.debtor-bucket-overdue {
  background: #fee2e2;
  color: #991b1b;
}

.debtor-bucket-warning {
  background: #fef3c7;
  color: #92400e;
}

.debtor-bucket-fresh {
  background: #dcfce7;
  color: #166534;
}

/* Debtor Detail Modal */
.debtor-detail {
  padding: 16px;
}

.debtor-detail-header {
  text-align: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 16px;
}

.debtor-detail-phone {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.debtor-detail-total {
  background: #fee2e2;
  padding: 16px;
  border-radius: var(--radius);
}

.debtor-detail-label {
  display: block;
  font-size: 12px;
  color: #991b1b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.debtor-detail-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--danger);
  margin-top: 4px;
}

.debtor-detail-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.debtor-detail-actions button {
  flex: 1;
}

.debtor-invoices-section h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gray-700);
}

.debtor-invoices-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debtor-invoice-item {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px;
}

.debtor-invoice-item.overdue {
  border-left: 3px solid var(--danger);
}

.debtor-invoice-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.debtor-invoice-number {
  font-weight: 600;
  font-size: 14px;
}

.debtor-invoice-date {
  font-size: 12px;
  color: var(--gray-500);
}

.debtor-invoice-amounts {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 10px;
}

.debtor-invoice-balance {
  color: var(--danger);
  font-weight: 500;
}

.debtor-invoice-actions {
  display: flex;
  gap: 8px;
}

.debtor-invoice-actions button {
  padding: 6px 12px;
  font-size: 12px;
}

/* ============================================
   Timeline View
   ============================================ */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-date-group {
  margin-bottom: 4px;
}

.timeline-date-header {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  padding: 12px 0 8px;
  position: sticky;
  top: 0;
  background: var(--gray-100);
  z-index: 1;
}

.timeline-event {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.timeline-event.clickable {
  cursor: pointer;
}

.timeline-event.clickable:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--gray-300);
}

.timeline-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: var(--gray-100);
}

.timeline-event.invoice_created .timeline-icon {
  background: #dbeafe;
}

.timeline-event.payment_received .timeline-icon {
  background: #dcfce7;
}

.timeline-event.invoice_paid .timeline-icon {
  background: #dcfce7;
}

.timeline-event.became_overdue .timeline-icon {
  background: #fee2e2;
}

.timeline-event.reminder_sent .timeline-icon {
  background: #e0f2fe;
}

.timeline-content {
  flex: 1;
  min-width: 0;
}

.timeline-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-subtitle {
  font-size: 12px;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-amount {
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  color: var(--gray-700);
}

.timeline-amount.positive {
  color: var(--success);
}

.timeline-time {
  font-size: 11px;
  color: var(--gray-400);
  flex-shrink: 0;
  min-width: 50px;
  text-align: right;
}

/* ============================================
   Expense Timeline Event
   ============================================ */
.timeline-event.expense_recorded .timeline-icon {
  background: #fef3c7;
}

.timeline-amount.expense {
  color: var(--danger);
}

/* ============================================
   Spend Summary Card
   ============================================ */
.spend-summary {
  margin-bottom: 16px;
}

.spend-card {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
}

.spend-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.spend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.spend-label {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.spend-expand {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
}

.spend-metrics {
  display: flex;
  gap: 8px;
}

.spend-metric {
  flex: 1;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  padding: 10px 12px;
  text-align: center;
}

.spend-metric-label {
  display: block;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.8);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.spend-metric-value {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
}

/* ============================================
   Expenses List Modal
   ============================================ */
.expenses-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 0 16px;
}

.expenses-list {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.expense-item {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.expense-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fef3c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.expense-item-details {
  flex: 1;
  min-width: 0;
}

.expense-item-category {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-item-note {
  font-size: 12px;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-item-date {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}

.expense-item-amount {
  font-size: 16px;
  font-weight: 700;
  color: var(--danger);
  flex-shrink: 0;
}

.expense-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.expense-item-actions button {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gray-100);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.expense-item-actions button:hover {
  background: var(--gray-200);
}

/* ============================================
   Nudge System
   ============================================ */
.nudge-banner {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nudge-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.nudge-message {
  flex: 1;
  font-size: 13px;
  color: #92400e;
  min-width: 150px;
}

.nudge-action-btn {
  padding: 6px 12px;
  background: #f59e0b;
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.nudge-action-btn:hover {
  background: #d97706;
}

.debtor-nudge {
  font-size: 12px;
  color: #92400e;
  background: #fef3c7;
  padding: 4px 8px;
  border-radius: 4px;
  margin-top: 6px;
  display: inline-block;
}

/* ============================================
   Weekly Summary Card
   ============================================ */
.weekly-summary {
  margin-bottom: 16px;
}

.weekly-card {
  background: linear-gradient(135deg, #1a56db 0%, #1e40af 100%);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
}

.weekly-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.weekly-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.weekly-label {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.weekly-expand {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
}

.weekly-metrics {
  display: flex;
  gap: 8px;
}

.weekly-metric {
  flex: 1;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  padding: 10px 8px;
  text-align: center;
}

.weekly-metric-label {
  display: block;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.8);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.weekly-metric-value {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--white);
}

.weekly-metric-value.in {
  color: #86efac;
}

.weekly-metric-value.out {
  color: #fca5a5;
}

.weekly-metric-value.positive {
  color: #86efac;
}

.weekly-metric-value.negative {
  color: #fca5a5;
}

/* ============================================
   Weekly Summary Modal
   ============================================ */
.weekly-summary-detail {
  padding: 16px;
}

.weekly-summary-main {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-200);
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row.summary-net {
  border-top: 2px solid var(--gray-300);
  margin-top: 8px;
  padding-top: 16px;
  font-weight: 700;
}

.summary-label {
  font-size: 14px;
  color: var(--gray-700);
}

.summary-value {
  font-size: 16px;
  font-weight: 600;
}

.summary-value.in {
  color: var(--success);
}

.summary-value.out {
  color: var(--danger);
}

.summary-value.positive {
  color: var(--success);
}

.summary-value.negative {
  color: var(--danger);
}

.summary-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.stat-item {
  flex: 1;
  text-align: center;
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

.summary-section {
  margin-bottom: 20px;
}

.summary-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 12px;
}

.summary-list {
  background: var(--gray-50);
  border-radius: var(--radius);
  overflow: hidden;
}

.summary-list-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
}

.summary-list-item:last-child {
  border-bottom: none;
}

.summary-list-name {
  font-size: 14px;
  color: var(--gray-700);
}

.summary-list-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
}

/* ============================================
   Empty States
   ============================================ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
  font-size: 14px;
}

/* ============================================
   Utilities
   ============================================ */
.hidden {
  display: none !important;
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

/* ============================================
   Desktop Adjustments
   ============================================ */
@media (min-width: 600px) {
  .modal {
    border-radius: var(--radius-lg);
    align-self: center;
  }

  .modal-overlay {
    align-items: center;
  }
}

/* ============================================
   Debt Summary View
   ============================================ */
.debt-summary-view {
  max-width: 100%;
}

.debt-summary-customer {
  text-align: center;
  padding: 12px 16px;
  background: var(--gray-50);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.debt-summary-customer-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-right: 4px;
}

.debt-summary-customer-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
}

.debt-summary-customer-phone {
  font-size: 14px;
  color: var(--gray-500);
  margin-left: 4px;
}

.debt-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.debt-summary-card {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.debt-summary-card.total {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fecaca;
}

.debt-summary-card.count {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #bfdbfe;
}

.debt-summary-card.oldest {
  background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
  border: 1px solid #fde68a;
}

.debt-summary-card-label {
  display: block;
  font-size: 12px;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.debt-summary-card-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
}

.debt-summary-card.total .debt-summary-card-value {
  color: #dc2626;
}

.debt-summary-invoices {
  margin-top: 20px;
}

.debt-summary-invoices-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
}

.debt-summary-invoice-item {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--gray-200);
}

.debt-summary-invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.debt-summary-invoice-number {
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-800);
}

.debt-summary-invoice-date {
  font-size: 12px;
  color: var(--gray-500);
}

.debt-summary-invoice-desc {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.debt-summary-invoice-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--gray-600);
}

.debt-summary-invoice-balance {
  font-weight: 600;
  color: #dc2626;
}

.debt-summary-invoice-receipt-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--primary);
  text-decoration: none;
}

.debt-summary-invoice-receipt-link:hover {
  text-decoration: underline;
}

/* ============================================
   Products Management
   ============================================ */
.products-header {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
}

.products-list {
  padding: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

.product-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
  margin-bottom: 10px;
  border: 1px solid var(--gray-200);
}

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

.product-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--gray-900);
  margin-bottom: 2px;
}

.product-category {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 4px;
}

.product-price {
  font-size: 14px;
  font-weight: 500;
  color: var(--primary);
}

.product-stock-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.product-stock {
  font-size: 13px;
  color: var(--gray-600);
}

.product-stock.low-stock {
  color: var(--warning);
}

.product-stock.negative-stock {
  color: var(--danger);
}

.stock-warning-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  background: #fef3c7;
  color: #92400e;
  margin-left: 6px;
}

.stock-warning-badge.negative {
  background: #fee2e2;
  color: #991b1b;
}

.product-actions {
  display: flex;
  gap: 6px;
}

.product-actions button {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  background: var(--white);
  cursor: pointer;
}

.product-actions button:hover {
  background: var(--gray-100);
}

.product-actions .btn-danger-text {
  color: var(--danger);
  border-color: var(--danger);
}

.product-actions .btn-danger-text:hover {
  background: #fee2e2;
}

/* ============================================
   Stock Adjustment Modal
   ============================================ */
.stock-adjust-info {
  background: var(--gray-50);
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.stock-adjust-info p {
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--gray-700);
}

.stock-adjust-info p:last-child {
  margin-bottom: 0;
}

.stock-adjust-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stock-adjust-controls input {
  width: 80px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  padding: 8px;
}

.stock-btn {
  min-width: 44px;
  padding: 8px 12px;
  font-size: 16px;
  font-weight: 600;
}

.stock-adjust-preview {
  text-align: center;
  padding: 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 15px;
}

.stock-adjust-preview strong {
  font-size: 20px;
  color: var(--primary);
}

.stock-warning {
  display: block;
  margin-top: 8px;
  color: var(--warning);
  font-size: 13px;
  font-weight: 500;
}

.stock-warning.hidden {
  display: none;
}
