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

:root {
  --bg: #0d0f14;
  --bg2: #141720;
  --bg3: #1c2030;
  --border: #252a3a;
  --text: #e8ecf4;
  --text2: #8892aa;
  --accent: #7c6aff;
  --accent2: #a395ff;
  --red: #ff5e6c;
  --orange: #ffad5e;
  --green: #5effa0;
  --teal: #4ECDC4;
  --pink: #FF6B6B;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --sidebar-w: 240px;
}

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.sidebar.hidden { transform: translateX(-100%); }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px 32px;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.5px;
}
.logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 900; color: #fff;
}

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { color: var(--text); background: var(--bg3); }
.nav-item.active { color: var(--accent2); background: rgba(124,106,255,0.12); }
.nav-item.active svg { fill: var(--accent); }

.sidebar-users {
  padding: 16px 12px 0;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 16px;
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
  font-size: 13px; font-weight: 500;
}
.user-chip:hover { background: var(--bg3); }
.user-chip.active-user { background: var(--bg3); outline: 1px solid var(--border); }
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
}

/* ===== MAIN ===== */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
}
.main-content.full-width { margin-left: 0; }

/* ===== TOPBAR ===== */
.topbar {
  position: sticky; top: 0;
  height: 64px;
  background: rgba(13,15,20,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.menu-btn, .add-btn {
  background: none; border: none; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  color: var(--text);
  transition: all 0.2s;
}
.menu-btn { padding: 8px; border-radius: 8px; }
.menu-btn:hover { background: var(--bg3); }
.menu-btn svg { width: 22px; height: 22px; fill: currentColor; }

.page-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 20px;
}

.date-badge {
  font-size: 13px;
  color: var(--text2);
  background: var(--bg3);
  padding: 6px 14px;
  border-radius: 20px;
}

.add-btn {
  background: var(--accent);
  padding: 8px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
}
.add-btn svg { width: 18px; height: 18px; fill: currentColor; }
.add-btn:hover { background: var(--accent2); transform: translateY(-1px); }

/* ===== PAGES ===== */
.page { display: none; }
.page.active { display: block; }
.page-inner { padding: 28px; max-width: 1200px; }

/* ===== CARDS GRID ===== */
.cards-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}
@media (max-width: 1100px) { .cards-grid { grid-template-columns: 1fr 1fr; } }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-big { padding: 28px; }
.card-accent { background: linear-gradient(135deg, #1a1f35 0%, #1c1440 100%); border-color: rgba(124,106,255,0.3); }

.card-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--text2); margin-bottom: 8px; font-weight: 600; }
.card-value { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.card-big .card-value { font-size: 36px; }
.card-sub { font-size: 12px; color: var(--text2); }
.card-red { color: var(--red); }
.card-orange { color: var(--orange); }
.card-green { color: var(--green); }

/* ===== PROFILES ROW ===== */
.profiles-row {
  display: flex; gap: 20px; align-items: center;
  margin-bottom: 32px;
}
.profile-card {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
}
.profile-header { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.profile-avatar { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; color: #fff; }
.profile-name { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 17px; }
.profile-role { font-size: 12px; color: var(--text2); }
.profile-total { margin-left: auto; font-family: 'Syne', sans-serif; font-weight: 800; font-size: 20px; }

.profile-bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text2); }
.bar-row > span:first-child { width: 60px; flex-shrink: 0; }
.bar-row > span:last-child { width: 50px; text-align: right; flex-shrink: 0; color: var(--text); font-weight: 600; font-size: 12px; }
.bar-track { flex: 1; height: 8px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }
.bar-fill.red { background: var(--red); }
.bar-fill.orange { background: var(--orange); }
.bar-fill.green { background: var(--green); }

.vs-divider {
  width: 40px; flex-shrink: 0;
  text-align: center;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 14px;
  color: var(--text2);
}

/* ===== SECTION TITLE ===== */
.section-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ===== ACTIVITY ===== */
.activity-list {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
}
.activity-item {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--bg3); }
.activity-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.activity-info { flex: 1; }
.activity-title { font-weight: 500; font-size: 14px; }
.activity-meta { font-size: 12px; color: var(--text2); }
.activity-amount { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 15px; }
.activity-amount.neg { color: var(--red); }
.activity-amount.pos { color: var(--green); }
.activity-user-badge {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
}

/* ===== CHART ===== */
.chart-container {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 32px;
}

/* ===== PAGE HEADER ROW ===== */
.page-header-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== INPUTS & SELECTS ===== */
.select-filter, .input-field, .input-color {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.select-filter:focus, .input-field:focus { border-color: var(--accent); }
.input-field { width: 100%; }
.input-color { width: 52px; height: 38px; padding: 4px; cursor: pointer; }

/* ===== DEPENSES SUMMARY ===== */
.depenses-summary {
  display: flex; gap: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.dep-sum-item { display: flex; flex-direction: column; gap: 2px; }
.dep-sum-item span { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }
.dep-sum-item strong { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 700; }

/* ===== TABLE ===== */
.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text2); font-weight: 600;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 13px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-cat { background: rgba(124,106,255,0.15); color: var(--accent2); }
.badge-active { background: rgba(94,255,160,0.12); color: var(--green); }
.badge-done { background: rgba(136,146,170,0.15); color: var(--text2); }

.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--text2); padding: 6px; border-radius: 6px;
  transition: all 0.15s; font-size: 15px;
}
.btn-icon:hover { color: var(--red); background: rgba(255,94,108,0.1); }
.btn-icon.edit:hover { color: var(--accent2); background: rgba(124,106,255,0.1); }

/* ===== DETTES OVERVIEW ===== */
.dettes-overview {
  display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.dette-overview-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 18px;
  flex: 1; min-width: 160px;
}
.dette-ov-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.dette-ov-val { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 800; }

/* ===== PREVISION TABS ===== */
.prev-tabs {
  display: flex; gap: 8px; margin-bottom: 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  width: fit-content;
}
.prev-tab {
  background: none; border: none; cursor: pointer;
  color: var(--text2); padding: 9px 20px;
  border-radius: 8px; font-family: 'DM Sans', sans-serif;
  font-size: 14px; font-weight: 600;
  transition: all 0.2s;
}
.prev-tab:hover { color: var(--text); background: var(--bg3); }
.prev-tab.active { background: var(--accent); color: #fff; }

.prev-view { display: none; }
.prev-view.active { display: block; }

/* ===== PREVISION KPIs ===== */
.prev-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.prev-kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}
.prev-kpi-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.prev-kpi-val { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 800; }
.prev-kpi-sub { font-size: 11px; color: var(--text2); margin-top: 4px; }

/* ===== PREVISIONS ===== */
.prevision-config {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.config-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.config-card label { font-size: 12px; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

.prevision-table {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  margin-top: 20px;
}

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.stat-card.full { grid-column: 1 / -1; }
.stat-title {
  font-family: 'Syne', sans-serif; font-weight: 700; font-size: 14px;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text2); margin-bottom: 20px;
}

/* ===== PROFILS ===== */
.profils-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  margin-bottom: 32px;
}
.profil-edit-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.profil-avatar-big {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 32px; color: #fff;
  transition: background 0.3s;
}
.profil-edit-fields { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 12px; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

.profil-stats-mini {
  width: 100%;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex; flex-direction: column; gap: 6px;
}

.danger-zone {
  background: rgba(255,68,68,0.05);
  border: 1px solid rgba(255,68,68,0.2);
  border-radius: var(--radius);
  padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--accent);
  color: #fff; border: none; cursor: pointer;
  padding: 10px 20px; border-radius: 10px;
  font-weight: 600; font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s; white-space: nowrap;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }

.btn-danger {
  background: rgba(255,68,68,0.1);
  color: #ff4444; border: 1px solid rgba(255,68,68,0.3);
  cursor: pointer; padding: 10px 20px; border-radius: 10px;
  font-weight: 600; font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s; width: fit-content;
}
.btn-danger:hover { background: rgba(255,68,68,0.2); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -60%) scale(0.95);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: min(520px, 94vw);
  z-index: 300;
  opacity: 0; pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.modal.open {
  opacity: 1; pointer-events: all;
  transform: translate(-50%, -50%) scale(1);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700; font-size: 18px;
}
.modal-close {
  background: var(--bg3); border: none; cursor: pointer;
  color: var(--text2); width: 30px; height: 30px;
  border-radius: 50%; font-size: 14px; transition: all 0.2s;
}
.modal-close:hover { color: var(--text); background: var(--border); }
.modal-body { padding: 26px; display: flex; flex-direction: column; gap: 16px; }

/* FORM inside modal */
.form-row { display: flex; gap: 12px; }
.form-row .field-group { flex: 1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.btn-secondary {
  background: var(--bg3); color: var(--text2); border: 1px solid var(--border);
  cursor: pointer; padding: 10px 20px; border-radius: 10px;
  font-weight: 600; font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
}
.btn-secondary:hover { color: var(--text); }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 14px; font-weight: 500;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 999;
  max-width: 300px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: rgba(94,255,160,0.3); color: var(--green); }
.toast.error { border-color: rgba(255,94,108,0.3); color: var(--red); }

/* ===== EMPTY STATE ===== */
.empty-state {
  padding: 40px; text-align: center;
  color: var(--text2); font-size: 14px;
}

/* ===== PROGRESS ===== */
.progress-bar-wrap { margin-top: 8px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.progress-track { height: 6px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 0.6s; }

/* ===== DETTE REMBOURSER ===== */
.dette-payment-row {
  display: flex; gap: 8px; align-items: center;
}
.dette-payment-row input { flex: 1; }

/* ===== TOP EXPENSES ===== */
.top-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.top-item:last-child { border-bottom: none; }
.top-rank { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 18px; color: var(--border); width: 24px; }
.top-info { flex: 1; }
.top-desc { font-weight: 500; }
.top-meta { color: var(--text2); font-size: 11px; }
.top-amount { font-family: 'Syne', sans-serif; font-weight: 700; color: var(--red); }

/* ===== BALANCE DETAIL ===== */
.balance-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.balance-row:last-child { border-bottom: none; }
.balance-label { color: var(--text2); }
.balance-val { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 16px; }

/* ===== PREVISION TABLE ===== */
.prev-table { width: 100%; border-collapse: collapse; }
.prev-table th {
  padding: 12px 16px; background: var(--bg3);
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text2); font-weight: 600; text-align: left;
  border-bottom: 1px solid var(--border);
}
.prev-table td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.prev-table tr:last-child td { border-bottom: none; }

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); --sidebar-w: 240px; }
  .sidebar.visible { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .cards-grid { grid-template-columns: 1fr 1fr; }
  .profiles-row { flex-direction: column; }
  .vs-divider { transform: rotate(90deg); }
  .stats-grid { grid-template-columns: 1fr; }
  .profils-grid { grid-template-columns: 1fr; }
}
