/* ══════════════════════════════════════════════════════
   CASHFLOW PRO DESKTOP — Design System
   Palette : Vert forêt #1B5E20 / Or #F9A825 / Fond #F5F4EF
══════════════════════════════════════════════════════ */

:root {
  --green:        #1B5E20;
  --green-mid:    #2E7D32;
  --green-light:  #E8F5E9;
  --green-border: #B8D0B8;
  --gold:         #F9A825;
  --gold-light:   #FFF8E1;
  --red:          #B71C1C;
  --red-light:    #FFEBEE;
  --orange:       #E65100;
  --orange-light: #FFF3E0;
  --blue:         #1565C0;
  --blue-light:   #E3F2FD;
  --bg:           #F5F4EF;
  --surface:      #FFFFFF;
  --surface-2:    #F0EFE9;
  --border:       #E0DED6;
  --border-2:     #C8C6BE;
  --text:         #1A1A18;
  --text-2:       #5A5A52;
  --text-3:       #9A9A90;
  --sidebar-w:    220px;
  --topbar-h:     52px;
  --radius:       10px;
  --radius-sm:    7px;
  --radius-xs:    5px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.07);
  --shadow:       0 4px 16px rgba(0,0,0,0.10);
  --transition:   0.15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#screen-app .app-layout {
  height: 100vh;
  overflow: hidden;
}

/* ══════════════════════════════════════════════
   UTILITAIRES
══════════════════════════════════════════════ */
.hidden { display: none !important; }
.screen { display: none; }
.screen.active { display: flex; }
.montant { font-variant-numeric: tabular-nums; }

/* ══════════════════════════════════════════════
   AUTH
══════════════════════════════════════════════ */
#screen-auth {
  min-height: 100vh;
  width: 100%;
}

.auth-bg {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.auth-left {
  width: 420px;
  background: var(--green);
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-shrink: 0;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 48px;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.auth-tagline {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
}

.auth-features {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.feat {
  display: flex;
  align-items: center;
  gap: 14px;
  color: rgba(255,255,255,0.8);
  font-size: 0.88rem;
}

.feat i {
  font-size: 1.2rem;
  color: var(--gold);
  width: 24px;
  flex-shrink: 0;
}

.auth-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
  margin-bottom: 22px;
  border: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn.active {
  background: var(--green);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.tab-panel { display: flex; flex-direction: column; gap: 14px; }
.tab-panel.hidden { display: none; }

/* FORM */
.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.optional { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-3); }

.input-icon {
  position: relative;
}

.input-icon i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 1rem;
  pointer-events: none;
  z-index: 0;
}

.input-icon input {
  position: relative;
  z-index: 1;
}

input[type="tel"],
input[type="text"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="month"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.input-icon input { padding-left: 34px; }

input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(27,94,32,0.10);
}

input::placeholder, textarea::placeholder { color: var(--text-3); }

/* PIN */
.pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 10px 0 4px;
}

.pin-dots span {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--border);
  transition: background var(--transition), transform var(--transition);
}

.pin-dots span.filled {
  background: var(--green);
  border-color: var(--green);
  transform: scale(1.12);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.pin-key {
  padding: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  box-shadow: var(--shadow-sm);
}

.pin-key:hover { border-color: var(--green); background: var(--green-light); }
.pin-key:active, .pin-key.pressed { transform: scale(0.94); background: var(--green-light); }
.pin-key.empty { visibility: hidden; box-shadow: none; border: none; }
.pin-key.del { color: var(--text-2); font-size: 0.85rem; }

/* BOUTONS */
.btn-primary {
  width: 100%;
  padding: 10px 16px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background var(--transition), opacity var(--transition);
  box-shadow: 0 2px 6px rgba(27,94,32,0.25);
}

.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary:not(:disabled):hover { background: var(--green-mid); }
.btn-primary i { font-size: 1rem; }

.btn-secondary {
  padding: 8px 14px;
  background: var(--surface);
  color: var(--green);
  border: 1.5px solid var(--green);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-secondary:hover { background: var(--green-light); }

.btn-gold {
  padding: 8px 14px;
  background: var(--gold);
  color: #0D1F0D;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-danger {
  padding: 8px 14px;
  background: transparent;
  color: var(--red);
  border: 1.5px solid var(--red);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-danger:hover { background: var(--red-light); }

.icon-btn {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover { border-color: var(--green); color: var(--green); }
.icon-btn i { font-size: 1rem; }

.form-error {
  background: var(--red-light);
  border: 1px solid rgba(183,28,28,0.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--red);
  font-size: 0.8rem;
  font-weight: 500;
}

/* ══════════════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════════════ */
#screen-app {
  min-height: 100vh;
  width: 100%;
}

.app-layout {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--green);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sb-brand {
  padding: 18px 14px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sb-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.sb-plan {
  font-size: 0.68rem;
  color: var(--gold);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 1px;
}

.sb-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
}

.sb-section {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 10px 10px 3px;
}

.sb-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: rgba(255,255,255,0.6);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  margin-bottom: 2px;
}

.sb-btn i { font-size: 0.95rem; flex-shrink: 0; }
.sb-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sb-btn.active { background: rgba(255,255,255,0.18); color: #fff; }
.sb-btn.active i { color: var(--gold); }

.sb-footer {
  padding: 10px 8px;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.sb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--green);
  flex-shrink: 0;
}

.sb-username {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-userplan {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.35);
}

.sb-logout {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.sb-logout:hover { background: rgba(255,92,92,0.2); color: #ffcdd2; border-color: rgba(255,92,92,0.3); }
.sb-logout i { font-size: 0.95rem; }

/* CONTENU */
.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.topbar-date {
  font-size: 0.75rem;
  color: var(--text-3);
}

.plan-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--green-light);
  color: var(--green);
}

.plan-badge.pro { background: var(--gold-light); color: #7A5000; }
.plan-badge.business { background: var(--gold); color: #0D1F0D; }

.banner-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 24px;
  background: var(--orange-light);
  border-bottom: 1px solid rgba(230,81,0,0.2);
  color: var(--orange);
  font-size: 0.8rem;
  font-weight: 500;
  flex-shrink: 0;
}

.banner-warning i { font-size: 1rem; flex-shrink: 0; }
.banner-warning span { flex: 1; }

.banner-cta {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px;
}

/* ══════════════════════════════════════════════
   DASHBOARD
══════════════════════════════════════════════ */
.dash-grid { display: flex; flex-direction: column; gap: 16px; }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover { border-color: var(--green); }
.kpi-card.revealed { border-color: var(--green); border-width: 1.5px; }

.kpi-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-label i { font-size: 0.85rem; color: var(--green); }

.kpi-masked {
  font-size: 1.2rem;
  letter-spacing: 5px;
  color: var(--border-2);
  margin-bottom: 5px;
}

.kpi-hint {
  font-size: 0.7rem;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 500;
}

.kpi-hint i { font-size: 0.8rem; }

.kpi-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 3px;
  letter-spacing: -0.01em;
}

.kpi-value.neutral { color: var(--text); }

.kpi-sub {
  font-size: 0.7rem;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
}

.trend-up { color: var(--green); font-size: 0.7rem; display: flex; align-items: center; gap: 2px; }
.trend-down { color: var(--red); font-size: 0.7rem; display: flex; align-items: center; gap: 2px; }

/* PANNEAU INLINE KPI */
.kpi-panel {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: fadeSlide 0.15s ease;
}

@keyframes fadeSlide { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.kpi-panel label { font-size: 0.7rem; color: var(--text-2); font-weight: 600; display: block; margin-bottom: 5px; }

.kpi-result {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--green-light);
  border-radius: var(--radius-xs);
  text-align: center;
}

.kpi-result-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green);
}

.kpi-result-sub {
  font-size: 0.7rem;
  color: #3B6D11;
  margin-top: 2px;
}

/* MID ROW */
.dash-mid { display: grid; grid-template-columns: 1.8fr 1fr; gap: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header a {
  font-size: 0.7rem;
  color: var(--green);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 80px;
}

.c-bar {
  flex: 1;
  border-radius: 2px 2px 0 0;
  background: var(--green-border);
  min-height: 3px;
  transition: background var(--transition);
}

.c-bar:hover { background: var(--green); }
.c-bar.today { background: var(--green); }

.alert-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.alert-row:last-child { border-bottom: none; }
.alert-row:hover .a-nom { color: var(--green); }

.a-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.a-nom { flex: 1; font-size: 0.8rem; color: var(--text); font-weight: 500; transition: color var(--transition); }
.a-val { font-size: 0.75rem; font-weight: 700; }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }
.text-green { color: var(--green); }

/* TOP PRODUITS */
.top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.top-row:last-child { border-bottom: none; }

.top-rank {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-2);
  flex-shrink: 0;
}

.top-nom { flex: 1; font-size: 0.78rem; font-weight: 500; color: var(--text); }
.top-qte { font-size: 0.7rem; color: var(--text-3); width: 60px; text-align: right; }
.top-ca { font-size: 0.78rem; font-weight: 700; color: var(--green); width: 80px; text-align: right; }

/* BOTTOM ROW */
.dash-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ══════════════════════════════════════════════
   IMPORT DOCUMENT
══════════════════════════════════════════════ */
.import-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color var(--transition), background var(--transition);
}

.import-zone:hover { border-color: var(--green); background: var(--green-light); }
.import-zone.drag-over { border-color: var(--green); background: var(--green-light); transform: scale(1.01); }

.import-zone i { font-size: 2rem; color: var(--green); display: block; margin-bottom: 8px; }
.import-title { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.import-sub { font-size: 0.75rem; color: var(--text-2); margin-top: 4px; }

.import-types {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}

.file-type {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.file-type.xlsx { background: var(--green-light); color: var(--green); }
.file-type.docx { background: var(--blue-light); color: var(--blue); }
.file-type.pdf  { background: var(--red-light); color: var(--red); }

.import-dest-label {
  font-size: 0.72rem;
  color: var(--text-2);
  font-weight: 600;
  margin: 12px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.import-dest {
  display: flex;
  gap: 8px;
}

.dest-btn {
  flex: 1;
  padding: 8px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: var(--transition);
}

.dest-btn:hover { border-color: var(--green); color: var(--green); }
.dest-btn.active { border-color: var(--green); color: var(--green); background: var(--green-light); }
.dest-btn i { font-size: 0.9rem; }

/* ══════════════════════════════════════════════
   TABLEAU PRODUITS / VENTES / ACHATS
══════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-actions { display: flex; align-items: center; gap: 8px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.search-wrap { position: relative; flex: 1; max-width: 320px; }
.search-wrap i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 0.9rem; pointer-events: none; }
.search-wrap input { padding-left: 32px; }

.filter-chip {
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.filter-chip:hover { border-color: var(--green); color: var(--green); }
.filter-chip.active { border-color: var(--green); color: var(--green); background: var(--green-light); }

/* TABLE */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

thead th {
  background: var(--surface-2);
  padding: 10px 14px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

thead th:hover { color: var(--green); }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); cursor: pointer; }

td {
  padding: 10px 14px;
  color: var(--text);
  vertical-align: middle;
}

/* BADGES */
.badge-ok     { background: var(--green-light);  color: var(--green);  font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.badge-low    { background: var(--orange-light); color: var(--orange); font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.badge-out    { background: var(--red-light);    color: var(--red);    font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.badge-valid  { background: var(--green-light);  color: var(--green);  font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.badge-cancel { background: var(--red-light);    color: var(--red);    font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; }

/* PAGINATION */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-2);
  background: var(--surface);
}

.page-btns { display: flex; gap: 3px; }

.page-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.page-btn:hover { border-color: var(--green); color: var(--green); }
.page-btn.active { background: var(--green); color: #fff; border-color: var(--green); }
.page-btn i { font-size: 0.8rem; }

/* ══════════════════════════════════════════════
   PANEL LATÉRAL (édition produit / détail vente)
══════════════════════════════════════════════ */
.split-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  height: calc(100vh - var(--topbar-h) - 44px);
}

.side-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.side-panel-title { font-size: 0.88rem; font-weight: 700; color: var(--text); }

/* ══════════════════════════════════════════════
   VENTES — SPLIT VIEW
══════════════════════════════════════════════ */
.vente-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  min-height: calc(100vh - var(--topbar-h) - 44px);
}

.panier-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  max-height: calc(100vh - var(--topbar-h) - 44px);
  overflow-y: auto;
}

.panier-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.panier-title { font-size: 0.82rem; font-weight: 700; color: var(--text); }

.panier-ligne {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.panier-ligne-nom { flex: 1; font-size: 0.78rem; font-weight: 600; color: var(--text); }
.panier-ligne-prix { font-size: 0.72rem; color: var(--text-2); }

.qty-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-weight: 700;
}

.qty-btn:hover { border-color: var(--green); color: var(--green); }
.qty-val { min-width: 20px; text-align: center; font-size: 0.8rem; font-weight: 700; }

.panier-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
}

.panier-total-label { font-size: 0.72rem; font-weight: 700; color: var(--green); text-transform: uppercase; letter-spacing: 0.05em; }
.panier-total-value { font-size: 1.1rem; font-weight: 800; color: var(--green); }

.panier-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-3);
  font-size: 0.8rem;
}

/* ══════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,20,10,0.45);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-top: 3px solid var(--green);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow: var(--shadow);
  animation: modalIn 0.18s ease;
}

.modal.wide { max-width: 760px; }

@keyframes modalIn { from { opacity: 0; transform: scale(0.97) translateY(-8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 0.92rem; font-weight: 700; color: var(--text); }

.modal-close {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: var(--transition);
}

.modal-close:hover { background: var(--red-light); border-color: var(--red); color: var(--red); }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.modal-actions .btn-primary { flex: 1; }

/* ══════════════════════════════════════════════
   TABLEAU OCR IMPORT
══════════════════════════════════════════════ */
.ocr-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

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

.ocr-table th {
  padding: 8px 10px;
  background: var(--green);
  color: #fff;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ocr-table th.gold { background: var(--gold); color: #0D1F0D; }

.ocr-table td { padding: 6px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ocr-table tr:last-child td { border-bottom: none; }
.ocr-table tr:nth-child(even) td { background: var(--surface-2); }

.ocr-input {
  width: 100%;
  border: 1.5px solid transparent;
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 0.78rem;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  transition: border-color var(--transition);
}

.ocr-input:focus { border-color: var(--green); background: var(--surface); outline: none; }
.ocr-input.num { text-align: right; width: 72px; }
.ocr-pt-cell { font-weight: 700; color: var(--green); text-align: right; padding-right: 10px; white-space: nowrap; }
.ocr-del { background: none; border: none; color: var(--red); cursor: pointer; font-size: 1rem; font-weight: 700; padding: 2px 6px; }
.ocr-del:hover { color: var(--red); opacity: 0.7; }

.ocr-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--green-light);
  border-top: 2px solid var(--green);
}

.ocr-total-label { font-size: 0.75rem; font-weight: 800; color: var(--green); text-transform: uppercase; letter-spacing: 0.06em; }
.ocr-total-value { font-size: 1rem; font-weight: 800; color: var(--green); }

/* ══════════════════════════════════════════════
   STOCK HISTORIQUE
══════════════════════════════════════════════ */
.hist-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }

.hist-kpi {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: center;
}

.hist-kpi-l { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-2); margin-bottom: 4px; }
.hist-kpi-v { font-size: 1.1rem; font-weight: 700; }

.mouv-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.mouv-row:last-child { border-bottom: none; }

.mouv-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.mouv-info { flex: 1; min-width: 0; }
.mouv-type { font-size: 0.78rem; font-weight: 600; color: var(--text); }
.mouv-date { font-size: 0.68rem; color: var(--text-3); }
.mouv-note { font-size: 0.68rem; color: var(--text-3); font-style: italic; }
.mouv-qty { font-size: 0.9rem; font-weight: 800; }
.mouv-stock { font-size: 0.65rem; color: var(--text-3); text-align: right; }

/* ══════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 56px 24px;
}

.empty-icon {
  width: 52px;
  height: 52px;
  background: var(--green-light);
  border: 1.5px solid var(--green-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.empty-icon i { font-size: 1.4rem; color: var(--green); }
.empty-state h3 { font-size: 0.9rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 0.78rem; color: var(--text-2); line-height: 1.5; }

/* ══════════════════════════════════════════════
   LOADER & TOAST
══════════════════════════════════════════════ */
.global-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-ring {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 500;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
}

.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast i { font-size: 1rem; }

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

/* ══════════════════════════════════════════════
   UTILITAIRES LAYOUT
══════════════════════════════════════════════ */
.row { display: flex; align-items: center; gap: 10px; }
.row.space { justify-content: space-between; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-muted { color: var(--text-2); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--green-border); }
