/* Pieuvre Hub — administration. Charte Pieuvre : papier, marine, un seul
   accent (l'émeraude du hub), filets fins, ni ombres ni dégradés. */
:root {
  --papier: #F5F3EE;
  --marine: #05173F;
  --ardoise: #4A5470;
  --brume: #DAD5CB;
  --carte: #ECE9E2;
  --accent: #2D6E4B;
  --accent-texte: #1A482F;
  --accent-clair: #E9F7F0;
  --barre: #439469;
  --alerte: #8A5A00;
  --alerte-fond: #F6EDDA;
  --danger: #A3122F;
  --danger-fond: #F7E4E6;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papier);
  color: var(--ardoise);
  font-family: 'Public Sans', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--accent-texte); text-underline-offset: 3px; }
h1, h2, h3 { font-family: 'Cormorant Garamond', Georgia, serif; color: var(--marine); font-weight: 400; line-height: 1.15; }
h1 { font-size: 44px; font-weight: 300; margin: 0 0 8px; }
h2 { font-size: 28px; margin: 0 0 12px; }
h3 { font-size: 20px; margin: 0 0 8px; font-weight: 500; }
code, .mono { font-family: 'JetBrains Mono', 'Courier New', monospace; font-size: 13px; }

.kicker {
  font-size: 12px; font-weight: 600; letter-spacing: 3px; text-transform: uppercase;
  color: var(--accent-texte); margin: 0 0 8px;
}
.muted { color: var(--ardoise); opacity: .8; }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* --- Barre du haut --- */
header.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  max-width: 1180px; margin: 0 auto; padding: 18px 24px; border-bottom: 1px solid var(--brume);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--marine); }
.brand img { width: 34px; height: auto; }
.brand span { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 24px; font-weight: 500; }
.brand small { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent-texte); font-weight: 600; margin-left: 4px; }
header.bar nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 15px; }
header.bar nav a { color: var(--marine); text-decoration: none; }
header.bar nav a[aria-current="page"] { color: var(--accent-texte); font-weight: 600; border-bottom: 2px solid var(--accent); padding-bottom: 2px; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.who form { margin: 0; }
nav.langs { display: inline-flex; gap: 2px; font-size: 12px; font-weight: 600; letter-spacing: 1px; }
nav.langs a { color: var(--ardoise); text-decoration: none; padding: 2px 5px; border-radius: 3px; }
nav.langs a[aria-current] { color: var(--accent-texte); background: var(--accent-clair); }
.login nav.langs { float: right; }

main { max-width: 1180px; margin: 0 auto; padding: 32px 24px 64px; }
section { padding: 28px 0; border-top: 1px solid var(--brume); }
section:first-of-type { border-top: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }

/* --- Messages --- */
.flash { padding: 10px 14px; margin: 0 0 20px; border-left: 2px solid var(--accent); background: var(--accent-clair); color: var(--accent-texte); }
.flash.error { border-color: var(--danger); background: var(--danger-fond); color: var(--danger); }
.secret {
  padding: 14px 16px; margin: 0 0 24px; background: var(--carte); border-left: 2px solid var(--accent);
}
.secret code { display: block; margin-top: 8px; font-size: 14px; color: var(--marine); word-break: break-all; user-select: all; }

/* --- Chiffres clés --- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--brume); border-bottom: 1px solid var(--brume); margin: 16px 0 8px; }
.tile { padding: 18px 20px; border-left: 1px solid var(--brume); }
.tile:first-child { border-left: 0; padding-left: 0; }
.tile .label { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; font-weight: 600; color: var(--ardoise); }
.tile .value { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 40px; color: var(--marine); line-height: 1.1; margin-top: 4px; }
.tile .note { font-size: 13px; }
.tile.accent .value { color: var(--accent-texte); }

/* --- Graphique --- */
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--brume); stroke-width: 1; }
.chart .axis-label { fill: var(--ardoise); font-size: 14px; font-family: 'Public Sans', Arial, sans-serif; }
.chart .bar { fill: var(--barre); }
.chart .hit { fill: transparent; }
.chart .hit:hover + .bar, .chart .bar:hover { fill: var(--accent); }
details.table-view { margin-top: 8px; font-size: 13px; }
details summary { cursor: pointer; color: var(--accent-texte); }

/* --- Tableaux --- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; font-weight: 600; color: var(--ardoise); padding: 8px 10px 8px 0; border-bottom: 1px solid var(--marine); }
td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--brume); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td a { font-weight: 600; }
tfoot td { border-top: 1px solid var(--marine); border-bottom: 0; font-weight: 600; color: var(--marine); }
.empty { padding: 16px 0; color: var(--ardoise); font-style: italic; }

/* --- États --- */
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brume); }
.state.ok::before { background: var(--accent); }
.state.warning { color: var(--alerte); }
.state.warning::before { background: var(--alerte); }
.state.exceeded, .state.suspended { color: var(--danger); }
.state.exceeded::before, .state.suspended::before { background: var(--danger); }
.tag { display: inline-block; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; font-weight: 600; padding: 1px 6px; border: 1px solid var(--brume); color: var(--ardoise); }

/* --- Formulaires --- */
form.stack { display: grid; gap: 12px; max-width: 520px; }
form.stack.wide { max-width: 880px; }
form.stack fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; min-width: 0; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
pre.prompt { white-space: pre-wrap; background: #FBFAF7; border: 1px solid var(--brume); border-radius: 4px; padding: 10px 12px; font: 13px/1.5 'JetBrains Mono', 'Courier New', monospace; margin: 0 0 12px; }
textarea.short { min-height: 64px; font-family: inherit; }
form.stack.wide textarea { min-height: 160px; }
form.stack.wide textarea.short { min-height: 64px; }
@media (max-width: 1340px) { .brand small { display: none; } }
form.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.presets { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 16px; font-size: 14px; }
.presets a { color: var(--marine); text-decoration: none; }
.presets a:hover { color: var(--accent-texte); text-decoration: underline; }
.presets a[aria-current] { color: var(--accent-texte); font-weight: 600; border-bottom: 2px solid var(--accent); padding-bottom: 1px; }
form.filters { margin-bottom: 8px; }
.scroll + form.row { margin-top: 20px; }
nav.tabs { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 4px 0 24px; padding-bottom: 10px; border-bottom: 1px solid var(--brume); font-size: 15px; }
nav.tabs a { color: var(--marine); text-decoration: none; padding-bottom: 10px; margin-bottom: -11px; }
nav.tabs a:hover { color: var(--accent-texte); }
nav.tabs a[aria-current="page"] { color: var(--accent-texte); font-weight: 600; border-bottom: 2px solid var(--accent); }
label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--marine); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--marine); background: #FBFAF7;
  border: 1px solid var(--brume); border-radius: 4px; padding: 8px 10px; min-width: 0;
}
textarea { min-height: 120px; font-family: 'JetBrains Mono', 'Courier New', monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.hint { font-weight: 400; color: var(--ardoise); font-size: 12px; }
button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 4px; padding: 8px 14px;
  background: var(--accent); color: var(--papier); border: 1px solid var(--accent);
}
button:hover { background: var(--accent-texte); border-color: var(--accent-texte); }
button.quiet { background: transparent; color: var(--marine); border-color: var(--brume); font-weight: 400; padding: 5px 10px; }
button.quiet:hover { border-color: var(--marine); }
button.danger { background: transparent; color: var(--danger); border-color: var(--brume); font-weight: 400; padding: 5px 10px; }
button.danger:hover { border-color: var(--danger); }
button.link { background: none; border: 0; padding: 0; color: var(--accent-texte); font-weight: 400; text-decoration: underline; text-underline-offset: 3px; }
details.panel { border: 1px solid var(--brume); border-radius: 4px; padding: 12px 16px; margin-top: 16px; background: #FBFAF7; }
details.panel summary { font-weight: 600; }
details.panel[open] summary { margin-bottom: 12px; }

.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 40px; }
.scroll + dl.facts { margin-top: 16px; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--ardoise); }
dl.facts dd { margin: 0; color: var(--marine); }

/* --- Connexion --- */
.login { max-width: 380px; margin: 10vh auto 0; padding: 0 24px; }
.login img { width: 140px; height: auto; display: block; margin-bottom: 24px; }

/* Meter (backlog #71): usage read like an electricity bill */
.meter-controls { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 18px; }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--brume); border-radius: 6px; overflow: hidden; background: #FBFAF7; }
.segmented a { padding: 8px 14px; color: var(--marine); text-decoration: none; font-weight: 600; font-size: 14px; border-left: 1px solid var(--brume); }
.segmented a:first-child { border-left: 0; }
.segmented a[aria-current] { background: var(--accent); color: #fff; }
.segmented a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.meter-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr); border-top: 1px solid var(--brume); border-bottom: 1px solid var(--brume); margin-bottom: 8px; }
.meter-top > div { padding: 18px 20px; border-left: 1px solid var(--brume); min-width: 0; }
.meter-top > div:first-child { border-left: 0; padding-left: 0; }
.meter-top .label { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; font-weight: 600; color: var(--ardoise); }
.meter-top .note { font-size: 13px; color: var(--ardoise); }
.meter-top .big, .solar .big { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 38px; color: var(--marine); line-height: 1.15; margin-top: 4px; }
.meter-top .big.accent { color: var(--accent-texte); }
.meter-digits { display: inline-flex; gap: 3px; margin: 10px 0 6px; padding: 8px 10px; background: var(--marine); border-radius: 6px; max-width: 100%; overflow-x: auto; }
.meter-digits span { font: 500 24px/1 'JetBrains Mono', 'Courier New', monospace; color: var(--papier); background: rgba(255, 255, 255, .07); padding: 6px 4px; border-radius: 3px; min-width: 1.05em; text-align: center; }
.meter-digits span.dec { color: #E0607A; }
.meter-digits i { width: 6px; }
svg.gauge { display: block; width: 100%; height: auto; margin: 10px 0 6px; overflow: visible; }
.gauge-track { fill: var(--brume); }
.gauge-tick { stroke: var(--ardoise); stroke-width: 2; }
.gauge-cut { stroke: var(--danger); stroke-width: 2; }
.gauge-label { fill: var(--ardoise); font: 600 11px 'Public Sans', Arial, sans-serif; }
.gauge-label.cut { fill: var(--danger); }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 16px; flex-wrap: wrap; margin-bottom: 10px; }
.chart .bar.current { fill: #7DB896; }
.chart .grid.future { stroke-dasharray: 3 4; }
.meter-two { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 36px; align-items: start; }
svg.stack { display: block; width: 100%; height: 44px; border-radius: 4px; margin: 4px 0 14px; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.legend li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px; align-items: baseline; padding-bottom: 8px; border-bottom: 1px solid var(--brume); }
.legend li:last-child { border-bottom: 0; }
.legend .v { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend .p { text-align: right; font-weight: 600; min-width: 3.2em; font-variant-numeric: tabular-nums; }
svg.sw { display: inline-block; vertical-align: -1px; }
.solar { border: 1px solid var(--brume); background: #FBFAF7; border-radius: 6px; padding: 16px 18px; }
.solar .label { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; font-weight: 600; color: var(--ardoise); }
.solar-row { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.solar .note { font-size: 13px; color: var(--ardoise); margin: 10px 0 0; }
.ring-track { stroke: var(--brume); }
.ring-val { stroke: var(--accent); }
svg.donut { display: block; width: 100%; max-width: 300px; height: auto; margin-inline: auto; }
svg.donut path { stroke: var(--papier); stroke-width: 2; }
.donut-big { font: 400 30px 'Cormorant Garamond', Georgia, serif; fill: var(--marine); }
.donut-small { font: 13px 'Public Sans', Arial, sans-serif; fill: var(--ardoise); }

@media (max-width: 760px) {
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .meter-top { grid-template-columns: 1fr; }
  .meter-top > div { border-left: 0; padding-left: 0; border-top: 1px solid var(--brume); }
  .meter-top > div:first-child { border-top: 0; }
  .meter-two { grid-template-columns: 1fr; gap: 20px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile:nth-child(3) { border-left: 0; padding-left: 0; }
  .tile { border-top: 1px solid var(--brume); }
  .tile:nth-child(-n+2) { border-top: 0; }
  .cols { grid-template-columns: 1fr; gap: 0; }
  .scroll { overflow-x: auto; }
  .chart svg { min-width: 620px; }
  .page-head p { margin: 0; }
  h1 { font-size: 36px; }
}

/* Client documentation (portal) */
.doc { max-width: 880px; }
.doc section { padding: 24px 0; }
.doc p, .doc li { line-height: 1.6; }
.doc ul, .doc ol { padding-left: 22px; }
.doc li { margin-bottom: 6px; }
.doc h3 { margin-top: 18px; }
nav.toc { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 8px; font-size: 14px; }
pre.code { overflow-x: auto; background: var(--marine); color: #F4F1EA; border-radius: 4px; padding: 12px 14px; font: 13px/1.55 'JetBrains Mono', 'Courier New', monospace; margin: 0 0 14px; }
ol.order li::marker { color: var(--accent-texte); font-weight: 600; }
.method { font-size: 11px; letter-spacing: 1px; font-weight: 700; color: #fff; background: var(--accent-texte); padding: 2px 6px; border-radius: 3px; }
.pre-line { white-space: pre-line; }
table.fields td { font-size: 13px; }
details.endpoint summary code { overflow-wrap: anywhere; }

/* --- Temps de traitement : courbes --- */
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.p50, .chart .dot.p50 { stroke: var(--accent); }
.chart .line.p95 { stroke: var(--marine); stroke-dasharray: 5 4; }
.chart .dot { fill: var(--papier); stroke-width: 2; }
.chart .dot.p95 { stroke: var(--marine); }
.chart .dot:hover { fill: currentColor; }
.keys { display: flex; gap: 16px; margin: 0; }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key::before { content: ""; width: 18px; border-top: 2px solid var(--accent); }
.key.p95::before { border-top: 2px dashed var(--marine); }

/* --- Fonctionnalités d'une app --- */
.features-summary { margin: 8px 0 12px; }
.ranking { margin: 0; padding-left: 20px; }
.ranking li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--brume); }
.ranking li:last-child { border-bottom: 0; }
ul.ranking { list-style: none; padding-left: 0; }
.group-title { margin-top: 24px; }
svg.share { width: 90px; height: 6px; vertical-align: middle; margin-right: 6px; }
svg.share .track { fill: var(--brume); }
svg.share .fill { fill: var(--barre); }
table.features { table-layout: fixed; min-width: 620px; }
table.features th:first-child { width: 40%; }
table.features th:nth-child(2) { width: 24%; }
ul.plain { list-style: none; padding: 0; margin: 0 0 12px; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--brume); }
ul.plain li:last-child { border-bottom: 0; }
.legend.engines { margin-top: 10px; }
.legend.engines li { grid-template-columns: minmax(0, 1fr) auto; }
.solar-section { padding: 16px 0 0; border-top: 0; }

/* --- Analyse par l'IA --- */
.analysis { padding-top: 8px; }
.analysis-text { white-space: pre-line; background: #FBFAF7; border-left: 2px solid var(--accent); padding: 12px 16px; margin: 0 0 8px; color: var(--marine); }
.busy { display: none; margin-left: 8px; }
.htmx-request .busy { display: inline; }
.htmx-request button { opacity: .6; }
