@font-face {
  font-family: "Public Sans";
  src: url("../fonts/public-sans-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("../fonts/public-sans-400i.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("../fonts/public-sans-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("../fonts/public-sans-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #161d2b;
  --ink-2: #4b5568;
  --ink-3: #6b7380;
  --line: #d5dbe6;
  --line-strong: #b8c0ce;
  --paper: #eef0f4;
  --surface: #ffffff;
  --accent: #1f4e79;
  --accent-2: #163a5c;
  --accent-soft: #e7eef6;
  --danger: #b42318;
  --danger-soft: #f8e4e2;
  --ok: #17663a;
  --ok-soft: #e4f2ea;
  --warn: #8a5a00;
  --warn-soft: #f6eedd;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(22, 29, 43, 0.05), 0 10px 28px rgba(22, 29, 43, 0.08);
  --shadow-sm: 0 1px 2px rgba(22, 29, 43, 0.06);
  --topbar: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --drawer: 420px;
  --font: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --z-map: 1;
  --z-chrome: 20;
  --z-drawer: 30;
  --z-pop: 40;
  --z-modal: 50;
  --z-toast: 60;
  --kb: 0px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

html {
  font-size: 15px;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}
button, a.btn {
  touch-action: manipulation;
}

body.is-map {
  overflow: hidden;
  height: 100dvh;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.sci { font-style: italic; }

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--topbar) + var(--safe-top));
  padding: var(--safe-top) 14px 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: var(--z-chrome);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  flex: 0 0 auto;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 7px;
}
.brand-mark .ph { font-size: 16px; }
.brand-name {
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 15px;
}
.brand-sub {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-3);
  letter-spacing: 0;
  margin-top: -1px;
}

.topbar-search {
  flex: 1 1 auto;
  max-width: 420px;
  margin: 0 auto;
  position: relative;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 160ms var(--ease), transform 100ms var(--ease), opacity 160ms;
}
.btn:hover { background: var(--accent-2); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn .ph { font-size: 16px; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--paper); color: var(--ink); }

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent);
}
.btn-soft:hover { background: #d7e4f1; color: var(--accent-2); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #8f1c14; }

.btn-icon {
  width: 36px;
  padding: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
[hidden] { display: none !important; }
.field label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
}
.field .hint { font-size: 12px; color: var(--ink-3); }
.field .error {
  font-size: 12.5px;
  color: var(--danger);
}
.field .error:empty { display: none; }
.input,
.select,
.textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 150ms, box-shadow 150ms;
}
.textarea { min-height: 88px; resize: vertical; }
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.16);
}
.input.is-invalid,
.select.is-invalid,
.textarea.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px var(--danger-soft);
}
.input-wrap {
  position: relative;
}
.input-wrap .ph {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  font-size: 16px;
  pointer-events: none;
}
.input-wrap .input { padding-left: 34px; }
.pwd-field { position: relative; }
.pwd-field .input { padding-right: 40px; }
.pwd-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.pwd-toggle:hover,
.pwd-toggle[aria-pressed="true"] { color: var(--ink); background: var(--paper); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--paper);
  color: var(--ink-2);
}
.badge-sain { background: var(--ok-soft); color: var(--ok); }
.badge-vigilance { background: var(--warn-soft); color: var(--warn); }
.badge-probleme { background: var(--danger-soft); color: var(--danger); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: var(--danger-soft); color: var(--danger); }
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.menu {
  position: relative;
}
.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  z-index: var(--z-pop);
}
.menu.open .menu-panel { display: block; }
.menu-panel a,
.menu-panel button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  font-weight: 400;
}
.menu-panel a:hover,
.menu-panel button:hover { background: var(--paper); text-decoration: none; }

.toast-wrap {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--ink);
  color: #f4f5f7;
  padding: 10px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  min-width: 240px;
  max-width: 420px;
}
.toast.err { background: var(--danger); }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow: auto;
  display: none;
  z-index: var(--z-pop);
}
.search-results.open { display: block; }
.search-item {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.search-item.active { background: var(--paper); }
@media (hover: hover) {
  .search-item:hover { background: var(--paper); }
}
.search-item .meta { color: var(--ink-3); font-size: 12px; }
.search-empty { padding: 12px; color: var(--ink-3); font-size: 13px; }

.sheet-scrim {
  display: none;
  position: fixed;
  top: calc(var(--topbar) + var(--safe-top));
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(22, 29, 43, 0.32);
  z-index: calc(var(--z-chrome) - 1);
}
.sheet-scrim.show { display: block; }

dialog.modal {
  border: 0;
  padding: 0;
  border-radius: 12px;
  box-shadow: var(--shadow);
  width: min(480px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--ink);
}
dialog.modal::backdrop { background: rgba(22, 29, 43, 0.42); }
.modal-body { padding: 22px 22px 16px; }
.modal-body h2 { margin: 0 0 8px; font-size: 18px; letter-spacing: -0.02em; }
.modal-body p { margin: 0; color: var(--ink-2); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 22px 18px;
}

.page {
  min-height: 100dvh;
  padding-top: calc(var(--topbar) + var(--safe-top));
}

.auth-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    linear-gradient(180deg, #e8edf3 0%, var(--paper) 42%);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 28px 28px 22px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}
.auth-brand:hover { text-decoration: none; }
.auth-brand .brand-name { display: block; }
.auth-brand .brand-sub { display: block; margin-top: 1px; }
.auth-card h1 {
  margin: 22px 0 6px;
  font-size: 22px;
  letter-spacing: -0.03em;
}
.auth-card .lead {
  margin: 0 0 18px;
  color: var(--ink-2);
}
.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13.5px;
  line-height: 1.4;
}
.auth-alert .ph { flex: 0 0 auto; margin-top: 1px; }
.auth-card .stack { display: flex; flex-direction: column; gap: 14px; }
.auth-card .btn { width: 100%; min-height: 44px; margin-top: 2px; }
.auth-help {
  margin: 16px 0 0;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.45;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  color: var(--ink-2);
  font-size: 13px;
}

.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th,
table.data td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
table.data tbody tr:hover td { background: #f7f8fb; }
table.data .num { font-variant-numeric: tabular-nums; }

.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--ink-2);
}
.empty .ph { font-size: 28px; color: var(--ink-3); display: block; margin-bottom: 8px; }

.card-list {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}
.point-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  min-height: 64px;
}
.point-card:hover { text-decoration: none; background: #f7f8fb; }
.point-card .grow { flex: 1; min-width: 0; }
.point-card strong { display: block; }
.point-card .meta { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.point-card .ph { color: var(--ink-3); }

.mk {
  display: block;
  width: var(--mk-size, 14px);
  height: var(--mk-size, 14px);
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--mk-border, #fff);
  background: var(--mk-fill, var(--accent));
  box-shadow: 0 0 0 1px rgba(22, 29, 43, 0.18), 0 2px 6px rgba(22, 29, 43, 0.22);
}
.mk-etat-vigilance {
  box-shadow: 0 0 0 3px var(--mk-vigilance, var(--warn)), 0 2px 6px rgba(22, 29, 43, 0.22);
}
.mk-etat-probleme {
  box-shadow: 0 0 0 3px var(--mk-probleme, var(--danger)), 0 2px 6px rgba(22, 29, 43, 0.22);
}
html[data-mk-shape="square"] .mk,
.mk-stage[data-mk-shape="square"] .mk { border-radius: 3px; }
html[data-mk-shape="diamond"] .mk,
.mk-stage[data-mk-shape="diamond"] .mk { border-radius: 2px; rotate: 45deg; }
html[data-mk-shape="pin"] .mk,
.mk-stage[data-mk-shape="pin"] .mk { border-radius: 50% 50% 50% 0; rotate: -45deg; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

@media (max-width: 900px), (max-height: 540px) and (pointer: coarse) {
  html { font-size: 16px; }
  :root { --topbar: 64px; }

  .brand { gap: 0; }
  .brand > span:not(.brand-mark) { display: none; }
  .brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 12px;
  }
  .brand-mark .ph { font-size: 22px !important; }

  .topbar {
    gap: 8px;
    padding-left: max(10px, env(safe-area-inset-left, 10px));
    padding-right: max(10px, env(safe-area-inset-right, 10px));
  }
  .topbar-search { max-width: none; margin: 0; }
  .topbar-search .input {
    min-height: 48px;
    padding-left: 40px;
    border-radius: 12px;
  }
  .topbar-search .input-wrap .ph {
    left: 12px;
    font-size: 20px;
  }
  .topbar-actions { gap: 8px; }
  .btn-toolbar .btn-label,
  .btn-toolbar .user-name { display: none; }
  .btn-toolbar {
    width: 48px;
    min-height: 48px;
    padding: 0;
    border-radius: 12px;
  }
  .btn-toolbar .ph { font-size: 22px !important; }

  .btn {
    min-height: 48px;
    padding: 0 16px;
    font-size: 16px;
    border-radius: 12px;
    gap: 8px;
  }
  .btn .ph { font-size: 20px !important; }
  .btn-icon { width: 48px; min-height: 48px; }

  .input, .select, .textarea {
    font-size: 16px;
    min-height: 48px;
    border-radius: 10px;
    padding: 10px 14px;
  }
  .pwd-toggle { width: 44px; height: 44px; }
  .pwd-field .input { padding-right: 52px; }

  .menu-panel {
    position: fixed;
    top: calc(var(--topbar) + var(--safe-top) + 8px);
    right: max(10px, env(safe-area-inset-right, 10px));
    left: auto;
    min-width: 240px;
    padding: 8px;
  }
  .menu-panel a,
  .menu-panel button {
    min-height: 48px;
    padding: 12px 14px;
    font-size: 16px;
    border-radius: 10px;
  }
  .menu-panel .ph { font-size: 20px !important; }

  .search-results {
    position: fixed;
    top: calc(var(--topbar) + var(--safe-top));
    left: 0;
    right: 0;
    max-height: min(50dvh, 360px);
    border-radius: 0 0 12px 12px;
    z-index: var(--z-pop);
  }
  .search-item { min-height: 52px; padding: 12px 16px; font-size: 16px; }

  body.is-searching .brand,
  body.is-searching .topbar-actions { display: none; }

  dialog.modal {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-radius: 16px 16px 0 0;
  }
  .modal-actions {
    padding-bottom: calc(18px + var(--safe-bottom));
    gap: 10px;
  }
  .modal-actions .btn { flex: 1; }

  .toast-wrap { bottom: calc(20px + var(--safe-bottom) + var(--kb)); }
  .toast { min-width: 0; width: min(420px, calc(100vw - 24px)); font-size: 15px; padding: 12px 16px; }

  .auth-page {
    padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
    align-items: start;
  }
  .auth-card { padding: 22px 18px 20px; }
  .auth-card .btn { min-height: 52px; font-size: 16px; }

  .card-list { display: flex; }
  table.data.desk-only,
  .desk-only { display: none; }

  .point-card { min-height: 72px; padding: 14px; }
}

@media (max-width: 380px) {
  .topbar { gap: 6px; }
}
