/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r-ctl); background: var(--bg); font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none; transition: background .12s ease-out, border-color .12s ease-out; }
.btn:hover { background: var(--bg-subtle); border-color: var(--border-strong); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #27272a; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-muted); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.linkbtn { all: unset; cursor: pointer; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn:disabled { cursor: default; text-decoration: none; }
.linkbtn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* Champs */
.input, .select { height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-ctl); background: var(--bg); font-size: 13px; min-width: 0; }
.select { padding-right: 26px; }
.input:hover, .select:hover { border-color: var(--border-strong); }
.field { display: grid; gap: 4px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.field .input, .field .select { color: var(--text); font-weight: 400; }

/* Segmenté et onglets */
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--bg-muted); border-radius: var(--r-ctl); }
.seg button { border: 0; background: none; height: 28px; padding: 0 10px; border-radius: 4px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: var(--shadow-sm); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--bg); font-size: 13px; font-weight: 500; color: var(--text-2); }
.tabs button[aria-pressed="true"] { border-color: var(--text); color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.tabs small { color: var(--text-3); margin-left: 4px; }

/* Pastilles */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--bg); font-size: 13px; font-weight: 500; }
button.chip:hover { background: var(--bg-subtle); border-color: var(--border-strong); }
.chip .idx { width: 16px; height: 16px; border-radius: 4px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; }
.chip.alt .idx { background: var(--primary); }
.chip.on { background: var(--brand-soft); border-color: var(--brand); }
.chip.add { border-style: dashed; color: var(--text-2); cursor: pointer; }
.chip.add:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-subtle); }
.chip .ico { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; color: var(--text-3); }
/* Pastille de filtre : libellé cliquable (modifier) + croix (retirer) */
.fchip { display: inline-flex; align-items: center; height: 28px; max-width: 100%; background: var(--bg-muted); border-radius: var(--r-ctl); font-size: 13px; font-weight: 500; }
.fchip .ftext { display: block; height: 28px; line-height: 28px; padding: 0 10px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: var(--r-ctl); }
.fchip summary.ftext { padding-right: 4px; }
.fchip summary.ftext:hover { background: var(--border); }
.fchip > button { all: unset; cursor: pointer; padding: 0 8px; height: 28px; color: var(--text-3); border-radius: var(--r-ctl); }
.fchip > button:hover { color: var(--text); }
.fchip > button:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }
.chip .select { border: 0; height: 24px; padding: 0 4px; background: none; font-weight: 500; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: var(--r-chip); background: var(--bg-muted); font-size: 12px; font-weight: 500; }
.tag.t0 { background: #fef3c7; } .tag.t1 { background: #dbeafe; } .tag.t2 { background: #fce7f3; } .tag.t3 { background: #dcfce7; } .tag.t4 { background: #ede9fe; }
.pillnum { display: inline-block; padding: 1px 7px; border-radius: 5px; background: var(--bg-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.badge { position: absolute; left: 8px; bottom: 8px; background: rgb(24 24 27 / .78); color: #fff; font-size: 11.5px; font-weight: 500; padding: 2px 7px; border-radius: var(--r-chip); }
.delta { font-size: 12px; font-weight: 500; }
.delta.up { color: var(--success); } .delta.down { color: var(--danger); } .delta.flat { color: var(--text-3); }
.sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; }

/* Popover (basé sur <details>) */
.pop { position: relative; }
.pop > summary { list-style: none; cursor: pointer; user-select: none; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-panel { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 260px; padding: 8px; background: var(--bg); border-radius: var(--r-card); box-shadow: var(--shadow-pop); display: grid; gap: 8px; }
.pop-panel.right { left: auto; right: 0; }
.menuitem { all: unset; box-sizing: border-box; cursor: pointer; display: grid; gap: 2px; width: 100%; padding: 8px 10px; border-radius: var(--r-ctl); font-size: 13px; }
.menuitem:hover, .menuitem:focus-visible { background: var(--bg-muted); }
.menuitem small { color: var(--text-3); }
.menuitem.danger { color: var(--danger); }

/* Modale */
.modal { border: 0; padding: 0; border-radius: var(--r-board); box-shadow: 0 24px 60px rgb(0 0 0 / .22); width: min(440px, calc(100vw - 32px)); color: var(--text); }
.modal::backdrop { background: rgb(24 24 27 / .45); }
.modal form { display: grid; gap: 14px; padding: 20px; }
.modal h2 { margin: 0; }
.modal p { color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Toasts */
.toasts { position: fixed; z-index: 60; left: 50%; bottom: 20px; translate: -50% 0; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r-card); background: var(--primary); color: #fff; font-size: 13px; box-shadow: var(--shadow-pop); }
.toast.error { background: var(--danger); }
.toast a { color: #fff; font-weight: 600; }
.toast button { all: unset; cursor: pointer; margin-left: auto; padding: 0 4px; opacity: .8; }

/* Cartes et grilles */
.card { display: flex; flex-direction: column; text-align: left; padding: 0; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--bg); overflow: hidden; font-weight: 400; color: inherit; text-decoration: none; }
button.card, a.card { cursor: pointer; transition: box-shadow .14s ease-out, border-color .14s ease-out; }
button.card:hover, a.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
button.card:disabled { cursor: default; opacity: 1; }
.thumb { position: relative; aspect-ratio: 4 / 5; background: var(--bg-muted); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { padding: 10px 12px 12px; display: grid; gap: 8px; }
.card-title { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.board { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-board); padding: 12px; box-shadow: var(--shadow-sm); }
.board .card .thumb { margin: 8px 8px 0; border-radius: 6px; }
.boardbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 0 0 12px; }
.mrows { display: grid; }
.mrows > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.mrows > div:first-child { border-top: 0; }
.mrows b { color: var(--text); font-weight: 500; padding: 1px 7px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.rank { position: absolute; right: 8px; top: 8px; width: 26px; height: 26px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-weight: 700; font-size: 12px; box-shadow: var(--shadow-sm); }
.scorepill { position: absolute; right: 8px; bottom: 8px; background: var(--brand); color: #fff; font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: var(--r-pill); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 1px solid var(--border); border-radius: var(--r-board); overflow: hidden; background: var(--bg); }
.kpi { padding: 14px 16px; box-shadow: 0 0 0 .5px var(--border); display: grid; gap: 2px; }
.kpi small { color: var(--text-3); font-weight: 500; }
.kpi b { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

/* Tableau de données */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-board); background: var(--bg); }
table { border-collapse: collapse; width: 100%; font-size: 13px; line-height: 18px; }
th, td { height: 40px; padding: 0 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
th { height: 36px; font-weight: 500; color: var(--text-3); background: var(--bg-subtle); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
th.stick, td.stick { position: sticky; left: 0; z-index: 1; text-align: left; background: var(--bg); min-width: 280px; max-width: 340px; }
th.stick { background: var(--bg-subtle); z-index: 2; }
th button { all: unset; cursor: pointer; }
th button:hover, th[aria-sort] button { color: var(--text); }
th button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
td.heat { border-left: 1px solid var(--bg); }
td.best { font-weight: 600; }
.colhead { display: inline-flex; align-items: center; gap: 7px; }
.colnum { all: unset; cursor: pointer; width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--border-strong); display: inline-grid; place-items: center; font-size: 10.5px; font-weight: 700; color: #fff; }
.colnum[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); }
.rowlabel { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rowname { display: grid; min-width: 0; }
.rowname > :first-child { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowname small { color: var(--text-3); }
.strip { display: flex; flex: none; }
.strip img { width: 28px; height: 35px; object-fit: cover; border-radius: 4px; border: 2px solid var(--bg); margin-left: -8px; background: var(--bg-muted); }
.strip img:first-child { margin-left: 0; }

/* Divers */
.empty { padding: 48px 20px; text-align: center; color: var(--text-3); border: 1px dashed var(--border-strong); border-radius: var(--r-board); }
.note { font-size: 13px; color: var(--text-2); background: var(--warning-bg); border-radius: var(--r-card); padding: 10px 12px; max-width: 90ch; }
.msg { font-size: 13px; }
.msg.err { color: var(--danger); } .msg.ok { color: var(--success); }
.avatar { width: 20px; height: 20px; flex: none; border-radius: 5px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 600; font-style: normal; }
.avatar.big { width: 48px; height: 48px; border-radius: 50%; font-size: 20px; background: var(--brand); }
.skeleton { border-radius: var(--r-card); background: linear-gradient(90deg, var(--bg-muted), var(--bg-subtle), var(--bg-muted)); background-size: 200% 100%; animation: sk 1.2s linear infinite; min-height: 120px; }
@keyframes sk { to { background-position: -200% 0; } }

/* Tiroir */
.drawer { position: fixed; inset: 0; z-index: 40; background: rgb(24 24 27 / .4); display: flex; justify-content: flex-end; }
.drawer-panel { width: min(720px, 100%); height: 100%; overflow-y: auto; background: var(--bg); padding: 24px 28px 48px; box-shadow: var(--shadow-pop); }
.drawer-head { display: grid; grid-template-columns: 112px 1fr auto; gap: 16px; align-items: start; }
.drawer-head img { width: 112px; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--r-card); }
.chart { border: 1px solid var(--border); border-radius: var(--r-board); padding: 14px; }
.chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.hbarrow { display: grid; grid-template-columns: 52px 1fr 64px; gap: 8px; align-items: center; font-size: 12px; color: var(--text-2); }
.hbarrow i { height: 10px; border-radius: 3px; background: var(--bg-muted); overflow: hidden; display: block; }
.hbarrow i span { display: block; height: 100%; background: var(--primary); }
.hbarrow b { color: var(--text); text-align: right; font-weight: 500; }
@media (max-width: 640px) { .drawer-head { grid-template-columns: 80px 1fr; } .drawer-head img { width: 80px; } .drawer-panel { padding: 18px 16px 40px; } }

/* Champs de modale supplémentaires */
.checks { border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 8px 10px; margin: 0; display: grid; gap: 6px; max-height: 180px; overflow-y: auto; font-size: 13px; }
.checks legend { font-size: 12px; font-weight: 500; color: var(--text-2); padding: 0 4px; }
.checks label { display: flex; gap: 8px; align-items: center; }
.codelist { margin: 6px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pop-panel.up { top: auto; bottom: calc(100% + 6px); }
.menuhead { display: grid; padding: 6px 10px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.menuhead small { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
a.menuitem { text-decoration: none; color: inherit; }

/* Menus, boutons-icônes, états */
.pop-panel.menu { gap: 2px; min-width: 220px; }
.pop-panel.scroll { max-height: min(70vh, 560px); overflow-y: auto; }
.menulabel { padding: 6px 10px 2px; font-size: 12px; font-weight: 500; color: var(--text-3); }
.menuitem[aria-pressed="true"] { background: var(--bg-muted); font-weight: 500; }
.iconbtn { all: unset; cursor: pointer; width: 26px; height: 26px; display: grid; place-items: center; border-radius: var(--r-ctl); color: var(--text-3); flex: none; }
.iconbtn:hover { background: var(--bg-muted); color: var(--text); }
.iconbtn:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }
.iconbtn[aria-pressed="true"] { color: var(--warning); }
.state { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.state.on::before { background: var(--success); }
.seriesdot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.checks.tall { max-height: 220px; }
th.txt, td.txt { text-align: left; }
table.plain td.stick a { font-weight: 500; color: inherit; text-decoration: none; }
table.plain td.stick a:hover { text-decoration: underline; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.input.grow { flex: 1; min-width: 200px; max-width: 420px; }
@media (max-width: 640px) {
  .pop-panel:not(.up) { position: fixed; z-index: 50; left: 12px; right: 12px; top: auto; bottom: 12px; max-height: 75vh; overflow-y: auto; }
}

/* Étiquettes de performance et tags manuels */
.perf { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--bg-muted); color: var(--text-2); }
.perf::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.perf.winner { background: var(--success-bg); color: var(--success); }
.perf.underperformer { background: var(--danger-bg); color: var(--danger); }
.perf.testing { background: var(--info-bg); color: var(--info); }
.perf.scaled { background: var(--warning-bg); color: var(--warning); }
.mtag { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: var(--r-pill); font-size: 12px; font-weight: 500; white-space: nowrap; background: #f4f4f5; color: #3f3f46; }
.mtag.red { background: #fee2e2; color: #991b1b; } .mtag.orange { background: #ffedd5; color: #9a3412; } .mtag.yellow { background: #fef9c3; color: #854d0e; }
.mtag.green { background: #dcfce7; color: #166534; } .mtag.blue { background: #dbeafe; color: #1e40af; } .mtag.violet { background: #ede9fe; color: #5b21b6; } .mtag.pink { background: #fce7f3; color: #9d174d; }
td .tags { flex-wrap: nowrap; }
tr[aria-current="true"] td { background: var(--bg-subtle); font-weight: 500; }
.input.short { width: 96px; flex: none; }

/* Fiche créa complète */
.drawer-title { font-size: 20px; line-height: 28px; }
.drawer-tabs { margin: 18px 0 10px; }
.drawer-panel { width: min(820px, 100%); }
.variants { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.variants li { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-card); }
.variants p { min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }
.variants .small { flex: none; }
.ratebar.wide { width: 96px; }
.ratebar.wide i { background: var(--primary); }
.playcurve { display: grid; grid-template-columns: repeat(22, minmax(0, 1fr)); gap: 2px; height: 190px; }
.playcurve .pc { display: grid; grid-template-rows: 16px 1fr 16px; justify-items: center; min-width: 0; }
.playcurve .pc i { align-self: end; width: 100%; min-height: 2px; background: #2a78d6; border-radius: 4px 4px 0 0; }
.playcurve .val, .playcurve .tick { font-size: 10.5px; color: var(--text-3); white-space: nowrap; }

/* Tendance de dépense, distinctions, bandes de score (lot 8) */
.perf.underperformer { background: var(--warning-bg); color: var(--warning); }
.perf.scaled { background: var(--info-bg); color: var(--info); }
.trend { font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--text-3); }
.trend.up { color: var(--success); } .trend.up::before { content: "▲ "; }
.trend.down { color: var(--danger); } .trend.down::before { content: "▼ "; }
.trend.new { background: var(--info-bg); color: var(--info); border-radius: var(--r-pill); padding: 1px 8px; }
.badges { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.badgepill { display: inline-block; font-size: 11px; font-weight: 600; line-height: 18px; padding: 0 7px; border-radius: var(--r-pill); background: var(--surface-2, var(--bg)); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.badgepill.unicorn, .badgepill.winning { border-color: transparent; background: var(--success-bg); color: var(--success); }
.badgepill.won { color: var(--text-3); }
.scorechips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.scorechip { font-size: 12px; padding: 2px 8px; border-radius: var(--r-pill); background: var(--bg); border: 1px solid var(--border); }
.scorechip b { margin-left: 4px; }
.scorechip.low { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.scorechip.mid { background: var(--warning-bg); border-color: transparent; }
.scorechip.good, .scorechip.top { background: var(--success-bg); border-color: transparent; color: var(--success); }
.votes { display: inline-flex; gap: 4px; margin-left: 8px; }
