/* Recharge kWh — interface d'administration
   Palette : gris-vert froid (papier), ardoise (encre), boîtier de compteur, jaune signal. */
:root {
  --paper: #eef1ee;
  --panel: #ffffff;
  --ink: #1c2a2e;
  --ink-soft: #55666a;
  --line: #d3dbd7;
  --housing: #24383d;      /* boîtier du compteur */
  --drum: #10191c;         /* rouleaux des chiffres */
  --drum-digit: #f4f6f2;
  --signal: #8cc63f;       /* action principale : vert interfaces énergies */
  --signal-ink: #13240a;
  --brand-green: #8cc63f;
  --ok: #2e7d5b;
  --warn: #b7791f;
  --bad: #b8402b;
  --focus: #1f6f8b;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Avenir Next", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--focus); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.875rem; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------ structure */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.nav {
  background: var(--housing);
  color: #dfe7e3;
  padding: 24px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; color: #fff; font-weight: 650; font-size: 1.05rem; }
.brand svg { flex: none; }
.brand small { display: block; font-weight: 400; font-size: 0.8rem; color: #a9bab4; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  color: inherit; text-decoration: none;
  padding: 10px 12px; border-radius: var(--radius-s);
  font-size: 0.95rem;
}
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a[aria-current="page"] { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.nav a svg { width: 20px; height: 20px; flex: none; opacity: .85; }
.nav .spacer { flex: 1; }
/* nom de l'éditeur */
.wm { font-family: Arial, "Helvetica Neue", sans-serif; font-weight: 400; letter-spacing: -0.01em; white-space: nowrap; }
.wm-s { color: var(--brand-green); }
.wm-nav { display: block; color: #fff; font-size: 1.28rem; line-height: 1.2; }
.wm-login { display: block; font-size: 1.9rem; color: var(--ink); line-height: 1.1; }
.wm-inline { font-size: inherit; }
.nav-credit { margin: 10px 10px 0; font-size: 0.75rem; color: #8fa39c; }
.login .credit { margin-top: 18px; font-size: 0.85rem; color: #a9bab4; text-align: center; }
.login .credit .wm { color: #fff; }
.brand-plate { background: #fff; border-radius: var(--radius-s); padding: 8px 10px; display: flex; align-items: center; max-width: 100%; }
.brand-logo { display: block; max-height: 44px; max-width: 170px; object-fit: contain; }
.brand:has(.brand-plate) { flex-direction: column; align-items: flex-start; gap: 8px; }
.nav button.link { color: #a9bab4; }

main { padding: 32px clamp(16px, 4vw, 48px) 80px; max-width: 1120px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--ink-soft); margin-top: 4px; }
section + section { margin-top: 36px; }
section > h2 { margin-bottom: 12px; }

/* ------------------------------------------------ boutons et champs */
button, .btn {
  font: inherit; font-size: 0.95rem; font-weight: 600;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: var(--radius-s); padding: 9px 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; min-height: 40px;
}
button:hover, .btn:hover { border-color: var(--ink-soft); }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--signal); border-color: #74ad2c; color: var(--signal-ink); }
.primary:hover { background: #9dd252; border-color: #659a24; }
.danger { color: var(--bad); }
.danger-fill { background: var(--bad); border-color: var(--bad); color: #fff; }
button.link { background: none; border: 0; padding: 6px 4px; min-height: 0; color: var(--focus); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 6px; }
label .hint { font-weight: 400; color: var(--ink-soft); }
input, textarea, select {
  font: inherit; color: var(--ink); width: 100%;
  border: 1px solid #b9c5c0; border-radius: var(--radius-s);
  padding: 9px 12px; background: #fff; min-height: 42px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(31,111,139,.2); }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.search { max-width: 320px; }

/* ------------------------------------------------ compteur (élément signature) */
.meter {
  display: inline-flex; align-items: stretch; gap: 2px;
  background: var(--housing); padding: 4px; border-radius: 5px;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.meter .d {
  background: linear-gradient(#000 0%, var(--drum) 18%, var(--drum) 82%, #000 100%);
  color: var(--drum-digit); font-weight: 600;
  width: 1.05em; padding: .28em 0; text-align: center; border-radius: 2px;
}
.meter .d.dec { background: linear-gradient(#5a1e14 0%, #8c2f1f 18%, #8c2f1f 82%, #5a1e14 100%); }
.meter .sep { width: .3em; }
.meter .u { color: #c8d4cf; font-size: .62em; font-weight: 600; align-self: center; padding: 0 .35em 0 .45em; }
.meter.neg .d { color: #ffb4a6; }
.meter-lg { font-size: 2.6rem; }
.meter-md { font-size: 1.15rem; }

/* ------------------------------------------------ listes et tableaux */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); }
.panel-pad { padding: 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); background: #f7f9f7; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f5f8f6; }
.table-wrap { overflow-x: auto; }
.empty { padding: 32px 20px; text-align: center; color: var(--ink-soft); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.875rem; font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st-ok { color: var(--ok); }
.st-warn { color: var(--warn); }
.st-bad { color: var(--bad); }
.st-off { color: #8a9893; }
.tag { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: #e4ebe8; color: var(--ink-soft); }
.tag.twint { background: #e6eef7; color: #24507a; }
.tag.especes { background: #e7f2ea; color: #2b6446; }
.tag.correction { background: #f7ecdc; color: #7a5115; }
.tag.offert { background: #efe8f5; color: #5b3d78; }

/* ------------------------------------------------ tableau de bord */
.chargers { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.charger { padding: 16px 18px; }
.charger h3 { margin-bottom: 2px; }
.live {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center;
  padding: 16px 18px; border-left: 4px solid var(--ok);
}
.live + .live { border-top: 1px solid var(--line); }
.live .kwh { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.alert {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; border: 1px solid #e3c766; background: #fdf6dc; border-radius: var(--radius-m);
}
.alert + .alert { margin-top: 8px; }
.figures { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--panel); }
.figures div { padding: 16px 18px; }
.figures div + div { border-left: 1px solid var(--line); }
.figures dt { font-size: 0.85rem; color: var(--ink-soft); }
.figures dd { margin: 4px 0 0; font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ fiche carte */
.card-hero { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; padding: 24px; }
.card-hero .who h1 { margin-bottom: 4px; }
.card-hero .bal { text-align: right; }
.card-hero .bal p { margin-top: 8px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 16px 0 0; font-size: 0.95rem; }
dl.facts dt { color: var(--ink-soft); }
dl.facts dd { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 0; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 10px 14px; color: var(--ink-soft); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

/* ------------------------------------------------ dialogues */
dialog {
  border: 0; border-radius: var(--radius-m); padding: 0; width: min(520px, calc(100vw - 24px));
  box-shadow: 0 24px 60px rgba(16,25,28,.35); color: var(--ink);
}
dialog::backdrop { background: rgba(28,42,46,.55); }
dialog form { padding: 24px; }
dialog h2 { margin-bottom: 4px; }
dialog .sub { color: var(--ink-soft); margin-bottom: 20px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.methods input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.methods label {
  margin: 0; border: 1px solid #b9c5c0; border-radius: var(--radius-s); padding: 10px 4px; text-align: center;
  cursor: pointer; font-weight: 600; background: #fff;
}
.methods input:checked + label { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: #f3f6f4; }
.methods input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.calc { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; }
.calc .eq { padding-bottom: 10px; color: var(--ink-soft); }
.preview { margin: 4px 0 16px; padding: 12px 14px; background: #f3f6f4; border-radius: var(--radius-s); font-size: 0.92rem; }
.error { color: var(--bad); font-size: 0.9rem; margin: 0 0 12px; font-weight: 600; }

/* ------------------------------------------------ connexion */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; background: var(--housing); }
.login form { background: var(--panel); padding: 32px; border-radius: var(--radius-m); width: min(380px, 100%); }
.login h1 { margin: 18px 0 4px; font-size: 1.4rem; }
.login p { color: var(--ink-soft); margin-bottom: 22px; }
.login button { width: 100%; margin-top: 4px; }
.login-logo { display: block; max-height: 64px; max-width: 220px; object-fit: contain; }
.label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 6px; }
.logo-edit { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-preview { width: 180px; height: 72px; border: 1px dashed #b9c5c0; border-radius: var(--radius-s); display: grid; place-items: center; padding: 8px; background: #fff; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ------------------------------------------------ notifications */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--radius-s);
  font-weight: 600; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.err { background: var(--bad); }

/* ------------------------------------------------ quittance (impression) */
.receipt { padding: 28px; font-size: 0.95rem; }
.receipt h2 { font-size: 1.3rem; margin-bottom: 2px; }
.receipt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 32px; }
.receipt-logo { max-height: 70px; max-width: 240px; object-fit: contain; }
.receipt-issuer { text-align: right; font-size: 0.9rem; line-height: 1.45; }
.receipt table td { padding: 8px 0; }
.receipt .total td { font-weight: 700; font-size: 1.1rem; border-top: 2px solid var(--ink); }
#print-area { display: none; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  body { background: #fff; }
}

/* ------------------------------------------------ mobile */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; z-index: 50;
    flex-direction: row; padding: 6px; gap: 0; justify-content: space-around;
  }
  .brand, .nav .spacer, .nav .logout { display: none; }
  .nav a { flex-direction: column; gap: 2px; font-size: 0.7rem; padding: 6px 4px; flex: 1; text-align: center; }
  main { padding: 20px 16px 96px; }
  h1 { font-size: 1.45rem; }
  .figures { grid-template-columns: 1fr 1fr; }
  .figures div:nth-child(3) { border-left: 0; }
  .figures div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .card-hero { grid-template-columns: 1fr; }
  .card-hero .bal { text-align: left; }
  .meter-lg { font-size: 2rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .methods { grid-template-columns: 1fr 1fr; }
  .hide-sm { display: none; }
  td .meter-md { font-size: 0.95rem; }
  td button { padding: 8px 10px; }
  th, td { padding: 10px 10px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* lecture de carte au bureau */
.input-btn { display: flex; gap: 8px; }
.input-btn input { flex: 1; min-width: 0; }
.input-btn button { flex: none; }
.scan-zone { display: flex; align-items: center; gap: 14px; padding: 16px; border: 2px dashed #b9c5c0; border-radius: var(--radius-m); background: #f7f9f7; margin-bottom: 10px; color: var(--ink-soft); }
.scan-zone input { font-size: 1.15rem; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
