/* FLUIDES — jetons repris de la maquette Claude Design */
:root {
  --bg: #F4F0E6; --surf: #FBF9F4; --field: #FFFFFF; --ink: #1C1B18; --ink2: #4F4A41; --muted: #6A6458;
  --key: #E9E3D6; --rule: #D9D2C3; --rule2: #CFC7B6; --track: #E3DCCD; --spark: #DDD6C7; --inv: #F7F3EA; --field-bd: #A39D90;
  --elec: #7A5300; --elec-f: #A87410; --elec-t: #F3E3BE;
  --gas: #A3401C; --gas-f: #C2532B; --gas-t: #F6DDD2;
  --water: #24598F; --water-f: #2F6CAB; --water-t: #DDE7F2;
  --chart-elec: #DBA827; --chart-gas: #A8401F; --chart-water: #2F6CAB; --chart-prev: #CFC7B6; --chart-grid: #E4DED1;
  --serif: 'Newsreader', Georgia, serif;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141311; --surf: #1E1C18; --field: #1E1C18; --ink: #EEE9DD; --ink2: #CFC8BA; --muted: #A29B8D;
    --key: #24221E; --rule: #34312B; --rule2: #4A453C; --track: #2E2B26; --spark: #3A3630; --inv: #141311; --field-bd: #5A5448;
    --elec: #E2AE45; --elec-f: #E2AE45; --elec-t: #3A2E14;
    --gas: #EE8460; --gas-f: #EE8460; --gas-t: #3D2219;
    --water: #79A9E3; --water-f: #79A9E3; --water-t: #1B2A3D;
    --chart-elec: #BB8A1F; --chart-gas: #B54A2C; --chart-water: #4C86CF; --chart-prev: #4A453C; --chart-grid: #2A2722;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141311; --surf: #1E1C18; --field: #1E1C18; --ink: #EEE9DD; --ink2: #CFC8BA; --muted: #A29B8D;
  --key: #24221E; --rule: #34312B; --rule2: #4A453C; --track: #2E2B26; --spark: #3A3630; --inv: #141311; --field-bd: #5A5448;
  --elec: #E2AE45; --elec-f: #E2AE45; --elec-t: #3A2E14;
  --gas: #EE8460; --gas-f: #EE8460; --gas-t: #3D2219;
  --water: #79A9E3; --water-f: #79A9E3; --water-t: #1B2A3D;
  --chart-elec: #BB8A1F; --chart-gas: #B54A2C; --chart-water: #4C86CF; --chart-prev: #4A453C; --chart-grid: #2A2722;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--sans); }
a { color: inherit; }
a:hover { opacity: .85; }
h1, h2, h3 { margin: 0; font-weight: 400; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.ink2 { color: var(--ink2); }
.small { font-size: 12.5px; }
.tnum { font-variant-numeric: tabular-nums; }

/* Couleurs de fluide */
.fl-elec { --c: var(--elec); --f: var(--elec-f); --t: var(--elec-t); --chart-main: var(--chart-elec); }
.fl-gas { --c: var(--gas); --f: var(--gas-f); --t: var(--gas-t); --chart-main: var(--chart-gas); }
.fl-water { --c: var(--water); --f: var(--water-f); --t: var(--water-t); --chart-main: var(--chart-water); }
.fl-name { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--c); display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 5px; background: var(--f); display: inline-block; flex: none; }
.fl-icon { width: 34px; height: 34px; border-radius: 17px; background: var(--t); color: var(--c); display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* Structure */
.wrap { max-width: 1280px; margin: 0 auto; padding: 32px 40px 56px; display: flex; flex-direction: column; gap: 28px; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px 32px; padding-bottom: 22px; border-bottom: 1px solid var(--rule); }
.brand { display: flex; flex-direction: column; gap: 8px; text-decoration: none; }
.brand-name { font-family: var(--serif); font-weight: 500; font-size: 30px; line-height: 1; letter-spacing: .26em; }
.brand-tag { font-size: 13px; color: var(--muted); }
.mainnav { display: flex; flex-wrap: wrap; gap: 6px; }
.mainnav a { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--rule); text-decoration: none; font-size: 13px; font-weight: 500; }
.mainnav a[aria-current="page"] { background: var(--ink); color: var(--inv); border-color: var(--ink); }
.tabbar { display: none; }
.cta-mobile { display: none; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 0 20px; border-radius: 22px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--ink); color: var(--inv); }
.btn-big { height: 60px; border-radius: 30px; font-size: 17px; width: 100%; }
.btn-new { height: 52px; padding: 0 26px 0 20px; border-radius: 26px; background: var(--ink); color: var(--inv); border: 0; font-size: 15px; box-shadow: 0 10px 24px -14px rgba(28,27,24,.55); }
.kbd { margin-left: 4px; padding: 2px 6px; border-radius: 4px; border: 1px solid currentColor; opacity: .55; font: 500 11px/1.2 var(--mono); }
.btn-link { border: 0; background: none; padding: 0; min-height: 40px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font-size: 13.5px; font-weight: 500; cursor: pointer; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn-danger { border-color: var(--gas); color: var(--gas); }
button:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }

/* Formulaires */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--ink2); }
.input, select.input, textarea.input { height: 44px; padding: 0 12px; border: 1px solid var(--field-bd); border-radius: 6px; background: var(--field); color: var(--ink); font-size: 14px; width: 100%; }
textarea.input { height: auto; min-height: 72px; padding: 10px 12px; }
.input.mono { font-family: var(--mono); font-weight: 500; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; align-items: end; }

/* Messages */
.flash { padding: 12px 16px; border-radius: 8px; border: 1px solid var(--rule2); background: var(--surf); font-size: 14px; }
.flash-error { border: 2px solid var(--gas); }
.alert-bar { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border-radius: 10px; background: var(--ink); color: var(--inv); text-decoration: none; }
.alert-bar strong { font-weight: 600; }
.bang { width: 22px; height: 22px; flex: none; border-radius: 11px; background: var(--inv); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; font: 700 13px/1 var(--sans); }

/* Statuts */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; border: 1px solid var(--rule2); font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--ink2); }
.pill.st-soon { border-color: var(--ink2); color: var(--ink); }
.pill.st-late { background: var(--ink); border-color: var(--ink); color: var(--inv); }
.pill.st-none { color: var(--muted); }

/* Tableau de bord */
.period { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; }
.period h2 { font-family: var(--serif); font-size: 26px; }
.period em { color: var(--muted); }
.cards { display: flex; flex-wrap: wrap; gap: 20px; }
.card { flex: 1 1 320px; min-width: 0; background: var(--surf); border: 1px solid var(--rule); border-radius: 6px; padding: 22px 24px 20px; display: flex; flex-direction: column; gap: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head > div { display: flex; align-items: center; gap: 10px; }
.big { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.big .v { font-family: var(--serif); font-size: 54px; line-height: 1; font-variant-numeric: tabular-nums; }
.big .u { font-family: var(--serif); font-size: 22px; }
.delta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink2); flex-wrap: wrap; }
.delta b { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.spark { height: 46px; display: flex; align-items: flex-end; gap: 4px; }
.spark span { flex: 1; border-radius: 2px 2px 0 0; background: var(--spark); }
.spark span.cur { background: var(--f); }
.spark.ghost span { background: none; border: 1px dashed var(--rule2); border-bottom: 0; }
.spark-cap { display: flex; justify-content: space-between; font: 10px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.card-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 1px solid var(--rule); }
.card-foot .cost { font-family: var(--serif); font-size: 24px; line-height: 1; }
.card-foot .next { max-width: 50%; text-align: right; font-size: 11.5px; line-height: 1.45; color: var(--ink2); }
.start-idx { font: 500 30px var(--mono); letter-spacing: .04em; }
.label-caps { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.row2 { display: flex; flex-wrap: wrap; gap: 20px; }
.panel { flex: 1 1 360px; min-width: 0; background: var(--surf); border: 1px solid var(--rule); border-radius: 6px; padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; }
.panel.wide { flex: 999 1 560px; }
.panel h2 { font-family: var(--serif); font-size: 22px; }
.ycost { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; }
.ycost .v { font-family: var(--serif); font-size: 48px; line-height: 1; }
.split { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--track); }
.split span { background: var(--f); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--rule); }
.list li:last-child { border-bottom: 1px solid var(--rule); }
.steps li { justify-content: flex-start; align-items: baseline; gap: 14px; }

/* Mobile accueil */
.m-rows { display: flex; flex-direction: column; }
.m-row { display: flex; flex-direction: column; gap: 8px; padding: 14px 0; border-top: 1px solid var(--rule); text-decoration: none; }
.m-row .top, .m-row .mid { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.m-row .mid { align-items: flex-end; }
.m-row .val { font-family: var(--serif); font-size: 40px; line-height: 1; }
.m-row .unit { font-family: var(--serif); font-size: 17px; }
.bar { height: 4px; border-radius: 2px; background: var(--track); position: relative; }
.bar > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--f); }
.bar > i { position: absolute; top: -3px; width: 2px; height: 10px; margin-left: -1px; background: var(--ink); }

/* Saisie */
.saisie { max-width: 460px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 18px; }
.meter-choice { display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 12px 16px; border: 1px solid var(--rule); border-radius: 12px; background: var(--surf); text-decoration: none; }
.meter-choice .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.meter-choice.late { border: 2px solid var(--ink); }
.last-box { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--t); }
.idx-field { display: flex; align-items: center; height: 76px; padding: 0 16px; border: 2px solid var(--f); border-radius: 12px; background: var(--field); }
.idx-field input { flex: 1; min-width: 0; height: 60px; border: 0; padding: 0; background: transparent; font: 500 34px var(--mono); outline: none; letter-spacing: .02em; }
.idx-field .u { font-size: 18px; color: var(--muted); }
.feedback { min-height: 64px; }
.fb-ok { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; }
.fb-ok .v { font: 600 22px var(--mono); }
.fb-warn, .fb-err { display: flex; gap: 12px; padding: 14px; border-radius: 10px; background: var(--surf); border: 2px solid var(--ink); }
.fb-err { border-color: var(--gas); }
.fb-warn .bang, .fb-err .bang { background: var(--ink); color: var(--inv); }
.fb-err .bang { background: var(--gas); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--rule2); background: transparent; font-size: 13.5px; cursor: pointer; }
.chip input[type="datetime-local"] { border: 0; background: transparent; font: 500 13px var(--mono); }
/* Pavé numérique : seulement sur écran tactile */
.keypad { display: none; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.keypad button { height: 54px; border: 0; border-radius: 10px; background: var(--key, #E9E3D6); color: var(--ink); font: 500 24px/1 var(--mono); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; touch-action: manipulation; }
.keypad button:active { background: var(--rule2); }
@media (pointer: coarse) { .keypad { display: grid; } }
.ok-card { display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: 14px; background: var(--surf); border: 1px solid var(--rule); }
.ok-check { width: 56px; height: 56px; border-radius: 28px; background: var(--ink); color: var(--inv); display: inline-flex; align-items: center; justify-content: center; }

/* Historique */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg a { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--rule); text-decoration: none; font-size: 13px; }
.seg a[aria-current="true"] { background: var(--ink); color: var(--inv); border-color: var(--ink); }
.table-box { overflow-x: auto; border: 1px solid var(--rule); border-radius: 6px; background: var(--surf); }
table.hist { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.hist th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.hist td { padding: 12px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.hist tr:last-child td { border-bottom: 0; }
table.hist .num { text-align: right; font-family: var(--mono); white-space: nowrap; }
table.hist .actions { white-space: nowrap; text-align: right; }
table.hist tr.event td { background: var(--bg); font-size: 13px; color: var(--ink2); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--ink2); font-size: 11.5px; }
.icon-btn { width: 36px; height: 36px; border: 1px solid var(--rule); border-radius: 18px; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); text-decoration: none; }

/* Réglages */
.settings { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 40px; align-items: start; }
.settings nav { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 4px; }
.settings nav a { padding: 8px 12px; border-radius: 6px; text-decoration: none; font-size: 14px; }
.settings nav a:hover { background: var(--surf); }
.settings section { display: flex; flex-direction: column; gap: 16px; padding-bottom: 36px; border-bottom: 1px solid var(--rule); margin-bottom: 36px; scroll-margin-top: 24px; }
.settings section h2 { font-family: var(--serif); font-size: 26px; }
.box { border: 1px solid var(--rule); border-radius: 8px; background: var(--surf); padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
details.box summary { cursor: pointer; font-weight: 600; font-size: 14px; }

/* Onboarding / login */
.narrow { max-width: 440px; margin: 0 auto; padding: 24px 24px 32px; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; gap: 22px; }
.progress { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.progress span { height: 3px; border-radius: 2px; background: var(--rule); }
.progress span.on { background: var(--ink); }
.opt { display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 12px 16px; border: 2px solid var(--rule); border-radius: 12px; cursor: pointer; }
.opt:has(input:checked) { border-color: var(--ink); background: var(--surf); }
.opt input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
.title-xl { font-family: var(--serif); font-size: 30px; line-height: 1.12; }

/* Analyse */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 24px; }
.filters .group { display: flex; flex-direction: column; gap: 6px; }
.filters .group > span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: var(--surf); border: 1px solid var(--rule); border-radius: 6px; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi .v { font-family: var(--serif); font-size: 30px; line-height: 1.1; }
.chart-row { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 20px; align-items: start; }
.chart-box { position: relative; height: 320px; }
.chart-box.short { height: 240px; }
.detail { border-left: 1px solid var(--rule); padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.detail dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 6px 12px; font-size: 13px; }
.detail dt { color: var(--ink2); }
.detail dd { margin: 0; text-align: right; font-family: var(--mono); }
.key { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--ink2); }
.key span { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 6px 10px; border-bottom: 1px solid var(--rule); text-align: right; font-family: var(--mono); }
.data-table th:first-child, .data-table td:first-child { text-align: left; font-family: var(--sans); }

/* Mobile */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .wrap { padding: 18px 20px 150px; gap: 18px; }
  .topbar { padding-bottom: 0; border: 0; }
  .brand-name { font-size: 20px; }
  .brand-tag, .mainnav, .btn-new { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--rule); background: var(--surf); z-index: 10; }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 11px; }
  .tabbar a[aria-current="page"] { color: var(--ink); font-weight: 600; }
  .cta-mobile { display: block; position: fixed; left: 20px; right: 20px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 10; }
  .desk-only { display: none !important; }
  .settings { grid-template-columns: 1fr; gap: 16px; }
  .settings nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .card { padding: 18px; }
  .big .v { font-size: 44px; }
  .period h2 { font-size: 22px; }
  table.hist .hide-sm { display: none; }
  .chart-row { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 12px 14px; }
  .kpi .v { font-size: 24px; }
  .detail { border-left: 0; border-top: 1px solid var(--rule); padding: 14px 0 0; }
  .chart-box { height: 260px; }
}
@media (min-width: 761px) { .mob-only { display: none !important; } }
