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

:root { --good: #2f6b45; --bad: #a5470d; --c-n: #1f3d36; --c-n1: #b9c7c1; }
.kpi-value, .mini td, .dt td, .ech .e-m, .ag-leg b { 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 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; flex: 1 1 420px; }

.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(--sapin-800); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.btn-export { min-height: 44px; padding: .6em 1.1em; font-size: .92rem; background: #fff; color: var(--sapin-900); border-color: var(--line); }
.btn-export:hover { border-color: var(--sapin-800); }
.scope { margin-top: -6px !important; }
@media (max-width: 640px) {
  .controls { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .seg { width: 100%; grid-column: 1 / -1; }
  .seg label { flex: 1 1 auto; }
  .seg span { width: 100%; justify-content: center; padding: 0 8px; }
  .btn-export { width: 100%; padding: .6em .6em; }
}

.card { padding: clamp(16px, 2vw, 24px); border-radius: 16px; min-width: 0; box-shadow: 0 1px 2px rgba(15, 34, 30, .05), 0 8px 24px -14px rgba(15, 34, 30, .2); }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 20px; margin-bottom: 12px; }
.card-head .small { max-width: 62ch; }
.row { display: grid; gap: 20px; min-width: 0; }
.row-top { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.row-bottom { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.col { display: grid; gap: 20px; min-width: 0; align-content: start; }
@media (max-width: 1080px) { .row-top, .row-bottom { grid-template-columns: minmax(0, 1fr); } }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(6, 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 { 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.25rem, 1.9vw, 1.6rem)/1.1 var(--font-display); color: var(--sapin-900); letter-spacing: -.02em; white-space: nowrap; }
.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(--ok-100); }
.delta.bad { color: var(--bad); background: #f8e3d8; }
.delta.flat { color: var(--muted); background: var(--papier-100); }
@media (max-width: 420px) { .kpi { padding: 12px; } .kpi-value { font-size: 1.15rem; } .kpi-label { font-size: .76rem; } }

/* Graphiques */
.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; flex: none; }
.sw-n { background: var(--c-n); }
.sw-n1 { background: var(--c-n1); }
.ln { width: 20px; height: 0; border-top: 3px solid var(--c-n); display: inline-block; }
.ln-p { border-top-style: dashed; border-top-color: var(--sapin-600); }
.ln-s { border-top: 2px dashed var(--stop-600); }
.chart { min-height: 200px; }
.chart svg { display: block; overflow: visible; max-width: 100%; }
.chart text { font: 500 12px/1 var(--font-body); fill: #5a6662; }
.chart text.on { fill: var(--sapin-900); font-weight: 800; }
.chart .gl { stroke: rgba(20, 32, 29, .08); }
.chart .baseline { stroke: rgba(20, 32, 29, .3); }
.chart .b0 { fill: var(--c-n); opacity: .72; }
.chart .b0.on { opacity: 1; }
.chart .b1 { fill: var(--c-n1); }
.chart .hl { fill: var(--verif-100); }
.chart .seuil { stroke: var(--stop-600); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .zone { fill: rgba(31, 61, 54, .05); }
.chart .lr { fill: none; stroke: var(--c-n); stroke-width: 2.5; stroke-linejoin: round; }
.chart .lp { fill: none; stroke: var(--sapin-600); stroke-width: 2.5; stroke-dasharray: 6 5; }
.chart .dr { fill: var(--c-n); stroke: #fff; stroke-width: 2; }
.chart .dp { fill: #fff; stroke: var(--sapin-600); stroke-width: 2; }
.chart .dp.low { fill: var(--stop-600); stroke: #fff; }
.data-details { margin-top: 10px; font-size: .86rem; }
.data-details summary { cursor: pointer; color: var(--sapin-800); font-weight: 600; padding: 6px 0; width: max-content; max-width: 100%; }
table.mini { border-collapse: collapse; width: 100%; min-width: 760px; 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); }

/* Commentaire IA */
.c-ai { background: var(--sapin-900); color: var(--papier-100); border-color: transparent; display: flex; flex-direction: column; }
.c-ai h2 { color: #fff; margin-bottom: 12px !important; }
.ai-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.ai-eyebrow { display: flex; align-items: center; gap: 6px; font-size: .74rem !important; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--verif-200); }
.review { font: 800 .72rem/1 var(--font-body) !important; letter-spacing: .05em; text-transform: uppercase; background: var(--verif-200); color: #2b1d02; padding: 6px 9px; border-radius: 6px; }
.review.ok { background: #bfe3c9; color: #163b22; }
.ai-text p { font: 400 .96rem/1.6 var(--font-body); color: rgba(255, 255, 255, .9); margin: 0 0 10px !important; }
.ai-h { font: 700 .82rem/1 var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--sapin-300); margin: 8px 0 10px; }
.alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.al { background: rgba(255, 255, 255, .06); border: 1px solid rgba(241, 239, 231, .12); border-left: 4px solid var(--verif-200); border-radius: 12px; padding: 11px 13px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; }
.al-hi { border-left-color: #f08a5d; }
.al-ok { border-left-color: #9fd0ae; }
.al-n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .12); font: 700 .76rem/1 var(--font-body); color: #fff; }
.al-t { font-weight: 700; font-size: .92rem; color: #fff; line-height: 1.35; }
.al-c { font-size: .82rem; line-height: 1.45; color: rgba(241, 239, 231, .8); margin-top: 6px !important; background: rgba(0, 0, 0, .18); border-radius: 8px; padding: 6px 9px; font-variant-numeric: tabular-nums; }
.al-c span { color: var(--verif-200); font-weight: 700; }
.ai-act { margin-top: auto; padding-top: 16px; display: grid; gap: 10px; }
.c-ai .btn-primary { background: var(--papier-100); color: var(--sapin-900); justify-self: start; }
.c-ai .btn-primary:hover { background: #fff; }
.c-ai .btn-soft { background: transparent; color: var(--papier-100); border-color: rgba(241, 239, 231, .4); justify-self: start; }
.ai-foot { color: rgba(241, 239, 231, .66); }

/* Encours */
.ag-bar { display: flex; height: 16px; border-radius: 99px; overflow: hidden; margin-bottom: 10px; }
.ag0 { background: var(--sapin-300); }
.ag1 { background: var(--verif-200); }
.ag2 { background: #e8a159; }
.ag3 { background: var(--stop-600); }
.ag-leg { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; font-size: .86rem; }
.ag-leg li { display: flex; align-items: center; gap: 8px; }
.ag-leg b { margin-left: auto; }
@media (max-width: 420px) { .ag-leg { grid-template-columns: minmax(0, 1fr); } }
table.dt { width: 100%; min-width: 420px; border-collapse: collapse; font-size: .88rem; }
.dt th, .dt td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.dt thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.dt .r { text-align: right; white-space: nowrap; }
.dt tr.late td { background: var(--stop-100); color: #5f1717; }

/* Échéances */
.ech { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.ech li { display: grid; grid-template-columns: 5.6em minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; padding: 9px 10px; border-radius: 10px; background: var(--papier-50); border-left: 4px solid var(--sapin-600); font-size: .9rem; }
.ech li.e-social { border-left-color: #7a5a8a; }
.ech li.e-cloture { border-left-color: var(--verif-500); }
.e-d { font-weight: 800; color: var(--sapin-900); }
.e-l { line-height: 1.4; }
.e-m { font-weight: 700; white-space: nowrap; }
@media (max-width: 520px) { .ech li { grid-template-columns: minmax(0, 1fr) auto; } .e-l { grid-column: 1 / -1; grid-row: 2; } }
.note { color: var(--muted); line-height: 1.45; }

@media print {
  .topbar, .demo-banner, .controls, .cta-end, .foot, .skip, .ai-act .btn, .data-details { display: none !important; }
  body { background: #fff; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  .c-ai { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .row-top, .row-bottom { grid-template-columns: minmax(0, 1fr); }
}
