/* Dashboard CRM DealLens — langage de design repris de Fluid Functionalism (Inter, 5 styles, lignes 36/28 px). */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(fonts/inter-latin-opsz-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(fonts/inter-latin-ext-opsz-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --bg: #ffffff; --s1: #fafafa; --s2: #ffffff; --s3: #ffffff;
  --line: #ebebeb; --fg: #171717; --muted: #6f6f6f;
  --hover: rgba(0, 0, 0, .04); --selected: rgba(0, 0, 0, .07);
  --accent: #2563eb; --accent-fg: #ffffff;
  --ok: #15803d; --warn: #b45309; --err: #dc2626;
  --shadow-1: 0 1px 2px rgba(0,0,0,.04), 0 1px 1px rgba(0,0,0,.03);
  --shadow-3: 0 0 0 1px rgba(0,0,0,.06), 0 8px 24px -4px rgba(0,0,0,.12), 0 2px 6px rgba(0,0,0,.05);
  --row: 36px; --r: 8px;
  --fast: 80ms; --moderate: 160ms; --slow: 240ms; --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #171717; --s1: #1c1c1c; --s2: #252525; --s3: #333333;
  --line: rgba(255,255,255,.08); --fg: #ededed; --muted: #a1a1a1;
  --hover: rgba(255,255,255,.06); --selected: rgba(255,255,255,.10);
  --accent: #3b82f6; --ok: #4ade80; --warn: #fbbf24; --err: #f87171;
  --shadow-1: none; --shadow-3: 0 0 0 1px rgba(255,255,255,.08), 0 12px 32px -6px rgba(0,0,0,.6);
} }
:root[data-theme="dark"] {
  --bg: #171717; --s1: #1c1c1c; --s2: #252525; --s3: #333333;
  --line: rgba(255,255,255,.08); --fg: #ededed; --muted: #a1a1a1;
  --hover: rgba(255,255,255,.06); --selected: rgba(255,255,255,.10);
  --accent: #3b82f6; --ok: #4ade80; --warn: #fbbf24; --err: #f87171;
  --shadow-1: none; --shadow-3: 0 0 0 1px rgba(255,255,255,.08), 0 12px 32px -6px rgba(0,0,0,.6);
}
body.compact { --row: 28px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 400 13px/20px "Inter", system-ui, sans-serif;
  font-variation-settings: "opsz" 14; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
.num, td.n, .stat b { font-variant-numeric: tabular-nums; }

/* 5 styles de texte, sans majuscules ni opacité */
.display { font-size: 28px; line-height: 34px; font-weight: 700; font-variation-settings: "opsz" 25; margin: 0; text-wrap: balance; }
.title { font-size: 16px; line-height: 22px; font-weight: 550; font-variation-settings: "opsz" 18; margin: 24px 0 8px; text-wrap: balance; }
.subtitle { font-size: 14px; line-height: 20px; font-weight: 550; font-variation-settings: "opsz" 18; margin: 20px 0 8px; }
.caption { font-size: 12px; line-height: 16px; color: var(--muted); margin: 8px 0 0; }
p { margin: 12px 0 0; text-wrap: pretty; }
body.compact .title { margin: 16px 0 4px; } body.compact .subtitle { margin: 12px 0 4px; }

/* structure */
.app { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
.side { background: var(--s1); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; min-height: 0; }
.brand { padding: 4px 8px 16px; }
.brand b { font-weight: 550; font-size: 14px; display: block; }
.nav { position: relative; display: flex; flex-direction: column; gap: 4px; }
.nav.bas { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.nav button { all: unset; position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; height: var(--row);
  padding: 0 10px; border-radius: var(--r); cursor: pointer; color: var(--muted); transition: color var(--fast) var(--ease); }
.nav button svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; }
.nav button:hover, .nav button[aria-current="page"] { color: var(--fg); }
.nav button[aria-current="page"] { background: var(--selected); font-weight: 550; font-variation-settings: "opsz" 18; }
.nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.glisse { position: absolute; left: 0; right: 0; top: 0; height: var(--row); border-radius: var(--r); background: var(--hover);
  opacity: 0; pointer-events: none; transition: transform var(--moderate) var(--ease), opacity var(--fast) var(--ease), height var(--moderate) var(--ease); }
.glisse.on { opacity: 1; }

.main { overflow: auto; min-width: 0; }
.page { max-width: 1280px; margin: 0 auto; padding: 32px 32px 64px; }
.entete { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* cartes et statistiques */
.grille { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 24px; }
.carte { background: var(--s2); border: 1px solid var(--line); border-radius: calc(var(--r) + 4px); padding: 16px; box-shadow: var(--shadow-1); }
.stat .caption { margin: 0 0 8px; }
.stat b { font-size: 28px; line-height: 34px; font-weight: 700; font-variation-settings: "opsz" 25; }
.deux { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-top: 12px; }
.barres { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.barre { display: grid; grid-template-columns: minmax(0, 1fr) 56px; align-items: center; gap: 12px; height: 28px; }
.barre .lib { position: relative; height: 28px; display: flex; align-items: center; padding: 0 8px; border-radius: 6px; overflow: hidden; }
.barre .lib i { position: absolute; inset: 0 auto 0 0; background: var(--selected); border-radius: 6px; transition: width var(--slow) var(--ease); }
.barre .lib span { position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* outils de filtre */
.outils { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 24px; }
.champ { height: var(--row); padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--s2);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease); }
.champ:hover { border-color: var(--muted); }
.champ:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
input.champ[type="search"] { min-width: 260px; flex: 1 1 260px; max-width: 420px; }
select.champ { padding-right: 28px; max-width: 220px; }
.compte { color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }

.btn { height: var(--row); padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--s2); cursor: pointer;
  font-weight: 550; font-variation-settings: "opsz" 18; transition: background var(--fast) var(--ease), transform var(--fast) var(--ease); }
.btn:hover { background: var(--hover); } .btn:active { transform: scale(.98); }
.btn.principal { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.principal:hover { opacity: .9; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { cursor: progress; opacity: .6; }

/* tableaux */
.table-boite { margin-top: 12px; border: 1px solid var(--line); border-radius: calc(var(--r) + 4px); background: var(--s2); overflow: auto; box-shadow: var(--shadow-1); }
table { width: 100%; border-collapse: collapse; }
thead th { position: sticky; top: 0; background: var(--s2); z-index: 2; text-align: left; font-weight: 550; font-variation-settings: "opsz" 18;
  color: var(--muted); height: var(--row); padding: 0 12px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
thead th:hover { color: var(--fg); }
thead th[aria-sort] { color: var(--fg); }
thead th[aria-sort="ascending"]::after { content: " ↑"; } thead th[aria-sort="descending"]::after { content: " ↓"; }
tbody { position: relative; }
tbody tr { height: var(--row); }
tbody td { padding: 0 12px; border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; position: relative; z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.cliquable { cursor: pointer; }
tbody tr.cliquable:hover td { background: var(--hover); }
td.n { text-align: right; } td.m { color: var(--muted); }
.vide { padding: 32px; text-align: center; color: var(--muted); }
.plus { display: flex; justify-content: center; padding: 12px; }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 12px; line-height: 16px;
  background: var(--selected); color: var(--fg); white-space: nowrap; }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.err { color: var(--err); }
.badge.ok, .badge.warn, .badge.err { background: color-mix(in srgb, currentColor 12%, transparent); }

/* tiroir de fiche */
.voile { position: fixed; inset: 0; background: rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity var(--slow) var(--ease); z-index: 10; }
.voile.ouvert { opacity: 1; pointer-events: auto; }
.tiroir { position: fixed; top: 8px; right: 8px; bottom: 8px; width: min(720px, calc(100vw - 16px)); background: var(--s3); border-radius: calc(var(--r) + 6px);
  box-shadow: var(--shadow-3); transform: translateX(calc(100% + 16px)); transition: transform var(--slow) var(--ease); z-index: 11; display: flex; flex-direction: column; }
.tiroir.ouvert { transform: none; }
.tiroir header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 20px 12px; border-bottom: 1px solid var(--line); }
.tiroir .corps { overflow: auto; padding: 0 20px 24px; }
.tiroir .table-boite { background: transparent; box-shadow: none; }
.tiroir thead th { background: var(--s3); cursor: default; }
.fermer { all: unset; cursor: pointer; width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--r); color: var(--muted); }
.fermer:hover { background: var(--hover); color: var(--fg); }
dl.champs { display: grid; grid-template-columns: 180px 1fr; gap: 4px 16px; margin: 12px 0 0; }
dl.champs dt { color: var(--muted); } dl.champs dd { margin: 0; word-break: break-word; }

/* configuration */
form.config { display: grid; grid-template-columns: 160px minmax(0, 360px); gap: 8px 16px; align-items: center; margin-top: 24px; }
form.config label { color: var(--muted); }
form.config .actions { grid-column: 2; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.message { margin-top: 16px; padding: 12px 16px; border-radius: var(--r); background: var(--s2); border: 1px solid var(--line); }
.message.ok { color: var(--ok); } .message.err { color: var(--err); }
.reglages { display: flex; gap: 8px; margin-top: 24px; flex-wrap: wrap; }

/* connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.connexion form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; }
.connexion .champ { width: 100%; }
.erreur { color: var(--err); min-height: 20px; }
[hidden] { display: none !important; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100vh; }
  .side { flex-direction: row; flex-wrap: wrap; padding: 8px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { display: none; } .nav { flex-direction: row; flex-wrap: wrap; } .nav.bas { margin: 0; padding: 0; border: 0; }
  .glisse { display: none; } .page { padding: 20px 16px 48px; }
  form.config { grid-template-columns: 1fr; } form.config .actions { grid-column: 1; }
  dl.champs { grid-template-columns: 1fr; } input.champ[type="search"] { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.tiroir header .title { margin: 0; } .connexion .display { margin-bottom: 4px; }
.carte .subtitle { margin-top: 0; }
label.choix { display: flex; align-items: center; gap: 8px; color: var(--fg) !important; cursor: pointer; }
input[type="file"].champ { padding: 5px 8px; height: auto; min-height: var(--row); }
input[type="file"].champ::file-selector-button { font: inherit; font-weight: 550; border: 1px solid var(--line); background: var(--s3); color: var(--fg);
  border-radius: 6px; padding: 2px 10px; margin-right: 10px; cursor: pointer; }
