:root {
  --ink: #061527;
  --muted: #607085;
  --line: #d9e2eb;
  --panel: #ffffff;
  --teal: #004f54;
  --teal-2: #006d70;
  --blue: #0d64b8;
  --orange: #ff7a00;
  --green: #3e9b43;
  --red: #d9272e;
  --yellow: #f3c400;
  --sky: #2d8de0;
  --soft: #f5f9fc;
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(123,201,189,.28), transparent 34%),
    radial-gradient(circle at bottom right, rgba(18,113,117,.16), transparent 36%),
    linear-gradient(135deg, #f9fffd 0%, #eef7f6 46%, #ffffff 100%);
  background-attachment: fixed;
  cursor: crosshair;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 88% 8%, rgba(123,201,189,.26), transparent 24%),
    radial-gradient(circle at 6% 92%, rgba(0,79,84,.12), transparent 28%);
  z-index: -1;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 32px;
  gap: 20px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
}

.brand-strip {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  width: fit-content;
  max-width: 100%;
  padding: 10px 18px;
  background: #fff;
  border: 1px solid rgba(217,226,235,.9);
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(12,65,68,.08);
}
.partner-logo { object-fit: contain; display: block; }
.fmd-logo { width: 248px; height: 132px; }
.dna-logo { width: 240px; height: 132px; }
.kordelia-header-logo { width: min(333px, 28vw); height: auto; }
.brand-separator { width: 1px; height: 132px; background: #9aa7b4; }

.main-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(128px, 1fr));
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  min-width: 0;
}
.tab-button {
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  color: #043f48;
  min-height: 56px;
  padding: 0 12px;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.tab-button:last-child { border-right: 0; }
.tab-button.active,
.setting-link.active {
  color: #fff;
  background: linear-gradient(135deg, var(--teal), var(--teal-2));
}

.top-actions, .inline-actions { display: flex; align-items: center; gap: 18px; justify-content: flex-end; }
.icon-label {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 7px;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
}
.icon-label.ghost { background: #fff; color: var(--teal); text-transform: none; }
.icon-label.primary { background: linear-gradient(135deg, var(--teal), var(--teal-2)); color: #fff; box-shadow: 0 8px 18px rgba(0, 79, 84, .2); }
.icon-label.small { min-height: 44px; padding: 0 18px; }
.history-button { width: 52px; padding: 0; }
.history-button.hidden { display: none; }
.history-button[disabled] { opacity: .35; cursor: not-allowed; }
.icon { font-size: 24px; line-height: 1; }

main { flex: 1; }
.view { display: none; }
.view.active { display: block; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.view-head.compact { justify-content: flex-start; margin-bottom: 46px; }
h1 { margin: 0; color: var(--teal); font-size: 34px; letter-spacing: 0; }
h2 { margin: 0 0 22px; color: var(--teal); font-size: 28px; letter-spacing: 0; }

.home-layout {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(520px, 1fr);
  gap: 32px;
  align-items: start;
}
.import-card input { width: min(100%, 460px); }
.import-card p {
  margin: 18px 0 0;
  color: var(--muted);
  font-weight: 700;
}
.import-status {
  color: var(--teal);
  font-weight: 900;
}
.alerts-panel { padding: 24px 28px; }
.alerts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.alerts-head h2 { margin: 0; }
.alerts-head span {
  color: var(--teal);
  font-weight: 900;
  white-space: nowrap;
}
.alerts-list { display: grid; gap: 20px; }
.alert-section {
  display: grid;
  gap: 10px;
}
.alert-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.alert-section-head h3 {
  margin: 0;
  color: var(--teal);
  font-size: 18px;
  letter-spacing: 0;
}
.alert-section-head span {
  min-width: 34px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #eaf4fb;
  color: var(--blue);
  font-weight: 900;
}
.alert-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px dashed var(--line);
}
.alert-row:last-child { border-bottom: 0; }
.new-meter-alert {
  background: #f5fbff;
  margin: 0 -12px;
  padding: 14px 12px;
  border-radius: 7px;
}
.alert-row strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
}
.alert-row span:not(.dot) {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}
.text-link {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}
.empty-state {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.period-panel {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 28px;
  padding: 24px 18px 18px;
  margin: 0 0 24px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  min-width: min(760px, 100%);
}
.period-panel.narrow { min-width: 730px; margin-top: 12px; }
.panel-label {
  position: absolute;
  left: -1px;
  top: -36px;
  background: linear-gradient(135deg, var(--teal), var(--teal-2));
  color: #fff;
  padding: 10px 26px;
  border-radius: 7px 7px 0 0;
  font-weight: 800;
}
label { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; color: #073c45; }
.period-reset-link {
  border: 0;
  border-bottom: 2px solid #064fa8;
  background: transparent;
  color: #064fa8;
  font-weight: 900;
  cursor: pointer;
  padding: 3px 0;
}
.period-reset-link:hover { color: var(--teal); border-bottom-color: var(--teal); }
input, select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  font: inherit;
  background: #fff;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px 42px;
  align-items: start;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(10, 31, 68, .05);
}
.metric-table { overflow: hidden; align-self: start; }
.table-title {
  display: grid;
  grid-template-columns: 1fr 180px;
  background: linear-gradient(135deg, var(--teal), var(--teal-2));
  color: #fff;
  font-weight: 800;
  padding: 14px 28px;
  font-size: 20px;
}
.metric-row {
  display: grid;
  grid-template-columns: 1fr 180px;
  align-items: center;
  padding: 13px 28px;
  border-bottom: 1px dashed var(--line);
  font-size: 17px;
}
.metric-row strong { color: #064fa8; font-size: 24px; }
.metric-row strong.danger { color: var(--orange); }
.correction-note {
  display: none;
  margin: 14px 28px 22px;
  padding: 12px 14px;
  border: 1px solid #f2c66d;
  border-radius: 6px;
  background: #fff8e8;
  color: #7a4b00;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}
.correction-note.visible { display: block; }
.total-consumption-row span,
.total-consumption-row strong {
  color: #111;
  font-weight: 900;
}
.total-consumption-row strong {
  font-size: 30px;
}
.total-consumption-row span {
  font-size: 20px;
}
.total-box {
  display: grid;
  grid-template-columns: 1fr 180px;
  align-items: center;
  margin: 8px 12px 12px;
  padding: 12px 16px;
  border: 1px solid var(--teal);
  border-radius: 6px;
  color: var(--teal);
  font-weight: 800;
  font-size: 22px;
}
.state-line { display: grid; grid-template-columns: 28px 1fr 90px; align-items: center; padding: 11px 28px; border-bottom: 1px dashed var(--line); font-size: 16px; }
.dot { width: 17px; height: 17px; border-radius: 50%; display: inline-block; }
.chart-panel { padding: 22px 28px; }
.chart-layout { display: grid; grid-template-columns: 270px 1fr; gap: 32px; align-items: center; }
.donut {
  width: 260px;
  height: 260px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--blue) 0 70%, var(--orange) 70% 100%);
  position: relative;
  color: #fff;
  font-size: 26px;
  font-weight: 800;
}
.donut::after {
  content: "";
  position: absolute;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: #fff;
}
.donut-label {
  position: absolute;
  z-index: 2;
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .28);
}
.donut-label.dark { color: #0b1b2d; text-shadow: none; }
.donut-label.center { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.donut-label.top { left: 50%; top: 18px; transform: translateX(-50%); }
.donut-label.right { right: 28px; top: 50%; transform: translateY(-50%); }
.donut-label.bottom { left: 50%; bottom: 18px; transform: translateX(-50%); }
.donut-label.left { left: 26px; top: 50%; transform: translateY(-50%); }
.donut-label.upper-left { left: 42px; top: 54px; }
.donut-label.lower-left { left: 40px; bottom: 54px; }
.donut-label.upper-right { right: 42px; top: 54px; }
.donut-label.lower-right { right: 38px; bottom: 54px; }
.legend { display: grid; gap: 18px; }
.legend-item { display: grid; grid-template-columns: 18px 1fr; gap: 16px; align-items: center; font-size: 16px; }
.legend-swatch { width: 18px; height: 18px; border-radius: 4px; }

.search-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 300px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 14px;
  background: #fff;
  color: var(--teal);
  font-size: 28px;
}
.search-box.wide { min-width: 440px; }
.search-box input { border: 0; outline: 0; flex: 1; height: 48px; font-size: 16px; }

.table-filters {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: -8px 0 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbfd;
}
.table-filters.open { display: grid; }
.filter-field {
  display: grid;
  gap: 6px;
}
.filter-field label {
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
}
.filter-field input,
.filter-field select {
  width: 100%;
}
.clear-filters {
  align-self: end;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--teal);
  font-weight: 900;
  cursor: pointer;
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: #073c45; font-weight: 800; background: #fbfdff; }
td { font-size: 15px; }
td:first-child { font-weight: 700; }
.cell-compteur { display: grid; grid-template-columns: 18px minmax(0, 1fr) 34px; gap: 12px; align-items: center; }
.subline { display: block; margin-top: 4px; font-weight: 700; }
.new-meter-row td { background: #f5fbff; }
.new-meter-label {
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 5px;
  font-weight: 800;
}
.badge.normal { background: #d9f2d4; color: #111; }
.badge.operationnel, .badge.resolu { background: #58b957; color: #111; }
.badge.surveillance, .badge.travaux, .badge.fige { background: #ffd34d; color: #111; }
.badge.verifier, .badge.zero { background: #ff9f33; color: #111; }
.badge.intervention, .badge.aucune { background: #e50914; color: #fff; }
.badge.arret { background: #bfd4ed; color: #111; }
.badge.incoherent { background: #acd0f3; color: #111; }
.badge.supprime { background: #d8b8ff; color: #111; }
.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  color: #17324a;
}
.settings-layout { display: grid; grid-template-columns: 320px 1fr; gap: 70px; padding-top: 20px; }
.settings-menu {
  display: grid;
  align-content: start;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.setting-link {
  min-height: 74px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #f7fbfc, #eef7f7);
  color: var(--teal);
  font-weight: 800;
  text-align: left;
  padding: 0 26px;
  text-transform: uppercase;
  cursor: pointer;
}
.settings-content { max-width: 920px; }
.settings-card { border: 1px solid var(--line); border-radius: 7px; padding: 28px; background: #fff; }
.settings-card h2 { display: flex; align-items: center; gap: 12px; }
.setting-grid { display: grid; gap: 12px; }
.setting-row { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(260px, auto); align-items: center; gap: 18px; min-height: 58px; border-bottom: 1px solid var(--line); }
.setting-row strong { color: var(--teal); }
.setting-row input { width: 120px; }
.editable-field {
  width: 120px;
  text-align: center;
  font-weight: 800;
}
.editable-select {
  width: 100%;
  min-width: 150px;
  font-weight: 700;
}
.date-input {
  width: 145px;
  font-weight: 700;
}
.date-input.locked {
  background: #f1f4f7;
  color: #7a8794;
  cursor: not-allowed;
}

.comment-input {
  width: 100%;
  min-width: 220px;
  min-height: 58px;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid #b9cbd1;
  border-radius: 6px;
  background: #fff;
  color: #17324a;
  font: inherit;
  line-height: 1.35;
}
.comment-input:focus {
  outline: 2px solid rgba(18, 113, 117, 0.22);
  border-color: var(--teal);
}
#fuitesView table, #anomaliesView table { min-width: 1320px; }
.prob-meter {
  display: grid;
  gap: 6px;
  min-width: 130px;
}
.prob-track {
  height: 10px;
  border-radius: 999px;
  background: transparent;
}
.prob-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3fb7b4, #ffcc4d, #e50914);
}
.prob-value {
  font-weight: 900;
  color: #073c45;
}
.list-editor {
  display: grid;
  gap: 12px;
}
.editor-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}
.editor-row input {
  width: 100%;
}
.meter-search {
  min-width: 0;
}
.meter-search input {
  width: 100%;
}
.danger-button,
.add-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}
.danger-button { background: #ffe6e8; color: #9b1016; }
.add-button { background: var(--teal); color: #fff; justify-self: start; }
.editable-select.normal { background: #d9f2d4; color: #111; }
.editable-select.operationnel,
.editable-select.resolu { background: #58b957; color: #111; }
.editable-select.surveillance,
.editable-select.travaux,
.editable-select.fige { background: #ffd34d; color: #111; }
.editable-select.verifier,
.editable-select.zero { background: #ff9f33; color: #111; }
.editable-select.intervention,
.editable-select.aucune { background: #e50914; color: #fff; }
.editable-select.arret { background: #bfd4ed; color: #111; }
.editable-select.incoherent { background: #acd0f3; color: #111; }
.editable-select.supprime { background: #d8b8ff; color: #111; }
.pill-list { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 16px; }
.pill-list.single { grid-template-columns: minmax(280px, 520px); }
.profile-pill, .state-pill {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  font-weight: 800;
  background: #fff;
}

.status-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  min-height: 54px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f4f9ff;
  color: #063568;
}
.info-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #1685df;
  color: #fff;
  font-weight: 800;
}
.footer-brand { justify-self: end; }

.toast {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 20;
  min-width: 220px;
  padding: 14px 18px;
  border-radius: 7px;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(0, 79, 84, .24);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.about-page {
  max-width: 1120px;
  display: grid;
  gap: 22px;
  line-height: 1.55;
}
.about-page section,
.about-intro {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 24px 28px;
}
.about-page p,
.about-page li {
  color: #1b3042;
  font-size: 16px;
  font-weight: 600;
}
.about-summary {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbfd;
}
.about-summary a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 6px;
  background: #fff;
  color: var(--teal);
  font-weight: 900;
  text-decoration: none;
}

@media (max-width: 1350px) {
  .topbar { grid-template-columns: 1fr; }
  .kordelia-header-logo { width: min(333px, 48vw); }
  .main-tabs { grid-template-columns: repeat(3, minmax(110px, 1fr)); }
  .top-actions { justify-content: flex-start; }
}

@media (max-width: 1100px) {
  .brand-strip { flex-wrap: wrap; }
  .kordelia-header-logo { width: min(333px, 100%); }
  .main-tabs { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .home-layout, .settings-layout { grid-template-columns: 1fr; }
  .chart-layout { grid-template-columns: 1fr; }
  .table-shell { overflow-x: auto; }
  table { min-width: 980px; }
}

.sort-date-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--teal);
  border-radius: 4px;
  margin-left: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
}
.sort-date-button.active { background: var(--teal); color: #fff; }
.rule-editor-row {
  grid-template-columns: minmax(190px, 1.2fr) 48px repeat(4, minmax(150px, auto)) auto;
  align-items: center;
}
.rule-editor-row label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.color-input { width: 42px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.danger-zone { margin-top: 24px; border-color: #f0b8b8; background: #fffafa; }
.danger-button.wide { min-height: 44px; padding: 0 18px; }
@media (max-width: 1200px) { .rule-editor-row { grid-template-columns: 1fr; } }

.settings-save-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 0 4px;
  background: linear-gradient(to top, #fff 70%, rgba(255,255,255,.85));
  z-index: 5;
}

.settings-save-hint {
  color: var(--muted);
  font-weight: 700;
}

.settings-save-hint.dirty {
  color: var(--orange);
}

.copy-meter-button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--teal);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.copy-meter-button:hover {
  background: var(--soft);
  border-color: var(--teal);
}

.analysis-info-button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--teal);
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
}
.analysis-info-button:hover { background: var(--soft); border-color: var(--teal); }

.meter-modal.hidden { display: none; }
.meter-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
.meter-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 21, 39, .48);
}
.meter-modal-card {
  position: relative;
  width: min(1280px, 96vw);
  max-height: 94vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
  padding: 22px;
}
.meter-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 14px;
}
.meter-modal-head h2 { margin: 0 0 8px; font-size: 26px; color: var(--ink); }
.meter-modal-head p { margin: 0; color: var(--muted); font-weight: 700; }
.meter-modal-close {
  border: 0;
  background: #fff;
  color: #000;
  font-weight: 900;
  cursor: pointer;
  font-size: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.meter-modal-close span { font-size: 15px; }
#meterModalCanvas {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: crosshair;
}
.meter-modal-explanation {
  margin-top: 18px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}
.meter-modal-explanation h3 { margin: 0 0 8px; color: var(--teal); }
.meter-modal-explanation p { margin: 0; line-height: 1.45; color: var(--ink); }
.meter-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* Kordelia 1.0.18 - bouton fixe de retour en haut */
.scroll-top-button {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  cursor: pointer;
}
.scroll-top-button:hover { transform: translateY(-2px); }
.scroll-top-button:focus-visible { outline: 3px solid rgba(13, 100, 184, .35); outline-offset: 3px; }
.scroll-top-button.footer-visible { bottom: 78px; }
.virtual-meter-dot { background: #e5eaee; }
.virtual-meter-state {
  display: block;
  width: 100%;
  min-height: 40px;
}
@media (prefers-reduced-motion: no-preference) {
  .scroll-top-button { transition: bottom .2s ease, transform .2s ease; }
}
@media (max-width: 700px) {
  .scroll-top-button { right: 14px; bottom: 14px; padding: 10px 13px; }
  .scroll-top-button.footer-visible { bottom: 82px; }
}


/* KORDELIA V1.1 - Messagerie */
.messaging-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.messaging-field{display:flex;flex-direction:column;gap:6px}.messaging-field.full{grid-column:1/-1}.messaging-field label{font-weight:700;color:#173033}.messaging-field input,.messaging-field select,.messaging-field textarea{width:100%;box-sizing:border-box;border:1px solid #cbd8d6;border-radius:8px;padding:10px 11px;background:#fff;color:#173033}.messaging-field textarea{min-height:88px;resize:vertical}.messaging-help{font-size:12px;color:#687779}.messaging-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:18px}.messaging-status{margin-top:14px;padding:12px;border-radius:8px;background:#eef5f4;color:#0c4144}.messaging-history{width:100%;border-collapse:collapse;font-size:13px}.messaging-history th,.messaging-history td{padding:9px;border-bottom:1px solid #e7eeee;text-align:left;vertical-align:top}.messaging-history th{background:#edf4f3;color:#0c4144}.password-configured{font-size:12px;color:#3b7d68;font-weight:700}@media(max-width:760px){.messaging-grid{grid-template-columns:1fr}.messaging-field.full{grid-column:auto}.messaging-history{display:block;overflow-x:auto}}

/* V1.1.3 - Historique des commentaires */
.comment-editor { min-width: 260px; }
.comment-history { max-height: 180px; overflow-y: auto; margin-bottom: 7px; }
.comment-entry { padding: 7px 8px; margin-bottom: 5px; border: 1px solid #dfe8e5; border-radius: 8px; background: #f7faf9; }
.comment-meta { font-size: 10px; font-weight: 700; color: #60736f; margin-bottom: 3px; }
.comment-text { font-size: 12px; line-height: 1.35; color: #263c38; }
.comment-empty { font-size: 11px; color: #82918e; margin-bottom: 5px; }
.comment-draft { width: 100%; min-height: 48px; resize: vertical; box-sizing: border-box; border: 1px solid #cfdad7; border-radius: 8px; padding: 7px 8px; font: inherit; }
.comment-add-button { margin-top: 5px; border: 0; border-radius: 7px; padding: 6px 10px; background: #0c6f70; color: #fff; font-weight: 700; cursor: pointer; }
.comment-add-button:hover { filter: brightness(.95); }


/* KORDELIA V1.1.4 - Fenêtre d'historique des commentaires */
.comment-open-button{border:1px solid #b9d2cd;border-radius:9px;background:#f4faf8;color:#0c6062;padding:8px 10px;font-weight:800;cursor:pointer;white-space:nowrap}.comment-open-button:hover{background:#e6f4f1}.comment-modal{position:fixed;inset:0;z-index:1200;display:grid;place-items:center;padding:20px}.comment-modal.hidden{display:none}.comment-modal-backdrop{position:absolute;inset:0;background:rgba(2,26,28,.55)}.comment-modal-card{position:relative;width:min(680px,96vw);max-height:88vh;overflow:auto;background:#fff;border-radius:16px;box-shadow:0 24px 70px rgba(0,0,0,.28);padding:20px}.comment-modal-head{display:flex;align-items:center;justify-content:space-between;gap:15px;margin-bottom:15px}.comment-modal-head h2{margin:0;color:#0c4144}.comment-modal-close{border:0;background:#edf5f3;border-radius:50%;width:36px;height:36px;font-size:24px;cursor:pointer}.comment-entry-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}.comment-delete-button{border:0;background:transparent;color:#a22b2b;font-size:11px;font-weight:800;cursor:pointer}.comment-modal-label{display:block;margin:15px 0 6px;font-weight:800;color:#173033}.comment-modal-card textarea{width:100%;box-sizing:border-box;border:1px solid #cbd8d6;border-radius:9px;padding:10px;font:inherit;resize:vertical}.comment-modal-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:12px}.comment-history{max-height:none}.table-wrap table th:nth-last-child(-n+5),.table-wrap table td:nth-last-child(-n+5){white-space:nowrap}.table-wrap table th:last-child,.table-wrap table td:last-child{min-width:170px}.table-wrap table td select,.table-wrap table td input[type=date]{min-width:105px}

/* KORDELIA V1.1.6 - Colonnes proportionnelles et commentaires visibles */
.brand-strip {
  gap: 14px;
  padding-right: 14px;
}

/* Les tableaux restent lisibles sans donner la même largeur à toutes les colonnes. */
#fuitesView .table-shell,
#anomaliesView .table-shell {
  overflow-x: auto;
}

#fuitesView table.events-table { min-width: 1460px; }
#anomaliesView table.events-table { min-width: 1420px; }

/* Fuites : largeur fondée sur le contenu réel, avec priorité au compteur et aux commentaires. */
#fuitesView .leaks-table .col-meter       { width: 28%; }
#fuitesView .leaks-table .col-probability { width: 7%; }
#fuitesView .leaks-table .col-flow        { width: 10%; }
#fuitesView .leaks-table .col-profile     { width: 11%; }
#fuitesView .leaks-table .col-start       { width: 7%; }
#fuitesView .leaks-table .col-end         { width: 9%; }
#fuitesView .leaks-table .col-status      { width: 10%; }
#fuitesView .leaks-table .col-comment     { width: 18%; }

/* Anomalies : type et état restent adaptés à leurs libellés, le reste va aux commentaires. */
#anomaliesView .anomalies-table .col-meter         { width: 27%; }
#anomaliesView .anomalies-table .col-meter-type    { width: 12%; }
#anomaliesView .anomalies-table .col-anomaly-state { width: 14%; }
#anomaliesView .anomalies-table .col-start         { width: 7%; }
#anomaliesView .anomalies-table .col-end           { width: 9%; }
#anomaliesView .anomalies-table .col-status        { width: 10%; }
#anomaliesView .anomalies-table .col-comment       { width: 21%; }

#fuitesView th, #fuitesView td,
#anomaliesView th, #anomaliesView td {
  padding-left: 10px;
  padding-right: 10px;
}

#fuitesView .cell-compteur,
#anomaliesView .cell-compteur {
  grid-template-columns: 16px minmax(0, 1fr) 30px 30px;
  gap: 7px;
}

/* Nom + site limités ensemble à deux lignes maximum. */
#fuitesView .meter-text,
#anomaliesView .meter-text {
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
#fuitesView .meter-name,
#anomaliesView .meter-name { font-weight: 800; }
#fuitesView .meter-site,
#anomaliesView .meter-site {
  font-weight: 700;
  margin-left: .35em;
}

#fuitesView td select,
#anomaliesView td select,
#fuitesView td input[type="date"],
#anomaliesView td input[type="date"] {
  min-width: 0;
  width: 100%;
  padding-left: 10px;
  padding-right: 8px;
}

/* Historique directement visible dans la cellule commentaire. */
.comment-inline-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}
.comment-inline-entry {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 7px;
  border-left: 3px solid #b8d8d3;
  background: #f6faf9;
  border-radius: 5px;
}
.comment-inline-content {
  min-width: 0;
  flex: 1;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.comment-inline-author {
  display: inline;
  font-size: 11px;
  font-weight: 900;
  color: #496864;
}
.comment-inline-text {
  display: inline;
  margin-left: 4px;
  font-size: 12px;
  color: #203a37;
}
.comment-inline-delete {
  flex: 0 0 auto;
  padding: 0 2px;
  font-size: 17px;
  line-height: 1;
}
.comment-inline-empty {
  font-size: 12px;
  color: #82918e;
  font-style: italic;
}
.comment-inline-add {
  align-self: flex-start;
  border: 0;
  background: transparent;
  padding: 2px 0;
  color: #087174;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}
.comment-inline-add:hover { text-decoration: underline; }


/* KORDELIA V1.1.7 - noms courts, statut lisible et colonnes affinées */
#fuitesView table.events-table { min-width: 1320px; }
#anomaliesView table.events-table { min-width: 1280px; }

#fuitesView .leaks-table .col-meter       { width: 24%; }
#fuitesView .leaks-table .col-probability { width: 6%; }
#fuitesView .leaks-table .col-flow        { width: 9%; }
#fuitesView .leaks-table .col-profile     { width: 10%; }
#fuitesView .leaks-table .col-start       { width: 6%; }
#fuitesView .leaks-table .col-end         { width: 7%; }
#fuitesView .leaks-table .col-status      { width: 13%; }
#fuitesView .leaks-table .col-comment     { width: 25%; }

#anomaliesView .anomalies-table .col-meter         { width: 25%; }
#anomaliesView .anomalies-table .col-meter-type    { width: 11%; }
#anomaliesView .anomalies-table .col-anomaly-state { width: 13%; }
#anomaliesView .anomalies-table .col-start         { width: 6%; }
#anomaliesView .anomalies-table .col-end           { width: 7%; }
#anomaliesView .anomalies-table .col-status        { width: 14%; }
#anomaliesView .anomalies-table .col-comment       { width: 24%; }

#fuitesView .meter-name,
#anomaliesView .meter-name,
#inventaireView .meter-name {
  font-size: 12.5px;
  line-height: 1.22;
}

#fuitesView .meter-text,
#anomaliesView .meter-text {
  -webkit-line-clamp: 2;
  overflow-wrap: break-word;
  word-break: normal;
}

#fuitesView td:nth-child(7) select,
#anomaliesView td:nth-child(6) select {
  font-size: 12px;
}


/* KORDELIA 1.2.8 — Accueil tableau de bord, import dans les paramètres */
.home-dashboard{display:grid;gap:28px}.home-summary-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}.home-summary-card{position:relative;overflow:hidden;display:grid;gap:10px;min-height:112px;padding:22px 24px;border:1px solid var(--line);border-radius:14px;background:linear-gradient(145deg,#fff,#f2f8f7);box-shadow:0 8px 24px rgba(12,65,68,.06)}.home-summary-card::after{content:"";position:absolute;right:-28px;bottom:-38px;width:110px;height:110px;border-radius:50%;background:rgba(18,113,117,.08)}.home-summary-card-wide{grid-column:1/-1}.home-summary-label{position:relative;z-index:1;color:var(--muted);font-size:13px;font-weight:900;text-transform:uppercase;letter-spacing:.04em}.home-summary-card strong{position:relative;z-index:1;color:var(--teal);font-size:20px;line-height:1.35}.home-priorities-panel{border-radius:14px;box-shadow:0 8px 24px rgba(12,65,68,.06)}
.settings-import-card{max-width:850px}.settings-intro{margin:-8px 0 22px;color:var(--muted);line-height:1.55}.import-file-zone{padding:22px;border:2px dashed #b9d2cd;border-radius:12px;background:#f7fbfa}.import-file-zone input{width:100%}.import-details-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 24px;margin-top:20px}.import-details-grid p{display:grid;gap:5px;margin:0;padding:14px 0;border-bottom:1px solid var(--line)}.import-details-grid strong{color:var(--teal)}.import-details-grid span{color:var(--muted);font-weight:700}.settings-card-title-row{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:22px}.settings-card-title-row h2{margin:0}.danger-button.compact{width:auto;padding:10px 14px;white-space:nowrap}
@media(max-width:760px){.home-summary-grid,.import-details-grid{grid-template-columns:1fr}.home-summary-card-wide{grid-column:auto}.home-summary-card{min-height:94px;padding:18px}.home-summary-card strong{font-size:17px}.settings-card-title-row{align-items:stretch;flex-direction:column}.danger-button.compact{width:100%}}

/* KORDELIA V1.3.0 - Automatisation imports et rapports */
.automation-card,.daily-report-card{max-width:850px}.automation-toggle{display:flex;align-items:center;gap:9px;padding:13px 15px;border:1px solid #cbd8d6;border-radius:10px;background:#f7fbfa;color:#173033}.automation-toggle input{width:18px;height:18px;accent-color:#127175}.schedule-layout{display:grid;grid-template-columns:minmax(0,1fr) 240px;gap:22px;align-items:end;margin-top:20px}.import-schedule-layout{align-items:center}.field-caption{display:block;margin-bottom:8px;font-weight:700;color:#173033}.weekday-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}.weekday-grid label{display:flex;align-items:center;gap:7px;padding:10px;border:1px solid #dbe5e3;border-radius:8px;background:#fff}.weekday-grid input{accent-color:#127175}.last-treatment{display:grid;gap:7px;margin-top:18px;padding:15px;border:1px solid #d9e5e2;border-radius:10px;background:#f8fbfa;color:#324b48}.last-treatment>strong{color:#0c4144;font-size:16px}.last-treatment-message{font-size:13px;color:#667a77}.status-success{color:#247347}.status-failure{color:#a32727}.settings-import-card{margin-top:18px}
@media(max-width:760px){.schedule-layout{grid-template-columns:1fr}.weekday-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.automation-toggle{align-items:flex-start}}


/* Dashboard — détail du parc analysé et des compteurs virtuels */
.total-box-breakdown {
  row-gap: 8px;
}
.total-box-breakdown > span,
.total-box-breakdown > strong {
  min-width: 0;
}
.total-box-breakdown > strong {
  text-align: right;
}
.total-box-grand-label,
.total-box-grand-value {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--teal);
  font-size: 24px;
}


/* KORDELIA BETA 2.0.0-beta.1 — identification permanente */
body.beta-environment {
  padding-top: 42px;
}
.beta-environment-banner {
  position: fixed;
  z-index: 20000;
  top: 0;
  left: 0;
  right: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 18px;
  box-sizing: border-box;
  background: #8f1d1d;
  color: #fff;
  font-size: 13px;
  letter-spacing: .025em;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.beta-environment-banner strong {
  letter-spacing: .09em;
}
.beta-header-badge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid #d79b9b;
  border-radius: 999px;
  background: #fff0f0;
  color: #8f1d1d;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .055em;
  white-space: nowrap;
}
@media(max-width:760px) {
  body.beta-environment { padding-top: 58px; }
  .beta-environment-banner {
    min-height: 58px;
    flex-direction: column;
    gap: 1px;
    font-size: 11px;
    line-height: 1.25;
  }
  .beta-header-badge { display:none; }
}
