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

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
  width: 40px; height: 40px;
  border: 3px solid #e5e7eb;
  border-top-color: #059669;
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  transform: translateX(-100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.sidebar.open { transform: translateX(0); }

@media (min-width: 1024px) {
  .sidebar { transform: translateX(0); }
}

.sidebar-overlay { transition: opacity .25s ease; }

/* ============================================================
   NAVIGATION ITEMS
   ============================================================ */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 500;
  color: #9ca3af;
  text-decoration: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover  { background: rgba(255,255,255,.08); color: #e5e7eb; }
.nav-item.active { background: #059669; color: #fff; }
.nav-icon { font-size: 1rem; flex-shrink: 0; }

/* Mobile bottom nav */
.mob-nav {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 7px 4px 5px;
  color: #9ca3af;
  text-decoration: none;
  transition: color .15s;
  min-width: 0;
}
.mob-nav.active { color: #059669; }
.mob-nav-icon { font-size: 1.25rem; line-height: 1; }
.mob-nav-label { font-size: .625rem; margin-top: 3px; font-weight: 500; white-space: nowrap; }

/* ============================================================
   CARDS
   ============================================================ */
.kpi-card {
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 9999px;
  font-size: .72rem; font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-gray   { background: #f3f4f6; color: #374151; }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.label {
  display: block;
  font-size: .8rem; font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}

.form-input {
  display: block; width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  font-size: .875rem;
  color: #111827;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  font-family: inherit;
}
.form-input::placeholder { color: #9ca3af; }
.form-input:focus {
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(5,150,105,.12);
}
textarea.form-input { resize: vertical; }
select.form-input { cursor: pointer; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #059669; color: #fff;
  font-size: .875rem; font-weight: 600;
  padding: 9px 18px; border-radius: 10px; border: none;
  cursor: pointer; transition: background .15s, transform .1s;
  font-family: inherit;
}
.btn-primary:hover   { background: #047857; }
.btn-primary:active  { transform: scale(.98); }

.btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #fff; color: #374151;
  font-size: .875rem; font-weight: 600;
  padding: 9px 18px; border-radius: 10px;
  border: 1.5px solid #e5e7eb;
  cursor: pointer; transition: border-color .15s, background .15s;
  font-family: inherit;
}
.btn-outline:hover  { background: #f9fafb; border-color: #d1d5db; }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #ef4444; color: #fff;
  font-size: .875rem; font-weight: 600;
  padding: 9px 18px; border-radius: 10px; border: none;
  cursor: pointer; transition: background .15s;
  font-family: inherit;
}
.btn-danger:hover { background: #dc2626; }

/* ============================================================
   TABLES
   ============================================================ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 12px; text-align: left;
  font-size: .73rem; font-weight: 700; letter-spacing: .03em;
  color: #6b7280; text-transform: uppercase;
  background: #f9fafb;
  border-bottom: 1px solid #f3f4f6;
}
.data-table td {
  padding: 11px 12px;
  font-size: .84rem;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafafa; }

/* ============================================================
   TOASTS
   ============================================================ */
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 12px;
  font-size: .85rem; font-weight: 500;
  color: #fff; max-width: 320px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  animation: slideIn .25s ease forwards;
  transition: opacity .3s ease, transform .3s ease;
}
.toast-icon { font-size: 1rem; flex-shrink: 0; }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast-success { background: #059669; }
.toast-error   { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info    { background: #2563eb; }

/* ============================================================
   TYPE SELECTOR (new transaction form)
   ============================================================ */
.type-btn {
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  background: none;
  font-family: inherit;
}
.type-btn:hover  { transform: scale(1.04); }
.type-btn.selected { border-color: #059669 !important; box-shadow: 0 0 0 3px rgba(5,150,105,.15); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 3rem 1rem; color: #9ca3af;
}
.empty-state-icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state-text { font-size: .875rem; }

/* ============================================================
   SECTION CARD
   ============================================================ */
.section-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* ============================================================
   MISC
   ============================================================ */
.mono { font-family: ui-monospace, SFMono-Regular, monospace; }
.truncate-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Smooth page transition */
#app { animation: fadeUp .2s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   DIALOGS STYLÉS (remplace confirm / prompt / alert natifs)
   ============================================================ */
.cdlg-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: cdlgFadeIn .15s ease;
}
@keyframes cdlgFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.cdlg {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,.22), 0 4px 16px rgba(0,0,0,.1);
  width: 100%; max-width: 420px;
  animation: cdlgSlideUp .22s cubic-bezier(.34,1.46,.64,1);
  overflow: hidden;
  transition: opacity .15s, transform .15s;
}
@keyframes cdlgSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(.95); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

.cdlg-header {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid #f3f4f6;
}
.cdlg-icon {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
}
.cdlg-icon-primary { background: #d1fae5; }
.cdlg-icon-danger  { background: #fee2e2; }
.cdlg-icon-warning { background: #fef3c7; }
.cdlg-icon-info    { background: #dbeafe; }
.cdlg-icon-purple  { background: #ede9fe; }

.cdlg-title {
  font-size: 1rem; font-weight: 700; color: #111827; line-height: 1.3;
}

.cdlg-body {
  padding: 16px 20px;
  font-size: .875rem; color: #4b5563; line-height: 1.65;
}
.cdlg-body strong { color: #111827; }
.cdlg-body ul {
  margin: 10px 0 0; padding-left: 0; list-style: none;
}
.cdlg-body ul li {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid #f9fafb;
  font-size: .82rem;
}
.cdlg-body ul li:last-child { border-bottom: none; }

.cdlg-input-wrap { margin-top: 12px; }
.cdlg-err {
  color: #ef4444; font-size: .78rem; margin-top: 5px; display: none;
}

.cdlg-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 20px 20px;
}
.cdlg-footer .btn-outline,
.cdlg-footer .btn-primary,
.cdlg-footer .btn-danger {
  min-width: 90px;
}
