/* Fix for native date input alignment */
input[type="date"].form-control {
  line-height: 1.6;
}

/* CUSTOM DATEPICKER CSS (Lines 7-100) REMOVED */

:root {
  --primary: #4a55a2;
  --secondary: #6d28d9;
  --danger: #e53e3e;
  --success: #38a169;
  --warning: #dd6b20;
  --text-dark: #1e293b;
  --text-gray: #64748b;
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-radius: 0.75rem;
  --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05),
    0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --primary-t-08: rgba(74, 85, 162, 0.08);
  --success-t-15: rgba(56, 161, 105, 0.15);
  --danger-t-10: rgba(229, 62, 62, 0.1);
  --warning-t-15: rgba(221, 107, 32, 0.15);

  /* Motion tokens */
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.25, 0.1, 0.25, 1);
  --duration-fast: 160ms;
  --duration-normal: 240ms;
}

/* Respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
/* Base Dark Theme */
html[data-theme="dark"] {
  --primary: #818cf8;
  --secondary: #a78bfa;
  --danger: #f87171;
  --success: #4ade80;
  --warning: #facc15;
  --text-dark: #e2e8f0;
  --text-gray: #94a3b8;
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --border-color: #334155;
  --primary-t-08: rgba(129, 140, 248, 0.1);
  --success-t-15: rgba(74, 222, 128, 0.15);
  --danger-t-10: rgba(248, 113, 113, 0.1);
  --warning-t-15: rgba(250, 204, 21, 0.15);
}

/* --- ALL THEME STYLES --- */
html[data-theme="midnight-sapphire"] {
  --primary: #1e40af;
  --secondary: #3730a3;
  --danger: #dc2626;
  --success: #059669;
  --warning: #d97706;
  --text-dark: #0f172a;
  --text-gray: #475569;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --primary-t-08: rgba(30, 64, 175, 0.08);
  --success-t-15: rgba(5, 150, 105, 0.15);
  --danger-t-10: rgba(220, 38, 38, 0.1);
}
html[data-theme="midnight-sapphire-dark"] {
  --primary: #60a5fa;
  --secondary: #818cf8;
  --danger: #f87171;
  --success: #34d399;
  --warning: #f59e0b;
  --text-dark: #e2e8f0;
  --text-gray: #94a3b8;
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --border-color: #334155;
  --primary-t-08: rgba(96, 165, 250, 0.1);
  --success-t-15: rgba(52, 211, 153, 0.15);
  --danger-t-10: rgba(248, 113, 113, 0.1);
}
html[data-theme="crimson-blaze"] {
  --primary: #dc2626;
  --secondary: #b91c1c;
  --danger: #e11d48;
  --success: #16a34a;
  --warning: #ea580c;
  --text-dark: #450a0a;
  --text-gray: #737373;
  --bg-main: #fef2f2;
  --bg-card: #ffffff;
  --border-color: #fecaca;
  --primary-t-08: rgba(220, 38, 38, 0.08);
  --success-t-15: rgba(22, 163, 74, 0.15);
  --danger-t-10: rgba(225, 29, 72, 0.1);
}
html[data-theme="crimson-blaze-dark"] {
  --primary: #f87171;
  --secondary: #ef4444;
  --danger: #fb7185;
  --success: #4ade80;
  --warning: #fb923c;
  --text-dark: #fecaca;
  --text-gray: #fca5a5;
  --bg-main: #450a0a;
  --bg-card: #7f1d1d;
  --border-color: #b91c1c;
  --primary-t-08: rgba(248, 113, 113, 0.1);
  --success-t-15: rgba(74, 222, 128, 0.15);
  --danger-t-10: rgba(251, 113, 133, 0.1);
}
html[data-theme="emerald-oasis"] {
  --primary: #059669;
  --secondary: #047857;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #ca8a04;
  --text-dark: #064e3b;
  --text-gray: #525252;
  --bg-main: #f0fdf4;
  --bg-card: #ffffff;
  --border-color: #bbf7d0;
  --primary-t-08: rgba(5, 150, 105, 0.08);
  --success-t-15: rgba(22, 163, 74, 0.15);
  --danger-t-10: rgba(220, 38, 38, 0.1);
}
html[data-theme="emerald-oasis-dark"] {
  --primary: #34d399;
  --secondary: #10b981;
  --danger: #f87171;
  --success: #86efac;
  --warning: #facc15;
  --text-dark: #d1fae5;
  --text-gray: #a7f3d0;
  --bg-main: #052e16;
  --bg-card: #064e3b;
  --border-color: #065f46;
  --primary-t-08: rgba(52, 211, 153, 0.1);
  --success-t-15: rgba(134, 239, 172, 0.15);
  --danger-t-10: rgba(248, 113, 113, 0.1);
}
html[data-theme="royal-amethyst"] {
  --primary: #7c3aed;
  --secondary: #6d28d9;
  --danger: #e11d48;
  --success: #059669;
  --warning: #d97706;
  --text-dark: #1e1b4b;
  --text-gray: #6b7280;
  --bg-main: #faf5ff;
  --bg-card: #ffffff;
  --border-color: #ddd6fe;
  --primary-t-08: rgba(124, 58, 237, 0.08);
  --success-t-15: rgba(5, 150, 105, 0.15);
  --danger-t-10: rgba(225, 29, 72, 0.1);
}
html[data-theme="royal-amethyst-dark"] {
  --primary: #a78bfa;
  --secondary: #8b5cf6;
  --danger: #f87171;
  --success: #34d399;
  --warning: #facc15;
  --text-dark: #ddd6fe;
  --text-gray: #c4b5fd;
  --bg-main: #1e1b4b;
  --bg-card: #312e81;
  --border-color: #4338ca;
  --primary-t-08: rgba(167, 139, 250, 0.1);
  --success-t-15: rgba(52, 211, 153, 0.15);
  --danger-t-10: rgba(248, 113, 113, 0.1);
}
html[data-theme="sunset-orange"] {
  --primary: #ea580c;
  --secondary: #c2410c;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --text-dark: #431407;
  --text-gray: #737373;
  --bg-main: #fff7ed;
  --bg-card: #ffffff;
  --border-color: #fdba74;
  --primary-t-08: rgba(234, 88, 12, 0.08);
  --success-t-15: rgba(22, 163, 74, 0.15);
  --danger-t-10: rgba(220, 38, 38, 0.1);
}
html[data-theme="sunset-orange-dark"] {
  --primary: #fb923c;
  --secondary: #f97316;
  --danger: #f87171;
  --success: #4ade80;
  --warning: #facc15;
  --text-dark: #fed7aa;
  --text-gray: #fdba74;
  --bg-main: #431407;
  --bg-card: #7c2d12;
  --border-color: #9a3412;
  --primary-t-08: rgba(251, 146, 60, 0.1);
  --success-t-15: rgba(74, 222, 128, 0.15);
  --danger-t-10: rgba(248, 113, 113, 0.1);
}
html[data-theme="ocean-teal"] {
  --primary: #0d9488;
  --secondary: #0f766e;
  --danger: #dc2626;
  --success: #059669;
  --warning: #d97706;
  --text-dark: #134e4a;
  --text-gray: #525252;
  --bg-main: #f0fdfa;
  --bg-card: #ffffff;
  --border-color: #99f6e4;
  --primary-t-08: rgba(13, 148, 136, 0.08);
  --success-t-15: rgba(5, 150, 105, 0.15);
  --danger-t-10: rgba(220, 38, 38, 0.1);
}
html[data-theme="ocean-teal-dark"] {
  --primary: #2dd4bf;
  --secondary: #14b8a6;
  --danger: #f87171;
  --success: #34d399;
  --warning: #facc15;
  --text-dark: #ccfbf1;
  --text-gray: #99f6e4;
  --bg-main: #042f2e;
  --bg-card: #115e59;
  --border-color: #0f766e;
  --primary-t-08: rgba(45, 212, 191, 0.1);
  --success-t-15: rgba(52, 211, 153, 0.15);
  --danger-t-10: rgba(248, 113, 113, 0.1);
}
html[data-theme="slate-gray"] {
  --primary: #374151;
  --secondary: #4b5563;
  --danger: #dc2626;
  --success: #059669;
  --warning: #d97706;
  --text-dark: #111827;
  --text-gray: #6b7280;
  --bg-main: #f9fafb;
  --bg-card: #ffffff;
  --border-color: #e5e7eb;
  --primary-t-08: rgba(55, 65, 81, 0.08);
  --success-t-15: rgba(5, 150, 105, 0.15);
  --danger-t-10: rgba(220, 38, 38, 0.1);
}
html[data-theme="slate-gray-dark"] {
  --primary: #9ca3af;
  --secondary: #6b7280;
  --danger: #f87171;
  --success: #34d399;
  --warning: #facc15;
  --text-dark: #e5e7eb;
  --text-gray: #d1d5db;
  --bg-main: #111827;
  --bg-card: #1f2937;
  --border-color: #374151;
  --primary-t-08: rgba(156, 163, 175, 0.1);
  --success-t-15: rgba(52, 211, 153, 0.15);
  --danger-t-10: rgba(248, 113, 113, 0.1);
}

/* --- GENERAL STYLES --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: "Inter", sans-serif;
  background-color: var(--bg-main);
  color: var(--text-dark);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
}
.hidden {
  display: none !important;
}
.loading-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
    transition: background-color var(--duration-fast) var(--ease-soft), color var(--duration-fast) var(--ease-soft), transform var(--duration-fast) var(--ease-soft), box-shadow var(--duration-fast) var(--ease-soft);
    will-change: transform, box-shadow;
  min-height: 100vh;
  .btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,0.08); }
  .btn:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
  padding: 1rem;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5000;
  background-color: #eef2f7;
  background-image: linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.5) 1px,
      transparent 1px
    ),
    linear-gradient(180deg, rgba(255, 255, 255, 0.5) 1px, transparent 1px);
  background-size: 20px 20px;
  transition: opacity 0.5s, visibility 0.5s;
}
.auth-container.hidden {
  opacity: 0;
  visibility: hidden;
  z-index: -1;
}
.auth-card {
  width: 100%;
  max-width: 850px;
  height: 480px;
  display: flex;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 5px 10px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-color);
  overflow: hidden;
  transition: all 0.3s;
}
.auth-panel {
  flex: 1;
  padding: 2.5rem 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-panel-branding {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  text-align: center;
}
.auth-panel-branding .branding-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -1px;
}
.auth-panel-branding .branding-subtitle {
  font-size: 1rem;
  opacity: 0.8;
}
.auth-panel-branding .auth-logo {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  margin: 0 auto 1.5rem auto;
}
.auth-header {
  margin-bottom: 2rem;
  text-align: left;
}
.auth-header h3 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-dark);
}
.auth-header p {
  color: var(--text-gray);
}
.input-group {
  position: relative;
}
.input-group i {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-gray);
  transition: color 0.3s;
}
.auth-card .form-control {
  padding: 0.75rem 0 0.75rem 2.25rem;
  background-color: transparent;
  border: none;
  border-bottom: 2px solid var(--border-color);
  border-radius: 0;
  transition: border-color 0.3s;
  color: var(--text-dark);
}
.auth-card .form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: none;
}
.auth-card .form-control:focus ~ i {
  color: var(--primary);
}
.auth-card input:-webkit-autofill,
.auth-card input:-webkit-autofill:hover,
.auth-card input:-webkit-autofill:focus,
.auth-card input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text-dark) !important;
  -webkit-box-shadow: 0 0 0px 1000px #f8f9fa inset !important;
  transition: background-color 5000s ease-in-out 0s;
  caret-color: var(--text-dark);
}
.auth-card .form-group label {
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-gray);
}
.auth-card .btn-block {
  width: 100%;
  padding: 0.85rem;
  margin-top: 1rem;
  border-radius: 8px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--secondary) 0%, var(--primary) 100%);
  transition: transform 0.2s, box-shadow 0.2s;
}
.auth-card .btn-block:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(74, 85, 162, 0.3);
}
.auth-footer {
  margin-top: 1.5rem;
  text-align: center;
}
.btn-link {
  background: none;
  border: none;
  color: var(--text-gray);
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
  font-family: inherit;
  text-decoration: none;
  transition: color 0.2s;
}
.btn-link:hover {
  color: var(--primary);
  text-decoration: underline;
}
.error-message {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 0.5rem;
  min-height: 1em;
}
.admin-container {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  display: flex;
  flex-direction: column;
  width: 280px;
  background: var(--bg-card);
  box-shadow: 2px 0 15px rgba(0, 0, 0, 0.05);
  padding: 1.5rem 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  z-index: 1100;
  transition: transform 0.35s ease-out;
  transform: translateX(0);
}
.sidebar-header {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.sidebar-header h2 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}
.sidebar-header h2 i {
  font-size: 1.8rem;
}
.sidebar-brand-short {
  display: none;
}
.sidebar-menu {
  flex-grow: 1;
}
.menu-item {
  display: flex;
  align-items: center;
  padding: 0.85rem 1.5rem;
  color: var(--text-gray);
  text-decoration: none;
  margin: 0.25rem 1rem;
  border-radius: var(--border-radius);
  transition: all 0.2s;
  gap: 1rem;
}
.menu-item i {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
}
.menu-item:hover,
.menu-item.active {
  color: var(--primary);
  background: var(--primary-t-08);
  font-weight: 600;
}
.sidebar-summary {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
}
.summary-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.4rem 0;
}
.summary-label {
  color: var(--text-gray);
}
.summary-value {
  font-weight: 600;
}
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1099;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s;
}
.sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
}
.main-content {
  flex: 1;
  margin-left: 280px;
  padding: 1rem;
  transition: margin-left 0.35s ease-out;
  display: flex;
  flex-direction: column;
}
.section-content {
  display: none;
  flex-grow: 1;
}
.section-content.is-active {
  display: block;
}
.app-footer {
  text-align: center;
  padding: 1rem 0;
  margin-top: 1.5rem;
  color: var(--text-gray);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
}
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-dark);
  cursor: pointer;
  z-index: 1200;
}
.header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.header h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-right: auto;
  letter-spacing: -0.5px;
  color: var(--primary);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.theme-toggle-btn,
.logout-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-gray);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
  flex-shrink: 0;
}
.theme-toggle-btn:hover,
.logout-btn:hover {
  background: var(--primary-t-08);
  color: var(--primary);
}
.form-card,
.stat-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  border: 1px solid var(--border-color);
}
.form-card {
  padding: 1.5rem;
}
.form-card h3 {
  margin-bottom: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 1.25rem;
}
.form-card h3 .btn-sm {
  margin-left: auto;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.card-header h3 {
  margin-right: auto;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.form-group {
  margin-bottom: 1.5rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
}
.form-control,
select.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  background-color: var(--bg-main);
  color: var(--text-dark);
  transition: all 0.25s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
select.form-control {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
}
html[data-theme="dark"] select.form-control {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-t-08);
}
textarea.form-control {
  min-height: 80px;
}
.file-input-wrapper {
  position: relative;
  width: 100%;
  height: 48px; /* fixed control height for visual consistency */
}
.file-input {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}
.file-input-label {
  display: flex;
  align-items: center; /* vertically center icon and text */
  justify-content: flex-start; /* icon then text on same row */
  gap: 0.75rem; /* Space between icon and text */
  width: 100%;
  height: 100%;
  padding: 0.5rem 1rem; /* reduce vertical padding to avoid text clipping */
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: var(--bg-main);
  color: var(--text-gray);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-soft), box-shadow var(--duration-fast) var(--ease-soft), transform var(--duration-fast) var(--ease-soft), background-color var(--duration-fast) var(--ease-soft);
  will-change: transform, box-shadow;
  /* Prevent oversized filenames from spilling outside the label */
  overflow: hidden;
  line-height: 1; /* normalized line-height so text aligns with icon */
  white-space: nowrap; /* keep contents in one line */
}
.file-input:focus + .file-input-label,
.file-input-label:hover {
  border-color: var(--primary);
}
.file-input:focus + .file-input-label {
  box-shadow: 0 0 0 3px var(--primary-t-08);
}
.file-input-label:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,0,0,0.08); }
.file-input-label:active { transform: translateY(0); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.file-input-label i {
  font-size: 1.1rem;
  color: var(--primary);
  flex-shrink: 0; /* Prevent icon from shrinking */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1; /* align icon visually with text */
}
.file-input-label span {
  display: inline-flex; /* keep on the same row as icon */
  align-items: center; /* vertically center text with icon */
  line-height: 1; /* align text with icon */
  white-space: nowrap; /* stay on one line next to icon */
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0; /* allow flex item to shrink for ellipsis */
  flex: 1 1 auto; /* text takes remaining space */
  max-width: 100%;
  text-align: left;
}
.installment-preview {
  margin-top: 1rem;
  padding: 1rem;
  background-color: var(--bg-main);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
}
.installment-preview.error {
  background-color: var(--danger-t-10);
  border-color: var(--danger);
  color: var(--danger);
}
.installment-preview p {
  margin: 0;
}
.installment-preview strong {
  color: var(--primary);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  gap: 0.5rem;
}
.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
}
.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-dark);
}
.btn-outline:hover:not(:disabled) {
  background: var(--primary-t-08);
  border-color: var(--primary);
  color: var(--primary);
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover:not(:disabled) {
  background: #c53030;
}
.btn-success {
  background-color: var(--success);
  color: white;
}
.btn-success:hover:not(:disabled) {
  background: #2f855a;
}
.btn-whatsapp {
  background-color: #25d366;
  color: white;
  border-color: #25d366;
}
.btn-whatsapp:hover:not(:disabled) {
  background-color: #128c7e;
  border-color: #128c7e;
}
.btn-outline.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
fieldset {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
fieldset legend {
  font-weight: 600;
  padding: 0 0.5rem;
}
.form-hr {
  border: 0;
  height: 1px;
  background-color: var(--border-color);
  margin: 1.5rem 0;
}
.stats-container {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.stat-card {
  padding: 1.5rem;
}
.stat-card .stat-title {
  font-size: 0.9rem;
  color: var(--text-gray);
  margin-bottom: 0.5rem;
}
.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.grid-col-span-2 {
  grid-column: span 1;
}
.chart-container {
  position: relative;
  height: 320px;
}
.chart-controls {
  display: flex;
  gap: 0.5rem;
}
.activity-container {
  max-height: 350px;
  overflow-y: auto;
}
.activity-list,
.customer-list {
  list-style: none;
  padding: 0;
}
.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  border-radius: 0.5rem;
  transition: background-color 0.2s;
}
.activity-item:last-child {
  border-bottom: none;
}
.activity-item:hover {
  background-color: var(--primary-t-08);
}
.activity-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.activity-icon {
  font-size: 1rem;
  color: var(--text-gray);
  width: 20px;
  text-align: center;
}
.activity-text {
  display: flex;
  flex-direction: column;
}
.activity-name {
  font-weight: 600;
}
.activity-details,
.activity-date {
  font-size: 0.85rem;
  color: var(--text-gray);
}
.activity-value {
  text-align: right;
}
.activity-amount {
  font-weight: 600;
}
.activity-amount.overdue {
  color: var(--danger);
}
.activity-amount.upcoming {
  color: var(--text-dark);
}
.activity-actions .delete-activity-btn {
  background: none;
  border: none;
  color: var(--text-gray);
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 0;
  transition: all 0.2s;
  padding: 0.5rem;
}
.activity-item:hover .delete-activity-btn {
  opacity: 0.7;
}
.delete-activity-btn:hover {
  color: var(--danger);
  opacity: 1;
}
.customer-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 1rem;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 0.5rem;
}
.customer-item:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-t-08);
}
.customer-info {
  width: 100%;
}
.customer-info .customer-name {
  font-weight: 600;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.finance-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0 8px;
  height: 24px;
  border-radius: 999px;
  background-color: var(--primary-t-08);
  color: var(--primary);
  border: 1px solid var(--primary);
}
.finance-status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  background-color: var(--bg-main);
  color: var(--text-gray);
  border: 1px solid var(--border-color);
}
.customer-info .customer-details {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--text-gray);
  margin-top: 0.25rem;
}
.customer-details .list-profit-display {
  color: var(--success);
  font-weight: 500;
}
.customer-actions {
  width: 100%;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}
.customer-actions .view-details-prompt {
  font-size: 0.85rem;
  color: var(--text-gray);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  font-weight: 500;
}
.customer-item:hover .view-details-prompt {
  color: var(--primary);
  border-color: currentColor;
  background-color: var(--primary-t-08);
}
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-normal) var(--ease-soft), visibility var(--duration-normal) var(--ease-soft);
  padding: 1rem;
}
.modal.show {
  opacity: 1;
  visibility: visible;
}
.modal-content {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  width: calc(100% - 2rem);
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  will-change: transform, opacity;
  transition: transform var(--duration-normal) var(--ease-smooth), opacity var(--duration-normal) var(--ease-smooth);
  transform: translateY(8px) scale(0.98);
  opacity: 0;
}
#customer-form-modal .modal-content,
#new-loan-modal .modal-content {
  max-width: 650px;
}
#payment-modal .modal-content {
  max-width: 480px;
}
#confirmation-modal .modal-content {
  max-width: 450px;
}
  /* Ensure reset password modal is visible above the login auth container */
  #reset-password-modal {
    z-index: 6001;
  }

.modal.show .modal-content {
  transform: translateY(0) scale(1);
  opacity: 1;
}
.modal-content.large {
  max-width: 1100px;
}
.modal-header {
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.modal-title-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.loan-frequency-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.frequency-daily {
  background-color: var(--success-t-15);
  color: var(--success);
}
.frequency-weekly {
  background-color: var(--warning-t-15);
  color: var(--warning);
}
.frequency-monthly {
  background-color: var(--primary-t-08);
  color: var(--primary);
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.75rem;
  cursor: pointer;
  color: var(--text-gray);
}
.modal-body {
  padding: 1rem 1.5rem;
  overflow-y: auto;
}
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background-color: var(--bg-main);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.details-view-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
.customer-profile-panel {
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  height: fit-content;
}
.profile-header {
  text-align: center;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background-color: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto 1rem auto;
}
.profile-name {
  font-size: 1.25rem;
  font-weight: 600;
}
.profile-contact {
  color: var(--text-gray);
}
.profile-section {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border-color);
}
.profile-section:last-child {
  border-bottom: none;
}
.profile-section h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.profile-stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.profile-stat .label {
  color: var(--text-gray);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.profile-stat .value {
  font-weight: 500;
  text-align: right;
}
/* Tweak only the Address layout inside the details panel */
.profile-stat.profile-stat-address {
  /* Keep other stats row-like; address becomes a neat two-line block */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.profile-stat.profile-stat-address .label {
  /* Slightly separate the label from the address body */
  margin-bottom: 2px;
}
.profile-stat.profile-stat-address .address-value {
  /* Constrain width so long addresses don’t stretch the whole panel */
  display: block;
  max-width: 65ch;
  width: 100%;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

/* Fallback: apply to address value even if parent helper class is missing */
.value.address-value {
  display: block;
  max-width: 65ch;
  padding-left: 10px;
  width: 60%;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}
.loan-progress-section {
  padding: 1.5rem 0;
}
.loan-progress-section h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.progress-bar {
  width: 100%;
  height: 8px;
  background-color: var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}
.progress-bar-inner {
  height: 100%;
  background-color: var(--success);
  width: 0%;
  border-radius: 8px;
  transition: width 0.5s;
}
.loan-actions {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.emi-schedule-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.emi-table-container {
  flex-grow: 1;
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.emi-table {
  width: 100%;
  border-collapse: collapse;
}
.emi-table th,
.emi-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.emi-table thead {
  position: sticky;
  top: 0;
  background-color: var(--bg-main);
  z-index: 1;
}
.emi-table td.no-pdf {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.emi-status {
  padding: 0.25rem 0.6rem;
  border-radius: 1rem;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  text-align: center;
}
.emi-status.status-paid {
  background-color: var(--success-t-15);
  color: var(--success);
}
.emi-status.status-pending {
  background-color: var(--warning-t-15);
  color: var(--warning);
}
.emi-status.status-due {
  background-color: var(--danger-t-10);
  color: var(--text-gray);
}
.emi-status.status-overdue {
  background-color: var(--danger);
  color: white;
}
.emi-table .emi-paid-row {
  opacity: 0.65;
  background-color: var(--bg-main);
  transition: opacity 0.3s, background-color 0.3s;
}
.emi-table .emi-paid-row:hover {
  opacity: 1;
}
.loan-summary-box {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background-color: var(--bg-main);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}
.loan-summary-box h4 {
  margin-bottom: 1rem;
  font-weight: 600;
}
.modal-summary-stats {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}
.summary-stat-item {
  flex: 1;
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--border-radius);
  text-align: center;
  box-shadow: var(--box-shadow);
}
.summary-stat-item .label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-gray);
  margin-bottom: 0.25rem;
}
.summary-stat-item .value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
}
.summary-stat-item .value.received {
  color: var(--success);
}
.summary-stat-item .value.remaining {
  color: var(--danger);
}
.calc-result-item {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}
.calc-result-item:last-child {
  border: none;
}
.calc-result-item span:first-child {
  color: var(--text-gray);
}
.calc-result-item span:last-child {
  font-weight: 600;
}
#calculator-results {
  margin-top: 2rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}
#calculator-results .calc-result-item span:last-child {
  font-size: 1.2rem;
  color: var(--primary);
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}
.setting-card {
  display: flex;
  flex-direction: column;
  padding: 0;
}
.setting-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.setting-card-header i {
  font-size: 1.25rem;
  color: var(--primary);
}
.setting-card-header h3 {
  margin-bottom: 0;
  font-size: 1.1rem;
}
.setting-card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex-grow: 1;
}
.setting-card .form-group:last-child {
  margin-bottom: 0;
}
.setting-description {
  font-size: 0.9rem;
  color: var(--text-gray);
  margin-bottom: 0.5rem;
}
.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.setting-item.column {
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}
.setting-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
}
.setting-label i {
  width: 20px;
  text-align: center;
  color: var(--text-gray);
}
#change-password-form .btn {
  margin-top: 1rem;
}
.import-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  width: 100%;
}
.import-controls .file-name {
  flex-grow: 1;
  font-size: 0.9rem;
  color: var(--text-gray);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.import-controls .btn-danger {
  margin-top: 0.5rem;
  width: 100%;
}
.warning-text {
  font-size: 0.8rem;
  color: var(--warning);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: 0.4s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
}
input:checked + .slider {
  background-color: var(--primary);
}
input:checked + .slider:before {
  transform: translateX(22px);
}
.slider.round {
  border-radius: 34px;
}
.slider.round:before {
  border-radius: 50%;
}
.summary-line {
  font-size: 0.9rem;
  color: var(--text-gray);
  margin-top: 1rem;
}
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  width: calc(100% - 2rem);
  max-width: 350px;
}
.toast {
  display: flex;
  align-items: flex-start;
  padding: 1rem 1.5rem;
  margin-bottom: 1rem;
  border-radius: var(--border-radius);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  color: white;
  min-width: 100%;
  opacity: 0.95;
  transform: translateX(120%);
  animation: slideIn 0.5s forwards;
}
@keyframes slideIn {
  to {
    transform: translateX(0);
  }
}
.toast.hide {
  animation: slideOut 0.5s forwards;
}
@keyframes slideOut {
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}
.toast-success {
  background-color: var(--success);
}
.toast-error {
  background-color: var(--danger);
}
.toast-icon {
  font-size: 1.5rem;
  margin-right: 1rem;
}
.toast-title {
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.toast-message {
  font-size: 0.9rem;
}
.toast-close {
  background: none;
  border: none;
  color: white;
  opacity: 0.7;
  margin-left: auto;
  padding-left: 1rem;
  font-size: 1.5rem;
  cursor: pointer;
}
#theme-modal .modal-body {
  background-color: var(--bg-main);
}
.theme-section {
  margin-bottom: 2rem;
}
.theme-section h4 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-dark);
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
}
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
}
.theme-card {
  background-color: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  position: relative;
  overflow: hidden;
}
.theme-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--box-shadow);
  border-color: var(--primary);
}
.theme-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-t-08);
}
.theme-card.active::after {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--success);
  font-size: 1.2rem;
}
.theme-name {
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-dark);
}
.theme-palette {
  display: flex;
  height: 30px;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--border-color);
}
.theme-color-swatch {
  flex: 1;
  height: 100%;
}
@media (min-width: 576px) {
  .customer-item {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .customer-info {
    flex-grow: 1;
  }
  .customer-actions {
    width: auto;
    flex-shrink: 0;
  }
  .customer-info .customer-details {
    gap: 1.5rem;
  }
  .modal-summary-stats {
    flex-direction: row;
  }
}
@media (min-width: 768px) {
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }
}
@media (min-width: 992px) {
  .details-view-grid {
    grid-template-columns: 350px 1fr;
    gap: 2rem;
  }
}
@media (min-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .grid-col-span-2 {
    grid-column: span 2;
  }
}
@media (max-width: 991px) {
  .main-content {
    margin-left: 0;
    padding: 1.5rem;
  }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.1);
  }
  .mobile-menu-btn {
    display: block;
  }
  .sidebar-brand-full {
    display: none;
  }
  .sidebar-brand-short {
    display: inline;
  }
  .sidebar-header h2 {
    font-size: 1.8rem;
  }
}
@media (max-width: 767px) {
  .auth-card {
    flex-direction: column;
    height: auto;
    max-width: 420px;
  }
  .auth-panel {
    padding: 2rem 1.5rem;
  }
  .main-content {
    padding: 1rem;
  }
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .header h1 {
    font-size: 1.5rem;
  }
  .btn-text-desktop {
    display: none;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .grid-col-span-2 {
    grid-column: span 1;
  }
  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .customer-item {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .customer-info {
    flex-grow: 1;
  }
  .customer-actions {
    width: auto;
    flex-shrink: 0;
  }
  .customer-details {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem !important;
  }
}
@media (max-width: 480px) {
  .header-actions .btn {
    padding: 0.5rem 0.8rem;
  }
  .header-actions .theme-toggle-btn,
  .header-actions .logout-btn {
    width: 38px;
    height: 38px;
    font-size: 0.9rem;
  }
  .stat-card .stat-value {
    font-size: 1.5rem;
  }
  .ola {
    margin-left: 30px;
    margin-top: -10px;
  }
  .modal-footer {
    flex-direction: column;
    gap: 0.5rem;
  }
  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
  .modal-footer .btn .btn-text-desktop {
    display: inline;
  }
}
.payment-customer-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 1.5rem;
}
.payment-customer-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.payment-customer-name {
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--text-dark);
}
.payment-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.payment-detail-item {
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
  text-align: center;
}
.payment-detail-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-gray);
  margin-bottom: 0.25rem;
}
.payment-detail-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark);
}
.payment-detail-value.large {
  font-size: 1.5rem;
  color: var(--primary);
}
.input-group-payment {
  position: relative;
}
.input-group-payment .input-group-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  color: var(--text-gray);
}
.input-group-payment .form-control-lg {
  padding: 1rem 1rem 1rem 2.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: right;
}
.payment-quick-actions {
  text-align: right;
  margin-top: -1rem;
  margin-bottom: 1.5rem;
}
.payment-pending-display {
  text-align: center;
  margin-top: 1rem;
  padding: 0.75rem;
  background-color: var(--danger-t-10);
  border-radius: var(--border-radius);
  display: none;
}
.payment-pending-label {
  color: var(--text-gray);
}
.payment-pending-value {
  color: var(--danger);
}
.custom-select-wrapper {
  position: relative;
  user-select: none;
  width: 150px;
}
.custom-select {
  position: relative;
}
.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  background-color: var(--bg-main);
  color: var(--text-dark);
  border-radius: 999px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
}
.custom-select-trigger:hover {
  border-color: var(--primary);
}
.custom-select.open .custom-select-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-t-08);
}
.custom-select-trigger i {
  margin-left: 0.5rem;
  transition: transform 0.3s;
}
.custom-select.open .custom-select-trigger i {
  transform: rotate(180deg);
}
.custom-options {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s;
}
.custom-select.open .custom-options {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.custom-option {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background-color 0.2s;
  font-size: 0.9rem;
}
.custom-option:hover {
  background-color: var(--primary-t-08);
}
.custom-option.selected {
  background-color: var(--primary);
  color: white;
  font-weight: 600;
}
.selection-list {
  margin-top: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  max-height: 250px;
  overflow-y: auto;
}
.selection-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: background-color 0.2s;
}
.selection-item:hover {
  background-color: var(--bg-main);
}
.selection-item:last-child {
  border-bottom: none;
}
.selection-item input[type="radio"] {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.selection-item label {
  flex-grow: 1;
  font-weight: 500;
  cursor: pointer;
}
.selection-item label span {
  display: block;
  font-size: 0.85rem;
  color: var(--text-gray);
  font-weight: 400;
  margin-top: 2px;
}
#settle-selection-modal .modal-content {
  max-width: 500px;
}
/* Styles for the dynamically created size alert popup */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(5px);
}
.popup-content {
  background-color: var(--bg-card);
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 400px;
  width: 90%;
  transform: scale(0.95);
  animation: popup-appear 0.3s ease-out forwards;
}
@keyframes popup-appear {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.popup-content h2 {
  margin-top: 0;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-dark);
}
.popup-content p {
  color: var(--text-gray);
  font-size: 1.1rem;
}
.profile-avatar-img {
  width: 100%; 
  height: 100%;
  object-fit: cover; 
  border-radius: 50%; 
}

/* Make details modal wider to avoid horizontal scrolling */
#customer-details-modal .modal-content {
  max-width: 90%;
  width: 90%;
  box-sizing: border-box;
  max-height: 92vh;
  overflow: hidden; /* keep scrolling inside dedicated containers */
}

/* Ensure EMI table scrolls vertically inside modal without causing page scroll */
#customer-details-modal .emi-table-container {
  max-height: 56vh; /* large enough to show many rows but keep footer visible */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Small visual highlight animation used when auto-scrolling to a row */
#customer-details-modal .emi-table tbody tr.auto-highlight {
  animation: highlightRow 2s ease forwards;
}
@keyframes highlightRow {
  0% { background-color: rgba(250, 215, 160, 0.45); }
  80% { background-color: transparent; }
  100% { background-color: transparent; }
}