:root {
  --page: #f9f9f7; --surface: #fcfcfb; --ink: #0b0b0b; --ink-2: #52514e; --muted: #77756f;
  --line: #e1e0d9; --axis: #c3c2b7; --accent: #2a78d6; --accent-ink: #1c5cab;
  --good: #006300; --bad: #b42a2a; --warn-bg: #fdf3d7; --bad-bg: #fbe6e3; --good-bg: #e3f3e3; --info-bg: #e8f0fb;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #99978f;
    --line: #2c2c2a; --axis: #383835; --accent: #3987e5; --accent-ink: #86b6ef;
    --good: #37b837; --bad: #ee7b74; --warn-bg: #3a3013; --bad-bg: #40201d; --good-bg: #17331a; --info-bg: #17263b;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
/* La grille vit sur un conteneur à nous, pas sur body : les extensions y injectent leurs propres éléments. */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
h2 small { font-weight: 400; color: var(--muted); }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .5rem; }
small, .muted { color: var(--muted); }
p { margin: 0 0 .6rem; }
code { font-size: .85em; background: var(--line); padding: .05em .35em; border-radius: 4px; overflow-wrap: anywhere; }
main { padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 4rem; max-width: 1280px; width: 100%; }
main > section, main > details { margin-top: 2rem; }

/* Navigation */
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 1rem .75rem; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side a { color: var(--ink-2); padding: .4rem .6rem; border-radius: 6px; }
.side a:hover { background: var(--line); text-decoration: none; }
.side a.on { background: var(--info-bg); color: var(--accent-ink); font-weight: 600; }
.side .brand { font-weight: 700; color: var(--ink); margin-bottom: .5rem; }
.brand span, .login h1 span { color: var(--accent); }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .9rem .6rem .2rem; }
.menu-items { display: flex; flex-direction: column; gap: 2px; }
.menu-toggle, .menu-button { display: none; }
.logout { margin-top: auto; padding: .75rem .6rem 0; display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; color: var(--muted); }

/* Boutons, formulaires */
button, .button { font: inherit; border: 1px solid var(--axis); background: var(--surface); color: var(--ink); padding: .4rem .8rem; border-radius: 6px; cursor: pointer; display: inline-block; }
.button:hover { text-decoration: none; border-color: var(--ink-2); }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.link { border: 0; background: none; padding: 0; color: var(--accent-ink); }
button.link:hover { text-decoration: underline; }
.danger { color: var(--bad) !important; }
input, select, textarea { font: inherit; width: 100%; padding: .4rem .55rem; border: 1px solid var(--axis); border-radius: 6px; background: var(--page); color: var(--ink); }
input[type=checkbox] { width: auto; }
input[type=range] { padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: grid; gap: .25rem; font-size: .85rem; color: var(--ink-2); font-weight: 600; }
label small { font-weight: 400; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .8rem 1rem; margin-bottom: 1rem; }
.fields .wide, .fields .check { grid-column: 1 / -1; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
form.inline { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; margin-bottom: .75rem; }
form.inline input { flex: 1 1 220px; width: auto; }
.actions { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; }
.actions form { display: inline; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.section-head h1, .section-head h2 { margin: 0; }
.page-head { margin-bottom: 1.25rem; }
.crumbs { font-size: .85rem; margin-bottom: .4rem; }
details.add > summary { cursor: pointer; color: var(--accent-ink); margin: .6rem 0; width: fit-content; }
.flash { padding: .6rem .8rem; border-radius: 8px; background: var(--info-bg); }
.flash.bad { background: var(--bad-bg); }
.flash.warn { background: var(--warn-bg); }

/* Badges */
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; background: var(--line); color: var(--ink-2); white-space: nowrap; }
a.badge:hover { text-decoration: none; filter: brightness(.95); }
.badge.threat, .badge.late, .badge.prio.p1, .badge.decision-no_go { background: var(--bad-bg); color: var(--bad); }
.badge.opportunity, .badge.st-done, .badge.decision-go { background: var(--good-bg); color: var(--good); }
.badge.go, .badge.st-waiting_decision, .badge.prio.p2 { background: var(--warn-bg); color: var(--ink); }
.badge.st-in_progress { background: var(--info-bg); color: var(--accent-ink); }
.badges, .summary { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.late-text { color: var(--bad); font-weight: 600; }

/* Tuiles de métriques */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; }
.card > header { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem 0; }
.card h2 { margin: 0; }
.card h2 a { color: var(--ink); }
.card .tiles { padding: .6rem 1rem; flex: 1; align-content: start; }
.card-foot { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .6rem 1rem; border-top: 1px solid var(--line); color: var(--ink-2); font-size: .85rem; }
.card-foot:hover { text-decoration: none; background: var(--page); }
.card-foot progress { width: 90px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.tiles.wide { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.tile { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; align-content: start; gap: 0 .5rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--page); }
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile-label { flex: 1 0 100%; font-size: .76rem; color: var(--ink-2); line-height: 1.25; min-height: 2.5em; }
.tile-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile-value small { font-size: .7rem; font-weight: 400; color: var(--muted); }
.tile-value.none { color: var(--muted); }
.tile-delta { font-size: .8rem; font-weight: 600; color: var(--muted); white-space: nowrap; text-align: right; }
.good .tile-delta { color: var(--good); }
.bad .tile-delta { color: var(--bad); }
.tile .spark { flex: 1 0 100%; width: 100%; height: 34px; margin-top: .3rem; }
.tile-meta { flex: 1 0 100%; font-size: .7rem; color: var(--muted); }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark circle { fill: var(--accent); }
.hero { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.hero .tile-value { font-size: 2.2rem; }
.hero .tile-delta { font-size: 1rem; }

/* Graphique */
.chart { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .5rem; margin: .75rem 0; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .flag { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; }
.chart .note { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .note-n { fill: var(--ink-2); font-size: 10px; font-weight: 600; }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; }
.chart .hover-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.tip { position: absolute; transform: translate(10px, -120%); background: var(--ink); color: var(--page); padding: .25rem .5rem; border-radius: 6px; font-size: .8rem; white-space: nowrap; pointer-events: none; }
.tip.flip { transform: translate(calc(-100% - 10px), -120%); }
.notes { padding-left: 1.4rem; margin: 0; font-size: .9rem; }

/* Actions classées */
.actions-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.action { display: grid; grid-template-columns: 2rem minmax(0, 1fr) minmax(190px, 240px); gap: .75rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; }
.rank { font-size: 1.3rem; font-weight: 700; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.action-main { display: grid; gap: .35rem; }
.action-title { color: var(--ink); font-weight: 600; }
.tile.empty { border-style: dashed; align-self: stretch; align-content: center; }
@media (max-width: 800px) {
  .action { grid-template-columns: 1.5rem minmax(0, 1fr); }
  .action .tile { grid-column: 2; }
}

/* Alertes */
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; }
.headsups { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.headsup { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--bad); border-radius: 8px; padding: .65rem .8rem; display: grid; gap: .3rem; }
.headsup.opportunity { border-left-color: var(--good); }
.headsup.s1 { border-left-color: var(--axis); }
.headsup.resolved { opacity: .6; }
.headsup p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.headsup-head { display: flex; gap: .35rem; flex-wrap: wrap; }
.headsup-foot { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; font-size: .8rem; }
.headsup-foot small { overflow-wrap: anywhere; }

/* Todos */
.sorts { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.chip { font-size: .8rem; padding: .2rem .65rem; border: 1px solid var(--axis); border-radius: 99px; color: var(--ink-2); }
.chip:hover { text-decoration: none; border-color: var(--ink-2); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.tasks { list-style: none; margin: 0; padding: 0; }
.tasks .tasks { margin-left: clamp(.75rem, 2vw, 1.75rem); border-left: 2px solid var(--line); padding-left: .6rem; }
.tasks li { margin-top: .4rem; }
.tasks summary { cursor: pointer; list-style-position: outside; margin-left: 1rem; }
.task-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: .35rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .75rem; }
.task-row.closed { opacity: .6; }
.task-main { display: grid; gap: .3rem; }
.task-main > a { color: var(--ink); font-weight: 600; }
.tid { font-family: ui-monospace, monospace; font-size: .8em; color: var(--muted); font-weight: 400; }
.task-cells { display: flex; flex-wrap: wrap; gap: .2rem 1.1rem; font-size: .82rem; color: var(--ink-2); font-variant-numeric: tabular-nums; align-items: center; }
.cell i { font-style: normal; color: var(--muted); }
.cell.bar { display: flex; align-items: center; gap: .4rem; min-width: 150px; }
progress { appearance: none; width: 100px; height: 8px; border: 0; border-radius: 99px; background: var(--line); overflow: hidden; vertical-align: middle; }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }

/* Fiches */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem 1.25rem; margin: 1rem 0; }
.facts.text { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.facts dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.facts dd { margin: 0; }
.comments, .events, .reports, .team, .sources { list-style: none; padding: 0; margin: 0 0 .75rem; display: grid; gap: .5rem; }
.comments li { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .75rem; }
.comments p { margin: .2rem 0 0; }
.comments + form { display: grid; gap: .5rem; justify-items: start; }
.events { font-size: .85rem; }
.reports li { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.reports .closed a { text-decoration: line-through; color: var(--muted); }
.team li { display: grid; gap: .5rem; }
.token { display: flex; gap: .75rem; align-items: center; }
.sources { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); font-size: .85rem; }
.sources li { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .6rem; display: grid; }
.sources .stale span { color: var(--bad); font-weight: 600; }
.sources .none span { color: var(--muted); }
table { border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .3rem .8rem .3rem 0; border-bottom: 1px solid var(--line); }
.num { text-align: right; }
.prose { max-width: 78ch; overflow-wrap: anywhere; }
.prose table { display: block; overflow-x: auto; }
.prose pre { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); padding: .6rem; border-radius: 8px; }
.prose h1 { font-size: 1.25rem; margin-top: 1.4rem; }
.prose h2 { margin-top: 1.4rem; }

/* Connexion */
main.login { display: grid; place-items: center; min-height: 100vh; max-width: none; padding: 1rem; }
.login .panel { width: min(360px, 100%); display: grid; gap: .9rem; }

/* Mobile portrait */
@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  /* Barre du haut : marque, bouton Menu, déconnexion ; les liens se déplient dessous. */
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); padding: .5rem .75rem; }
  .side .brand { margin: 0; }
  .menu-toggle { display: block; position: absolute; opacity: 0; pointer-events: none; }
  .menu-button { display: block; margin-left: auto; padding: .35rem .8rem; border: 1px solid var(--axis); border-radius: 6px; cursor: pointer; color: var(--ink); font-weight: 600; }
  .menu-toggle:focus-visible + .menu-button { outline: 2px solid var(--accent); outline-offset: 1px; }
  .menu-toggle:checked + .menu-button { background: var(--info-bg); }
  .menu-items { display: none; order: 3; flex-basis: 100%; }
  .menu-toggle:checked ~ .menu-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .nav-label { grid-column: 1 / -1; padding-top: .5rem; }
  .logout { margin: 0; padding: 0; }
  .logout span { display: none; }
  .cards { grid-template-columns: minmax(0, 1fr); }
}
