/* ==================================================================
   MICROFINANCE APP - STYLE COMPLET
   Design original + Stabilisation + Optimisations performances
   Ne casse rien, ajoute des fonctionnalitÃ©s
   ================================================================== */

/* ===== VARIABLES ===== */
:root {
  /* Design original */
  --sidebar-width: 272px;
  --header-height: 64px;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #dbe4f0;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --secondary: #e2e8f0;
  --secondary-text: #1e293b;
  --danger: #dc2626;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.1);
  --transition-fast: 0.2s ease;
  --transition-mid: 0.35s ease;

  /* Ajouts stabilisation */
  --success: #059669;
  --success-light: #d1fae5;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --error: #dc2626;
  --error-light: #fee2e2;
  --info: #2563eb;
  --info-light: #dbeafe;
  --feedback-animation-duration: 0.3s;
  --toast-z-index: 9999;

  /* Ajouts performances */
  --skeleton-base: #e2e8f0;
  --skeleton-highlight: #f1f5f9;
  --image-loading-bg: #e2e8f0;
  --mobile-nav-height: 60px;
  --touch-target-min: 44px;
  --safe-area-inset: env(safe-area-inset-bottom, 0px);
}

/* ===== RESET & BASE ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ===== LAYOUT PRINCIPAL ===== */
.app {
  min-height: 100vh;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
  animation-delay: 0.1s;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: min(86vw, var(--sidebar-width));
  height: 100vh;
  overflow-y: auto;
  background: linear-gradient(185deg, #081225 0%, #0d1b34 52%, #0b1326 100%);
  color: #f8fafc;
  border-right: 1px solid rgba(148, 163, 184, 0.16);
  padding: calc(var(--header-height) + var(--space-4)) var(--space-4) var(--space-5);
  transform: translate3d(-100%, 0, 0);
  transition: transform var(--transition-mid);
  will-change: transform;
  backface-visibility: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.sidebar.open,
.sidebar.active {
  transform: translateX(0);
}

.brand {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: var(--space-4);
}

.sidebar nav {
  display: grid;
  gap: var(--space-2);
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: #dbe7ff;
  text-decoration: none;
  border-radius: 12px;
  padding: 0.72rem 0.8rem;
  min-height: var(--touch-target-min);
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  touch-action: manipulation;
}

.sidebar nav a:hover,
.sidebar nav a:focus-visible {
  background: rgba(37, 99, 235, 0.2);
  color: #ffffff;
  transform: translateX(2px);
}

.sidebar-actions {
  margin-top: var(--space-5);
}

/* ===== CONTENT ===== */
.content {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.sidebar.open + .content::before,
.sidebar.active + .content::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  z-index: 900;
  pointer-events: none;
  animation: fadeIn 0.3s ease;
}

/* ===== HEADER ===== */
header {
  position: sticky;
  top: 0;
  z-index: 950;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.72rem var(--space-4);
  background: linear-gradient(130deg, #0f172a, #1f365f);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

header h1 {
  font-size: clamp(1rem, 2.4vw, 1.45rem);
  font-weight: 650;
}

/* ===== CONTAINER & GRID ===== */
.container {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--space-4);
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

/* ===== CARDS ===== */
.card {
  width: 100%;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  overflow: hidden;
  animation: fadeInUp 0.42s ease both;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  will-change: transform, opacity;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #c8d7eb;
}

.card h2 {
  font-size: clamp(1rem, 2vw, 1.2rem);
  margin-bottom: var(--space-3);
}

.card h3 {
  font-size: 0.98rem;
  margin-bottom: var(--space-2);
}

/* ===== BOUTONS ===== */
.button,
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: 10px;
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  padding: 0.62rem 1rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  touch-action: manipulation;
  will-change: transform, opacity;
  transform: translateZ(0);
}

.button,
.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.button:hover,
.btn-primary:hover {
  background: var(--primary-600);
  transform: translateY(-1px);
}

.button.secondary,
.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-text);
  border-color: #cbd5e1;
}

.button.secondary:hover,
.btn-secondary:hover {
  background: #d5deea;
}

.button.danger {
  background: var(--danger);
  color: #ffffff;
}

.button.success {
  background: #15803d;
  color: #ffffff;
  border-color: #166534;
}

.button.success:hover {
  background: #166534;
}

.button:active,
.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.97);
  transition: transform 0.1s;
}

/* Ã‰tats boutons */
.button.loading,
.btn-primary.loading,
.btn-secondary.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  opacity: 0.8;
}

.button.loading::after,
.btn-primary.loading::after,
.btn-secondary.loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: calc(50% - 10px);
  left: calc(50% - 10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: button-spinner 0.8s linear infinite;
}

.btn-secondary.loading::after {
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--primary);
}

.button:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.button.disabled,
.btn-primary.disabled,
.btn-secondary.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
  filter: grayscale(0.3);
}

.button.success-feedback,
.btn-primary.success-feedback {
  background: var(--success) !important;
  transition: background 0.2s ease;
}

.button.error-feedback,
.btn-primary.error-feedback {
  background: var(--error) !important;
  animation: button-shake 0.4s ease;
}

/* ===== FORMULAIRES ===== */
label {
  display: block;
  margin: var(--space-3) 0 var(--space-2);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
textarea,
.input-field {
  width: 100%;
  min-height: var(--touch-target-min);
  border-radius: 10px;
  border: 1px solid #c7d2e3;
  background: #ffffff;
  color: var(--text);
  padding: 0.62rem 0.78rem;
  font-size: 0.95rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus,
.input-field:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

input:invalid,
select:invalid,
textarea:invalid {
  border-color: #f59e0b;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Ã‰tats formulaire */
input.valid,
select.valid,
textarea.valid {
  border-color: var(--success);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23059669' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

input.invalid,
select.invalid,
textarea.invalid {
  border-color: var(--error);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23dc2626' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

input.loading,
select.loading,
textarea.loading {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='10' stroke-dasharray='40' stroke-dashoffset='20'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='1s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

.field-error {
  color: var(--error);
  font-size: 0.75rem;
  margin-top: 4px;
  min-height: 20px;
  animation: slideDown var(--feedback-animation-duration) ease;
}

.field-success {
  color: var(--success);
  font-size: 0.75rem;
  margin-top: 4px;
}

form .button {
  margin-top: var(--space-3);
  width: 100%;
}

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.toolbar .button {
  flex: 1 1 150px;
}

/* ===== NOTICES & ALERTS ===== */
.notice {
  margin-top: var(--space-3);
  border-radius: 10px;
  border: 1px solid #bae6fd;
  background: #eff8ff;
  color: #0c4a6e;
  padding: 0.68rem 0.75rem;
  font-size: 0.86rem;
}

.alert {
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: slideDown var(--feedback-animation-duration) ease;
}

.alert.success {
  background: var(--success-light);
  border: 1px solid var(--success);
  color: #065f46;
}

.alert.error {
  background: var(--error-light);
  border: 1px solid var(--error);
  color: #991b1b;
}

.alert.warning {
  background: var(--warning-light);
  border: 1px solid var(--warning);
  color: #92400e;
}

.alert.info {
  background: var(--info-light);
  border: 1px solid var(--info);
  color: #1e40af;
}

.alert-icon {
  font-size: 1.2rem;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.alert-message {
  font-size: 0.9rem;
  opacity: 0.9;
}

.alert-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  opacity: 0.5;
  padding: 4px;
  min-width: 32px;
  min-height: 32px;
}

.alert-close:hover {
  opacity: 1;
}

/* ===== TOASTS ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: var(--toast-z-index);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 350px;
  width: calc(100% - 40px);
  pointer-events: none;
}

.toast {
  background: white;
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transform: translateX(120%);
  animation: slideInRight var(--feedback-animation-duration) forwards;
  pointer-events: auto;
  border-left: 4px solid transparent;
  position: relative;
  overflow: hidden;
  will-change: transform, opacity;
  transform: translateZ(0);
}

.toast.hiding {
  animation: slideOutRight var(--feedback-animation-duration) forwards;
}

.toast.success {
  border-left-color: var(--success);
  background: var(--success-light);
}

.toast.error {
  border-left-color: var(--error);
  background: var(--error-light);
}

.toast.warning {
  border-left-color: var(--warning);
  background: var(--warning-light);
}

.toast.info {
  border-left-color: var(--info);
  background: var(--info-light);
}

.toast-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.toast-message {
  font-size: 0.85rem;
  opacity: 0.9;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: inherit;
  opacity: 0.5;
  padding: 4px;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-fast);
}

.toast-close:hover {
  opacity: 1;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.1);
  width: 100%;
}

.toast-progress-bar {
  height: 100%;
  background: currentColor;
  opacity: 0.3;
  width: 100%;
  transform-origin: left;
  animation: toast-progress 5s linear forwards;
}

/* ===== ROWS & UTILS ===== */
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0.5rem 0;
}

.muted,
.empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.text-lead {
  font-size: 0.95rem;
  line-height: 1.6;
}

.header-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
}

.header-title {
  text-align: left;
}

.header-actions {
  justify-self: end;
}

.align-end-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
}

.section-divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-4) 0;
}

.auth-card {
  width: 100%;
  max-width: 520px;
  margin-inline: auto;
}

.card-contrast {
  background: #0f172a;
  color: #e2e8f0;
}

.contrast-title {
  color: #e2e8f0;
}

.row-contrast {
  border-bottom: 1px solid #1f2937;
}

.row-contrast:last-child {
  border-bottom: 0;
}

.span-12 { grid-column: span 12; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }

.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-5 { margin-top: var(--space-5); }
.mb-5 { margin-bottom: var(--space-5); }

.is-hidden {
  display: none;
}

/* ===== TABLEAUX ===== */
.table,
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-3);
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

thead,
tbody,
tr {
  width: 100%;
}

th,
td {
  white-space: nowrap;
  text-align: left;
  padding: 0.7rem 0.75rem;
  font-size: 0.84rem;
  border-bottom: 1px solid var(--border);
}

thead {
  background: var(--surface-soft);
}

.table-container {
  position: relative;
  max-height: 600px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== PRE ===== */
pre {
  margin-top: var(--space-3);
  width: 100%;
  max-width: 100%;
  background: #0b1220;
  color: #e2e8f0;
  border-radius: 12px;
  padding: var(--space-3);
  overflow: auto;
  font-size: 0.75rem;
}

/* ===== KPI ===== */
.kpi-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

.kpi-card {
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  color: #ffffff;
  background: linear-gradient(140deg, #2563eb, #1e40af);
  box-shadow: var(--shadow-sm);
}

.kpi-title {
  font-size: 0.85rem;
  opacity: 0.92;
}

.kpi-value {
  margin-top: var(--space-2);
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: 700;
}

/* ===== BADGES ===== */
#roleBadge {
  background: #0f172a;
  color: #f8fafc;
  border-left: 4px solid #020617;
  font-weight: 600;
}

.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.paid {
  background: var(--success-light);
  color: var(--success);
}

.status-badge.pending {
  background: var(--warning-light);
  color: var(--warning);
}

.status-badge.overdue {
  background: var(--error-light);
  color: var(--error);
}

.status-badge.approved {
  background: var(--info-light);
  color: var(--info);
}

/* ===== SIDEBAR TOGGLE ===== */
.sidebar-toggle {
  display: inline-flex;
}

/* ===== FOOTER ===== */
.footer {
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.84rem;
}

/* ===== SQUELETTES CHARGEMENT ===== */
.skeleton-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  position: relative;
  overflow: hidden;
}

.skeleton-line {
  height: 16px;
  background: var(--skeleton-base);
  border-radius: 8px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}

.skeleton-line.short {
  width: 60%;
}

.skeleton-line.medium {
  width: 80%;
}

.skeleton-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--skeleton-base);
  margin-bottom: 12px;
}

.skeleton-shimmer {
  position: relative;
  overflow: hidden;
}

.skeleton-shimmer::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 1.5s infinite;
  transform: translateX(-100%);
}

.skeleton-kpi {
  height: 100px;
  background: linear-gradient(140deg, #e2e8f0, #f1f5f9);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}

.skeleton-transaction {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.skeleton-transaction-icon {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: var(--skeleton-base);
}

.skeleton-transaction-content {
  flex: 1;
}

.skeleton-transaction-line {
  height: 14px;
  background: var(--skeleton-base);
  border-radius: 7px;
  margin-bottom: 8px;
}

/* ===== LOADER INITIAL ===== */
.initial-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease;
}

.initial-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ===== IMAGES ===== */
img.loading-lazy {
  opacity: 0;
  transition: opacity 0.3s ease;
}

img.loaded {
  opacity: 1;
}

img:not([src]), 
img[src=""],
img[src="null"] {
  visibility: hidden;
}

.image-placeholder {
  background: var(--image-loading-bg);
  position: relative;
  overflow: hidden;
  min-height: 100px;
}

.image-placeholder::before {
  content: "ðŸ“·";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  opacity: 0.5;
}

/* ===== TRANSACTIONS (microfinance) ===== */
.transaction-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  contain: content;
  transform: translateZ(0);
}

.transaction-item:last-child {
  border-bottom: none;
}

.transaction-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.transaction-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.transaction-date {
  font-size: 0.75rem;
  color: var(--muted);
}

.transaction-amount {
  font-weight: 700;
  font-size: 1rem;
}

.transaction-amount.credit {
  color: #059669;
}

.transaction-amount.debit {
  color: var(--danger);
}

.transactions-history {
  max-height: 500px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  contain: strict;
}

/* ===== AMOUNT DISPLAY ===== */
.amount-large {
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
}

.amount-positive {
  color: #059669;
}

.amount-negative {
  color: var(--danger);
}

.amount-change,
.amount-updated {
  animation: amount-pulse 0.5s ease;
}

.balance-container {
  content-visibility: auto;
  contain-intrinsic-size: 0 120px;
}

/* ===== LOAN PROGRESS ===== */
.loan-progress {
  width: 100%;
  height: 8px;
  background: var(--secondary);
  border-radius: 4px;
  overflow: hidden;
  margin: var(--space-2) 0;
}

.loan-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width var(--transition-mid);
}

/* ===== CONFIRMATION ===== */
.confirmation-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn var(--feedback-animation-duration) ease;
  padding: 20px;
}

.confirmation-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  animation: slideUp var(--feedback-animation-duration) ease;
}

.confirmation-icon {
  width: 64px;
  height: 64px;
  border-radius: 32px;
  background: var(--warning-light);
  color: var(--warning);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 20px;
}

.confirmation-title {
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
}

.confirmation-amount {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  color: var(--primary);
  margin-bottom: 20px;
  padding: 10px;
  background: var(--surface-soft);
  border-radius: var(--radius-md);
}

.confirmation-details {
  margin-bottom: 24px;
}

.confirmation-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.confirmation-row:last-child {
  border-bottom: none;
}

.confirmation-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.confirmation-value {
  font-weight: 600;
}

.confirmation-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.confirmation-actions button {
  flex: 1;
}

/* ===== MOBILE BOTTOM NAV ===== */
.mobile-bottom-nav {
  display: none;
}

.fab-container {
  display: none;
}

/* ===== MOBILE ONLY / DESKTOP ONLY ===== */
.mobile-only {
  display: none;
}

.desktop-only {
  display: block;
}

/* ===== PERFORMANCE METRICS ===== */
.performance-metrics {
  position: fixed;
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.8);
  color: #0f0;
  font-family: monospace;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  z-index: 10000;
  display: none;
}

.performance-metrics.visible {
  display: block;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes button-spinner {
  to { transform: rotate(360deg); }
}

@keyframes button-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideInRight {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}



@keyframes slideInUp {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideOutDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(24px);
    opacity: 0;
  }
}
@keyframes toast-progress {
  to { transform: scaleX(0); }
}

@keyframes amount-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); color: var(--success); }
}

/* ===== MEDIA QUERIES ===== */

/* Desktop (>=769px) */
@media (min-width: 769px) {
  .app {
    display: flex;
  }

  .sidebar {
    transform: none;
    position: fixed;
    width: var(--sidebar-width);
    padding-top: var(--space-5);
  }

  .content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
  }

  .sidebar-toggle {
    display: none;
  }

  .container {
    padding: var(--space-5);
  }

  .grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--space-5);
  }

  form .button {
    width: auto;
  }

  .toolbar .button {
    flex: 0 0 auto;
  }

  .kpi-container {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

/* Mobile (<=768px) */
@media (max-width: 768px) {
  :root {
    --header-height: 62px;
    --mobile-nav-height: 60px;
  }

  /* Layout */
  .container {
    padding: var(--space-3);
  }

  .card {
    border-radius: var(--radius-md);
    padding: var(--space-4);
    transition: none;
  }

  .card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }

  .grid {
    gap: var(--space-3);
  }

  .grid > * {
    grid-column: 1 / -1;
  }

  header {
    padding: 0.65rem 0.85rem;
  }

  .sidebar nav a {
    font-size: 0.92rem;
  }

  /* Performance mobile */
  .sidebar,
  .card,
  .button,
  .modal-content,
  .toast {
    will-change: auto;
  }

  .sidebar.open + .content::before,
  .sidebar.active + .content::before {
    backdrop-filter: none;
    background: rgba(15, 23, 42, 0.5);
  }

  /* Bottom navigation */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--mobile-nav-height) + var(--safe-area-inset));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    padding-bottom: var(--safe-area-inset);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .mobile-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--muted);
    font-size: 0.7rem;
    text-decoration: none;
    transition: color var(--transition-fast);
    min-height: var(--touch-target-min);
    touch-action: manipulation;
  }

  .mobile-bottom-nav-item.active {
    color: var(--primary);
  }

  .mobile-bottom-nav-item i,
  .mobile-bottom-nav-item svg {
    font-size: 1.4rem;
  }

  .content {
    padding-bottom: calc(var(--mobile-nav-height) + var(--safe-area-inset) + var(--space-3));
  }

  /* FAB */
  .fab-container {
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + var(--safe-area-inset) + var(--space-3));
    right: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    z-index: 950;
  }

  .fab-button {
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform var(--transition-fast), background var(--transition-fast);
    touch-action: manipulation;
  }

  .fab-button:hover {
    transform: scale(1.1);
    background: var(--primary-600);
  }

  .fab-button.secondary {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  /* KPI scrollable */
  .kpi-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    margin: 0 calc(-1 * var(--space-3));
    padding-left: var(--space-3);
    padding-right: var(--space-3);
    -webkit-overflow-scrolling: touch;
  }

  .kpi-card {
    flex: 0 0 220px;
    scroll-snap-align: start;
    min-width: 200px;
  }

  /* Sidebar */
  .sidebar:not(.open):not(.active) {
    transform: translateX(-100%);
  }

  /* Tableaux responsives */
  .table-responsive-mobile table,
  .table-responsive-mobile .table {
    display: block;
  }

  .table-responsive-mobile thead {
    display: none;
  }

  .table-responsive-mobile tr {
    display: block;
    margin-bottom: var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
  }

  .table-responsive-mobile td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    white-space: normal;
    text-align: right;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border);
  }

  .table-responsive-mobile td:last-child {
    border-bottom: none;
  }

  .table-responsive-mobile td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    text-align: left;
    padding-right: var(--space-3);
  }

  /* Formulaires */
  form .row {
    flex-direction: column;
    align-items: stretch;
  }

  .align-end-row {
    flex-direction: column;
    align-items: stretch;
  }

  /* Toasts */
  .toast-container {
    top: auto;
    bottom: 20px;
    right: 20px;
    left: 20px;
    width: auto;
    max-width: none;
  }

  .toast {
    animation: slideInUp var(--feedback-animation-duration) forwards;
  }

  .toast.hiding {
    animation: slideOutDown var(--feedback-animation-duration) forwards;
  }

  .confirmation-actions {
    flex-direction: column;
  }

  /* Hide desktop, show mobile */
  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: block;
  }

  .sidebar.open + .content {
    overflow: hidden;
    height: 100vh;
  }

  .table td,
  .table th {
    font-size: 0.75rem;
    padding: 0.5rem 0.4rem;
  }
}

/* TrÃ¨s petits Ã©crans (<=480px) */
@media (max-width: 480px) {
  :root {
    --header-height: 58px;
  }

  header h1 {
    font-size: 0.95rem;
  }

  .container {
    padding: var(--space-2);
  }

  .card {
    padding: var(--space-3);
    border-radius: 12px;
  }

  .button,
  .btn-primary,
  .btn-secondary {
    width: 100%;
    font-size: 0.9rem;
  }

  .toolbar {
    flex-direction: column;
  }

  .toolbar .button {
    width: 100%;
  }

  th,
  td {
    font-size: 0.8rem;
    padding: 0.56rem 0.5rem;
  }

  pre {
    font-size: 0.71rem;
  }

  .kpi-card {
    flex: 0 0 180px;
    min-width: 180px;
    padding: var(--space-3);
  }

  .kpi-value {
    font-size: 1.4rem;
  }
}

/* TrÃ¨s petits Ã©crans (<=360px) */
@media (max-width: 360px) {
  :root {
    --space-4: 0.75rem;
  }

  .card {
    padding: var(--space-3);
  }

  .kpi-card {
    flex: 0 0 160px;
    min-width: 160px;
    padding: var(--space-3);
  }

  .kpi-value {
    font-size: 1.2rem;
  }

  .button,
  .btn-primary,
  .btn-secondary {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
  }
}

/* Mode paysage sur mobile */
@media (max-width: 896px) and (orientation: landscape) {
  .mobile-bottom-nav {
    height: 50px;
  }

  .content {
    padding-bottom: calc(50px + var(--safe-area-inset) + var(--space-3));
  }

  .sidebar {
    padding-top: calc(var(--header-height) + var(--space-2));
  }

  .fab-container {
    bottom: calc(50px + var(--safe-area-inset) + var(--space-3));
  }
}

/* Gestion clavier ouvert sur mobile */
@media (max-height: 500px) {
  .mobile-bottom-nav {
    display: none;
  }
  
  .fab-container {
    bottom: var(--space-3);
  }
}

/* ===== DARK MODE ===== */
body.dark,
body.theme-dark {
  --bg: #0b1220;
  --surface: #111d32;
  --surface-soft: #152540;
  --text: #e2e8f0;
  --muted: #9fb3cf;
  --border: #2a3c58;
  --secondary: #2a3d5d;
  --secondary-text: #e2e8f0;
  --skeleton-base: #1e293b;
  --skeleton-highlight: #334155;
}

body.dark .sidebar,
body.theme-dark .sidebar {
  background: linear-gradient(185deg, #020617 0%, #0b1426 58%, #0b1220 100%);
}

body.dark input,
body.dark select,
body.dark textarea,
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #13233c;
  color: #f1f5f9;
  border-color: #2a3f60;
}

body.dark .notice,
body.theme-dark .notice {
  background: #10233d;
  border-color: #1f3b62;
  color: #bfdbfe;
}

body.dark thead,
body.theme-dark thead {
  background: #1a2d49;
}

body.dark .sidebar.open + .content::before,
body.theme-dark .sidebar.open + .content::before,
body.dark .sidebar.active + .content::before,
body.theme-dark .sidebar.active + .content::before {
  background: rgba(2, 6, 23, 0.5);
}

body.dark .skeleton-line,
body.dark .skeleton-circle,
body.dark .skeleton-kpi {
  --skeleton-base: #1e293b;
  --skeleton-highlight: #334155;
}

/* ===== ACCESSIBILITÃ‰ ===== */
.button:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.toast-close:focus-visible,
.alert-close:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .button:active,
  .btn-primary:active,
  .btn-secondary:active {
    transform: none;
  }
  
  .card,
  .button,
  .sidebar {
    transition: none;
  }
  
  .button.loading::after,
  .toast,
  .alert,
  .confirmation-overlay,
  .amount-change {
    animation: none !important;
  }
}




/* =============================================================
   TEMPLATE REFRESH: DASHBOARD (BANKING STYLE)
   Scoped to dashboard.html via body.dashboard-template
   ============================================================= */
body.dashboard-template {
  --bg: #070b17;
  --surface: rgba(16, 22, 40, 0.88);
  --surface-soft: rgba(20, 28, 50, 0.92);
  --text: #ecf1ff;
  --muted: #a9b4d2;
  --border: rgba(122, 147, 214, 0.24);
  --primary: #55a7ff;
  --primary-600: #3a90f2;
  --secondary: #151d33;
  --secondary-text: #d9e6ff;
  --danger: #ff6b6b;
  background:
    radial-gradient(1200px 600px at 12% -20%, rgba(255, 122, 61, 0.32), transparent 55%),
    radial-gradient(900px 540px at 95% 115%, rgba(79, 127, 255, 0.35), transparent 58%),
    linear-gradient(145deg, #060912 0%, #0a1020 45%, #070b17 100%);
  color: var(--text);
}

body.dashboard-template::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 300px at 80% 20%, rgba(92, 156, 255, 0.12), transparent 60%),
    radial-gradient(500px 300px at 20% 80%, rgba(255, 143, 90, 0.1), transparent 65%);
  z-index: -1;
}

.dashboard-template .app {
  max-width: 1360px;
  margin: 24px auto;
  min-height: calc(100vh - 48px);
  border: 1px solid rgba(124, 150, 218, 0.22);
  border-radius: 20px;
  overflow: hidden;
  background: rgba(6, 10, 20, 0.7);
  backdrop-filter: blur(8px);
  box-shadow: 0 24px 56px rgba(3, 8, 20, 0.65);
}

.dashboard-template .sidebar {
  background: linear-gradient(180deg, rgba(11, 16, 30, 0.95) 0%, rgba(8, 13, 26, 0.95) 100%);
  border-right: 1px solid rgba(122, 147, 214, 0.2);
}

.dashboard-template .brand {
  font-size: 1.55rem;
  letter-spacing: 0.02em;
  color: #f1f5ff;
}

.dashboard-template .sidebar nav a {
  color: #becaea;
  border: 1px solid transparent;
}

.dashboard-template .sidebar nav a:hover,
.dashboard-template .sidebar nav a:focus-visible {
  background: linear-gradient(90deg, rgba(88, 170, 255, 0.18), rgba(88, 170, 255, 0.06));
  border-color: rgba(88, 170, 255, 0.25);
  color: #f3f7ff;
  transform: translateX(0);
}

.dashboard-template header {
  background: rgba(7, 12, 24, 0.78);
  border-bottom: 1px solid rgba(122, 147, 214, 0.22);
  box-shadow: none;
  backdrop-filter: blur(10px);
}

.dashboard-template .header-title,
.dashboard-template header h1 {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.dashboard-template .container {
  max-width: 100%;
  padding: 18px;
}

.dashboard-template .grid {
  gap: 16px;
}

.dashboard-template .card {
  background:
    linear-gradient(155deg, rgba(23, 30, 54, 0.92), rgba(14, 20, 38, 0.9));
  border: 1px solid rgba(129, 156, 224, 0.22);
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(3, 9, 24, 0.42);
}

.dashboard-template .card:hover {
  border-color: rgba(102, 168, 255, 0.45);
  box-shadow: 0 14px 34px rgba(5, 12, 30, 0.58);
  transform: translateY(-1px);
}

.dashboard-template h2,
.dashboard-template h3,
.dashboard-template h4 {
  color: #f1f5ff;
}

.dashboard-template .muted,
.dashboard-template label,
.dashboard-template .notice,
.dashboard-template p,
.dashboard-template small {
  color: var(--muted);
}

.dashboard-template input,
.dashboard-template select,
.dashboard-template textarea,
.dashboard-template .input-field {
  background: rgba(10, 15, 29, 0.85);
  color: #f1f6ff;
  border-color: rgba(124, 150, 216, 0.3);
}

.dashboard-template input::placeholder,
.dashboard-template textarea::placeholder {
  color: #8f9cbd;
}

.dashboard-template input:focus,
.dashboard-template select:focus,
.dashboard-template textarea:focus,
.dashboard-template .input-field:focus {
  border-color: rgba(97, 174, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(85, 167, 255, 0.22);
}

.dashboard-template .button,
.dashboard-template .btn-primary {
  background: linear-gradient(135deg, #4a9cff 0%, #3588f0 100%);
  border-color: rgba(114, 182, 255, 0.45);
  color: #f8fbff;
}

.dashboard-template .button:hover,
.dashboard-template .btn-primary:hover {
  background: linear-gradient(135deg, #5aabff 0%, #4194fb 100%);
}

.dashboard-template .button.secondary,
.dashboard-template .btn-secondary {
  background: linear-gradient(140deg, rgba(29, 39, 67, 0.95), rgba(22, 31, 55, 0.95));
  border-color: rgba(126, 151, 214, 0.28);
  color: #dbe7ff;
}

.dashboard-template 
.button.success {
  background: #15803d;
  color: #ffffff;
  border-color: #166534;
}

.button.success:hover {
  background: #166534;
}

.dashboard-template .notice {
  border: 1px solid rgba(111, 156, 255, 0.24);
  background: rgba(32, 43, 76, 0.5);
  color: #c6d8ff;
}

.dashboard-template .table,
.dashboard-template table {
  border-color: rgba(126, 151, 214, 0.2);
  background: rgba(10, 14, 27, 0.5);
}

.dashboard-template th,
.dashboard-template td {
  border-bottom: 1px solid rgba(126, 151, 214, 0.14);
}

.dashboard-template thead {
  background: rgba(34, 46, 78, 0.55);
}

.dashboard-template tr:hover td {
  background: rgba(59, 88, 153, 0.18);
}

.dashboard-template pre {
  background: rgba(8, 12, 24, 0.76);
  border-color: rgba(126, 151, 214, 0.24);
  color: #dae7ff;
}

.dashboard-template .empty {
  color: #97a6c9;
}

@media (max-width: 768px) {
  .dashboard-template .app {
    margin: 0;
    border-radius: 0;
    border: none;
    min-height: 100vh;
  }

  .dashboard-template .container {
    padding: 14px;
  }

  .dashboard-template .card {
    border-radius: 14px;
  }
}

/* =============================================================
   ADMIN OVERVIEW DASHBOARD (Institutionnel)
   ============================================================= */
.admin-dashboard {
  order: -2;
  background: #ffffff;
  border: 1px solid #d9e2ef;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.admin-dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 12px;
  background: #0f2d5a;
  color: #ffffff;
}

.admin-dashboard-header h2 {
  margin: 0;
  color: #ffffff;
}

.admin-dashboard-header p {
  margin: 4px 0 0;
  color: #d7e4fb;
}

.admin-dashboard-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-dashboard-controls label {
  color: #d7e4fb;
  margin: 0;
}

.admin-dashboard-controls select {
  min-height: 40px;
  border: 1px solid #bfd0ea;
  background: #ffffff;
  color: #0f172a;
}

.admin-name {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #2e4f82;
  border-radius: 8px;
  background: #163765;
  color: #e9f1ff;
  display: flex;
  align-items: center;
  font-weight: 600;
}

.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.admin-kpi-card {
  background: #ffffff;
  border: 1px solid #d6dfec;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  padding: 14px;
}

.admin-kpi-card h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: #5b6f8d;
}

.admin-kpi-value {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  color: #0f2d5a;
}

.admin-kpi-card.warning .admin-kpi-value {
  color: #b45309;
}

.admin-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.admin-chart-card,
.admin-activity-card {
  background: #ffffff;
  border: 1px solid #d6dfec;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  padding: 14px;
}

.admin-chart-card h4,
.admin-activity-card h4 {
  margin: 0 0 10px;
  color: #1e3252;
}

#evolutionChart,
#groupChart {
  width: 100%;
  height: 220px;
  display: block;
}

@media (max-width: 768px) {
  .admin-dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-dashboard-controls {
    justify-content: space-between;
  }

  .admin-kpi-value {
    font-size: 1.3rem;
  }

  .admin-chart-grid {
    grid-template-columns: 1fr;
  }

  #evolutionChart,
  #groupChart {
    height: 200px;
  }
}

@media (max-width: 480px) {
  .admin-dashboard,
  .admin-kpi-card,
  .admin-chart-card,
  .admin-activity-card {
    border-radius: 10px;
  }

  .admin-dashboard-header {
    padding: 10px;
  }

  .admin-name {
    width: 100%;
  }
}

body.dark .admin-dashboard,
body.theme-dark .admin-dashboard,
body.dark .admin-kpi-card,
body.theme-dark .admin-kpi-card,
body.dark .admin-chart-card,
body.theme-dark .admin-chart-card,
body.dark .admin-activity-card,
body.theme-dark .admin-activity-card {
  background: #0f1b31;
  border-color: #2a3d5f;
}

body.dark .admin-dashboard-header,
body.theme-dark .admin-dashboard-header {
  background: #081428;
}

body.dark .admin-kpi-card h4,
body.theme-dark .admin-kpi-card h4,
body.dark .admin-chart-card h4,
body.theme-dark .admin-chart-card h4,
body.dark .admin-activity-card h4,
body.theme-dark .admin-activity-card h4 {
  color: #c5d6f5;
}

body.dark .admin-kpi-value,
body.theme-dark .admin-kpi-value {
  color: #8db8ff;
}

body.dark .admin-dashboard-controls select,
body.theme-dark .admin-dashboard-controls select {
  background: #142746;
  color: #e2e8f0;
  border-color: #2f486d;
}

body.dark .admin-name,
body.theme-dark .admin-name {
  background: #112745;
  border-color: #31527f;
  color: #dbe8ff;
}

/* ===== REPORT TABLE READABILITY ===== */
.report-output {
  margin-top: var(--space-3);
  width: 100%;
  max-width: 100%;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem;
  overflow: auto;
}

.report-output h4 {
  margin: 0.4rem 0 0.6rem;
  color: var(--text);
  font-size: 0.96rem;
}

.table,
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: var(--space-3);
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
}

thead,
tbody,
tr {
  width: 100%;
}

th,
td {
  white-space: normal;
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
  padding: 0.8rem 0.85rem;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

th {
  font-weight: 700;
  color: #0f172a;
}

thead {
  background: #edf3fb;
}

tbody tr:nth-child(even) td {
  background: #f9fbff;
}

tbody tr:hover td {
  background: #eef5ff;
}

body.dark .report-output,
body.theme-dark .report-output {
  background: #0f1b31;
  border-color: #2a3d5f;
  color: #e2e8f0;
}

body.dark th,
body.theme-dark th,
body.dark td,
body.theme-dark td {
  color: #e2e8f0;
  border-bottom-color: #2a3d5f;
}

body.dark thead,
body.theme-dark thead {
  background: #163053;
}

body.dark tbody tr:nth-child(even) td,
body.theme-dark tbody tr:nth-child(even) td {
  background: #12243f;
}

body.dark tbody tr:hover td,
body.theme-dark tbody tr:hover td {
  background: #1a3358;
}

@media (max-width: 768px) {
  th,
  td {
    font-size: 0.86rem;
    padding: 0.65rem 0.6rem;
  }
}
