/* ============================================================
   CRM AVA Conseil - Design System 2026
   Aesthetic: Luxury Minimal — slate & gold
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&family=DM+Serif+Display:ital@0;1&display=swap');

/* ─── Tokens ──────────────────────────────────────────────── */
:root {
  --gold:        #C9A84C;
  --gold-light:  #E8C97A;
  --gold-dark:   #A07830;
  --gold-muted:  rgba(201,168,76,.12);

  --bg:          #F7F6F3;
  --bg-card:     #FFFFFF;
  --bg-hover:    #F0EEE9;
  --bg-sidebar:  #1C1E26;
  --border:      rgba(0,0,0,.08);
  --border-strong: rgba(0,0,0,.15);
  --text:        #1A1B22;
  --text-2:      #6B6F7E;
  --text-3:      #A0A4B2;
  --text-inv:    #FFFFFF;

  --success:     #2E9E6B;
  --success-bg:  rgba(46,158,107,.1);
  --warning:     #E08B2A;
  --warning-bg:  rgba(224,139,42,.1);
  --danger:      #D94F4F;
  --danger-bg:   rgba(217,79,79,.1);
  --info:        #3B82C4;
  --info-bg:     rgba(59,130,196,.1);
  --super-expert:    #9333EA;
  --super-expert-bg: rgba(147, 51, 234, .1);

  --shadow-xs:   0 1px 3px rgba(0,0,0,.06);
  --shadow-sm:   0 2px 8px rgba(0,0,0,.08);
  --shadow-md:   0 8px 24px rgba(0,0,0,.1);
  --shadow-lg:   0 20px 60px rgba(0,0,0,.12);
  --shadow-gold: 0 4px 20px rgba(201,168,76,.25);

  --r-xs:  4px;
  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  24px;
  --r-full: 9999px;

  --ease: cubic-bezier(.4,0,.2,1);
  --t-fast: 120ms;
  --t-base: 200ms;
  --t-slow: 350ms;

  --sidebar-w:       268px;
  --sidebar-mini-w:  64px;
  --header-h:        64px;

  /* Alias utilitaires utilisés inline */
  --bg-1: var(--bg);
  --bg-2: var(--bg-hover);
}

[data-theme="dark"] {
  --bg:          #0F1117;
  --bg-card:     #181B24;
  --bg-hover:    #1E2130;
  --bg-sidebar:  #0B0D14;
  --border:      rgba(255,255,255,.07);
  --border-strong: rgba(255,255,255,.14);
  --text:        #E8EAF0;
  --text-2:      #8B90A8;
  --text-3:      #555970;
  --text-inv:    #0F1117;
  --shadow-xs:   0 1px 3px rgba(0,0,0,.3);
  --shadow-sm:   0 2px 8px rgba(0,0,0,.4);
  --shadow-md:   0 8px 24px rgba(0,0,0,.5);
  --shadow-lg:   0 20px 60px rgba(0,0,0,.6);
}

/* ─── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background var(--t-slow) var(--ease), color var(--t-slow) var(--ease);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--gold-light); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ─── Typography ──────────────────────────────────────────── */
h1,h2,h3,h4,h5 { font-family: 'DM Serif Display', Georgia, serif; line-height: 1.25; color: var(--text); }
h1 { font-size: 2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }
.text-serif { font-family: 'DM Serif Display', serif; }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-gold { color: var(--gold); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* ─── Layout ──────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  transition: width var(--t-slow) var(--ease), transform var(--t-slow) var(--ease);
  overflow: hidden;
}

/* ── Mode mini (collapsed) ── */
.sidebar.collapsed { width: var(--sidebar-mini-w); }
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-logo-sub { display: none; }
.sidebar.collapsed .sidebar-logo { padding: 20px 12px; justify-content: center; }
.sidebar.collapsed .nav-section-label { opacity: 0; height: 0; padding: 0; overflow: hidden; }
.sidebar.collapsed .nav-item {
  padding: 10px; justify-content: center; gap: 0;
  border-radius: var(--r-sm);
}
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .sidebar-footer { padding: 12px 10px; }
.sidebar.collapsed .sidebar-user { padding: 8px; justify-content: center; }
.sidebar.collapsed .sidebar-user-info { display: none; }
/* Tooltip mini */
.sidebar.collapsed .nav-item { position: relative; }
.sidebar.collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.85); color: #fff;
  padding: 5px 10px; border-radius: var(--r-sm); font-size: .78rem;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity var(--t-fast);
  z-index: 999;
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: padding var(--t-slow) var(--ease);
}
.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-gold);
}
.sidebar-logo-icon svg { width: 18px; height: 18px; color: #fff; }
.sidebar-logo-text { font-family: 'DM Serif Display', serif; color: #fff; font-size: 1.05rem; transition: opacity var(--t-base); white-space: nowrap; }
.sidebar-logo-sub { font-size: .67rem; color: rgba(255,255,255,.4); text-transform: uppercase; letter-spacing: .06em; margin-top: 1px; white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 10px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent; }
.nav-section-label {
  font-size: .65rem; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255,255,255,.22); padding: 14px 8px 4px; font-weight: 600;
  transition: all var(--t-base);
  white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm);
  color: rgba(255,255,255,.5); font-size: .875rem;
  cursor: pointer; transition: all var(--t-base) var(--ease);
  position: relative; text-decoration: none; white-space: nowrap;
  margin-bottom: 1px;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
.nav-item.active { background: var(--gold-muted); color: var(--gold); font-weight: 500; }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 2px; background: var(--gold); border-radius: 0 2px 2px 0;
}
.nav-badge {
  margin-left: auto; font-size: .67rem; font-weight: 700;
  background: var(--danger); color: #fff;
  border-radius: var(--r-full); padding: 1px 6px; min-width: 18px; text-align: center;
}
.nav-divider { height: 1px; background: rgba(255,255,255,.06); margin: 8px 0; }

.sidebar-footer { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.06); transition: padding var(--t-slow); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-sm); cursor: pointer; transition: background var(--t-base); text-decoration: none; }
.sidebar-user:hover { background: rgba(255,255,255,.06); }
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .78rem; flex-shrink: 0;
}
.sidebar-user-name { font-size: .83rem; font-weight: 500; color: #fff; white-space: nowrap; }
.sidebar-user-role { font-size: .68rem; color: rgba(255,255,255,.32); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }

/* ─── Main Content ────────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; transition: margin-left var(--t-slow) var(--ease); }
.sidebar.collapsed ~ .main-content,
body.sidebar-collapsed .main-content { margin-left: var(--sidebar-mini-w); }

/* ─── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--header-h); background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 28px; gap: 16px;
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(8px);
}
.topbar-title { font-family: 'DM Serif Display', serif; font-size: 1.15rem; flex: 1; }
.topbar-search { position: relative; width: 280px; }
.topbar-search input {
  width: 100%; height: 38px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--r-full);
  padding: 0 16px 0 40px; color: var(--text); font-size: .875rem;
  transition: all var(--t-base); outline: none;
}
.topbar-search input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,.12); }
.topbar-search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  width: 38px; height: 38px; border: 1px solid var(--border);
  background: transparent; border-radius: var(--r-sm);
  color: var(--text-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-base); position: relative;
  text-decoration: none;
}
.topbar-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.topbar-btn svg { width: 17px; height: 17px; }

/* ─── Page ────────────────────────────────────────────────── */
.page { padding: 32px 28px; max-width: 1600px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 28px; gap: 16px; }
.page-header-left { flex: 1; }
.page-header h1 { font-size: 1.75rem; }
.page-breadcrumb { font-size: .8rem; color: var(--text-3); margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.page-breadcrumb a { color: var(--text-2); }
.page-breadcrumb a:hover { color: var(--gold); }

/* ─── Cards ───────────────────────────────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); transition: box-shadow var(--t-base); }
.card:hover { box-shadow: var(--shadow-sm); }
.card-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: .95rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title svg { width: 17px; height: 17px; color: var(--gold); }
.card-body { padding: 24px; }
.card-footer { padding: 14px 24px; border-top: 1px solid var(--border); background: var(--bg); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ─── Stats KPI ───────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 22px 22px 18px;
  position: relative; overflow: hidden; transition: all var(--t-base);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, var(--gold), transparent); opacity: 0; transition: opacity var(--t-base); }
.stat-card:hover::after { opacity: 1; }
.stat-icon { width: 40px; height: 40px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.gold { background: var(--gold-muted); color: var(--gold); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.danger { background: var(--danger-bg); color: var(--danger); }
.stat-icon.info { background: var(--info-bg); color: var(--info); }
.stat-value { font-family: 'DM Serif Display', serif; font-size: 1.9rem; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: .8rem; color: var(--text-2); font-weight: 400; text-transform: uppercase; letter-spacing: .05em; }
.stat-change { font-size: .78rem; margin-top: 8px; display: flex; align-items: center; gap: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 9px 18px; border-radius: var(--r-sm);
  font-size: .875rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all var(--t-base) var(--ease);
  white-space: nowrap; text-decoration: none;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-sm { padding: 6px 13px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: .95rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-icon-sm { width: 30px; height: 30px; padding: 0; }

.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold-dark)); color: #fff; border-color: var(--gold-dark); box-shadow: 0 2px 8px rgba(201,168,76,.3); }
.btn-gold:hover { transform: translateY(-1px); box-shadow: var(--shadow-gold); color: #fff; }
.btn-gold:active { transform: translateY(0); }

.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--bg-hover); border-color: var(--gold); color: var(--gold); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #c04040; color: #fff; }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }

/* ─── Forms ───────────────────────────────────────────────── */
.form-section { margin-bottom: 28px; }
.form-section-title {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--gold); font-weight: 600;
  margin-bottom: 14px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.form-section-title svg { width: 14px; height: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-full { grid-column: 1/-1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: .8rem; font-weight: 500; color: var(--text-2); }
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text); font-size: .875rem;
  transition: all var(--t-base); outline: none;
}
.form-control:focus { border-color: var(--gold); background: var(--bg-card); box-shadow: 0 0 0 3px rgba(201,168,76,.1); }
.form-control:disabled { opacity: .5; cursor: not-allowed; }
textarea.form-control { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6F7E' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
.form-hint { font-size: .75rem; color: var(--text-3); }
.form-error { font-size: .75rem; color: var(--danger); }

/* Autocomplete */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-md);
  z-index: 300; max-height: 240px; overflow-y: auto;
  display: none;
}
.autocomplete-dropdown.open { display: block; }
.autocomplete-item {
  padding: 10px 14px; cursor: pointer; font-size: .875rem;
  border-bottom: 1px solid var(--border); transition: background var(--t-fast);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.focused { background: var(--bg-hover); }
.autocomplete-item strong { color: var(--gold); }
.autocomplete-item .hint { font-size: .75rem; color: var(--text-3); margin-top: 2px; }

/* ─── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: var(--bg); padding: 12px 16px; text-align: left;
  font-weight: 600; font-size: .75rem; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
.table-actions { display: flex; gap: 6px; align-items: center; }

/* ─── Chiffrage sections ──────────────────────────────────── */
.section-block {
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.section-header {
  background: var(--bg);
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.section-header:hover { background: var(--bg-hover); }
.section-label {
  font-family: 'DM Serif Display', serif;
  font-size: 1rem; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.section-roman {
  width: 28px; height: 28px; background: var(--gold);
  color: #fff; border-radius: var(--r-xs);
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Sans', sans-serif; font-size: .75rem; font-weight: 700;
  flex-shrink: 0;
}
.section-totals { display: flex; gap: 16px; align-items: center; }
.section-total-ht { font-size: .85rem; color: var(--text-2); }
.section-total-ttc { font-size: .9rem; font-weight: 600; color: var(--gold); }
.section-body { padding: 0; }
.section-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.section-table th {
  background: var(--bg); padding: 8px 12px;
  text-align: left; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-3); font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.section-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.section-table tr:last-child td { border-bottom: none; }
.section-table tr:hover td { background: var(--bg-hover); }
.section-table input, .section-table select {
  width: 100%; height: 34px; padding: 0 8px;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--r-xs); color: var(--text); font-size: .85rem;
  transition: all var(--t-fast);
}
.section-table input:focus, .section-table select:focus {
  border-color: var(--gold); background: var(--bg-card);
  outline: none; box-shadow: 0 0 0 2px rgba(201,168,76,.12);
}
.section-table .montant-ht { font-weight: 600; color: var(--text); text-align: right; }
.section-table select { appearance: none; padding-right: 24px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236B6F7E' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 6px center; }
.section-subtotal {
  background: var(--bg); padding: 10px 12px;
  display: flex; justify-content: flex-end; gap: 24px;
  border-top: 1px solid var(--border); font-size: .85rem;
}
.section-subtotal .label { color: var(--text-2); }
.section-subtotal .value { font-weight: 600; min-width: 90px; text-align: right; }
.section-subtotal .value.ttc { color: var(--gold); }

/* TVA selector */
.tva-pill {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-full); padding: 2px 3px;
  font-size: .72rem;
}
.tva-option { padding: 2px 8px; border-radius: var(--r-full); cursor: pointer; transition: all var(--t-fast); color: var(--text-2); }
.tva-option.active { background: var(--gold); color: #fff; }

/* Recap global */
.recap-global {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  margin-top: 24px;
}
.recap-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.recap-row:last-child { border-bottom: none; }
.recap-row.total { padding-top: 12px; margin-top: 4px; border-top: 2px solid var(--gold); border-bottom: none; }
.recap-row.total .recap-label { font-family: 'DM Serif Display', serif; font-size: 1.1rem; }
.recap-row.total .recap-value { font-family: 'DM Serif Display', serif; font-size: 1.4rem; color: var(--gold); }
.recap-value { font-weight: 600; }
.recap-franchise { color: var(--danger); }
.recap-net { color: var(--success); font-size: 1rem; font-weight: 700; }

/* ─── Badges ──────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-full); font-size: .72rem; font-weight: 600; letter-spacing: .03em; }
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-gold    { background: var(--gold-muted); color: var(--gold); }
.badge-neutral { background: var(--bg-hover);   color: var(--text-2); }

/* ─── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 24px; overflow-x: auto; scrollbar-width: none; }
.tab { padding: 10px 18px; font-size: .875rem; font-weight: 500; color: var(--text-2); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; transition: all var(--t-base); text-decoration: none; display: flex; align-items: center; gap: 6px; background: none; border-top: none; border-left: none; border-right: none; margin-bottom: -1px; }
.tab svg { width: 15px; height: 15px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ─── Modal ───────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity var(--t-base); }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; transform: translateY(20px) scale(.98); transition: transform var(--t-slow) var(--ease); }
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1.05rem; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Alert ───────────────────────────────────────────────── */
.alert { padding: 14px 16px; border-radius: var(--r-md); font-size: .875rem; display: flex; align-items: flex-start; gap: 10px; border: 1px solid transparent; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(46,158,107,.2); }
.alert-danger   { background: var(--danger-bg);  color: var(--danger);  border-color: rgba(217,79,79,.2); }
.alert-warning  { background: var(--warning-bg); color: var(--warning); border-color: rgba(224,139,42,.2); }
.alert-info     { background: var(--info-bg);    color: var(--info);    border-color: rgba(59,130,196,.2); }

/* ─── Toast ───────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 18px; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 10px; font-size: .875rem; max-width: 360px; pointer-events: all; animation: toast-in var(--t-slow) var(--ease) forwards; }
.toast.hiding { animation: toast-out var(--t-slow) var(--ease) forwards; }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast-success { border-left: 3px solid var(--success); }
.toast-danger  { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--info); }
.toast-close { margin-left: auto; width: 22px; height: 22px; background: none; border: none; cursor: pointer; color: var(--text-3); display: flex; align-items: center; justify-content: center; }
@keyframes toast-in  { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { from { transform: translateX(0); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }

/* ─── Login ───────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); position: relative; overflow: hidden; }
.login-bg-pattern { position: absolute; inset: 0; background-image: radial-gradient(ellipse 60% 60% at 30% 40%, rgba(201,168,76,.06) 0%, transparent 70%), radial-gradient(ellipse 40% 50% at 80% 70%, rgba(201,168,76,.04) 0%, transparent 60%); }
.login-bg-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(201,168,76,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(201,168,76,.04) 1px, transparent 1px); background-size: 40px 40px; opacity: .4; }
.login-card { width: 100%; max-width: 420px; margin: 20px; position: relative; z-index: 1; }
.login-logo { text-align: center; margin-bottom: 32px; animation: fadeUp .4s cubic-bezier(.4,0,.2,1) .05s both; }
.login-logo-icon { width: 60px; height: 60px; background: linear-gradient(135deg, var(--gold), var(--gold-dark)); border-radius: var(--r-lg); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; box-shadow: var(--shadow-gold); }
.login-logo-icon svg { width: 30px; height: 30px; color: #fff; }
.login-title { font-family: 'DM Serif Display', serif; font-size: 1.8rem; color: var(--text); margin-bottom: 4px; }
.login-subtitle { font-size: .875rem; color: var(--text-2); }
.login-form-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 32px; box-shadow: var(--shadow-lg); animation: fadeUp .5s cubic-bezier(.4,0,.2,1) both; }
.login-footer { text-align: center; margin-top: 20px; font-size: .8rem; color: var(--text-3); }
.login-theme-btn { position: fixed; top: 20px; right: 20px; width: 40px; height: 40px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-2); z-index: 10; }
.login-theme-btn svg { width: 18px; height: 18px; }
.pass-wrap { position: relative; }
.pass-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-3); padding: 4px; display: flex; align-items: center; }
.pass-toggle svg { width: 16px; height: 16px; }

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

/* ─── Dashboard ───────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; margin-top: 4px; }
.col-8 { grid-column: span 8; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; }
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); flex-shrink: 0; margin-top: 5px; }
.activity-text { font-size: .82rem; color: var(--text); line-height: 1.4; }
.activity-time { font-size: .72rem; color: var(--text-3); margin-top: 1px; }

/* ─── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: center; padding: 8px 0; }
.page-btn { height: 34px; min-width: 34px; padding: 0 10px; border: 1px solid var(--border); background: var(--bg-card); border-radius: var(--r-sm); color: var(--text-2); font-size: .85rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--t-base); }
.page-btn:hover { border-color: var(--gold); color: var(--gold); }
.page-btn.active { background: var(--gold); border-color: var(--gold); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ─── Empty State ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 64px 24px; color: var(--text-3); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 16px; opacity: .4; }
.empty-state h3 { font-size: 1.05rem; color: var(--text-2); margin-bottom: 6px; }
.empty-state p { font-size: .875rem; max-width: 320px; margin: 0 auto 20px; }

/* ─── Save indicator ──────────────────────────────────────── */
.save-bar { position: sticky; bottom: 0; background: var(--bg-card); border-top: 1px solid var(--border); padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; z-index: 50; gap: 12px; box-shadow: 0 -4px 20px rgba(0,0,0,.06); }
.save-status { font-size: .85rem; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); animation: pulse 2s infinite; }
.save-dot.saved { background: var(--success); animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ─── Chiffrage table (create/edit dossier) ───────────────── */
.bg-1 { background: var(--bg); }
.bg-2 { background: var(--bg-hover); }
.text-link { color: var(--text-2); text-decoration: none; transition: color var(--t-fast); }
.text-link:hover { color: var(--gold); }

.form-section-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--gold); font-weight: 700;
}

.form-control-sm {
  width: 100%; height: 32px; padding: 0 8px;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--r-xs); color: var(--text); font-size: .82rem;
  transition: all var(--t-fast); outline: none;
}
.form-control-sm:focus {
  border-color: var(--gold); background: var(--bg-card);
  box-shadow: 0 0 0 2px rgba(201,168,76,.12);
}
.form-control-sm:hover:not(:focus) { border-color: var(--border-strong); background: var(--bg-card); }
select.form-control-sm {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236B6F7E' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center; padding-right: 22px;
}

/* Chiffrage section wrapper */
.chiffrage-section {
  border-bottom: 1px solid var(--border);
}
.chiffrage-section:last-of-type { border-bottom: none; }

.chiffrage-section-header {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 20px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.chiffrage-section-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #fff; border-radius: var(--r-xs);
  font-size: .72rem; font-weight: 700; font-family: 'DM Sans', sans-serif;
  box-shadow: 0 2px 6px rgba(201,168,76,.3);
}
.chiffrage-section-title {
  font-weight: 600; font-size: .9rem;
}
.chiffrage-section-tva {
  font-size: .75rem; color: var(--text-3);
  background: var(--bg-hover); padding: 2px 9px; border-radius: var(--r-full);
  border: 1px solid var(--border);
}

/* Chiffrage table */
.chiffrage-table {
  width: 100%; border-collapse: collapse; font-size: .83rem;
}
.chiffrage-table thead th {
  background: var(--bg); padding: 9px 10px;
  text-align: left; font-size: .7rem;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.chiffrage-table tbody td {
  padding: 5px 6px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.chiffrage-table tbody tr:last-child td { border-bottom: none; }
.chiffrage-table tbody tr:hover td { background: var(--bg-hover); }

/* Remove line button */
.btn-remove-ligne {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent;
  border-radius: var(--r-xs); color: var(--text-3);
  font-size: 1.1rem; line-height: 1; cursor: pointer;
  transition: all var(--t-fast);
}
.btn-remove-ligne:hover {
  background: var(--danger-bg); border-color: rgba(217,79,79,.3);
  color: var(--danger);
}

/* Recap block at the bottom of chiffrage */
.chiffrage-recap {
  background: var(--bg);
  border-top: 2px solid var(--border);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.chiffrage-recap thead th {
  background: var(--bg-hover); padding: 11px 16px;
  font-size: .72rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-2);
  font-weight: 600; border-bottom: 1px solid var(--border);
}
.chiffrage-recap tbody td {
  padding: 8px 16px; border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.chiffrage-recap tbody tr:last-child td { border-bottom: none; }
.chiffrage-recap tfoot td { padding: 12px 16px; }

/* ─── Responsive ──────────────────────────────────────────── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 150; }

@media (max-width: 1200px) { .col-8, .col-4 { grid-column: span 12; } }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0 !important; }
  .topbar { padding: 0 16px; }
  .topbar-search { display: none; }
  .page { padding: 20px 16px; }
  .page-header { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .col-8, .col-4, .col-6 { grid-column: span 1; }
}
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr; } }

/* ─── Utilities ───────────────────────────────────────────── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }