/* Supervision Nexo Water : interface sobre, ordinateur et tablette.
   Identité visuelle reprise du site tecso.ch (projet Astro, src/styles/global.css) :
   un seul bleu de structure, police Archivo, angles droits. Le rouge de marque
   #ED1C24 n'existe que dans le logo (contraste insuffisant pour du texte). */

/* Archivo, police variable 400 à 600, auto-hébergée (SIL Open Font License 1.1). */
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/archivo-latin.cd56e2ec63d7.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/archivo-latin-ext.c5e41aa17045.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #f1f4fa;          /* teinte du site (aplat de section) */
  --surface: #fbfbf9;     /* « feuille » du site */
  --text: #16181c;        /* encre : 17:1 */
  --muted: #55595f;       /* encre secondaire : 6,8:1 (AA) */
  --border: #d8d8d2;      /* filet */
  --accent: #23408f;      /* bleu de structure : 9,2:1 sur le fond (AAA) */
  --accent-hover: #1b3274;
  --on-accent: #ffffff;   /* blanc sur bleu : 9,5:1 (AAA) */
  --accent-soft: #dde5f3; /* teinte 2 : en-têtes de tableau, élément actif */
  --ok: #1a7f45;
  --ok-soft: #e3f3e9;
  --danger: #b42318;
  --danger-soft: #fbe8e6;
  --warn: #9a5b00;
  --warn-soft: #fff1d9;
  --radius: 0;            /* le site n'a aucun angle arrondi */
  font-family: "Archivo", ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  font-feature-settings: "tnum" 1; /* chiffres tabulaires */
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
b, strong, th { font-weight: 600; } /* Archivo va jusqu'à 600 : pas de gras simulé */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topbar :focus-visible { outline-color: var(--on-accent); }
h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85em; word-break: break-all; }

/* Barre du haut : aplat bleu, texte blanc, comme l'en-tête du site */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.75rem;
  padding: .7rem 1.25rem; background: var(--accent); color: var(--on-accent);
}
.brand { display: flex; align-items: center; }
.brand img { height: 36px; width: auto; display: block; }
.mainnav { display: flex; flex-wrap: wrap; gap: .1rem 1.1rem; flex: 1; }
.mainnav a {
  padding: .35rem 0 .25rem; color: rgba(255, 255, 255, .82);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.mainnav a:hover { color: var(--on-accent); border-bottom-color: rgba(255, 255, 255, .5); text-decoration: none; }
.mainnav a[aria-current="page"] { color: var(--on-accent); border-bottom-color: var(--on-accent); font-weight: 600; }
.usermenu { display: flex; align-items: center; gap: .9rem; }
.usermenu form { margin: 0; }
.topbar .who { color: var(--on-accent); }
.topbar button.link { color: rgba(255, 255, 255, .82); }
.topbar button.link:hover { color: var(--on-accent); text-decoration: underline; }
.lang select {
  padding: .15rem .3rem; background: transparent; color: var(--on-accent);
  border: 1px solid rgba(255, 255, 255, .45);
}
.lang select option { color: var(--text); }

main.page { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 1.25rem; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }

.topbar .tech-link { font-size: .8rem; color: rgba(255, 255, 255, .7); }
.topbar .tech-link:hover { color: var(--on-accent); }

/* Sous-menu « Gestion » */
.subnav { display: flex; flex-wrap: wrap; gap: .25rem; margin: -.25rem 0 1.25rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.subnav a { padding: .3rem .65rem; border-radius: var(--radius); color: var(--muted); font-size: .9rem; }
.subnav a:hover { background: var(--surface); text-decoration: none; }
.subnav a[aria-current="page"] { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; color: var(--text); }
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile b { display: block; font-size: 1.8rem; margin-top: .25rem; }
.tile-ok b { color: var(--ok); }
.tile-danger { border-color: var(--danger-soft); }
.tile-danger b { color: var(--danger); }
.tile-warn b { color: var(--warn); }
div.tile:hover { border-color: var(--border); }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: .35rem 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child { border-bottom: none; }
@media (max-width: 760px) { .grid > [style*="span 2"] { grid-column: auto !important; } }

/* En-tête de page */
.pagehead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; }
.pagehead .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.stats { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .9rem; }
.stat b { display: block; font-size: 1.3rem; }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.charts { grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); }
.card hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.actions-block { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.actions-block p { margin: 0; }
.grid > .card { margin-bottom: 0; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* Tableaux */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; white-space: nowrap; }
th { font-size: .8rem; color: var(--text); font-weight: 600; background: var(--accent-soft); position: sticky; top: 0; }
th a { color: var(--accent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* Badges */
.badge { display: inline-block; padding: .1rem .45rem; border-radius: var(--radius); font-size: .8rem; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.neutral { background: var(--bg); color: var(--muted); }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .35rem; vertical-align: baseline; }
.dot.ok { background: var(--ok); }
.dot.danger { background: var(--danger); }

/* Formulaires */
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); padding: .4rem .55rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type="checkbox"] { width: auto; align-self: flex-start; margin: .5rem 0; }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
button, .button {
  font: inherit; padding: .45rem .9rem; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; display: inline-block;
}
button:hover, .button:hover { background: var(--bg); border-color: var(--accent); text-decoration: none; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
button.danger:hover { background: #8f1c13; border-color: #8f1c13; }
.button.danger-outline { color: var(--danger); border-color: var(--danger-soft); }
.button.danger-outline:hover { background: var(--danger-soft); }
button.link { border: none; background: none; color: var(--accent); padding: 0; }
button.link:disabled { color: var(--text); font-weight: 600; cursor: default; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.filters label { min-width: 9rem; }
.fieldgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem 1rem; }
.fieldgrid .wide { grid-column: 1 / -1; }
.errorlist { color: var(--danger); margin: .2rem 0 0; padding: 0; list-style: none; font-size: .8rem; }
.helptext { font-size: .75rem; color: var(--muted); }
.formbar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: .75rem 1.25rem; margin: 1rem -1.25rem -1rem; display: flex; justify-content: flex-end; gap: .75rem; align-items: center; }
.inline-form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: .5rem; background: var(--accent-soft); border-left: 3px solid var(--accent); }
.messages .msg-success { border-left-color: var(--ok); }
.messages .msg-error { border-left-color: var(--danger); }
.messages .msg-warning { border-left-color: var(--warn); }
.messages .msg-success { background: var(--ok-soft); color: var(--ok); }
.messages .msg-error { background: var(--danger-soft); color: var(--danger); }
.messages .msg-warning { background: var(--warn-soft); color: var(--warn); }
.error { color: var(--danger); }

/* Pagination */
.pagination { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; padding: .6rem; }

/* Carte */
#map { height: calc(100vh - 230px); min-height: 420px; border-radius: var(--radius); border: 1px solid var(--border); }
.chart-box { position: relative; height: 320px; }
.chart-box.tall { height: 420px; }

/* Historique */
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.history li:last-child { border-bottom: none; }
.history .changes { margin: .3rem 0 0; font-size: .85rem; }
.history .changes del { color: var(--danger); }
.history .changes ins { color: var(--ok); text-decoration: none; }

/* Connexion */
main.login-page { flex: 1; display: grid; place-items: center; padding: 1rem; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--accent);
  border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 380px;
}
.login-card .login-logo { display: block; width: 210px; max-width: 100%; height: auto; margin: 0 auto .5rem; }
.login-card .muted { text-align: center; margin: 0; }
.login-card form { display: flex; flex-direction: column; gap: .9rem; margin-top: 1.25rem; }
.lang-inline { flex-direction: row !important; justify-content: center; gap: .4rem !important; color: var(--muted); }

details summary { cursor: pointer; color: var(--accent); }

@media (max-width: 700px) {
  main.page { padding: .75rem; }
  .topbar { padding: .5rem .75rem; }
  .brand img { height: 28px; }
  .formbar { margin: 1rem -.75rem -1rem; }
}
