/* ═══════════════════════════════════════════════════════════════
   Médiablue Compta — main.css
   Inspiré du dashboard (même palette, mêmes variables)
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --blue:        #3b5bdb;
  --blue-light:  #eef2ff;
  --blue-dark:   #2f4ac0;

  --bg:          #f7f7f5;
  --surface:     #ffffff;
  --surface-2:   #f5f5f3;
  --border:      #e8e7e5;
  --border-light:#f0efed;

  --text:        #1a1a1a;
  --text-muted:  #6b6b6b;
  --text-faint:  #a0a0a0;

  --topbar-bg:   #ffffff;
  --topbar-h:    44px;

  --green:       #15803d;
  --green-light: #f0fdf4;
  --orange:      #ca8a04;
  --orange-light:#fefce8;
  --red:         #b91c1c;
  --red-light:   #fef2f2;

  --radius:      10px;
  --radius-sm:   6px;
  --radius-lg:   14px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.03);
  --shadow:      0 3px 10px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.04);
  --shadow-lg:   0 12px 32px rgba(0,0,0,.10), 0 3px 8px rgba(0,0,0,.05);
}

/* ── Dark mode ─────────────────────────────────────────────────── */
body.dark {
  --bg:          #0f172a;
  --surface:     #1e293b;
  --surface-2:   #263447;
  --border:      #334155;
  --border-light:#2a3a4e;
  --text:        #f1f5f9;
  --text-muted:  #94a3b8;
  --text-faint:  #475569;
  --topbar-bg:   #1e293b;
  --blue-light:  #1e2d5a;
  --green-light: #14532d;
  --orange-light:#451a03;
  --red-light:   #450a0a;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ─────────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; gap: 16px;
}
.topbar-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; flex-shrink: 0;
  color: var(--text-muted);
}
.topbar-logo { display: flex; align-items: center; color: var(--text); }
.topbar-logo:hover { text-decoration: none; opacity: .8; }
.topbar-sep { color: var(--border); }
.topbar-section { color: var(--text); font-weight: 600; }

.topbar-nav-links {
  display: flex; align-items: center; gap: 2px; flex: 1;
  justify-content: center;
}
.topbar-navlink {
  padding: 5px 12px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  transition: color .12s, background .12s;
  text-decoration: none;
}
.topbar-navlink:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.topbar-navlink.active { color: var(--blue); background: var(--blue-light); }

.topbar-nav { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.topbar-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  color: var(--text-muted); transition: background .12s, color .12s;
  background: transparent; border: none; cursor: pointer;
}
.topbar-btn:hover { background: var(--surface-2); color: var(--text); }
.topbar-logout { text-decoration: none; }
.topbar-logout:hover { text-decoration: none; }

.main-content { padding-top: var(--topbar-h); min-height: 100vh; }
.page-inner { max-width: 1100px; margin: 0 auto; }
.page-inner--full { max-width: none; }
.home-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0; align-items: start; }
.home-col { min-width: 0; }

/* ── Auth ───────────────────────────────────────────────────────── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 36px 32px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow);
}
.auth-logo {
  width: 48px; height: 48px; border-radius: var(--radius);
  background: var(--blue-light); color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}
.auth-title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.auth-subtitle { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 24px; line-height: 1.5; }
.auth-error { background: var(--red-light); color: var(--red); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: opacity .12s, background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-light); border-color: #fecaca; }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Dropdown menu ──────────────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  min-width: 190px; z-index: 200; padding: 4px 0;
}
.dropdown-menu[hidden] { display: none; }
.dropdown-menu form { display: block; margin: 0; }
.dropdown-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 14px; font-size: 13px; color: var(--text);
  cursor: pointer; background: none; border: none; width: 100%;
  text-align: left; text-decoration: none; white-space: nowrap;
  line-height: 1.4;
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item.danger  { color: var(--red); }
.dropdown-item.primary { color: var(--blue); font-weight: 600; }
.dropdown-item.success { color: var(--green); font-weight: 600; }
.dropdown-divider { border: none; border-top: 1px solid var(--border-light); margin: 4px 0; }

/* ── Modaux de confirmation ─────────────────────────────────────── */
.modal-overlay { position:fixed;inset:0;background:rgba(15,23,42,.5);display:flex;align-items:center;justify-content:center;z-index:300;padding:20px; }
.modal-overlay[hidden] { display:none; }
.modal-card { background:var(--surface);border-radius:12px;padding:28px;max-width:440px;width:100%;box-shadow:var(--shadow-lg); }
.modal-title { font-size:17px;font-weight:700;margin-bottom:16px;color:var(--text); }
.modal-info { border-top:1px solid var(--border-light);margin-bottom:16px; }
.modal-row { display:flex;justify-content:space-between;gap:16px;padding:9px 0;border-bottom:1px solid var(--border-light);font-size:13px; }
.modal-row span:first-child { color:var(--text-muted);flex-shrink:0; }
.modal-row span:last-child { font-weight:500;color:var(--text);text-align:right; }
.modal-hint { font-size:12px;color:var(--text-muted);margin-bottom:20px;line-height:1.5; }
.modal-btns { display:flex;gap:8px;justify-content:flex-end; }

/* ── Fields & Forms ─────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .field-label {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
}
.field input, .field select, .field textarea {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,91,219,.12);
}
.field textarea { resize: vertical; }
.field-checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text); }
.field-checkbox input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--blue); }
.required { color: var(--red); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-span2 { grid-column: span 2; }

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.form-card { padding: 20px; }
.form-card-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 14px; }

/* ── Page header ─────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 24px 24px 16px;
  gap: 16px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }

/* ── Breadcrumb ──────────────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }

/* ── Section ─────────────────────────────────────────────────────── */
.section { padding: 0 24px 20px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 6px; }
.section-link { font-size: 12px; color: var(--blue); }

/* ── Table ───────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); padding: 10px 16px; border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap;
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table--document th, .table--document td { padding: 10px 16px; }
.text-right { text-align: right; white-space: nowrap; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-medium { font-weight: 600; }
.mono { font-family: ui-monospace, monospace; font-size: 12px; }

/* ── Badges statuts ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge--brouillon { background: var(--surface-2); color: var(--text-muted); }
.badge--envoye    { background: var(--blue-light); color: var(--blue); }
.badge--accepte   { background: var(--green-light); color: var(--green); }
.badge--refuse    { background: var(--red-light); color: var(--red); }
.badge--expire    { background: var(--orange-light); color: var(--orange); }
.badge--orange    { background: var(--orange-light); color: var(--orange); }

/* ── Badges statuts factures ─────────────────────────────────────── */
.badge--envoyee   { background: var(--blue-light); color: var(--blue); }
.badge--payee     { background: var(--green-light); color: var(--green); }
.badge--annulee   { background: var(--red-light); color: var(--red); }

/* ── Badges types factures ───────────────────────────────────────── */
.badge--type-f { background: #eff2ff; color: #3b5bdb; }
.badge--type-a { background: #fefce8; color: #854d0e; }
.badge--type-s { background: #f0fdf4; color: #15803d; }
.badge--type-v { background: #fef2f2; color: #b91c1c; }

.statut-badge-lg {
  display: inline-block; padding: 5px 14px; border-radius: 99px;
  font-size: 13px; font-weight: 700;
}

/* ── Stats ───────────────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  padding: 0 24px 20px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-card--green  { border-left: 3px solid var(--green); }
.stat-card--orange { border-left: 3px solid var(--orange); }
.stat-card--muted  { opacity: .8; }
.stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── List toolbar (search + filters + tri) ──────────────────────── */
.list-toolbar { display:flex;align-items:center;gap:8px;padding:0 24px 14px;flex-wrap:wrap; }
.search-box { position:relative;flex:1;min-width:180px;max-width:300px; }
.search-box svg { position:absolute;left:9px;top:50%;transform:translateY(-50%);color:var(--text-faint);pointer-events:none; }
.search-box input { width:100%;padding:6px 10px 6px 30px;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);color:var(--text);font-size:13px; }
.search-box input:focus { outline:none;border-color:var(--blue);box-shadow:0 0 0 2px var(--blue-light); }
.filter-select { padding:6px 10px;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);color:var(--text);font-size:13px;cursor:pointer;max-width:200px; }
.filter-select:focus { outline:none;border-color:var(--blue); }
.toolbar-spacer { flex:1; }

/* ── Filter tabs ─────────────────────────────────────────────────── */
.filter-tabs {
  display: flex; gap: 2px; padding: 0 24px 16px;
  flex-wrap: wrap;
}
.filter-tab {
  padding: 5px 12px; border-radius: 99px;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  background: transparent; transition: color .12s, background .12s;
  text-decoration: none; border: 1px solid transparent;
}
.filter-tab:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.filter-tab.active { color: var(--blue); background: var(--blue-light); border-color: rgba(59,91,219,.2); }

/* ── Form layout ─────────────────────────────────────────────────── */
.form-layout {
  display: flex; gap: 20px;
  padding: 0 24px 24px;
  align-items: flex-start;
}
.form-layout--narrow { max-width: 680px; }
.form-main { flex: 1; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.form-aside { width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; }

.form-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding-top: 4px;
}
.form-actions--fixed {
  position: sticky; bottom: 0;
  background: var(--bg); border-top: 1px solid var(--border);
  padding: 12px 24px; margin: 0 -24px;
  display: flex; justify-content: flex-end; gap: 8px;
  z-index: 50;
}

/* ── Detail layout ───────────────────────────────────────────────── */
.detail-layout {
  display: flex; gap: 20px;
  padding: 0 24px 40px;
  align-items: flex-start;
}
.detail-main { flex: 1; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.detail-aside { width: 260px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; }

/* ── Parties (émetteur / client) ─────────────────────────────────── */
.parties-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border-light); margin-bottom: 14px; }
.partie-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 6px; }
.partie-nom { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.partie-adresse { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.partie-legal { font-size: 11px; color: var(--text-faint); margin-top: 3px; }

.meta-row { display: flex; gap: 20px; flex-wrap: wrap; }
.meta-item { font-size: 12px; color: var(--text-muted); }
.meta-label { font-weight: 700; color: var(--text); }

/* ── Document lines ──────────────────────────────────────────────── */
.ligne-libelle { font-weight: 600; font-size: 13px; }
.ligne-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.ligne-desc ul, .ligne-desc ol { padding-left: 16px; }
.ligne-desc p { margin: 0; }

.totaux-section {
  display: flex; justify-content: flex-end;
  padding: 14px 16px;
  border-top: 1px solid var(--border-light);
}
.totaux-doc-table { border-collapse: collapse; min-width: 240px; }
.totaux-doc-table td { padding: 3px 0; font-size: 13px; }
.totaux-doc-table td:first-child { color: var(--text-muted); padding-right: 24px; }
.totaux-doc-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.total-ttc-row td { font-size: 15px; font-weight: 700; border-top: 1px solid var(--border); padding-top: 8px; }

/* ── Montants aside ──────────────────────────────────────────────── */
.montant-bloc { display: flex; flex-direction: column; gap: 6px; }
.montant-ligne { display: flex; justify-content: space-between; font-size: 13px; }
.montant-ttc { font-size: 16px; font-weight: 700; padding-top: 8px; border-top: 1px solid var(--border-light); margin-top: 4px; }

/* ── Link styles ─────────────────────────────────────────────────── */
.link-strong { font-weight: 600; color: var(--text); }
.link-strong:hover { color: var(--blue); }
.doc-num { font-family: ui-monospace, monospace; font-size: 12px; font-weight: 700; color: var(--blue); }
.doc-num:hover { text-decoration: underline; }

/* ── Link box (share URL) ────────────────────────────────────────── */
.link-box {
  font-size: 11px; font-family: ui-monospace, monospace;
  background: var(--surface-2); padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); word-break: break-all; color: var(--text-muted);
  line-height: 1.5;
}

/* ── Aside list ──────────────────────────────────────────────────── */
.aside-list { display: flex; flex-direction: column; }
.aside-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--border-light);
  font-size: 12px; text-decoration: none; color: var(--text);
  transition: background .1s;
}
.aside-item:last-child { border-bottom: none; }
.aside-item:hover { background: var(--surface-2); text-decoration: none; }
.aside-amount { margin-left: auto; font-weight: 600; }

/* ── Flash messages ──────────────────────────────────────────────── */
.flash-stack {
  position: fixed; top: calc(var(--topbar-h) + 10px); right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 500; max-width: 420px;
}
.flash {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow);
  background: var(--surface); border: 1px solid var(--border);
  animation: slideIn .2s ease;
}
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.flash--success { border-left: 3px solid var(--green); }
.flash--success svg { color: var(--green); flex-shrink: 0; margin-top: 1px; }
.flash--error { border-left: 3px solid var(--red); }
.flash--error svg { color: var(--red); flex-shrink: 0; margin-top: 1px; }
.flash-close { background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 0; margin-left: auto; flex-shrink: 0; }
.flash-close:hover { color: var(--text); }
.flash--sandbox { border-left: 3px solid #f59f00; background: #fff9db; }
.flash--sandbox svg { color: #f59f00; flex-shrink: 0; margin-top: 1px; }

/* ── Sandbox ─────────────────────────────────────────────────────── */
.sandbox-banner {
  background: #fff3cd; color: #7a4f00; font-size: 12px;
  padding: 7px 20px; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid #f0c36d; position: sticky; top: 48px; z-index: 200;
}
.sandbox-banner code { background: rgba(0,0,0,.08); padding: 1px 5px; border-radius: 3px; font-size: 11px; }
.sandbox-banner-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.sandbox-banner-actions a,
.sandbox-banner-actions button {
  background: none; border: 1px solid #c49000; color: #7a4f00; border-radius: 5px;
  padding: 2px 9px; font-size: 11px; cursor: pointer; text-decoration: none;
}
.sandbox-banner-actions a:hover,
.sandbox-banner-actions button:hover { background: rgba(0,0,0,.06); }
body.dark .sandbox-banner { background: #2a2100; color: #f0c36d; border-color: #4a3800; }
body.dark .sandbox-banner code { background: rgba(255,255,255,.1); }
body.dark .sandbox-banner-actions a,
body.dark .sandbox-banner-actions button { border-color: #7a6000; color: #f0c36d; }
/* env-switch : bascule PROD / SBX */
.env-switch {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 6px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--bg-card);
  cursor: pointer; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  color: var(--text-muted); transition: border-color .15s;
}
.env-switch:hover { border-color: var(--text-muted); }
.env-switch-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--text-muted);
  transition: background .2s;
}
.env-switch-prod { order: -1; }
.env-switch-sbx  { order: 1; }
/* état PROD actif */
.env-switch:not(.env-switch--sandbox) .env-switch-prod { color: var(--text); }
.env-switch:not(.env-switch--sandbox) .env-switch-sbx  { opacity: .4; }
.env-switch:not(.env-switch--sandbox) .env-switch-thumb { background: #4dabf7; }
/* état SBX actif */
.env-switch--sandbox { border-color: #f59f00; }
.env-switch--sandbox .env-switch-sbx  { color: #f59f00; }
.env-switch--sandbox .env-switch-prod { opacity: .4; }
.env-switch--sandbox .env-switch-thumb { background: #f59f00; }
body.dark .env-switch { border-color: var(--border); background: var(--bg-card); }
body.dark .env-switch--sandbox { border-color: #e67700; }

.sandbox-mail-btn { position: relative; }
.sandbox-badge {
  position: absolute; top: 2px; right: 2px; background: #f03e3e; color: #fff;
  font-size: 9px; font-weight: 700; border-radius: 10px; padding: 0 4px; min-width: 14px;
  text-align: center; line-height: 14px;
}

/* ── Accordion ───────────────────────────────────────────────────── */
.accordion { margin-bottom: 10px; }
.accordion summary { list-style: none; }
.accordion summary::-webkit-details-marker { display: none; }

.accordion-summary {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 10px 2px; border-radius: var(--radius-sm);
  user-select: none;
}
.accordion-summary:hover .accordion-title { color: var(--blue); }

.accordion-chevron {
  color: var(--text-faint); flex-shrink: 0;
  transition: transform .18s ease;
}
details[open] > .accordion-summary .accordion-chevron {
  transform: rotate(90deg);
}

.accordion-title {
  font-size: 13px; font-weight: 700; color: var(--text); flex: 1;
  transition: color .12s;
}

.accordion-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; background: var(--surface-2); color: var(--text-muted);
}
.accordion-badge--green  { background: var(--green-light); color: var(--green); }
.accordion-badge--orange { background: var(--orange-light); color: var(--orange); }
.accordion-badge--blue   { background: var(--blue-light); color: var(--blue); }
.accordion-badge--muted  { background: var(--surface-2); color: var(--text-faint); }

.accordion-body { margin-bottom: 4px; }

.accordion-empty {
  font-size: 13px; color: var(--text-faint);
  padding: 8px 4px 16px; margin: 0;
}

/* Indicateur "non envoyé" / brouillon */
.tag-draft {
  display: inline-block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 6px; border-radius: 4px; margin-left: 6px;
  background: var(--orange-light); color: var(--orange);
  vertical-align: middle;
}

/* Ligne brouillon (léger fond) */
.row-draft td { background: color-mix(in srgb, var(--orange-light) 30%, transparent); }
body.dark .row-draft td { background: color-mix(in srgb, var(--orange-light) 20%, transparent); }

/* Ligne en retard */
.row-overdue td { background: color-mix(in srgb, var(--red-light) 30%, transparent); }
body.dark .row-overdue td { background: color-mix(in srgb, var(--red-light) 20%, transparent); }

/* Badge échéance dépassée */
.badge--retard { background: var(--red-light); color: var(--red); }

/* Avancement factures */
.progress-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.progress-label--done { color: var(--green); font-weight: 600; }

/* Couleur texte vert (montant encaissé) */
.text-green { color: var(--green); font-weight: 600; }

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 24px;
  color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-state svg { opacity: .35; }
.empty-state p { font-size: 14px; }

/* ── Footer ──────────────────────────────────────────────────────── */
.app-footer {
  position: fixed; bottom: 6px; right: 14px; z-index: 10;
  font-size: 10px; color: var(--text-faint);
  pointer-events: none;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .home-cols { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-layout, .form-layout { flex-direction: column; }
  .detail-aside, .form-aside { width: 100%; }
  .parties-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .field-grid { grid-template-columns: 1fr; }
  .field-span2 { grid-column: span 1; }
  .topbar-nav-links { display: none; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; padding: 16px; }
  .page-header .page-actions { width: 100%; }
  .section, .form-layout, .detail-layout { padding-left: 16px; padding-right: 16px; }
  .filter-tabs { padding-left: 16px; }
}
