/* =============================================================
   MEIJI — Design System v4 « PROFESSIONAL SaaS »
   Direction : outil métier sérieux, dashboard premium.
   Inspirations : Stripe Dashboard, Mercury Banking, Ramp,
   Brex, Pennylane. Sobre, dense, autoritaire.
   Light + Dark.
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* =====================  TOKENS — LIGHT  ===================== */
:root {
  /* Brand accents — palette pimpée : indigo électrique, émeraude, orange citrouille, rose framboise */
  --c-primary:    #4F46E5;   /* indigo électrique — actions, focus */
  --c-primary-2:  #4338CA;
  --c-primary-soft:#EEF2FF;

  --c-success:    #10B981;
  --c-success-2:  #059669;
  --c-success-soft:#D1FAE5;

  --c-danger:     #F43F5E;   /* rose framboise plus saturé */
  --c-danger-2:   #E11D48;
  --c-danger-soft:#FFE4E6;

  --c-warning:    #F97316;   /* orange citrouille plus punchy */
  --c-warning-2:  #EA580C;
  --c-warning-soft:#FFF7ED;

  --c-purple:     #8B5CF6;
  --c-purple-soft:#F3E8FF;

  --c-teal:       #14B8A6;
  --c-teal-soft:  #CCFBF1;

  --c-pink:       #EC4899;
  --c-pink-soft:  #FCE7F3;

  /* Caisses (catégorisation SUSHI/BAR/CHICHA — couleurs vibrantes) */
  --c-sushi:      #4F46E5;    /* indigo électrique */
  --c-sushi-soft: #EEF2FF;
  --c-bar:        #10B981;    /* émeraude */
  --c-bar-soft:   #D1FAE5;
  --c-chicha:     #F97316;    /* orange citrouille */
  --c-chicha-soft:#FFF7ED;

  /* Gradients de marque — utilisés ponctuellement sur boutons primary et tags caisses */
  --grad-primary: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
  --grad-sushi:   linear-gradient(135deg, #6366F1 0%, #4338CA 100%);
  --grad-bar:     linear-gradient(135deg, #10B981 0%, #047857 100%);
  --grad-chicha:  linear-gradient(135deg, #FB923C 0%, #EA580C 100%);
  --grad-danger:  linear-gradient(135deg, #FB7185 0%, #E11D48 100%);

  /* Alias historiques (compat avec les modules JS) */
  --c-red:        var(--c-danger);
  --c-amber:      var(--c-warning);
  --c-green:      var(--c-success);
  --c-blue:       var(--c-primary);

  /* Neutrals — fond gris très clair, surfaces blanches */
  --c-bg:         #F8FAFB;
  --c-bg-2:       #F1F5F9;
  --c-surface:    #FFFFFF;
  --c-surface-2:  #FAFBFC;
  --c-surface-3:  #F1F5F9;
  --c-text:       #0F172A;
  --c-text-2:     #334155;
  --c-muted:      #64748B;
  --c-muted-2:    #94A3B8;
  --c-border:     #E4E7EB;
  --c-border-2:   #EEF1F4;
  --c-line:       #F1F4F7;

  /* Radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 12px;
  --r-pill: 999px;

  /* Shadows — quasi imperceptibles, juste pour la profondeur */
  --sh-xs: 0 1px 1px rgba(15,23,42,.04);
  --sh-sm: 0 1px 2px rgba(15,23,42,.06);
  --sh-md: 0 2px 4px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --sh-lg: 0 8px 24px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
  --sh-xl: 0 16px 48px rgba(15,23,42,.12), 0 4px 8px rgba(15,23,42,.06);

  /* Focus ring */
  --focus-ring: 0 0 0 3px rgba(79,70,229,.22);

  /* Spacing */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 56px;

  /* Type */
  --font-body:    'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  /* Layout */
  --sb-w: 240px;
  --tb-h: 60px;

  /* Motion */
  --ease: cubic-bezier(.22,.8,.2,1);
  --t-fast: .12s var(--ease);
  --t-mid:  .2s var(--ease);
  --t-slow: .32s var(--ease);
}

/* =====================  TOKENS — DARK  ===================== */
:root[data-theme="dark"] {
  --c-primary:    #818CF8;   /* indigo plus clair pour fonds sombres */
  --c-primary-2:  #6366F1;
  --c-primary-soft:rgba(129,140,248,.16);

  --c-success:    #34D399;
  --c-success-2:  #10B981;
  --c-success-soft:rgba(52,211,153,.16);

  --c-danger:     #FB7185;
  --c-danger-2:   #F43F5E;
  --c-danger-soft:rgba(251,113,133,.16);

  --c-warning:    #FB923C;
  --c-warning-2:  #F97316;
  --c-warning-soft:rgba(251,146,60,.16);

  --c-purple:     #A78BFA;
  --c-purple-soft:rgba(167,139,250,.18);

  --c-teal:       #2DD4BF;
  --c-teal-soft:  rgba(45,212,191,.16);

  --c-pink:       #F472B6;
  --c-pink-soft:  rgba(244,114,182,.18);

  --c-sushi:      #818CF8;
  --c-sushi-soft: rgba(129,140,248,.16);
  --c-bar:        #34D399;
  --c-bar-soft:   rgba(52,211,153,.16);
  --c-chicha:     #FB923C;
  --c-chicha-soft:rgba(251,146,60,.16);

  --grad-primary: linear-gradient(135deg, #818CF8 0%, #6366F1 100%);
  --grad-sushi:   linear-gradient(135deg, #818CF8 0%, #4F46E5 100%);
  --grad-bar:     linear-gradient(135deg, #34D399 0%, #059669 100%);
  --grad-chicha:  linear-gradient(135deg, #FB923C 0%, #C2410C 100%);
  --grad-danger:  linear-gradient(135deg, #FB7185 0%, #BE123C 100%);

  --c-bg:         #0A0B0D;
  --c-bg-2:       #0F1115;
  --c-surface:    #15171A;
  --c-surface-2:  #1A1D21;
  --c-surface-3:  #1F2226;
  --c-text:       #E5E7EB;
  --c-text-2:     #CBD0D8;
  --c-muted:      #8B8F96;
  --c-muted-2:    #5F6369;
  --c-border:     #26282D;
  --c-border-2:   #1F2126;
  --c-line:       #1B1D21;

  --sh-xs: 0 1px 1px rgba(0,0,0,.45);
  --sh-sm: 0 1px 2px rgba(0,0,0,.45);
  --sh-md: 0 2px 4px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
  --sh-lg: 0 8px 24px rgba(0,0,0,.55), 0 2px 4px rgba(0,0,0,.4);
  --sh-xl: 0 16px 48px rgba(0,0,0,.65), 0 4px 8px rgba(0,0,0,.5);

  --focus-ring: 0 0 0 3px rgba(129,140,248,.32);
}

/* =====================  BASE  ===================== */
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--c-text);
  background: var(--c-bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01", "tnum";
}

button, input, select, textarea { font-family: inherit; color: inherit; font-size: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }

* { scrollbar-width: thin; scrollbar-color: var(--c-border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--c-border);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--c-muted-2); background-clip: padding-box; border: 2px solid transparent; }

::selection { background: var(--c-primary-soft); color: var(--c-primary-2); }

/* =====================  LAYOUT  ===================== */
.app {
  display: grid;
  grid-template-columns: var(--sb-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--c-bg);
}

.page { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.page.active { display: flex; animation: pageIn .25s var(--ease); }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-5) var(--s-6) var(--s-8);
  scroll-behavior: smooth;
}

/* =====================  SIDEBAR  ===================== */
.sidebar {
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  padding: var(--s-4) var(--s-3) var(--s-3);
  gap: 1px;
  overflow-y: auto;
}

.sb-logo {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-1) var(--s-2) var(--s-4);
  margin-bottom: var(--s-3);
  border-bottom: 1px solid var(--c-border);
}
.sb-logo-mark {
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  background: var(--grad-primary);
  display: grid;
  place-items: center;
  color: #FFFFFF;
  font-size: 17px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(79,70,229,.32), inset 0 1px 0 rgba(255,255,255,.16);
}
.sb-logo-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.sb-logo-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--c-text);
}
.sb-logo-sub {
  font-size: 11px;
  color: var(--c-muted);
  margin-top: 2px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.sb-section {
  font-size: 10.5px;
  color: var(--c-muted);
  padding: var(--s-4) var(--s-3) var(--s-2);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sb-section:first-of-type { padding-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--c-text-2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  user-select: none;
  position: relative;
}
.nav-item .ti {
  font-size: 17px;
  color: var(--c-muted);
  transition: color var(--t-fast);
  flex-shrink: 0;
}
.nav-item .label {
  font-weight: 500;
  letter-spacing: -0.005em;
}
.nav-item:hover {
  background: var(--c-bg-2);
  color: var(--c-text);
}
.nav-item:hover .ti { color: var(--c-text); }
.nav-item.active {
  background: var(--c-primary-soft);
  color: var(--c-primary);
}
.nav-item.active .ti { color: var(--c-primary); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -3px;
  top: 7px;
  bottom: 7px;
  width: 2px;
  background: var(--c-primary);
  border-radius: 999px;
}

/* =====================  TOPBAR  ===================== */
.topbar {
  height: var(--tb-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-6);
  flex-shrink: 0;
}
.tb-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--c-text);
  letter-spacing: -0.01em;
}
.tb-search {
  flex: 1;
  max-width: 420px;
  margin-left: auto;
  position: relative;
  display: flex;
  align-items: center;
}
.tb-search .ti {
  position: absolute;
  left: 11px;
  font-size: 16px;
  color: var(--c-muted-2);
  pointer-events: none;
}
.tb-search input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-bg);
  font-size: 13px;
  color: var(--c-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.tb-search input::placeholder { color: var(--c-muted-2); }
.tb-search input:focus {
  outline: none;
  border-color: var(--c-primary);
  background: var(--c-surface);
  box-shadow: var(--focus-ring);
}

.tb-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.icon-btn {
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--c-muted);
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
.icon-btn .ti { font-size: 17px; }
.icon-btn:hover { background: var(--c-bg-2); color: var(--c-text); }
.icon-btn .dot {
  position: absolute;
  top: 7px; right: 8px;
  width: 6px; height: 6px;
  background: var(--c-danger);
  border-radius: 999px;
  border: 1.5px solid var(--c-surface);
}
.theme-toggle .ti-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ti-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ti-sun { display: inline-block; }

.tb-avatar {
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--c-bg-2);
  color: var(--c-text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 4px;
  border: 1px solid var(--c-border);
  transition: background var(--t-fast);
}
.tb-avatar:hover { background: var(--c-surface-3); }

/* =====================  GLOBAL PERIOD BAR  ===================== */
.global-period {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 10px var(--s-6);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.gp-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.gp-label .ti { font-size: 14px; }
.period-inputs {
  display: flex;
  gap: 6px;
  align-items: center;
}
.period-inputs input[type="date"],
.period-inputs input[type="month"],
.period-inputs input[type="number"] {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 12.5px;
}
.period-label {
  font-size: 12px;
  color: var(--c-muted);
  margin-left: auto;
}

/* Segmented control (Jour/Mois/Année/...) */
.seg {
  display: inline-flex;
  background: var(--c-bg-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 1px;
}
.seg-btn {
  padding: 5px 11px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
}
.seg-btn:hover { color: var(--c-text); }
.seg-btn.active {
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--sh-sm);
  font-weight: 600;
}

/* =====================  PERIOD BAR (en haut de page)  ===================== */
.period-bar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-6);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.period-bar-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--c-text);
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.period-bar-title .ti {
  font-size: 19px;
  color: var(--c-muted);
}
.ml-auto { margin-left: auto; }

/* =====================  CARD  ===================== */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: var(--s-5);
  margin-bottom: var(--s-4);
  position: relative;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text);
  letter-spacing: -0.005em;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.card-title .ti {
  font-size: 16px;
  color: var(--c-muted);
}

/* =====================  METRIC CARDS (.mc) — Stripe-style KPI  ===================== */
.g4, .g3, .g2 {
  display: grid;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
}

.mc {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: var(--s-5);
  padding-left: calc(var(--s-5) + 4px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
  transition: transform var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.mc::before {
  content: '';
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--c-border);
  transition: background var(--t-fast), width var(--t-fast);
}
.mc:hover {
  border-color: color-mix(in srgb, var(--c-primary) 30%, var(--c-border));
  box-shadow: var(--sh-md);
  transform: translateY(-1px);
}
.mc:hover::before { width: 4px; }
.mc.blue::before   { background: var(--c-primary); }
.mc.green::before  { background: var(--c-success); }
.mc.red::before    { background: var(--c-danger); }
.mc.amber::before  { background: var(--c-warning); }
.mc.purple::before { background: var(--c-purple); }
.mc.teal::before   { background: var(--c-teal); }

.mc-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  line-height: 1.2;
}
.mc-label .ti {
  font-size: 14px;
  width: 22px; height: 22px;
  display: grid;
  place-items: center;
  border-radius: var(--r-xs);
  background: var(--c-bg-2);
  color: var(--c-muted);
}

.mc-val {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--c-text);
  letter-spacing: -0.018em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  margin-top: 2px;
}

.mc-sub {
  font-size: 12px;
  color: var(--c-muted);
  font-weight: 500;
  line-height: 1.3;
}

/* Variantes colorées — uniquement sur l'icône label + le chiffre via classe */
.mc.blue  .mc-label .ti { color: var(--c-primary);  background: var(--c-primary-soft); }
.mc.green .mc-label .ti { color: var(--c-success);  background: var(--c-success-soft); }
.mc.red   .mc-label .ti { color: var(--c-danger);   background: var(--c-danger-soft); }
.mc.amber .mc-label .ti { color: var(--c-warning);  background: var(--c-warning-soft); }
.mc.purple .mc-label .ti { color: var(--c-purple);  background: var(--c-purple-soft); }

.mc-label.blue  { color: var(--c-text-2); }
.mc-label.green { color: var(--c-text-2); }
.mc-label.red   { color: var(--c-text-2); }
.mc-label.amber { color: var(--c-text-2); }
.mc-label.purple { color: var(--c-text-2); }

/* Le chiffre reste majoritairement en text-primary, mais peut prendre la couleur d'accent si demandé */
.mc-val.blue   { color: var(--c-primary); }
.mc-val.green  { color: var(--c-success); }
.mc-val.red    { color: var(--c-danger); }
.mc-val.amber  { color: var(--c-warning); }
.mc-val.purple { color: var(--c-purple); }

/* =====================  CAISSES CARDS (.cc-card)  ===================== */
.g-caisse {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}
@media (max-width: 1100px) {
  .g-caisse { grid-template-columns: 1fr; }
}

.cc-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.cc-card:hover {
  box-shadow: var(--sh-sm);
}

.cc-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  width: fit-content;
}
.cc-tag .ti { font-size: 13px; }
.cc-tag.sushi  { background: var(--c-sushi-soft); color: var(--c-sushi); }
.cc-tag.bar    { background: var(--c-bar-soft); color: var(--c-bar); }
.cc-tag.chicha { background: var(--c-chicha-soft); color: var(--c-chicha); }

.cc-amount {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.cc-amount.sushi  { color: var(--c-sushi); }
.cc-amount.bar    { color: var(--c-bar); }
.cc-amount.chicha { color: var(--c-chicha); }

.cc-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}
.cc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}
.cc-row-key {
  color: var(--c-muted);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cc-row-key .ti {
  font-size: 14px;
  color: var(--c-muted-2);
}
.cc-row-val {
  color: var(--c-text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.cc-divider {
  height: 1px;
  background: var(--c-border-2);
  margin: 4px 0;
}

/* =====================  TABLES  ===================== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  color: var(--c-text);
}
thead th {
  background: var(--c-surface-2);
  font-size: 11px;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px var(--s-4);
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
tbody td {
  padding: 11px var(--s-4);
  border-bottom: 1px solid var(--c-line);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr {
  transition: background var(--t-fast);
}
tbody tr:hover { background: var(--c-surface-2); }
tbody tr.total-row {
  background: var(--c-surface-2);
  font-weight: 600;
}
tbody tr.total-row td {
  border-top: 1px solid var(--c-border);
  padding-top: 12px;
  padding-bottom: 12px;
}
tbody tr.row-total td {
  background: var(--c-bg-2);
  font-weight: 600;
}
.col-total {
  font-weight: 600;
  background: var(--c-surface-2);
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--c-muted); }
.text-blue { color: var(--c-primary); }
.text-green { color: var(--c-success); }
.text-red { color: var(--c-danger); }
.fw-bold { font-weight: 600; }
.nowrap { white-space: nowrap; }

/* =====================  BUTTONS  ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
  line-height: 1.2;
}
.btn .ti { font-size: 15px; }
.btn:hover {
  background: var(--c-bg-2);
  border-color: var(--c-border);
}
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn-primary {
  background: var(--grad-primary);
  border-color: var(--c-primary-2);
  color: #FFFFFF;
  box-shadow: 0 1px 2px rgba(79,70,229,.30), inset 0 1px 0 rgba(255,255,255,.10);
}
.btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 12px rgba(79,70,229,.35), inset 0 1px 0 rgba(255,255,255,.12);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--grad-bar);
  border-color: var(--c-success-2);
  color: #FFFFFF;
  box-shadow: 0 1px 2px rgba(16,185,129,.28), inset 0 1px 0 rgba(255,255,255,.10);
}
.btn-success:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 12px rgba(16,185,129,.32), inset 0 1px 0 rgba(255,255,255,.12);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--grad-danger);
  border-color: var(--c-danger-2);
  color: #FFFFFF;
  box-shadow: 0 1px 2px rgba(244,63,94,.28), inset 0 1px 0 rgba(255,255,255,.10);
}
.btn-danger:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 12px rgba(244,63,94,.32), inset 0 1px 0 rgba(255,255,255,.12);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--c-muted);
  padding: 6px 10px;
}
.btn-ghost:hover {
  background: var(--c-bg-2);
  color: var(--c-text);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}
.btn-sm .ti { font-size: 14px; }

/* =====================  INPUTS / SELECTS  ===================== */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 13px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea {
  height: auto;
  min-height: 70px;
  padding: 8px 10px;
  resize: vertical;
  line-height: 1.5;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: var(--focus-ring);
}
input::placeholder, textarea::placeholder { color: var(--c-muted-2); }

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2364748B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

label {
  font-size: 12px;
  color: var(--c-muted);
  font-weight: 500;
}

/* =====================  TABS  ===================== */
.tabs {
  display: inline-flex;
  background: var(--c-bg-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 1px;
}
.tab {
  padding: 5px 11px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
}
.tab:hover { color: var(--c-text); }
.tab.active {
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--sh-sm);
  font-weight: 600;
}

/* =====================  BADGES  ===================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  line-height: 1.5;
}
.b-blue   { background: var(--c-primary-soft); color: var(--c-primary); }
.b-green  { background: var(--c-success-soft); color: var(--c-success-2); }
.b-red    { background: var(--c-danger-soft); color: var(--c-danger-2); }
.b-amber  { background: var(--c-warning-soft); color: var(--c-warning-2); }
.b-purple { background: var(--c-purple-soft); color: var(--c-purple); }

:root[data-theme="dark"] .b-green { color: var(--c-success); }
:root[data-theme="dark"] .b-red   { color: var(--c-danger); }
:root[data-theme="dark"] .b-amber { color: var(--c-warning); }

/* =====================  SOLDE HEADER (Banque / Mobile)  ===================== */
.solde-header {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: var(--s-5) var(--s-6);
  margin-bottom: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.solde-header.banque::before,
.solde-header.mobile::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
}
.solde-header.banque::before { background: var(--c-sushi); }
.solde-header.mobile::before { background: var(--c-purple); }

.solde-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.solde-big {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.solde-update {
  font-size: 12px;
  color: var(--c-muted);
}
.solde-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.solde-form input {
  flex: 1;
  min-width: 200px;
}

/* =====================  EMPTY / HELPERS  ===================== */
.empty {
  text-align: center;
  padding: var(--s-7) var(--s-4);
  color: var(--c-muted);
  font-size: 13.5px;
}

/* =====================  CHARTS  ===================== */
.chart-container {
  position: relative;
  height: 280px;
  margin-top: 10px;
}
.chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--c-muted);
  margin-bottom: 6px;
}
.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-top: 10px;
  flex-wrap: wrap;
}
.donut-canvas-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  flex-shrink: 0;
}
.donut-canvas-wrap canvas {
  width: 220px !important;
  height: 220px !important;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.donut-center .v {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--c-text);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.donut-center .l {
  font-size: 11px;
  color: var(--c-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.donut-legend {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border-2);
}
.donut-dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  display: inline-block;
}

/* =====================  PROGRESS BARS  ===================== */
.progress-row {
  margin-bottom: 14px;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 12.5px;
}
.progress-label > :first-child {
  font-weight: 500;
  color: var(--c-text);
}
.progress-label > :last-child {
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.progress-bg {
  height: 6px;
  background: var(--c-bg-2);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--c-primary);
  border-radius: var(--r-pill);
  transition: width .4s var(--ease);
}

/* =====================  DROPDOWN DÉPENSES  ===================== */
.dep-dd {
  position: relative;
  display: inline-block;
}
.dep-dd-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 4px;
  display: none;
  flex-direction: column;
  gap: 1px;
  min-width: 160px;
  z-index: 50;
  box-shadow: var(--sh-lg);
}
.dep-dd-menu.show { display: flex; }
.dep-dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--r-xs);
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text);
  cursor: pointer;
  transition: background var(--t-fast);
  text-align: left;
}
.dep-dd-item:hover { background: var(--c-bg-2); }
.dep-dd-bullet {
  width: 8px; height: 8px;
  border-radius: 999px;
  display: inline-block;
}
.dep-dd-sushi  .dep-dd-bullet { background: var(--c-sushi); }
.dep-dd-bar    .dep-dd-bullet { background: var(--c-bar); }
.dep-dd-chicha .dep-dd-bullet { background: var(--c-chicha); }

/* =====================  DRAFT TABLE (saisie en cours)  ===================== */
.draft-card {
  border-color: var(--c-border);
  background: var(--c-surface);
  position: relative;
}
.draft-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  border-radius: var(--r-xl) 0 0 var(--r-xl);
  background: var(--c-primary);
  opacity: 0.5;
}

.draft-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.draft-table thead th {
  background: var(--c-surface-2);
  padding: 9px var(--s-3);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
.draft-table tbody td {
  padding: 6px var(--s-2);
  border-bottom: 1px solid var(--c-line);
  vertical-align: middle;
}
.draft-table tbody tr:last-child td { border-bottom: none; }
.draft-table tbody tr:hover { background: var(--c-surface-2); }

.draft-table input,
.draft-table select {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  background: transparent;
  font-size: 13px;
  color: var(--c-text);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.draft-table input:hover,
.draft-table select:hover {
  border-color: var(--c-border-2);
  background: var(--c-bg-2);
}
.draft-table input:focus,
.draft-table select:focus {
  border-color: var(--c-primary);
  background: var(--c-surface);
  box-shadow: var(--focus-ring);
}
.draft-table .montant {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.draft-del {
  background: transparent;
  border: 1px solid transparent;
  width: 28px; height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-xs);
  color: var(--c-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.draft-del:hover {
  background: var(--c-danger-soft);
  color: var(--c-danger);
}
.draft-del .ti { font-size: 16px; }

.fld-date    { min-width: 110px; }
.fld-dept    { min-width: 90px; }
.fld-cat     { min-width: 160px; }
.fld-qte     { min-width: 60px; text-align: right; }
.fld-prix    { min-width: 100px; text-align: right; }
.fld-montant { min-width: 120px; text-align: right; }
.fld-pay     { min-width: 100px; }
.fld-obs     { min-width: 140px; }

/* =====================  RECETTES DRAFT  ===================== */
.rec-draft {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  margin-bottom: var(--s-3);
}
.rec-draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
  flex-wrap: wrap;
}
.rec-draft-date input[type="date"] {
  height: 32px;
}
.rec-draft-total {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--c-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.rec-draft-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.rec-draft-table thead th {
  background: var(--c-surface-2);
  padding: 8px 10px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--c-border);
}
.rec-draft-table tbody td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--c-line);
}
.rec-draft-table tbody tr:last-child td { border-bottom: none; }
.rec-draft-table input,
.rec-draft-table select {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  background: transparent;
  font-size: 12.5px;
  text-align: right;
}
.rec-draft-table input:hover {
  background: var(--c-bg-2);
  border-color: var(--c-border-2);
}
.rec-draft-table input:focus {
  border-color: var(--c-primary);
  background: var(--c-surface);
  box-shadow: var(--focus-ring);
  outline: none;
}
.caisse-label {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.totals {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  background: var(--c-bg-2);
  padding: 6px 10px;
}

/* =====================  ANALYSE  ===================== */
.an-sub {
  font-size: 12.5px;
  color: var(--c-muted);
  margin-top: 4px;
}

.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  font-size: 13.5px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.cat-item:hover {
  border-color: var(--c-border);
  background: var(--c-surface-2);
}
.cat-item .montant {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--c-text);
}

/* =====================  MODALS  ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--s-5);
  animation: overlayIn .2s var(--ease);
}
:root[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.65); }
.modal-overlay.show { display: flex; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: var(--s-6);
  box-shadow: var(--sh-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .25s var(--ease);
}
.modal.modal-lg { max-width: 760px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--c-text);
  letter-spacing: -0.01em;
  margin-bottom: var(--s-4);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-title .ti {
  font-size: 18px;
  color: var(--c-primary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--c-border-2);
}

.modal label {
  display: block;
  margin-bottom: 4px;
  margin-top: var(--s-3);
}
.modal label:first-of-type { margin-top: 0; }
.modal input,
.modal select,
.modal textarea {
  width: 100%;
}

/* =====================  MVT (banque/mobile mouvements) - bouton type  ===================== */
.mvt-type {
  display: inline-flex;
  background: var(--c-bg-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 1px;
}
.mvt-btn {
  padding: 6px 14px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.mvt-btn:hover { color: var(--c-text); }
.mvt-btn.active.in {
  background: var(--c-success-soft);
  color: var(--c-success-2);
  box-shadow: var(--sh-sm);
  font-weight: 600;
}
.mvt-btn.active.out {
  background: var(--c-danger-soft);
  color: var(--c-danger-2);
  box-shadow: var(--sh-sm);
  font-weight: 600;
}
:root[data-theme="dark"] .mvt-btn.active.in  { color: var(--c-success); }
:root[data-theme="dark"] .mvt-btn.active.out { color: var(--c-danger); }

/* =====================  Comptes EMP cards  ===================== */
.esp-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* =====================  USERS  ===================== */
.u-nom, .u-role, .u-perms {
  font-size: 13px;
}
.u-save {
  font-size: 12px;
}

/* =====================  LOGIN ERROR  ===================== */
.login-error {
  font-size: 12.5px;
  color: var(--c-danger);
  padding: 8px 12px;
  background: var(--c-danger-soft);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--r-sm);
}
:root[data-theme="dark"] .login-error { border-color: rgba(248,113,113,.25); }

/* =====================  P-VIEW / P-EDIT (catégories inline)  ===================== */
.p-view, .p-edit {
  display: flex;
  align-items: center;
  gap: 6px;
}
.p-edit input {
  height: 28px;
  font-size: 13px;
}

/* =====================  FOOTER GRID (charts.js charges-bars)  ===================== */
.fg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.fr {
  display: flex;
  justify-content: space-between;
  flex: 1;
  font-size: 13px;
}
.fl {
  width: 110px;
  font-size: 12.5px;
  color: var(--c-muted);
  font-weight: 500;
}

/* =====================  MICRO HELPERS  ===================== */
.show { display: block !important; }

/* =====================  PRINT  ===================== */
@media print {
  .sidebar, .topbar, .global-period, .period-bar { display: none !important; }
  .app { display: block; }
  .main { overflow: visible; height: auto; }
  .content { padding: 0; overflow: visible; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
}

/* =====================  RESPONSIVE  ===================== */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    transform: translateX(-100%);
    transition: transform .25s var(--ease);
    z-index: 100;
  }
  .sidebar.show { transform: translateX(0); }
  .topbar { padding: 0 var(--s-4); }
  .content { padding: var(--s-4); }
  .period-bar { padding: var(--s-4); }
  .global-period { padding: 10px var(--s-4); }
}
