/* --- CUSTOM DESIGN SYSTEM & VARIABLES --- */
:root {
  /* Common variables */
  --transition-fast: 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  --font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
  --border-radius-sm: 10px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
  --border-radius-xl: 32px;

  /* Theme variables (default Dark mode) */
  --color-bg-primary: #090d16;
  --color-bg-secondary: #0f1420;
  --color-panel-bg: rgba(15, 20, 32, 0.75);
  --color-panel-border: rgba(255, 255, 255, 0.08);
  --panel-inner-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --color-text-primary: #f8fafc;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;
  --color-border: rgba(255, 255, 255, 0.08);
  
  /* Accent colors */
  --color-accent: #6366f1; /* Indigo */
  --color-accent-hover: #4f46e5;
  --color-accent-light: rgba(99, 102, 241, 0.15);
  --color-accent-glow: rgba(99, 102, 241, 0.35);
  
  --color-success: #10b981; /* Emerald */
  --color-success-light: rgba(16, 185, 129, 0.15);
  --color-success-glow: rgba(16, 185, 129, 0.35);
  
  --color-warning: #f59e0b; /* Amber */
  --color-warning-light: rgba(245, 158, 11, 0.15);
  --color-warning-glow: rgba(245, 158, 11, 0.35);
  
  --color-error: #f43f5e; /* Rose */
  --color-error-light: rgba(244, 63, 94, 0.15);
  --color-error-glow: rgba(244, 63, 94, 0.35);

  --color-card-glow: rgba(255, 255, 255, 0.015);
  --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.28);
  --backdrop-blur: 20px;
}

[data-theme="light"] {
  --color-bg-primary: #f8fafc;
  --color-bg-secondary: #f1f5f9;
  --color-panel-bg: rgba(255, 255, 255, 0.8);
  --color-panel-border: rgba(0, 0, 0, 0.06);
  --panel-inner-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;
  --color-border: rgba(0, 0, 0, 0.06);
  
  --color-accent: #4f46e5;
  --color-accent-hover: #3730a3;
  --color-accent-light: rgba(79, 70, 229, 0.08);
  --color-accent-glow: rgba(79, 70, 229, 0.2);
  
  --color-success: #059669;
  --color-success-light: rgba(5, 150, 105, 0.08);
  --color-success-glow: rgba(5, 150, 105, 0.2);
  
  --color-warning: #d97706;
  --color-warning-light: rgba(217, 119, 6, 0.08);
  --color-warning-glow: rgba(217, 119, 6, 0.2);
  
  --color-error: #e11d48;
  --color-error-light: rgba(225, 29, 72, 0.08);
  --color-error-glow: rgba(225, 29, 72, 0.2);

  --color-card-glow: rgba(0, 0, 0, 0.005);
  --shadow-main: 0 8px 32px 0 rgba(31, 38, 135, 0.04);
}

/* --- GENERAL RESET & LAYOUT --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
}

body {
  overflow-x: hidden;
  min-height: 100vh;
}

.bg-primary { background-color: var(--color-bg-primary); }
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-error { color: var(--color-error); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }

.font-extrabold { font-weight: 800; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mr-2 { margin-right: 0.5rem; }
.mr-4 { margin-right: 1rem; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-3 { margin-left: 0.75rem; }

.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.pb-4 { padding-bottom: 1rem; }

.block { display: block; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0%; }
.flex-wrap { flex-wrap: wrap; }
.space-x-3 > * + * { margin-left: 0.75rem; }
.space-x-4 > * + * { margin-left: 1rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }
.space-y-8 > * + * { margin-top: 2rem; }

.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

@media (min-width: 768px) {
  .md:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .lg:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lg:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lg:col-span-2 { grid-column: span 2 / span 2; }
}

.min-h-screen { min-height: 100vh; }
.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }
.max-w-sm { max-width: 24rem; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.transition-all { transition: all var(--transition-normal); }
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* --- DYNAMIC BACKGROUND DECORATIVE BLOBS --- */
.glass-bg-blobs {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  animation: float-blobs 25s infinite alternate ease-in-out;
}
[data-theme="light"] .blob {
  opacity: 0.15;
  filter: blur(100px);
}
.blob-1 {
  top: -10%;
  left: 10%;
  width: 40vw;
  height: 40vw;
  background: var(--color-accent);
  animation-duration: 20s;
}
.blob-2 {
  bottom: -10%;
  right: 10%;
  width: 45vw;
  height: 45vw;
  background: var(--color-success);
  animation-duration: 25s;
}
.blob-3 {
  top: 40%;
  right: 30%;
  width: 30vw;
  height: 30vw;
  background: var(--color-warning);
  animation-duration: 30s;
}

@keyframes float-blobs {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(8%, 12%) scale(1.15);
  }
}

/* --- PREMIUM UI GLASSMORPHIC PANEL --- */
.glass-panel {
  background: var(--color-panel-bg);
  backdrop-filter: blur(var(--backdrop-blur));
  -webkit-backdrop-filter: blur(var(--backdrop-blur));
  border: 1px solid var(--color-panel-border);
  box-shadow: var(--shadow-main), var(--panel-inner-shadow);
  border-radius: var(--border-radius-md);
}

/* --- AUTHENTICATION/LOGIN INTERFACE --- */
.logo-container {
  width: 72px;
  height: 72px;
  background: var(--color-accent-light);
  border-radius: var(--border-radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-panel-border);
  margin-bottom: 0.5rem;
  position: relative;
  overflow: hidden;
}
.logo-icon {
  font-size: 2rem;
  color: var(--color-accent);
}
.glow-accent {
  filter: drop-shadow(0 0 8px var(--color-accent));
}

.login-card {
  width: 90%;
  max-width: 400px;
  padding: 2.5rem;
  position: relative;
}

/* --- FORM & INPUT ELEMENTS --- */
.input-group {
  display: flex;
  flex-direction: column;
}
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: 1rem;
  transition: var(--transition-fast);
}
.input-wrapper input {
  padding-left: 42px;
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  color: var(--color-text-primary);
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
  transition: var(--transition-fast);
}
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  background: rgba(0, 0, 0, 0.02);
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
  background: rgba(255, 255, 255, 0.05);
}
[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
  background: #ffffff;
}

/* --- BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: var(--transition-fast);
}
.btn-accent {
  background: var(--color-accent);
  color: #ffffff;
}
.btn-accent:hover {
  background: var(--color-accent-hover);
  box-shadow: 0 0 16px var(--color-accent-glow);
  transform: translateY(-1px);
}
.btn-ghost {
  background: transparent;
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--color-text-secondary);
}
[data-theme="light"] .btn-ghost:hover {
  background: rgba(0, 0, 0, 0.04);
}
.btn-icon-ghost {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--border-radius-sm);
  background: transparent;
  color: var(--color-text-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.btn-icon-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
}
[data-theme="light"] .btn-icon-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
}
.btn-danger {
  background: var(--color-error-light);
  color: var(--color-error);
  border: 1px solid var(--color-error);
}
.btn-danger:hover {
  background: var(--color-error);
  color: #ffffff;
}

/* --- MAIN LAYOUT STRUCTURE --- */
.sidebar {
  width: 280px;
  height: 100vh;
  position: sticky;
  top: 0;
  left: 0;
  border-radius: 0;
  border-left: none;
  border-top: none;
  border-bottom: none;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  z-index: 100;
}
.sidebar-brand {
  display: flex;
  align-items: center;
}
.brand-icon {
  font-size: 1.8rem;
  margin-right: 0.75rem;
}
.sidebar-nav ul {
  list-style: none;
}
.nav-link {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  transition: var(--transition-fast);
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--color-text-primary);
}
[data-theme="light"] .nav-link:hover {
  background: rgba(0, 0, 0, 0.02);
}
.nav-link.active {
  background: var(--color-accent-light);
  color: var(--color-accent);
  font-weight: 600;
  border-left: 3px solid var(--color-accent);
}
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  padding-top: 1.5rem;
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bg-accent-light { background: var(--color-accent-light); }

.main-content {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.main-header {
  border-radius: 0;
  border-right: none;
  border-left: none;
  border-top: none;
  position: sticky;
  top: 0;
  z-index: 90;
}

/* --- THEME TOGGLE ICON WORKFLOW --- */
.icon-sun { display: block; }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* --- CARD CAROUSELS & STATISTICS PANELS --- */
.card {
  background: var(--color-panel-bg);
  border: 1px solid var(--color-panel-border);
  box-shadow: var(--shadow-main);
  border-radius: var(--border-radius-md);
  transition: all var(--transition-normal);
}
.glow-accent-hover:hover {
  border-color: var(--color-accent);
  box-shadow: 0 0 20px var(--color-accent-light);
}
.glow-warning-hover:hover {
  border-color: var(--color-warning);
  box-shadow: 0 0 20px var(--color-warning-light);
}
.glow-error-hover:hover {
  border-color: var(--color-error);
  box-shadow: 0 0 20px var(--color-error-light);
}
.glow-success-hover:hover {
  border-color: var(--color-success);
  box-shadow: 0 0 20px var(--color-success-light);
}

.card-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bg-warning-light { background: var(--color-warning-light); }
.bg-error-light { background: var(--color-error-light); }
.bg-success-light { background: var(--color-success-light); }

.card-glow-bg {
  position: absolute;
  bottom: -40px;
  right: -40px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.1;
  pointer-events: none;
}

/* --- DATA TABLES --- */
.table-container {
  overflow-x: auto;
  width: 100%;
}
.table-styled {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.table-styled th {
  padding: 16px;
  border-bottom: 2px solid var(--color-border);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  letter-spacing: 0.05em;
}
.table-styled td {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.95rem;
  color: var(--color-text-primary);
  transition: var(--transition-fast);
}
.table-styled tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}
[data-theme="light"] .table-styled tbody tr:hover td {
  background: rgba(0, 0, 0, 0.01);
}

/* --- BADGES --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.025em;
}
.badge-success {
  background: var(--color-success-light);
  color: var(--color-success);
}
.badge-warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
}
.badge-error {
  background: var(--color-error-light);
  color: var(--color-error);
}
.badge-accent {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

/* --- DIALOG MODALS --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}
.modal-box {
  background: var(--color-bg-primary);
  padding: 2rem;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5);
  border-radius: var(--border-radius-md);
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modal-pop {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* --- CLIENT GRID CARD STYLE --- */
.client-card {
  padding: 1.5rem;
  position: relative;
}
.client-avatar {
  width: 50px;
  height: 50px;
  background: var(--color-accent-light);
  color: var(--color-accent);
  font-size: 1.3rem;
  font-weight: 800;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

/* --- SELECT & OPTION CUSTOM STYLE --- */
select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M7 9l3 3 3-3' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 36px;
}

/* --- MOBILE RESPONSIVENESS AND SIDENAV DRAWER --- */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    height: 100vh;
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
  }
  .sidebar.show {
    left: 0;
  }
}

/* --- ADDED ADVANCED STYLES --- */

/* Budget progress bar animations & dynamic themes */
#budget-progress-bar {
  background: linear-gradient(90deg, var(--color-accent) 0%, #a855f7 100%);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
#budget-progress-bar.warning {
  background: linear-gradient(90deg, var(--color-warning) 0%, #f97316 100%);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}
#budget-progress-bar.danger {
  background: linear-gradient(90deg, var(--color-error) 0%, #ec4899 100%);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

/* Quick Check-in Button animation */
#btn-quick-checkin {
  border: 1px dashed var(--color-accent);
  background: rgba(99, 102, 241, 0.05);
  animation: quick-btn-pulse 2s infinite alternate;
}
@keyframes quick-btn-pulse {
  from {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 4px rgba(99, 102, 241, 0.1);
  }
  to {
    border-color: rgba(99, 102, 241, 1);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
  }
}

/* Custom styles for tables inside split-view panels */
.text-ellipsis {
  text-overflow: ellipsis;
}
.whitespace-nowrap {
  white-space: nowrap;
}

/* Adjust layout spacing for settlements list */
#settlements-history-body tr td {
  padding: 10px 12px;
}

