/* Tableau de bord paysagiste — démo Forge Labs. S'appuie sur ../_shared/demo.css. */

:root {
  --c-creation: #1f4a33;
  --c-entretien: #6f8f4e;
  --c-elagage: #b9842a;
  --n1: #cbd8b6;
  --good: #2f6a35;
  --bad: #a3401b;
  --heat-1: #eef2e6;
  --heat-2: #c7d6ae;
  --heat-3: #7f9c5c;
  --heat-4: #c8643b;
  --card-pad: clamp(16px, 2vw, 24px);
}

body { background: var(--sand-100); font-size: 16px; }
.num, .kpi-value, .dt td.r, .dt th.r, .mini td, .heat td, .tt { font-variant-numeric: tabular-nums; }

.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: #fff; padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 8px; }

/* ---------- Barre haute ---------- */
.topbar { background: var(--forest-900); color: var(--sand-100); position: sticky; top: 0; z-index: 40; }
.topbar-in { max-width: 1320px; margin: 0 auto; padding: 0 var(--gutter); min-height: 60px; display: flex; align-items: center; gap: 16px; }
.back { color: var(--sand-100); text-decoration: none; font-weight: 600; font-size: .95rem; white-space: nowrap; padding: 10px 0; }
.back:hover { text-decoration: underline; }
.topbar-title { margin: 0 auto; font: 600 .95rem/1.2 var(--font-display); display: flex; align-items: center; gap: 10px; color: rgba(244, 239, 228, .9); }
.btn-cta { min-height: 42px; padding: .65em 1.2em; font-size: .92rem; white-space: nowrap; }
.demo-banner { margin: 0; }
@media (max-width: 760px) {
  .topbar-title { display: none; }
  .topbar-in { justify-content: space-between; gap: 10px; }
  .back { font-size: .9rem; }
  .btn-cta { font-size: .84rem; padding: .6em .95em; min-height: 40px; white-space: normal; text-align: center; line-height: 1.15; max-width: 200px; }
}

/* ---------- Mise en page ---------- */
.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; }
.fict { font: 500 .55em/1 var(--font-body); color: var(--muted); letter-spacing: 0; vertical-align: middle; }

.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; }
.logo { flex: none; width: 52px; height: 52px; border-radius: 14px; background: var(--forest-800); color: var(--sun-400); display: grid; place-items: center; font: 700 1.1rem/1 var(--font-display); letter-spacing: .02em; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.seg { border: 0; padding: 3px; margin: 0; display: inline-flex; background: #fff; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); }
.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 14px; border-radius: 999px; font-size: .9rem; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.seg input:checked + span { background: var(--forest-800); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--sun-400); outline-offset: 1px; }
.seg label:hover span { color: var(--forest-900); }
.seg input:checked + span:hover, .seg label:hover input:checked + span { color: #fff; }
.btn-export { min-height: 44px; padding: .6em 1.1em; font-size: .92rem; background: #fff; color: var(--forest-900); border-color: var(--line); }
.btn-export:hover { border-color: var(--forest-700); }
.btn-soft { min-height: 42px; font-size: .9rem; background: var(--sand-100); color: var(--forest-900); }
.btn-soft:hover { background: var(--sage-200); }
.scope { margin-top: -6px !important; }

/* ---------- Cartes ---------- */
.card { padding: var(--card-pad); border-radius: 16px; min-width: 0; box-shadow: 0 1px 2px rgba(11, 31, 22, .05), 0 8px 24px -14px rgba(11, 31, 22, .18); }
.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: 60ch; }
.row { display: grid; gap: 20px; min-width: 0; }
.row-chart { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
.row-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); }
@media (max-width: 1080px) { .row-chart, .row-2 { grid-template-columns: minmax(0, 1fr); } }

.scroller { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; max-width: 100%; }
.scroller:focus-visible { outline: 3px solid var(--sun-400); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1080px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; box-shadow: 0 1px 2px rgba(11, 31, 22, .04); }
.kpi-label { font-size: .8rem; font-weight: 600; color: var(--muted); line-height: 1.25; }
.kpi-value { font: 700 clamp(1.3rem, 2.1vw, 1.75rem)/1.1 var(--font-display); color: var(--forest-900); letter-spacing: -.02em; white-space: nowrap; }
.kpi-value small { font-size: .55em; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 2px; }
.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; gap: 3px; font-weight: 700; font-size: .8rem; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.delta.good { color: var(--good); background: #e6efdc; }
.delta.bad { color: var(--bad); background: #f8e3d8; }
.delta.flat { color: var(--muted); background: #eef0ea; }
@media (max-width: 420px) {
  .kpi { padding: 12px 12px; }
  .kpi-value { font-size: 1.28rem; }
  .kpi-label { font-size: .76rem; }
}

/* ---------- Graphique CA ---------- */
.legend { list-style: none; margin: 0; padding: 0; display: flex; gap: 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; }
.sw-n { background: var(--c-creation); }
.sw-n1 { background: var(--n1); }
.chart svg { display: block; overflow: visible; }
.chart .axis text, .chart text { font: 500 11.5px/1 var(--font-body); fill: #5b6b61; }
.chart .grid line { stroke: rgba(18, 33, 26, .08); }
.chart .baseline { stroke: rgba(18, 33, 26, .3); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover, .chart .hit.on { fill: rgba(31, 74, 51, .06); }
.chart .hit:focus { outline: none; fill: rgba(232, 176, 74, .18); }
.chart .yr { font-weight: 700; fill: var(--forest-800); }
.data-details { margin-top: 10px; font-size: .86rem; }
.data-details summary { cursor: pointer; color: var(--forest-700); font-weight: 600; padding: 6px 0; width: max-content; max-width: 100%; }
table.mini { border-collapse: collapse; width: 100%; min-width: 420px; 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, .mini td:first-child { text-align: left; }
.mini thead th { font-size: .76rem; color: var(--muted); }

/* ---------- Encart IA ---------- */
.c-ai { background: var(--forest-900); color: var(--sand-100); border-color: transparent; display: flex; flex-direction: column; }
.c-ai h2 { color: #fff; margin-bottom: 14px; }
.ai-eyebrow { display: flex; align-items: center; gap: 6px; font-size: .74rem !important; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--moss-300); 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(244, 239, 228, .12); border-radius: 12px; padding: 12px 14px 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 2; }
.alert.high .alert-dot { background: var(--clay-400); box-shadow: 0 0 0 4px rgba(219, 123, 82, .22); }
.alert.mid .alert-dot { background: var(--sun-400); box-shadow: 0 0 0 4px rgba(232, 176, 74, .2); }
.alert-text { font-size: .93rem; line-height: 1.45; color: #fff; }
.alert-text strong { color: #fff; }
.alert-action { font-size: .82rem; line-height: 1.4; color: rgba(244, 239, 228, .76); }
.alert-action b { color: var(--moss-300); font-weight: 700; }
.ai-foot { margin-top: auto !important; padding-top: 12px; color: rgba(244, 239, 228, .62); }

/* ---------- Tableau des chantiers ---------- */
.tfilters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; margin-bottom: 12px; }
.tfilters label { display: grid; gap: 4px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.tfilters select { font: inherit; font-size: .92rem; font-weight: 500; color: var(--text); min-height: 42px; padding: 0 34px 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--sand-50) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235b6b61' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center; appearance: none; -webkit-appearance: none; max-width: 100%; }
.tfilters .check { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--text); min-height: 42px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--forest-700); margin: 0; }
.tcount { margin-left: auto !important; 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: 960px; 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 { position: sticky; top: 0; background: var(--sand-50); font-size: .76rem; font-weight: 700; color: var(--muted); letter-spacing: .02em; white-space: nowrap; z-index: 1; }
.dt th.r, .dt td.r { text-align: right; }
.dt th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 4px 2px; border-radius: 6px; }
.dt th button:focus-visible { outline: 3px solid var(--sun-400); }
.dt th button:hover { color: var(--forest-900); }
.dt th .arrow { width: 10px; opacity: .35; font-size: .8em; }
.dt th[aria-sort] .arrow { opacity: 1; color: var(--forest-800); }
.dt tbody tr:hover td { background: #fbfaf5; }
.dt tbody tr.drift td:first-child { box-shadow: inset 3px 0 0 var(--clay-500); }
.dt td:first-child, .dt th:first-child { position: sticky; left: 0; background: #fff; z-index: 0; }
.dt thead th:first-child { background: var(--sand-50); z-index: 2; }
.dt tbody tr:hover td:first-child { background: #fbfaf5; }
.cn { display: block; font-weight: 600; color: var(--forest-900); line-height: 1.3; max-width: 260px; }
.cs { display: block; font-size: .76rem; color: var(--muted); margin-top: 2px; }
.team-pill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.team-pill i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.marge { display: flex; align-items: center; gap: 8px; justify-content: flex-end; white-space: nowrap; }
.marge .bar { width: 72px; height: 8px; border-radius: 99px; background: #edf0e7; overflow: hidden; flex: none; }
.marge .bar span { display: block; height: 100%; border-radius: 99px; background: var(--moss-500); }
.marge .bar span.low { background: var(--clay-500); }
.marge .v { min-width: 48px; text-align: right; font-weight: 600; }
.hrs { white-space: nowrap; }
.badge { display: inline-block; margin-left: 6px; padding: 2px 7px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.badge.over { background: #f8e3d8; color: #8f3512; }
.badge.under { background: #e6efdc; color: var(--good); }
.st { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.st-paye { background: #e6efdc; color: #2c5a2f; }
.st-encaisser { background: #fff2cf; color: #6b4a00; }
.st-cours { background: #dfe9f2; color: #23465f; }
.st-contrat { background: var(--sage-200); color: var(--forest-800); }
.st-resilie { background: #eeeeea; color: #5b5b55; }
.dt tfoot td { font-weight: 700; background: var(--sand-50); border-bottom: 0; color: var(--forest-900); }
.dt tfoot td:first-child { background: var(--sand-50); }
.empty { text-align: center; color: var(--muted); padding: 28px !important; }
.tmore { display: flex; justify-content: center; margin-top: 14px; }
.tmore[hidden] { display: none; }

/* ---------- Entonnoir ---------- */
.funnel { display: grid; gap: 10px; }
.fstep { display: grid; gap: 6px; }
.fhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 12px; font-size: .86rem; }
.fhead .fl { font-weight: 700; color: var(--forest-900); }
.fhead .fv { color: var(--muted); font-variant-numeric: tabular-nums; }
.fhead .fv b { color: var(--forest-900); }
.fbar { position: relative; height: 22px; border-radius: 8px; background: #f1f3ec; overflow: hidden; }
.fbar > span { position: absolute; inset: 0 auto 0 0; border-radius: 8px; }
.f0 { background: var(--forest-700); }
.f1 { background: var(--moss-500); }
.f2 { background: var(--clay-500); }
.insight { margin-top: 14px !important; padding: 12px 14px; border-radius: 12px; background: var(--sand-50); border: 1px dashed rgba(111, 143, 78, .55); font-size: .9rem; line-height: 1.45; }
.h-sub { margin: 20px 0 10px; font-size: .95rem !important; }
.motifs { display: grid; gap: 8px; }
.motif { display: grid; grid-template-columns: minmax(0, 1fr) 110px 74px; gap: 10px; align-items: center; font-size: .86rem; }
.motif .ml { overflow-wrap: anywhere; }
.motif .mb { height: 10px; border-radius: 99px; background: #f1f3ec; overflow: hidden; }
.motif .mb span { display: block; height: 100%; background: var(--clay-500); border-radius: 99px; }
.motif .mv { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 420px) { .motif { grid-template-columns: minmax(0, 1fr) 64px 66px; } }

/* ---------- Heatmap ---------- */
table.heat { border-collapse: separate; border-spacing: 3px; width: 100%; min-width: 540px; font-size: .84rem; }
.heat th { font-weight: 600; color: var(--muted); font-size: .76rem; text-align: center; padding: 2px 0 4px; white-space: nowrap; }
.heat th small { display: block; font-weight: 500; font-size: .7rem; }
.heat th[scope="row"] { text-align: left; color: var(--forest-900); font-size: .84rem; padding-right: 6px; }
.heat th[scope="row"] small { color: var(--muted); }
.heat td { height: 48px; text-align: center; border-radius: 8px; font-weight: 700; cursor: default; position: relative; min-width: 50px; white-space: nowrap; }
.heat td:focus { outline: 3px solid var(--sun-400); outline-offset: 1px; }
.heat .h1 { background: var(--heat-1); color: var(--forest-900); }
.heat .h2 { background: var(--heat-2); color: var(--forest-900); }
.heat .h3 { background: var(--heat-3); color: #fff; }
.heat .h4 { background: var(--heat-4); color: #fff; }
.heat .h0 { background: repeating-linear-gradient(135deg, #f1efe8 0 6px, #e8e5dc 6px 12px); color: var(--muted); font-weight: 600; font-size: .74rem; }
.heat tr.dim td, .heat tr.dim th { opacity: .32; }
.heat tr.rain th, .heat tr.rain td { font-weight: 600; }
.heat tr.rain td { background: transparent; height: 38px; color: #2e5670; font-size: .8rem; }
.heat tr.rain td.trend { color: #557189; font-style: italic; font-weight: 500; }
.heat .drop { display: inline-block; width: 9px; height: 12px; margin-right: 3px; vertical-align: -1px; }
.heat-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); }
.heat-legend li { display: inline-flex; align-items: center; gap: 6px; }
.hl { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.hl-1 { background: var(--heat-1); box-shadow: inset 0 0 0 1px var(--line); }
.hl-2 { background: var(--heat-2); }
.hl-3 { background: var(--heat-3); }
.hl-4 { background: var(--heat-4); }
.hl-0 { background: repeating-linear-gradient(135deg, #f1efe8 0 3px, #e1ddd2 3px 6px); }
.meteo-note { margin-top: 8px !important; }

/* ---------- Contrats ---------- */
.contracts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 24px; }
@media (max-width: 900px) { .contracts { grid-template-columns: minmax(0, 1fr); } }
.cstats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.cstat { background: var(--sand-50); border-radius: 12px; padding: 12px; min-width: 0; }
.cstat b { display: block; font: 700 1.25rem/1.15 var(--font-display); color: var(--forest-900); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cstat span { font-size: .76rem; color: var(--muted); line-height: 1.25; display: block; margin-top: 3px; }
@media (max-width: 420px) { .cstat b { font-size: 1.05rem; } .cstat { padding: 10px; } }
.spark-wrap { margin-top: 4px; }
.spark-wrap p { font-size: .8rem; color: var(--muted); margin-bottom: 4px !important; }
.spark svg { width: 100%; height: auto; display: block; overflow: visible; }
.spark .hit { fill: transparent; cursor: pointer; }
.spark text { font: 500 11px/1 var(--font-body); fill: #5b6b61; }
.renew h3 { font-size: .95rem; margin: 0 0 8px; }
.renew-wrap { max-height: 330px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table.rt { border-collapse: collapse; width: 100%; font-size: .86rem; }
.rt th, .rt td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.rt thead th { position: sticky; top: 0; background: var(--sand-50); font-size: .74rem; color: var(--muted); z-index: 1; }
.rt td.r, .rt th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rt .st { font-size: .72rem; }
.st-tacite { background: #e6efdc; color: #2c5a2f; }
.st-envoyee { background: #dfe9f2; color: #23465f; }
.st-proposer { background: #f8e3d8; color: #8f3512; }
@media (max-width: 520px) { .rt .hide-s { display: none; } }

/* ---------- Bas de page ---------- */
.cta-end { background: var(--forest-900); color: var(--sand-100); border-radius: 18px; padding: clamp(24px, 4vw, 40px); display: grid; gap: 12px; }
.cta-end h2 { color: #fff; font-size: clamp(1.3rem, 2.4vw, 1.8rem); }
.cta-end p { color: rgba(244, 239, 228, .82); max-width: 62ch; }
.cta-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.cta-end .btn-ghost { color: var(--sand-100); }
.foot { text-align: center; color: var(--muted); padding: 8px var(--gutter) 36px; }
.noscript { text-align: center; padding: 20px; }

/* ---------- Infobulle ---------- */
.tt { position: fixed; z-index: 80; pointer-events: none; max-width: min(300px, calc(100vw - 24px)); background: var(--forest-950); color: var(--sand-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; font-size: .86rem; 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 .tn { color: rgba(244, 239, 228, .7); font-size: .78rem; margin-top: 3px; }
.tt[hidden] { display: none; }

/* ---------- Ajustements petits écrans ---------- */
.scroll-hint { display: none; color: var(--muted); margin: 0 0 6px !important; }
@media (max-width: 640px) {
  .scroll-hint { display: block; }
  .dt .c-type { display: none; }
  table.dt { min-width: 760px; }
  .rt th, .rt td { padding: 8px 7px; }
  .rt .st { white-space: normal; text-align: center; line-height: 1.2; font-size: .7rem; }
  .rt td:first-child { min-width: 9.5em; }
}

/* Répartition par activité */
.c-ca { display: flex; flex-direction: column; }
.split { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); }
.split .h-sub { margin-top: 0; }
.split-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; gap: 2px; background: #fff; }
.split-bar span.dim, .split-list li.dim { opacity: .3; }
.split-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; }
.split-list li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 8px; align-items: center; font-size: .84rem; }
.split-list i { width: 10px; height: 10px; border-radius: 3px; }
.split-list .sl { font-weight: 600; }
.split-list b, .split-list .muted { grid-column: 2; }
.split-list b { font-size: 1rem; color: var(--forest-900); }
.split-list .muted { font-size: .78rem; }
@media (max-width: 520px) { .split-list { grid-template-columns: minmax(0, 1fr); } }
