:root,
html[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --muted: #f1f5f9;
  --text-900: #0f172a;
  --text-700: #334155;
  --text-600: #475569;
  --text-500: #64748b;
  --border-200: #e5e7eb;
  --border-300: #cbd5e1;
  --overlay-80: rgba(255, 255, 255, .80);

  /* tables (light): outline = black */
  --table-head-bg: #0f6ad8;
  --table-head-text: #ffffff;
  --table-row-alt: #f3f6fb;
  --table-border: rgba(15, 106, 216, .15);
  --table-col-border: #d0d7e2;
  --table-outline: #000000;
}

html {
  scrollbar-gutter: stable;
}

html[data-theme="dark"] {
  --bg: #020617;
  --surface: #0f172a;
  --muted: #1e293b;
  --text-900: #e2e8f0;
  --text-700: #cbd5e1;
  --text-600: #94a3b8;
  --text-500: #94a3b8;
  --border-200: #334155;
  --border-300: #475569;
  --overlay-80: rgba(2, 6, 23, .70);

  /* tables (dark): outline = white */
  --table-head-bg: #0f4fa3;
  --table-head-text: #ffffff;
  --table-row-alt: rgba(15, 79, 163, .25);
  --table-border: rgba(255, 255, 255, .04);
  --table-col-border: rgba(226, 232, 240, .25);
  --table-outline: #ffffff;
}

html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"]  { color-scheme: dark; }

/* -------------------------------------------------
   Utility-like mappings (used across pages)
   ------------------------------------------------- */
.bg-slate-50 { background-color: var(--bg) !important; }
.bg-slate-100 { background-color: var(--muted) !important; }
.bg-white { background-color: var(--surface) !important; }
.bg-white\/80 { background-color: var(--overlay-80) !important; }
.border-slate-200 { border-color: var(--border-200) !important; }
.border-slate-300 { border-color: var(--border-300) !important; }
.text-slate-900 { color: var(--text-900) !important; }
.text-slate-700 { color: var(--text-700) !important; }
.text-slate-600 { color: var(--text-600) !important; }
.text-slate-500 { color: var(--text-500) !important; }
.hover\:bg-white:hover { background-color: var(--surface) !important; }
.hover\:bg-slate-50:hover { background-color: var(--muted) !important; }

.glass {
  backdrop-filter: blur(8px);
  background: var(--overlay-80);
}

/* invert svg in dark mode */
html[data-theme="dark"] img[src$=".svg"] {
  filter: invert(1) brightness(1.05);
}

/* -------------------------------------------------
   Notifications (global, as before)
   ------------------------------------------------- */
.notif-area {
  position: relative;
  display: flex;
  align-items: center;
}
.notif-bell {
  width: 34px;
  height: 34px;
  cursor: pointer;
  user-select: none;
}
.notif-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e02424;
  color: #fff;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
}
.notif-panel {
  position: absolute;
  right: 0;
  top: 40px;
  width: 340px;
  max-height: 70vh;
  overflow: auto;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0,0,0,.15);
  z-index: 999;
  padding: 10px;
  display: none;
}
.notif-panel h3 {
  margin: 6px 6px 10px 6px;
  font-size: 16px;
}
.notif-item {
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 8px;
  margin: 8px;
}
.notif-title {
  font-weight: 700;
  margin-bottom: 4px;
}
.notif-dates {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}

/* =========================================================
   PAIEMENTS-PAGE STYLES (scoped but safe for reuse)
   ========================================================= */

/* used on that page to make tables 100% */
.holebody {
  width: 100%;
}

/* top toggle bar */
.view-togglebar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 12px 20px 0;
  width: calc(100vw - 40px);
  box-sizing: border-box;
  position: relative;
  z-index: 3;
  background: transparent;
  padding: 0;
}
.view-togglebar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--border-200);
  z-index: 1;
}
.toggle-btn {
  margin: 0;
  padding: .6rem 1rem;
  background: var(--muted);
  color: var(--text-900);
  border: 1px solid var(--border-200);
  border-bottom: none;
  border-radius: .6rem .6rem 0 0;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
.toggle-btn.active {
  background: var(--surface);
  z-index: 4;
  margin-bottom: -1px;
}

/* main tab container */
.tab-section {
  margin: 0 20px 16px;
  border: 1px solid var(--border-200);
  border-top: none;
  background: var(--surface);
  border-radius: 0 0 .6rem .6rem;
  padding: 12px;
  box-sizing: border-box;
  width: calc(100vw - 40px);
  max-width: calc(100vw - 40px);
}

/* inputs in those tab-sections (scoped, so other pages are safe) */
.tab-section input[type="text"],
.tab-section input[type="number"],
.tab-section select {
  padding: 0.625rem 1.25rem;
  border: 1px solid var(--border-300);
  border-radius: 0.3125rem;
  background: var(--surface);
  color: var(--text-900);
  min-height: 2.5rem;
}

/* big grid for "Nouvelle vente" */
.nouveau-debit {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr minmax(360px, 4fr) minmax(90px, .8fr) 1fr auto;
  gap: 12px;
  align-items: center;
}
.nouveau-debit input[type="text"],
.nouveau-debit input[type="number"],
.nouveau-debit select {
  width: 100%;
  height: 44px;
  padding: 10px 12px;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border-300);
  color: var(--text-900);
}
.nouveau-debit > button {
  height: 44px;
  white-space: nowrap;
}

/* creator/category selects are muted */
#creatorSelect,
#categorySelect {
  background: var(--muted);
  border-color: var(--border-200);
}

/* caisse / pochette cards */
.cash-title {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  margin: .25rem 0 1rem;
  color: var(--text-900);
}
.cash-title span {
  font-weight: 800;
  color: var(--text-900);
}
.cash-subtitle {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  margin: .75rem 0 .35rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-900);
}
.cash-row-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .75rem;
  padding: .5rem;
  box-sizing: border-box;
}
.cash-item {
  background: var(--muted);
  border: 1px solid var(--border-200);
  border-radius: .5rem;
  padding: .5rem .5rem .75rem;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.03);
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}
.cash-item label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  margin-bottom: .5rem;
  font-weight: 700;
  color: var(--text-900);
  user-select: none;
  min-width: 0;
}
.cash-item img {
  display: block;
  width: clamp(88px, 10vw, 120px);
  height: clamp(88px, 10vw, 120px);
  object-fit: contain;
  border-radius: .35rem;
  background: transparent;
  margin: 0 auto;
}
.cash-item img.fallback {
  background: var(--muted);
}
.cash-item input[type="number"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 36px;
  padding: 4px 6px;
  text-align: center;
  border: .0625rem solid var(--border-300);
  border-radius: .35rem;
  font-size: .95rem;
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text-900);
}

/* transfer amount input (caisse -> pochette) */
#transferAmount {
  background: var(--surface);
  border: 1px solid var(--border-300);
  color: var(--text-900);
}

/* delete icon in table rows */
.delete-icon {
  cursor: pointer;
  color: #e02424;
  font-size: 1.25rem;
}

/* =========================================================
   Buttons (global-ish, theme-aware)
   ========================================================= */

/* Theme vars for buttons */
:root,
html[data-theme="light"] {
  --btn-bg: #0f6ad8;
  --btn-bg-hover: #0d5bb9;
  --btn-text: #ffffff;
  --btn-muted-bg: #e2e8f0;
  --btn-muted-text: #0f172a;
}

html[data-theme="dark"] {
  --btn-bg: #3b82f6;
  --btn-bg-hover: #2563eb;
  --btn-text: #ffffff;
  --btn-muted-bg: #1f2937;
  --btn-muted-text: #e2e8f0;
}

/* 1) Generic app buttons (.btn) — used a lot in plannings.html */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: .55rem;
  padding: .5rem 1rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--btn-bg);
  color: var(--btn-text);
  cursor: pointer;
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
  line-height: 1.2;
}
.btn:hover {
  background: var(--btn-bg-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 106, 216, .25);
}
.btn:active {
  transform: translateY(0);
}

/* variants already used in plannings.html */
.btn-primary {
  background: var(--btn-bg);
  color: var(--btn-text);
}
.btn-secondary {
  background: var(--btn-muted-bg);
  color: var(--btn-muted-text);
  border-color: rgba(148, 163, 184, .4);
}
.btn-danger {
  background: #e02424;
  color: #fff;
}

/* 2) Page buttons inside tab content (paiements.html) */
.tab-section button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: .55rem;
  padding: .5rem 1rem;
  font-weight: 600;
  background: var(--btn-bg);
  color: var(--btn-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.tab-section button:hover {
  background: var(--btn-bg-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 106, 216, .25);
}

/* keep your top toggle tabs untouched */
.toggle-btn {
  /* already styled above in theme.css, so we don’t override it here */
}
