/* =============================================================
   PLATEFORME DE GESTION DES ACTIVITÉS CULTURELLES - MAURITANIE
   Système de Design CSS — Version 1.0
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Playfair+Display:wght@600;700&family=Amiri:wght@400;700&family=Noto+Sans+Arabic:wght@300;400;500;600;700&display=swap');

/* ==================== CSS VARIABLES ==================== */
:root {
  /* Primary – Vert mauritanien */
  --color-primary:       #1B5E35;
  --color-primary-700:   #1A5430;
  --color-primary-600:   #1F6E3C;
  --color-primary-500:   #267A49;
  --color-primary-400:   #2D9158;
  --color-primary-300:   #4CAF78;
  --color-primary-200:   #A3D9B8;
  --color-primary-100:   #E8F5EE;
  --color-primary-50:    #F2FAF5;

  /* Accent – Or */
  --color-accent:        #C8922A;
  --color-accent-700:    #A0731F;
  --color-accent-600:    #B08025;
  --color-accent-500:    #D4A030;
  --color-accent-400:    #DDB040;
  --color-accent-300:    #E8C060;
  --color-accent-200:    #F3DC9B;
  --color-accent-100:    #FBF4D9;
  --color-accent-50:     #FEFBF0;

  /* Neutrals */
  --color-bg:            #F5F4F0;
  --color-bg-2:          #EDEBE4;
  --color-surface:       #FFFFFF;
  --color-surface-2:     #F9F8F5;
  --color-border:        #DDD8CC;
  --color-border-light:  #EDEAE3;

  /* Text */
  --color-text:          #1A1A2E;
  --color-text-secondary:#4A4A5A;
  --color-text-muted:    #8A8A9A;

  /* Status */
  --color-success:       #16A34A;
  --color-success-bg:    #F0FDF4;
  --color-warning:       #D97706;
  --color-warning-bg:    #FFFBEB;
  --color-danger:        #DC2626;
  --color-danger-bg:     #FEF2F2;
  --color-info:          #2563EB;
  --color-info-bg:       #EFF6FF;

  /* Spacing scale */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;

  /* Radius */
  --r-sm:  4px;
  --r-md:  8px;
  --r-lg:  12px;
  --r-xl:  16px;
  --r-2xl: 24px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.10), 0 4px 10px rgba(0,0,0,0.06);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.12);

  /* Typography */
  --font-base:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-arabic:  'Noto Sans Arabic', sans-serif;
  --font-arabic-display: 'Amiri', serif;

  /* Layout */
  --nav-height: 68px;
  --container-max: 1200px;

  /* Transitions */
  --t: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== RTL & LOGICAL PROPS ==================== */
[dir="rtl"] {
  text-align: right;
}

[dir="rtl"] .ml-auto { margin-right: auto; margin-left: 0; }
[dir="rtl"] .mr-auto { margin-left: auto; margin-right: 0; }

/* Use logical properties for newer components */
.ms-auto { margin-inline-start: auto; }
.me-auto { margin-inline-end: auto; }

[dir="rtl"] .nav-brand { flex-direction: row-reverse; }
[dir="rtl"] .stat-card-icon { margin-left: 0; margin-right: 0; margin-bottom: var(--sp-4); }
[dir="rtl"] .badge::before { margin-left: 4px; margin-right: 0; }
[dir="rtl"] .table th, [dir="rtl"] .table td { text-align: right; }
[dir="rtl"] .modal-header { flex-direction: row-reverse; }
[dir="rtl"] .modal-footer { flex-direction: row-reverse; }

/* ==================== RESET & BASE ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

[dir="rtl"] {
  font-family: var(--font-arabic);
}

[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] .font-display {
  font-family: var(--font-arabic-display);
}

body {
  font-family: var(--font-base);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
ul { list-style: none; }

/* ==================== LAYOUT ==================== */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

.container-narrow {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

.page-wrapper { min-height: 100vh; display: flex; flex-direction: column; }
.page-content { flex: 1; padding-top: var(--nav-height); }
.section { padding: var(--sp-16) 0; }
.section-sm { padding: var(--sp-10) 0; }

/* ==================== NAVIGATION ==================== */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--color-primary);
  z-index: 1000;
  box-shadow: 0 2px 20px rgba(0,0,0,0.18);
}

.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo {
  width: 42px; height: 42px;
  background: var(--color-accent);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 800;
  color: white;
  flex-shrink: 0;
  letter-spacing: -0.5px;
  box-shadow: 0 2px 8px rgba(200,146,42,0.4);
}

.nav-brand-text { display: flex; flex-direction: column; }

.nav-brand-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: white;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.nav-brand-sub {
  font-size: 0.68rem;
  color: var(--color-primary-300);
  font-weight: 400;
  line-height: 1.2;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  color: rgba(255,255,255,0.80);
  border-radius: var(--r-md);
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--t);
  white-space: nowrap;
  text-decoration: none;
}

.nav-link:hover { background: rgba(255,255,255,0.12); color: white; }
.nav-link.active { background: rgba(255,255,255,0.16); color: white; font-weight: 600; }

/* Language Switcher */
.lang-switcher {
  display: flex;
  gap: 4px;
  background: rgba(0,0,0,0.2);
  padding: 4px;
  border-radius: var(--r-md);
  margin-left: var(--sp-4);
  align-items: center;
}

.btn-lang {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  padding: 4px 10px;
  border-radius: var(--r-md);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--t);
  line-height: 1;
}

.btn-lang:hover { color: white; background: rgba(255,255,255,0.1); }
.btn-lang.active { background: var(--color-accent) !important; color: white !important; }

[dir="rtl"] .lang-switcher { margin-left: 0; margin-right: var(--sp-4); }

.nav-cta {
  background: var(--color-accent) !important;
  color: white !important;
  padding: var(--sp-2) var(--sp-5) !important;
  font-weight: 600 !important;
}

.nav-cta:hover {
  background: var(--color-accent-600) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(200,146,42,0.45) !important;
}

.nav-menu-toggle {
  display: none;
  background: none; border: none;
  color: white; font-size: 1.4rem;
  cursor: pointer;
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  transition: var(--t);
}

.nav-menu-toggle:hover { background: rgba(255,255,255,0.12); }

/* ==================== PAGE HEADER ==================== */
.page-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-700) 100%);
  padding: var(--sp-12) 0;
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 340px; height: 340px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  pointer-events: none;
}

.page-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent-300), var(--color-accent));
}

.page-header-content { position: relative; z-index: 1; }

.page-header-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: rgba(255,255,255,0.12);
  color: var(--color-accent-300);
  padding: 4px var(--sp-4);
  border-radius: var(--r-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--sp-4);
  border: 1px solid rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  color: white;
  margin-bottom: var(--sp-3);
  font-weight: 700;
  line-height: 1.25;
}

.page-header p {
  color: rgba(255,255,255,0.68);
  font-size: 0.95rem;
  max-width: 520px;
}

.page-header-actions {
  margin-top: var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* ==================== CARDS ==================== */
.card {
  background: var(--color-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
}

.card-header {
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.card-title-icon {
  width: 32px; height: 32px;
  background: var(--color-primary-100);
  color: var(--color-primary);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.card-body { padding: var(--sp-6); }

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--t);
  border: 1.5px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.01em;
  line-height: 1.4;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-primary { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-600); transform: translateY(-1px); box-shadow: 0 4px 15px rgba(27,94,53,0.3); }

.btn-accent { background: var(--color-accent); color: white; border-color: var(--color-accent); }
.btn-accent:hover:not(:disabled) { background: var(--color-accent-700); transform: translateY(-1px); box-shadow: 0 4px 15px rgba(200,146,42,0.35); }

.btn-outline { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover:not(:disabled) { background: var(--color-primary-50); transform: translateY(-1px); }

.btn-ghost { background: transparent; color: var(--color-text-secondary); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--color-bg-2); color: var(--color-text); }

.btn-danger-outline { background: transparent; color: var(--color-danger); border-color: var(--color-danger); }
.btn-danger-outline:hover:not(:disabled) { background: var(--color-danger-bg); }

.btn-white { background: white; color: var(--color-primary); border-color: white; }
.btn-white:hover:not(:disabled) { background: rgba(255,255,255,0.9); transform: translateY(-1px); }

.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: 0.8rem; gap: 4px; border-radius: var(--r-sm); }
.btn-lg { padding: var(--sp-4) var(--sp-8); font-size: 0.95rem; border-radius: var(--r-lg); }
.btn-xl { padding: var(--sp-5) var(--sp-10); font-size: 1rem; border-radius: var(--r-lg); font-weight: 700; }

.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--r-md); }

/* ==================== FORMS ==================== */
.form-group { margin-bottom: var(--sp-5); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--sp-5);
}

.form-label {
  display: block;
  margin-bottom: var(--sp-2);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  letter-spacing: 0.01em;
}

.form-label.required::after { content: ' *'; color: var(--color-danger); }

.form-control {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 0.94rem;
  color: var(--color-text);
  background-color: var(--color-surface);
  transition: var(--t);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27,94,53,0.1);
}

.form-control.error {
  border-color: var(--color-danger);
  background-color: var(--color-danger-bg);
}

.form-control.is-valid {
  border-color: var(--color-success);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2316A34A' 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: 18px;
  padding-right: 42px;
}

[dir="rtl"] .form-control.is-valid {
  background-position: left 12px center;
  padding-right: var(--sp-4);
  padding-left: 42px;
}

.form-control::placeholder { color: var(--color-text-muted); }

textarea.form-control { resize: vertical; min-height: 100px; line-height: 1.6; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B6B7B' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: var(--sp-10);
  cursor: pointer;
}

.form-text { font-size: 0.77rem; color: var(--color-text-muted); margin-top: var(--sp-1); }

.form-error {
  font-size: 0.77rem; color: var(--color-danger); margin-top: var(--sp-1);
  display: none; align-items: center; gap: 4px;
}
.form-error.visible { display: flex; }

.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-xl);
  padding: var(--sp-8);
  margin-bottom: var(--sp-6);
  box-shadow: var(--shadow-sm);
}

.form-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-4);
  border-bottom: 2px solid var(--color-primary-100);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.form-section-num {
  width: 28px; height: 28px;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
  flex-shrink: 0;
}

.form-check {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.form-check input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
  border-radius: 4px;
}

/* Inline radio group */
.radio-group {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.radio-card {
  flex: 1;
  min-width: 120px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  cursor: pointer;
  transition: var(--t);
  text-align: center;
  background: var(--color-surface);
}

.radio-card:hover { border-color: var(--color-primary-300); }
.radio-card.selected { border-color: var(--color-primary); background: var(--color-primary-50); }
.radio-card input { display: none; }
.radio-card-icon { font-size: 1.5rem; margin-bottom: var(--sp-2); }
.radio-card-label { font-size: 0.8rem; font-weight: 600; color: var(--color-text-secondary); }
.radio-card.selected .radio-card-label { color: var(--color-primary); }

/* ==================== BADGES ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px var(--sp-3);
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; flex-shrink: 0; }

.badge-success { background: var(--color-success-bg); color: #15803d; border: 1px solid rgba(22,163,74,0.2); }
.badge-warning { background: var(--color-warning-bg); color: #b45309; border: 1px solid rgba(217,119,6,0.2); }
.badge-danger  { background: var(--color-danger-bg);  color: #b91c1c; border: 1px solid rgba(220,38,38,0.2); }
.badge-info    { background: var(--color-info-bg);    color: #1d4ed8; border: 1px solid rgba(37,99,235,0.2); }
.badge-neutral { background: var(--color-bg-2);       color: var(--color-text-secondary); border: 1px solid var(--color-border); }

/* ==================== TABLES ==================== */
.table-wrapper { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  padding: var(--sp-3) var(--sp-5);
  background: var(--color-surface-2);
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
  white-space: nowrap;
}

.table td {
  padding: var(--sp-4) var(--sp-5);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: var(--t); }
.table tbody tr:hover { background: var(--color-bg); }

/* ==================== KPI / STAT CARDS ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-5);
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  border: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: var(--t);
}

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

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-accent, var(--color-primary));
}

.stat-card-icon {
  width: 48px; height: 48px;
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  margin-bottom: var(--sp-4);
  background: var(--icon-bg, var(--color-primary-100));
}

.stat-value { font-size: 2.2rem; font-weight: 800; line-height: 1; margin-bottom: var(--sp-1); }
.stat-label { font-size: 0.8rem; color: var(--color-text-muted); font-weight: 500; }
.stat-change {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 0.73rem; font-weight: 600; margin-top: var(--sp-2);
}
.stat-change.up   { color: var(--color-success); }
.stat-change.down { color: var(--color-danger); }

/* ==================== EMPTY STATE ==================== */
.empty-state {
  text-align: center;
  padding: var(--sp-20) var(--sp-6);
}
.empty-state-icon { font-size: 4rem; margin-bottom: var(--sp-4); opacity: 0.35; }
.empty-state h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: var(--sp-2); }
.empty-state p { color: var(--color-text-muted); font-size: 0.9rem; max-width: 360px; margin: 0 auto var(--sp-6); }

/* ==================== ALERTS ==================== */
.alert {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-lg);
  font-size: 0.875rem;
  margin-bottom: var(--sp-5);
  border: 1px solid transparent;
}

.alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--color-success-bg); color: #15803d; border-color: rgba(22,163,74,0.2); }
.alert-warning { background: var(--color-warning-bg); color: #92400e; border-color: rgba(217,119,6,0.2); }
.alert-danger  { background: var(--color-danger-bg);  color: #991b1b; border-color: rgba(220,38,38,0.2); }
.alert-info    { background: var(--color-info-bg);    color: #1e40af; border-color: rgba(37,99,235,0.2); }

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000; padding: var(--sp-4);
  backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden;
  transition: var(--t-slow);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: var(--color-surface);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xl);
  max-width: 640px; width: 100%;
  max-height: 92vh; overflow-y: auto;
  transform: scale(0.96) translateY(10px);
  transition: var(--t-slow);
}

.modal-overlay.active .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: var(--sp-6);
  border-bottom: 1px solid var(--color-border-light);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--color-surface); z-index: 1;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
}

.modal-header h2 { font-size: 1.05rem; font-weight: 700; }

.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.3rem; color: var(--color-text-muted);
  border-radius: var(--r-md);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--t);
}

.modal-close:hover { background: var(--color-bg-2); color: var(--color-text); }
.modal-body { padding: var(--sp-6); }
.modal-footer {
  padding: var(--sp-5) var(--sp-6);
  border-top: 1px solid var(--color-border-light);
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3);
}

/* ==================== TOAST ==================== */
.toast-container {
  position: fixed;
  bottom: var(--sp-6); right: var(--sp-6);
  z-index: 3000;
  display: flex; flex-direction: column; gap: var(--sp-3);
  pointer-events: none;
}

.toast {
  background: #1A1A2E;
  color: white;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-lg);
  font-size: 0.875rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: var(--sp-3);
  pointer-events: all;
  min-width: 280px; max-width: 420px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  border-left: 4px solid var(--color-accent);
}

.toast.toast-success { border-left-color: var(--color-success); }
.toast.toast-error   { border-left-color: var(--color-danger); }
.toast.toast-warning { border-left-color: var(--color-warning); }
.toast.hiding { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn  { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(110%); opacity: 0; } }

/* ==================== STEP WIZARD ==================== */
.steps-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--sp-8);
  position: relative;
}

.steps-bar::before {
  content: '';
  position: absolute;
  top: 18px; left: 10%; right: 10%;
  height: 2px;
  background: var(--color-border);
  z-index: 0;
}

.step-item {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  flex: 1; position: relative; z-index: 1;
}

.step-dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  transition: var(--t-slow);
}

.step-item.active .step-dot {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: white;
  box-shadow: 0 0 0 4px rgba(27,94,53,0.15);
}

.step-item.done .step-dot {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: white;
}

.step-item.done .step-dot::after { content: '✓'; }
.step-item.active .step-dot > span { display: inline; }

.step-text { font-size: 0.72rem; font-weight: 500; color: var(--color-text-muted); text-align: center; line-height: 1.3; }
.step-item.active .step-text { color: var(--color-primary); font-weight: 600; }
.step-item.done  .step-text { color: var(--color-primary); }

.form-step { display: none; animation: fadeUp 0.3s ease; }
.form-step.active { display: block; }

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

/* ==================== ADMIN LAYOUT ==================== */
.admin-layout { display: flex; min-height: calc(100vh - var(--nav-height)); }

.sidebar {
  width: 260px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border-light);
  padding: var(--sp-6) 0;
  flex-shrink: 0;
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
}

.sidebar-section { padding: 0 var(--sp-4); margin-bottom: var(--sp-6); }

.sidebar-label {
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--color-text-muted);
  padding: 0 var(--sp-3); margin-bottom: var(--sp-2);
}

.sidebar-nav { list-style: none; }

.sidebar-nav li a {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--r-lg);
  color: var(--color-text-secondary);
  font-size: 0.875rem; font-weight: 500;
  transition: var(--t);
}

.sidebar-nav li a:hover { background: var(--color-bg); color: var(--color-text); }
.sidebar-nav li.active a { background: var(--color-primary-100); color: var(--color-primary); font-weight: 600; }

.sidebar-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-count {
  margin-left: auto;
  background: var(--color-accent-100);
  color: var(--color-accent-700);
  border-radius: var(--r-full);
  padding: 2px 8px;
  font-size: 0.7rem; font-weight: 700;
}

.admin-main {
  flex: 1;
  padding: var(--sp-8);
  min-width: 0;
  overflow-x: hidden;
}

/* ==================== CHARTS ==================== */
.chart-container { position: relative; height: 280px; }
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--sp-5); }

/* ==================== ACTIVITY CARD (list view) ==================== */
.activity-list { display: flex; flex-direction: column; gap: var(--sp-4); }

.activity-card {
  background: var(--color-surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-xs);
  padding: var(--sp-5) var(--sp-6);
  display: flex; align-items: flex-start; gap: var(--sp-4);
  transition: var(--t);
}

.activity-card:hover { border-color: var(--color-primary-300); box-shadow: var(--shadow-sm); transform: translateY(-2px); }

.activity-card-icon {
  width: 48px; height: 48px;
  border-radius: var(--r-lg);
  background: var(--color-primary-100);
  color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}

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

.activity-card-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-2);
  flex-wrap: wrap;
}

.activity-card-title { font-size: 0.95rem; font-weight: 700; color: var(--color-text); margin-bottom: var(--sp-1); }
.activity-card-ref { font-size: 0.72rem; color: var(--color-text-muted); font-weight: 500; font-family: monospace; }

.activity-meta {
  display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
  font-size: 0.8rem; color: var(--color-text-muted); margin-top: var(--sp-2);
}

.activity-meta-item { display: flex; align-items: center; gap: 4px; }

.activity-card-actions { margin-top: var(--sp-4); display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ==================== SEARCH / FILTER BAR ==================== */
.filter-bar {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-xl);
  padding: var(--sp-4) var(--sp-5);
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
  box-shadow: var(--shadow-xs);
}

.search-wrapper {
  display: flex; align-items: center; gap: var(--sp-2);
  flex: 1; min-width: 180px;
}

.search-wrapper input {
  border: none; background: none; outline: none;
  font-size: 0.9rem; color: var(--color-text); width: 100%;
}

.search-wrapper input::placeholder { color: var(--color-text-muted); }
.search-icon { color: var(--color-text-muted); font-size: 1rem; flex-shrink: 0; }

.filter-divider { width: 1px; height: 24px; background: var(--color-border); }

.filter-select {
  border: none; background: none; outline: none;
  font-size: 0.85rem; color: var(--color-text-secondary);
  cursor: pointer;
}

/* ==================== DETAIL TABLE ==================== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4) var(--sp-6);
}

.detail-item-label {
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.detail-item-value {
  font-size: 0.9rem; font-weight: 500;
  color: var(--color-text);
}

/* ==================== FOOTER ==================== */
.footer {
  background: var(--color-primary);
  color: rgba(255,255,255,0.65);
  padding: var(--sp-8) 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-6);
  flex-wrap: wrap;
}

.footer-brand { display: flex; align-items: center; gap: var(--sp-3); }
.footer-brand-name { font-size: 0.85rem; font-weight: 700; color: white; }
.footer-copy { font-size: 0.75rem; color: rgba(255,255,255,0.45); margin-top: 2px; }
.footer-links { display: flex; gap: var(--sp-5); }
.footer-links a { font-size: 0.8rem; color: rgba(255,255,255,0.55); transition: var(--t); }
.footer-links a:hover { color: var(--color-accent-300); }

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn     { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInL   { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulse      { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin       { to { transform: rotate(360deg); } }

.animate-in { animation: fadeIn 0.4s cubic-bezier(0.16,1,0.3,1) both; }
.animate-in-1 { animation: fadeIn 0.4s 0.05s cubic-bezier(0.16,1,0.3,1) both; }
.animate-in-2 { animation: fadeIn 0.4s 0.1s  cubic-bezier(0.16,1,0.3,1) both; }
.animate-in-3 { animation: fadeIn 0.4s 0.15s cubic-bezier(0.16,1,0.3,1) both; }
.animate-in-4 { animation: fadeIn 0.4s 0.2s  cubic-bezier(0.16,1,0.3,1) both; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ==================== UTILITIES ==================== */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.text-accent  { color: var(--color-accent); }
.text-sm      { font-size: 0.875rem; }
.text-xs      { font-size: 0.75rem; }
.font-bold    { font-weight: 700; }
.flex         { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: var(--sp-2); }
.gap-3  { gap: var(--sp-3); }
.gap-4  { gap: var(--sp-4); }
.mt-2   { margin-top: var(--sp-2); }
.mt-4   { margin-top: var(--sp-4); }
.mt-6   { margin-top: var(--sp-6); }
.mb-4   { margin-bottom: var(--sp-4); }
.mb-6   { margin-bottom: var(--sp-6); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--color-border-light); margin: var(--sp-6) 0; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
  .sidebar { width: 220px; }
  .admin-main { padding: var(--sp-6); }
}

@media (max-width: 768px) {
  :root { --nav-height: 60px; }

  .container { padding: 0 var(--sp-4); }

  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-height); left: 0; right: 0;
    background: var(--color-primary-700);
    flex-direction: column;
    padding: var(--sp-4);
    gap: var(--sp-1);
    border-top: 1px solid rgba(255,255,255,0.1);
    box-shadow: var(--shadow-lg);
  }

  .nav-links.open { display: flex; }
  .nav-menu-toggle { display: flex; }

  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  .sidebar { display: none; }
  .admin-main { padding: var(--sp-4); }
  .charts-grid { grid-template-columns: 1fr; }

  .section { padding: var(--sp-10) 0; }
  .page-header { padding: var(--sp-8) 0; }

  .footer-inner { flex-direction: column; align-items: flex-start; }

  .toast-container { left: var(--sp-4); right: var(--sp-4); bottom: var(--sp-4); }
  .toast { min-width: unset; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .detail-grid { grid-template-columns: 1fr; }

  .steps-bar::before { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .activity-card { flex-direction: column; }
  .modal { border-radius: var(--r-lg); }
}

@media print {
  .nav, .footer, .btn, .filter-bar, .no-print { display: none !important; }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
