/* Tableau de bord du domaine — démo Forge Labs. S'appuie sur ../_shared/demo.css et vigne.css. */

:root { --good: #3d6a2c; --bad: #a3401b; }
.kpi-value, .tt, .mini td, .dt td.r, .sv, .cv, .pv { font-variant-numeric: tabular-nums; }

.dash { max-width: 1320px; margin: 0 auto; padding: 24px var(--gutter) 40px; display: grid; gap: 20px; }
.dash > * { min-width: 0; }
.dash h1 { font-size: clamp(1.45rem, 2.6vw, 2.05rem); margin: 0 0 4px; }
.dash h2 { font-size: clamp(1.08rem, 1.5vw, 1.24rem); margin: 0 0 4px; letter-spacing: -.01em; }
.dash h3 { font-size: 1rem; }
.dash p { margin: 0; }

.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; }
.dash-id { display: flex; align-items: center; gap: 14px; min-width: 0; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; min-width: 0; max-width: 100%; }
.seg { border: 0; padding: 3px; margin: 0; display: inline-flex; flex-wrap: wrap; background: #fff; border-radius: 22px; box-shadow: inset 0 0 0 1px var(--line); min-width: 0; max-width: 100%; }
.seg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: inline-flex; align-items: center; min-height: 38px; padding: 0 13px; border-radius: 999px; font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.seg input:checked + span { background: var(--wine-700); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.seg label:hover span { color: var(--wine-900); }
.seg label:hover input:checked + span { color: #fff; }
.seg-sm span { min-height: 34px; font-size: .82rem; padding: 0 11px; }
.btn-export { min-height: 44px; padding: .6em 1.1em; font-size: .92rem; background: #fff; color: var(--wine-900); border-color: var(--line); }
.btn-export:hover { border-color: var(--wine-700); }
.scope { margin-top: -6px !important; }
@media (max-width: 640px) {
  .controls { width: 100%; }
  .seg { width: 100%; }
  .seg label { flex: 1 1 auto; }
  .seg span { width: 100%; justify-content: center; padding: 0 10px; }
  .btn-export { width: 100%; }
}

.card { padding: clamp(16px, 2vw, 24px); border-radius: 16px; min-width: 0; box-shadow: 0 1px 2px rgba(30, 13, 18, .05), 0 8px 24px -14px rgba(30, 13, 18, .2); }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 20px; margin-bottom: 14px; }
.card-head .small { max-width: 62ch; }
.row { display: grid; gap: 20px; min-width: 0; }
.row-chart { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.col { display: grid; gap: 20px; min-width: 0; align-content: start; }
.stock { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
@media (max-width: 1080px) { .stock { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1080px) { .row-chart { grid-template-columns: minmax(0, 1fr); } .c-ai { order: -1; } }
.scroller { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.scroller:focus-visible { outline: 3px solid var(--focus); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1180px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; } }
@media (max-width: 640px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi:first-child { grid-column: 1 / -1; } }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi-label { font-size: .8rem; font-weight: 600; color: var(--muted); line-height: 1.25; }
.kpi-value { font: 700 clamp(1.3rem, 2vw, 1.7rem)/1.1 var(--font-display); color: var(--wine-900); letter-spacing: -.02em; white-space: nowrap; }
.kpi-value small { font-size: .55em; font-weight: 600; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.kpi-foot { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: .78rem; color: var(--muted); line-height: 1.3; }
.delta { display: inline-flex; align-items: center; font-weight: 700; font-size: .8rem; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.delta.good { color: var(--good); background: var(--leaf-100); }
.delta.bad { color: var(--bad); background: #f8e3d8; }
.delta.flat { color: var(--muted); background: var(--stone-100); }
@media (max-width: 420px) { .kpi { padding: 12px; } .kpi-value { font-size: 1.25rem; } .kpi-label { font-size: .76rem; } }

/* Graphique */
.legend { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart svg { display: block; overflow: visible; }
.chart text { font-size: 12px; }
@media (max-width: 520px) { .chart text { font-size: 11px; } }
.chart text { font: 500 12px/1 var(--font-body); fill: #6a5f62; }
.chart .gl { stroke: rgba(29, 23, 25, .08); }
.chart .baseline { stroke: rgba(29, 23, 25, .3); }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.chart .hit:hover { fill: rgba(91, 26, 43, .06); }
.chart .hit:focus-visible { fill: rgba(208, 138, 46, .18); stroke: var(--focus); stroke-width: 2; }
.data-details { margin-top: 10px; font-size: .86rem; }
.data-details summary { cursor: pointer; color: var(--wine-700); font-weight: 600; padding: 6px 0; width: max-content; max-width: 100%; }
table.mini { border-collapse: collapse; width: 100%; min-width: 560px; margin-top: 6px; }
.mini th, .mini td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.mini th:first-child { text-align: left; }
.mini thead th { font-size: .76rem; color: var(--muted); }

/* Alertes */
.c-ai { background: var(--wine-900); color: var(--stone-100); border-color: transparent; display: flex; flex-direction: column; }
.c-ai h2 { color: #fff; margin-bottom: 14px !important; }
.ai-eyebrow { display: flex; align-items: center; gap: 6px; font-size: .74rem !important; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ember); margin-bottom: 8px !important; }
.alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.alert { background: rgba(255, 255, 255, .06); border: 1px solid rgba(243, 239, 232, .12); border-radius: 12px; padding: 12px 14px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 11px; }
.alert-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; grid-row: span 3; }
.alert.high .alert-dot { background: #f08a5d; box-shadow: 0 0 0 4px rgba(240, 138, 93, .22); }
.alert.mid .alert-dot { background: var(--ember); box-shadow: 0 0 0 4px rgba(255, 177, 92, .2); }
.alert.info .alert-dot { background: #9fb98a; box-shadow: 0 0 0 4px rgba(159, 185, 138, .2); }
.alert .sr-only { grid-column: 2; }
.alert-text { font-size: .92rem; line-height: 1.45; color: rgba(255, 255, 255, .9); grid-column: 2; }
.alert-text strong { color: #fff; }
.alert-action { font-size: .82rem; line-height: 1.4; color: rgba(243, 239, 232, .74); grid-column: 2; }
.alert-action b { color: var(--ember); }
.ai-foot { margin-top: auto !important; padding-top: 12px; color: rgba(243, 239, 232, .62); }

/* Circuits */
.circ-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.circ-list li { display: grid; gap: 6px; transition: opacity .2s; }
.circ-list li.dim { opacity: .35; }
.ch { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-size: .9rem; }
.cl { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--wine-900); }
.cl i { width: 12px; height: 12px; border-radius: 3px; }
.cv { color: var(--muted); }
.cv b { color: var(--ink); }
.cb { height: 14px; border-radius: 99px; background: var(--stone-100); overflow: hidden; }
.cb span { display: block; height: 100%; border-radius: 99px; }
.cf { display: flex; justify-content: space-between; gap: 10px; font-size: .8rem; color: var(--muted); }
.insight { margin-top: 16px !important; padding: 12px 14px; border-radius: 12px; background: var(--stone-50); border: 1px dashed rgba(91, 26, 43, .35); font-size: .9rem; line-height: 1.45; }

/* Stocks */
.stock-legend { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); }
.stock-legend li { display: inline-flex; align-items: center; gap: 6px; }
.stock-legend i { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
.sl-cav, .seg-cav { background: var(--wine-700); }
.sl-chai, .seg-chai { background: #c99aa5; }
.sl-elev, .seg-elev { background: repeating-linear-gradient(135deg, #b8862b 0 4px, #e3c78a 4px 8px); }
.stock { display: grid; gap: 16px; }
.sg h3 { font-size: .95rem !important; margin: 0 0 6px; color: var(--wine-900); }
.sg h3 .muted { font-weight: 500; font-size: .8rem; font-family: var(--font-body); }
.sg ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sg li { display: grid; grid-template-columns: 7.2em minmax(0, 1fr) 7.5em 8.2em; gap: 10px; align-items: center; font-size: .84rem; }
.sm { font-weight: 600; white-space: nowrap; }
.sb { display: flex; height: 12px; border-radius: 99px; background: var(--stone-100); overflow: hidden; }
.sb span { display: block; height: 100%; }
.sv { text-align: right; font-weight: 700; white-space: nowrap; line-height: 1.15; }
.sv small { display: block; font-weight: 500; color: var(--muted); font-size: .72rem; }
.cov { font-size: .78rem; font-weight: 600; color: var(--leaf-600); }
.cov.low { color: #9a4304; }
.cov.muted { color: var(--muted); font-weight: 500; }
@media (max-width: 560px) {
  .sg li { grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
  .sm { grid-column: 1; grid-row: 1; }
  .cov { grid-column: 2; grid-row: 1; }
  .sv { grid-row: 1; grid-column: 3; }
  .sv small { display: inline; margin-left: 4px; }
  .sb { grid-column: 1 / -1; grid-row: 2; }
}

/* Allocations */
.tcount { color: var(--muted); align-self: center; }
.tscroll { border: 1px solid var(--line); border-radius: 12px; }
table.dt { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 900px; font-size: .88rem; }
.dt th, .dt td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dt thead th { background: var(--stone-50); font-size: .76rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.dt .r { text-align: right; }
.dt .nw { white-space: nowrap; }
.dt td:first-child, .dt th:first-child { position: sticky; left: 0; background: #fff; }
.dt thead th:first-child { background: var(--stone-50); }
.dt tr.warn td:first-child { box-shadow: inset 3px 0 0 #e07a1f; }
.dt tbody tr:last-child td { border-bottom: 0; }
.cn { display: block; font-weight: 600; color: var(--wine-900); }
.fict-s { font-weight: 500; color: var(--muted); font-size: .76rem; }
.cs { display: block; font-size: .76rem; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pill i { width: 8px; height: 8px; border-radius: 50%; }
.prog { display: flex; align-items: center; gap: 8px; }
.pbar { width: 90px; height: 8px; border-radius: 99px; background: var(--stone-100); overflow: hidden; flex: none; }
.pbar span { display: block; height: 100%; background: var(--wine-700); border-radius: 99px; }
.pv { font-weight: 600; min-width: 3.2em; }
.st { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.st-ok { background: var(--leaf-100); color: #2f4723; }
.st-cours { background: #e3ebf2; color: #2a4a63; }
.st-relance { background: var(--warn-100); color: #8a3c04; box-shadow: inset 0 0 0 1px rgba(224, 122, 31, .45); }
.empty { text-align: center; color: var(--muted); padding: 24px !important; }
.scroll-hint { display: none; color: var(--muted); margin: 0 0 6px !important; }
@media (max-width: 640px) {
  .c-alloc .tscroll { border: 0; overflow: visible; }
  table.dt, .dt tbody, .dt tr, .dt td { display: block; min-width: 0; }
  table.dt { width: 100%; }
  .dt thead { display: none; }
  .dt tbody { display: grid; gap: 10px; }
  .dt tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
  .dt tr.warn { box-shadow: inset 4px 0 0 #e07a1f; }
  .dt td { padding: 0; border: 0; position: static; text-align: left !important; font-size: .86rem; }
  .dt td:first-child { position: static; background: none; box-shadow: none !important; }
  .dt td[data-l]::before { content: attr(data-l); display: block; font-size: .7rem; font-weight: 700; color: var(--muted); }
  .dt .td-client { grid-column: 1 / -1; grid-row: 1; padding-right: 10.5em; min-width: 0; }
  .dt .td-st { grid-column: 1 / -1; grid-row: 1; justify-self: end; align-self: start; }
  .dt .td-prog { grid-column: 1 / -1; }
  .dt .td-prog .pbar { flex: 1; }
  .dt .empty { grid-column: 1 / -1; }
}

/* Infobulle */
.tt { position: fixed; z-index: 80; pointer-events: none; max-width: min(280px, calc(100vw - 24px)); background: var(--wine-950); color: var(--stone-100); border-radius: 10px; padding: 9px 12px; font-size: .82rem; line-height: 1.45; box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .45); }
.tt b { display: block; color: #fff; margin-bottom: 2px; }
.tt .tl { display: flex; justify-content: space-between; gap: 14px; }
.tt .tl span:last-child { font-weight: 700; color: #fff; white-space: nowrap; }
.tt .tt-tot { border-top: 1px solid rgba(243, 239, 232, .2); margin-top: 3px; padding-top: 3px; }
.tt[hidden] { display: none; }
