/* Pilotage Kiné-Fit : charte (pétrole #2C4A5A, orange #FF8B45, crème #FFE7C2, pêche #F5D3BB), Poppins. */
@font-face { font-family: "Poppins"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/fonts/poppins-400.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-style: normal; font-display: swap; src: url("/static/fonts/poppins-500.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-style: normal; font-display: swap; src: url("/static/fonts/poppins-600.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --bg: #F2F1EC;
  --surface: #FFFFFF;
  --surface-2: #F8F6F0;
  --line: #E6E2D8;
  --ink: #1B2A32;
  --ink-2: #3D5563;
  --muted: #6B7E88;
  --brand: #2C4A5A;
  --brand-ink: #FFFFFF;
  --accent: #FF8B45;
  --cream: #FFE7C2;
  --peach: #F5D3BB;
  --good: #2E7A58;
  --good-bg: #E3F1EA;
  --warning: #9A5B00;
  --warning-bg: #FDF0DC;
  --critical: #B42318;
  --critical-bg: #FDE7E4;
  --info: #2C4A5A;
  --info-bg: #E6EEF1;
  --chart-bar: #2C4A5A;
  --chart-accent: #FF8B45;
  --chart-grid: #E6E2D8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 42, 50, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0F1A20;
    --surface: #16252D;
    --surface-2: #1B2D36;
    --line: #27404C;
    --ink: #F2F1EC;
    --ink-2: #CBD7DC;
    --muted: #8FA3AD;
    --brand: #FFE7C2;
    --brand-ink: #1B2A32;
    --good: #6CCB9A;
    --good-bg: #173A2C;
    --warning: #F2B35E;
    --warning-bg: #3A2C14;
    --critical: #FF8A80;
    --critical-bg: #43201D;
    --info: #CBD7DC;
    --info-bg: #1F3642;
    --chart-bar: #F5D3BB;
    --chart-accent: #FF8B45;
    --chart-grid: #27404C;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 15px/1.5 "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .35em; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.1rem; }
.h3, h3 { font-size: 1rem; }
.h4, h4 { font-size: .9rem; margin-top: 1rem; }
p { margin: 0 0 .6em; }
code { font-size: .85em; background: var(--surface-2); padding: .05em .35em; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.mt { margin-top: 1.2rem; }

/* ---------- mise en page */
.app { min-height: 100vh; }
.sidebar { display: none; }
.main { min-width: 0; }
.content { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--brand); color: var(--brand-ink);
}
@media (prefers-color-scheme: dark) { .topbar { background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line); } }
.topbar-link svg { width: 24px; height: 24px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { border-radius: 8px; }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand small { color: var(--muted); font-size: .75rem; }
.brand--compact strong { font-size: 1.05rem; }

svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .7rem; padding: 4px 0; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.is-active { color: var(--ink); font-weight: 600; }
.tabbar a.is-active svg { color: var(--accent); }
.tabbar .badge { position: absolute; top: 0; right: calc(50% - 22px); }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 236px 1fr; }
  .topbar, .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 22px 14px;
    background: var(--surface); border-right: 1px solid var(--line);
  }
  .sidenav { display: flex; flex-direction: column; gap: 2px; margin-top: 26px; }
  .sidenav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; text-decoration: none; color: var(--ink-2); }
  .sidenav a svg { width: 20px; height: 20px; flex: none; }
  .sidenav a:hover { background: var(--surface-2); }
  .sidenav a.is-active { background: var(--brand); color: var(--brand-ink); font-weight: 500; }
  .sidenav a.is-active svg { color: var(--accent); }
  .sidenav .badge { margin-left: auto; }
  .sidenav .soon { margin-left: auto; font-size: .68rem; color: var(--muted); }
  .sidenav a.is-active .soon { color: inherit; opacity: .8; }
  .sidebar-foot { margin-top: auto; }
  .content { padding: 28px 32px 48px; }
}

.badge { display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px; align-items: center; justify-content: center; border-radius: 9px; background: var(--critical); color: #fff; font-size: .7rem; font-weight: 600; }
.offline-banner { background: var(--warning-bg); color: var(--warning); padding: 8px 16px; font-size: .85rem; text-align: center; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head p { margin: 0; }
.flash { background: var(--info-bg); color: var(--info); padding: 10px 14px; border-radius: 10px; font-size: .9rem; }

/* ---------- composants */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { margin-bottom: 12px; }
.card-head p { margin: 0; font-size: .88rem; }
.grid-2, .grid-3 { display: grid; gap: 16px; grid-template-columns: 1fr; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.grid-2, .grid-3 { margin-bottom: 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr 1fr; } }

.btn { font: inherit; font-weight: 500; border-radius: 10px; padding: 9px 16px; border: 1px solid transparent; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn--primary { background: var(--brand); color: var(--brand-ink); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--small { padding: 5px 10px; font-size: .82rem; }

.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; overflow-x: auto; max-width: 100%; }
.segmented a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-size: .85rem; white-space: nowrap; }
.segmented a.is-active { background: var(--brand); color: var(--brand-ink); font-weight: 500; }

.alerts { display: grid; gap: 10px; margin-bottom: 16px; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.alert h3 { margin: 0 0 4px; font-size: .98rem; }
.alert p { margin: 0; font-size: .88rem; color: var(--ink-2); }
.alert .alert-level { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-bottom: 2px; }
.alert-icon svg { width: 22px; height: 22px; }
.alert-body { flex: 1; min-width: 0; }
.alert--critical { background: var(--critical-bg); border-color: transparent; }
.alert--critical .alert-icon, .alert--critical .alert-level { color: var(--critical); }
.alert--warning { background: var(--warning-bg); border-color: transparent; }
.alert--warning .alert-icon, .alert--warning .alert-level { color: var(--warning); }
.alert--info .alert-icon, .alert--info .alert-level { color: var(--info); }

.today-strip { font-size: .9rem; color: var(--ink-2); margin: 0 0 14px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.tile-label { font-size: .8rem; color: var(--muted); margin: 0 0 4px; }
.tile-value { font-size: 1.5rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.tile-delta, .tile-sub { font-size: .74rem; margin: 4px 0 0; color: var(--muted); }
.delta--good { color: var(--good); }
.delta--bad { color: var(--critical); }
.delta--flat { color: var(--muted); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 500; }
.table tbody th { font-weight: 500; }
.table tfoot th, .table tfoot td { border-bottom: 0; }
.table tfoot tr:first-child th, .table tfoot tr:first-child td { border-top: 2px solid var(--line); }
.table td.small { white-space: normal; min-width: 180px; }
.table .num { text-align: right; }
.table tr.is-today th, .table tr.is-today td { background: var(--surface-2); }
.cell-note { display: block; font-size: .72rem; color: var(--muted); font-weight: 400; }
.gap { display: block; font-size: .72rem; color: var(--warning); }
@media (max-width: 640px) {
  .table--funnel, .table--funnel tbody, .table--funnel tfoot { display: block; width: 100%; }
  .table--funnel thead { display: none; }
  .table--funnel tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .table--funnel th, .table--funnel td { border: 0; padding: 0; white-space: normal; text-align: left; }
  .table--funnel th { grid-column: 1 / -1; }
  .table--funnel td.num { text-align: left; }
  .table--funnel td:empty { display: none; }
  .table--funnel td[data-label]::before { content: attr(data-label); display: block; font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .table--funnel tfoot tr:first-child { border-top: 2px solid var(--line); }
  .table--funnel tfoot tr:first-child th, .table--funnel tfoot tr:first-child td { border-top: 0; }
}
.note { font-size: .86rem; color: var(--ink-2); background: var(--surface-2); padding: 10px 12px; border-radius: 10px; margin-top: 12px; }

.pill { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.pill--good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.pill--warning { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.pill--critical { background: var(--critical-bg); color: var(--critical); border-color: transparent; }
.pill--info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.pill--muted { color: var(--muted); }
.pill--r1 { background: var(--info-bg); color: var(--info); border-color: transparent; }
.pill--r2 { background: var(--cream); color: #6A3B12; border-color: transparent; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; flex: none; }
.dot--ok { background: var(--good); }
.dot--ko { background: var(--critical); }
.dot--unknown { background: var(--line); box-shadow: inset 0 0 0 1px var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.list li:last-child { border-bottom: 0; }
.list li > span:last-child { min-width: 0; overflow-wrap: anywhere; }

/* ---------- graphiques (voir charts.py) */
.chart { position: relative; margin: 8px 0 0; padding: 0 0 22px; }
.chart--empty { padding: 30px 0; text-align: center; }
.chart-y { position: absolute; left: 0; top: 0; width: 36px; height: 100%; }
.chart-y span { position: absolute; right: 0; transform: translateY(-50%); font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-plot { display: block; margin-left: 40px; width: calc(100% - 40px); overflow: visible; }
.chart-plot .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-plot .mark { fill: var(--chart-bar); stroke: none; }
.chart-plot .zero { fill: var(--muted); stroke: none; opacity: .5; }
.chart-plot .hit { fill: transparent; stroke: none; }
.chart-plot .bar { cursor: pointer; outline: none; }
.chart-plot .bar.is-accent .mark { fill: var(--chart-accent); }
.chart-plot .bar.is-hover .mark, .chart-plot .bar:focus-visible .mark { opacity: .78; }
.chart-plot .bar.is-hover .hit, .chart-plot .bar:focus-visible .hit { fill: var(--chart-grid); opacity: .35; }
.chart-x { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; }
.chart-x span { position: absolute; transform: translateX(-50%); font-size: .68rem; color: var(--muted); white-space: nowrap; }
.chart-tip { position: absolute; top: -6px; transform: translate(-50%, -100%); background: var(--ink); color: var(--bg); padding: 5px 9px; border-radius: 8px; font-size: .78rem; pointer-events: none; white-space: nowrap; display: flex; gap: 6px; z-index: 5; }
.chart-tip[hidden] { display: none; }

.hbars { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.hbars li { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label value" "track track"; gap: 2px 8px; font-size: .84rem; }
.hbar-label { grid-area: label; color: var(--ink-2); }
.hbar-value { grid-area: value; font-weight: 600; font-variant-numeric: tabular-nums; }
.hbar-track { grid-area: track; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--chart-bar); border-radius: 0 4px 4px 0; }

/* ---------- stack */
.verdict-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { font: inherit; font-size: .82rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.chip strong { margin-left: 4px; }
.chip.is-active { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; padding: 7px 0; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.check-name { font-weight: 500; margin-right: 6px; }
.flags { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; }
.flags li { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); }
.flags li.is-on strong { color: var(--good); }
.flags li.is-off strong { color: var(--muted); font-weight: 500; }
.stack-group details > summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; list-style: none; }
.stack-group details > summary::-webkit-details-marker { display: none; }
.stack-group details > summary h2 { margin: 0; }
.stack-items { list-style: none; margin: 12px 0 0; padding: 0; }
.stack-item { padding: 12px 0; border-top: 1px solid var(--line); }
.stack-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.stack-item p { margin: 0 0 4px; font-size: .88rem; }
.stack-item .why { color: var(--ink-2); border-left: 3px solid var(--peach); padding-left: 10px; margin-top: 6px; }

/* ---------- formulaires, connexion */
.settings-form { display: grid; gap: 12px; max-width: 560px; }
.settings-form label { display: grid; gap: 4px; font-size: .86rem; color: var(--ink-2); }
input { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 100%; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login { max-width: 360px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 24px 16px; }
.login img { border-radius: 16px; margin-bottom: 14px; }
.login-form { width: 100%; display: grid; gap: 10px; text-align: left; margin-top: 18px; }
.login-form label { font-size: .86rem; color: var(--ink-2); }
.form-error { color: var(--critical); font-size: .86rem; margin: 0; }
.prose p { color: var(--ink-2); max-width: 70ch; }

@media (prefers-reduced-motion: no-preference) { .btn, .chip, .sidenav a { transition: background-color .15s, filter .15s; } }
