/* MétrIA — thème 2026 : jetons clair / sombre, profondeur, mouvement. Chargé après styles.css. */

:root {
  color-scheme: light;
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eceef2;
  --glass: rgba(255, 255, 255, .72);
  --line-soft: #eff1f4;
  --border: #e4e7ec;
  --text: #11151c;
  --muted: #667085;
  --muted-2: #98a2b3;
  --primary: #ff5b1f;
  --primary-2: #ff8a3d;
  --primary-dark: #e04608;
  --on-accent: #ffffff;
  --grad-primary: linear-gradient(135deg, #ff7a2f 0%, #ff4d1a 100%);
  --ai: #7048e8;
  --grad-ai: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 45%, #db2777 100%);
  --ai-bg: #f3efff;
  --ai-line: #d9ccff;
  --good: #12805c; --good-bg: #e3f7ee;
  --warn: #9a6700; --warn-bg: #fff4d6;
  --danger: #d92d20; --danger-bg: #fef0ef; --danger-bg-2: #fdd8d4;
  --accent-bg: #fff2ea; --accent-line: #ffd2b8;
  --info: #175cd3; --info-bg: #eaf2ff;
  --flash: #fff2a8;
  --grid-dot: #d5d9e0;
  --side: #0c0f14;
  --side-2: #151a22;
  --side-text: #aab3c2;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px -8px rgba(16, 24, 40, .12);
  --shadow-lg: 0 24px 60px -12px rgba(16, 24, 40, .28);
  --ease: cubic-bezier(.2, .8, .2, 1);
  /* graphiques : palette catégorielle de référence validée (ordre fixe), surface claire */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4; --series-6: #008300;
  --chart-grid: #e8eaee;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01", "tnum";
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0b0d12; --surface: #141821; --surface-2: #1a1f2a; --surface-3: #232937; --glass: rgba(20, 24, 33, .72);
    --line-soft: #1e2430; --border: #2a3140; --text: #eef1f6; --muted: #98a2b3; --muted-2: #667085;
    --ai-bg: #231a3d; --ai-line: #3d2f6b; --good: #3ccb8f; --good-bg: #0f2c22; --warn: #f5b83d; --warn-bg: #2e2410;
    --danger: #ff6b5f; --danger-bg: #331614; --danger-bg-2: #4a1c18; --accent-bg: #2c1a10; --accent-line: #5a3015;
    --info: #6aa5ff; --info-bg: #13233d; --flash: #4a4416; --grid-dot: #2a3140; --side: #07090d; --side-2: #10141b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -8px rgba(0, 0, 0, .6); --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300;
    --chart-grid: #232937;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d12; --surface: #141821; --surface-2: #1a1f2a; --surface-3: #232937; --glass: rgba(20, 24, 33, .72);
  --line-soft: #1e2430; --border: #2a3140; --text: #eef1f6; --muted: #98a2b3; --muted-2: #667085;
  --ai-bg: #231a3d; --ai-line: #3d2f6b; --good: #3ccb8f; --good-bg: #0f2c22; --warn: #f5b83d; --warn-bg: #2e2410;
  --danger: #ff6b5f; --danger-bg: #331614; --danger-bg-2: #4a1c18; --accent-bg: #2c1a10; --accent-line: #5a3015;
  --info: #6aa5ff; --info-bg: #13233d; --flash: #4a4416; --grid-dot: #2a3140; --side: #07090d; --side-2: #10141b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -8px rgba(0, 0, 0, .6); --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300;
  --chart-grid: #232937;
}

html, body { background: var(--bg); color: var(--text); }
::selection { background: color-mix(in srgb, var(--primary) 30%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--muted-2) transparent; }
input, select, textarea { background: var(--surface); color: var(--text); border-color: var(--border); border-radius: 8px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
h1 { letter-spacing: -.02em; }
h3 { font-size: 11.5px; letter-spacing: .08em; }

/* ---------- Barre latérale ---------- */
#sidebar { background: radial-gradient(120% 60% at 0% 0%, rgba(255, 91, 31, .16), transparent 60%), linear-gradient(180deg, var(--side-2), var(--side)); border-right: 1px solid rgba(255,255,255,.04); gap: 8px; }
.logo { background: var(--grad-primary); border-radius: 10px; box-shadow: 0 6px 18px -4px rgba(255, 91, 31, .6); }
#project-list li { transition: background .15s, transform .15s var(--ease); position: relative; }
#project-list li:hover { transform: translateX(2px); }
#project-list li.active { background: rgba(255, 255, 255, .07); color: #fff; }
#project-list li.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad-primary); }
.side-bottom .btn.ghost { justify-content: flex-start; border-color: transparent; }
.side-bottom .btn.ghost:hover { background: rgba(255, 255, 255, .06); }
.kbd-hint { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--side-text); opacity: .8; padding: 6px 10px; border: 1px solid rgba(255,255,255,.08); border-radius: 8px; cursor: pointer; }
.kbd-hint:hover { background: rgba(255,255,255,.05); }
kbd { font: 600 10.5px/1 Inter, system-ui; padding: 3px 5px; border-radius: 5px; background: var(--surface-3); color: var(--muted); border: 1px solid var(--border); }
#sidebar kbd { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.1); color: var(--side-text); }
.theme-toggle { display: flex; gap: 2px; background: rgba(255,255,255,.06); border-radius: 9px; padding: 2px; }
.theme-toggle button { flex: 1; border: none; background: transparent; color: var(--side-text); padding: 5px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.theme-toggle button.on { background: rgba(255,255,255,.12); color: #fff; }

/* ---------- Boutons ---------- */
.btn { border-radius: 9px; font-weight: 500; transition: transform .12s var(--ease), box-shadow .2s, background .15s, border-color .15s; background: var(--surface); border-color: var(--border); color: var(--text); }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad-primary); border-color: transparent; box-shadow: 0 6px 16px -6px rgba(255, 77, 26, .7); }
.btn.primary:hover { background: var(--grad-primary); filter: brightness(1.06); box-shadow: 0 10px 22px -6px rgba(255, 77, 26, .8); }
.btn.ai { position: relative; overflow: hidden; background: var(--grad-ai); border-color: transparent; box-shadow: 0 6px 18px -6px rgba(139, 92, 246, .75); }
.btn.ai::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%); transform: translateX(-120%); }
.btn.ai:hover::after { transition: transform .8s var(--ease); transform: translateX(120%); }
.btn.ai:disabled::after { animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { from { transform: translateX(-120%); } to { transform: translateX(120%); } }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
#sidebar .btn.primary { padding: 9px 12px; }

/* ---------- En-têtes, onglets ---------- */
.topbar { background: var(--glass); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-bottom-color: var(--border); position: relative; z-index: 3; }
.title-input, .sub-input { background: transparent; }
.project-tabs { position: relative; background: var(--glass); backdrop-filter: blur(14px); border-bottom-color: var(--border); }
.project-tabs button { color: var(--muted); border-bottom: none !important; transition: color .15s; padding: 11px 14px; }
.project-tabs button:hover { color: var(--text); }
.project-tabs button.active { color: var(--text); font-weight: 600; background: transparent; }
.tab-ink { position: absolute; bottom: -1px; height: 2px; border-radius: 2px; background: var(--grad-primary); transition: left .35s var(--ease), width .35s var(--ease); pointer-events: none; }
.tabs button.active { background: var(--accent-bg); color: var(--primary-dark); }
.auth-tabs button.active { background: var(--accent-bg); }

/* ---------- Surfaces ---------- */
.editor, .card, .kpis > div, .steps > div, table.grid, .totals, .livrable, .journal { border-color: var(--border); }
.editor, .kpis > div, .steps > div { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
table.grid { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); border-collapse: separate; border-spacing: 0; }
table.grid th { background: var(--surface-2); color: var(--muted); letter-spacing: .05em; border-bottom-color: var(--border); }
table.grid td { border-bottom-color: var(--line-soft); }
table.grid tbody tr { transition: background .12s; }
table.grid tbody tr:hover td { background: color-mix(in srgb, var(--primary) 4%, transparent); }
table.grid tr.lot-row td { background: var(--accent-bg); }
.panel, .devis-side, .toolbar, .plan-bar, .devis-actions, .filters { background: var(--surface); border-color: var(--border); }
.canvas-wrap { background-color: var(--surface-3); }
.modal { background: rgba(8, 10, 14, .45); backdrop-filter: blur(6px); animation: fade .18s ease-out; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: pop .22s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes fade { from { opacity: 0; } }
.toast { border-radius: 12px; box-shadow: var(--shadow-lg); animation: toast-in .3s var(--ease); background: #11151c; padding: 12px 16px 12px 40px; }
.toast::before { content: "✓"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; border-radius: 50%; background: #12b76a; color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.toast.error::before { content: "!"; background: #fff; color: var(--danger); }
.toast.error { background: #d92d20; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px) scale(.96); } }
.assistant { background: var(--glass); backdrop-filter: blur(18px) saturate(160%); border-left-color: var(--border); animation: slide-in .3s var(--ease); }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
.msg.assistant { background: var(--surface-2); }
.msg.user { background: var(--grad-primary); }
.msg .action { background: var(--surface); }
.auth { background: radial-gradient(80% 60% at 20% 10%, rgba(255, 91, 31, .35), transparent 60%), radial-gradient(70% 60% at 90% 90%, rgba(139, 92, 246, .35), transparent 60%), #07090d; }
.auth-box { border-radius: 20px; background: var(--glass); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,.12); animation: pop .4s var(--ease); }
.gauge { background: radial-gradient(closest-side, var(--surface) 78%, transparent 79%), conic-gradient(var(--primary) calc(var(--v) * 1%), var(--surface-3) 0); }
.valid { background: var(--surface); }

/* ---------- Apparition des vues ---------- */
.view:not(.hidden), .tab-body:not(.hidden) { animation: rise .35s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Tableau de bord ---------- */
.home { max-width: 1320px; padding: 28px 32px 48px; }
.hero { position: relative; overflow: hidden; border-radius: 22px; padding: 28px 30px; color: #fff; margin-bottom: 18px;
  background: radial-gradient(60% 120% at 100% 0%, rgba(139, 92, 246, .55), transparent 60%), radial-gradient(60% 120% at 0% 100%, rgba(255, 91, 31, .55), transparent 55%), #12151c; box-shadow: var(--shadow-lg); }
.hero::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.12) 1px, transparent 1px); background-size: 18px 18px; mask-image: linear-gradient(90deg, transparent, #000 70%); pointer-events: none; }
.hero h1 { font-size: 30px; margin: 0 0 6px; }
.hero p { margin: 0; max-width: 680px; color: rgba(255,255,255,.75); }
.hero .hero-actions { display: flex; gap: 10px; margin-top: 18px; position: relative; z-index: 1; flex-wrap: wrap; }
.hero .btn.glass { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.18); backdrop-filter: blur(8px); }
.hero .btn.glass:hover { background: rgba(255,255,255,.2); }
.bento { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; transition: transform .2s var(--ease), box-shadow .2s; min-width: 0; }
.tile:hover { box-shadow: var(--shadow); }
.tile h4 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.tile .big { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
@media (max-width: 1100px) { .span-3, .span-4 { grid-column: span 6; } .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; } }
@media (max-width: 640px) { .span-3, .span-4 { grid-column: span 12; } .home { padding: 16px; } }
.delta { font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 10px; }
.delta.up { background: var(--good-bg); color: var(--good); } .delta.down { background: var(--danger-bg); color: var(--danger); }
.icon-dot { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 14px; background: var(--surface-2); }
.chart { width: 100%; display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 500 11px Inter, system-ui; }
.chart .grid line { stroke: var(--chart-grid); }
.chart .bar { transition: opacity .15s; }
.chart .bar:hover, .chart .hit:hover + .bar { opacity: .82; }
.chart .ref { stroke: var(--muted-2); stroke-dasharray: 3 3; }
.chart-tip { position: fixed; z-index: 70; pointer-events: none; background: #11151c; color: #fff; border-radius: 8px; padding: 7px 10px; font-size: 12px; box-shadow: var(--shadow-lg); transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap; opacity: 0; transition: opacity .12s; }
.chart-tip.on { opacity: 1; }
.chart-tip b { font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; background: var(--surface); }
.stack span { height: 100%; transition: filter .15s; } .stack span:first-child { border-radius: 4px 0 0 4px; } .stack span:last-child { border-radius: 0 4px 4px 0; }
.stack span:hover { filter: brightness(1.12); }
.pipeline { display: grid; gap: 8px; }
.pipe-row { display: grid; grid-template-columns: 120px 1fr 34px; align-items: center; gap: 10px; font-size: 13px; }
.pipe-row .track { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.pipe-row .track i { display: block; height: 100%; border-radius: 4px; background: var(--series-1); width: 0; transition: width .9s var(--ease); }
.pipe-row b { text-align: right; font-variant-numeric: tabular-nums; }
.feed { display: grid; gap: 2px; max-height: 300px; overflow: auto; }
.feed div { display: grid; grid-template-columns: 8px 1fr; gap: 10px; padding: 7px 0; font-size: 13px; }
.feed div::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 5px; box-shadow: 0 0 0 3px var(--accent-bg); }
.feed small { color: var(--muted); display: block; }
.todo { display: grid; gap: 8px; }
.todo a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; background: var(--surface-2); color: inherit; text-decoration: none; font-size: 13px; transition: transform .15s var(--ease), background .15s; cursor: pointer; }
.todo a:hover { transform: translateX(3px); background: var(--accent-bg); }
.todo a span:last-child { margin-left: auto; color: var(--muted); }
.cards { gap: 14px; }
.card { background: var(--surface); border-radius: 16px; padding: 16px; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent-line); }
.card .ring { --v: 0; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: radial-gradient(closest-side, var(--surface) 76%, transparent 77%), conic-gradient(var(--c, var(--primary)) calc(var(--v) * 1%), var(--surface-3) 0); }
.card .foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.empty-hero { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ---------- Palette de commandes ---------- */
.palette { position: fixed; inset: 0; z-index: 80; display: grid; justify-items: center; align-items: start; padding-top: 12vh; background: rgba(8, 10, 14, .45); backdrop-filter: blur(6px); animation: fade .15s; }
.palette-box { width: min(620px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .2s var(--ease); }
.palette-box input { width: 100%; border: none; border-bottom: 1px solid var(--border); border-radius: 0; padding: 16px 18px; font-size: 16px; box-shadow: none !important; }
.palette-list { max-height: 50vh; overflow: auto; padding: 6px; }
.palette-list .grp { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px 4px; }
.palette-list button { display: flex; width: 100%; gap: 10px; align-items: center; border: none; background: transparent; color: var(--text); text-align: left; padding: 9px 10px; border-radius: 9px; font: inherit; cursor: pointer; }
.palette-list button.on { background: var(--accent-bg); }
.palette-list button small { margin-left: auto; color: var(--muted); }
.palette-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }
