/* ═══════════════════════════════════════════════════════════════════════════
   AlerteCoupure — Thème « Veilleuse »
   Sombre par défaut (bleu nuit + ambre), thème clair via [data-theme="light"].
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg:       #161A24;
  --side:     #121620;
  --panel:    #1E2330;
  --panel2:   #242A3A;
  --input:    #1A1F2B;
  --text:     #EAEBF2;
  --text2:    #98A0B8;
  --line:     #2C3242;
  --amber:    #F0B345;
  --amber-bg: rgba(240,179,69,.12);
  --amber-ln: rgba(240,179,69,.35);
  --ok:       #5BC98E;
  --ok-bg:    rgba(91,201,142,.12);
  --ok-ln:    rgba(91,201,142,.3);
  --err:      #E4654E;
  --err-bg:   rgba(228,101,78,.12);
  --err-ln:   rgba(228,101,78,.32);
  --btn-bg:   #F0B345;
  --btn-tx:   #241B07;
  --shadow:   rgba(0,0,0,.35);
  --beacon-ok:  radial-gradient(circle at 35% 30%, #9FF2C6, #5BC98E 65%, #2E7D57);
  --beacon-err: radial-gradient(circle at 35% 30%, #FFB3A3, #E4654E 65%, #93321F);
  --beacon-off: radial-gradient(circle at 35% 30%, #B9BECF, #7C8398 65%, #4A5062);
  --lamp: radial-gradient(circle at 35% 30%, #FFD98A, #F0B345 60%, #B87F1E);
}

:root[data-theme="light"] {
  --bg:       #F2F1EC;
  --side:     #FAF9F4;
  --panel:    #FFFFFF;
  --panel2:   #EDEBE3;
  --input:    #F6F5F0;
  --text:     #242835;
  --text2:    #6B7284;
  --line:     #E0DED4;
  --amber:    #A97710;
  --amber-bg: rgba(178,124,16,.10);
  --amber-ln: rgba(178,124,16,.35);
  --ok:       #1F8A5C;
  --ok-bg:    rgba(31,138,92,.10);
  --ok-ln:    rgba(31,138,92,.3);
  --err:      #C64B36;
  --err-bg:   rgba(198,75,54,.09);
  --err-ln:   rgba(198,75,54,.3);
  --btn-bg:   #B5820F;
  --btn-tx:   #FFFFFF;
  --shadow:   rgba(30,30,20,.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

a { color: var(--amber); }

/* ═══ Coquille : barre latérale + contenu ═══════════════════════════════════ */

.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }

.side {
  background: var(--side);
  border-right: 1px solid var(--line);
  padding: 1.5rem 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.logo {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 700; font-size: .98rem;
  padding: 0 .8rem 1.3rem;
  color: var(--text); text-decoration: none;
}
.lamp {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--lamp);
  box-shadow: 0 0 16px rgba(240,179,69,.45);
  flex-shrink: 0;
}
.nav-it {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .8rem; border-radius: 10px;
  color: var(--text2); font-size: .88rem; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-it:hover { color: var(--text); background: var(--panel); }
.nav-it.on {
  background: var(--panel2); color: var(--text); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--amber);
}
.nav-it .ic { width: 18px; text-align: center; opacity: .9; }
.nav-it.nav-sub { margin-left: 1.5rem; font-size: .82rem; padding: .48rem .8rem; }

.side-foot {
  margin-top: auto;
  padding-top: .9rem;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: .5rem;
  font-size: .76rem; color: var(--text2);
}
.side-user { padding: 0 .4rem; }
.side-user b { color: var(--text); font-weight: 600; }
.theme-btn, .logout-btn {
  display: flex; align-items: center; gap: .55rem;
  background: transparent; border: 1px solid var(--line); border-radius: 9px;
  color: var(--text2); font-size: .78rem; font-family: inherit;
  padding: .48rem .7rem; cursor: pointer; text-decoration: none;
  transition: border-color .15s, color .15s;
}
.theme-btn:hover { border-color: var(--amber); color: var(--amber); }
.logout-btn:hover { border-color: var(--err); color: var(--err); }

.main { padding: 2rem 2.4rem 3rem; max-width: 1060px; width: 100%; }

/* ═══ En-tête de page ═══════════════════════════════════════════════════════ */

.page-head { margin-bottom: 1.6rem; }
.page-head .date { font-size: .8rem; color: var(--text2); }
.page-head h1 { font-size: 1.5rem; font-weight: 600; margin-top: .15rem; }
.page-head p { color: var(--text2); font-size: .9rem; margin-top: .2rem; }

/* ═══ Balise d'état (héro) ══════════════════════════════════════════════════ */

.watch {
  display: flex; align-items: center; gap: 1.4rem;
  background: linear-gradient(135deg, var(--panel), var(--panel2));
  border: 1px solid var(--line); border-radius: 18px;
  padding: 1.5rem 1.9rem; margin-bottom: 1.2rem;
  flex-wrap: wrap;
}
.beacon {
  width: 62px; height: 62px; border-radius: 50%; flex-shrink: 0;
  background: var(--beacon-ok);
  box-shadow: 0 0 0 8px var(--ok-bg), 0 0 28px var(--ok-ln);
  animation: breathe 3.5s ease-in-out infinite;
}
.beacon.err {
  background: var(--beacon-err);
  box-shadow: 0 0 0 8px var(--err-bg), 0 0 28px var(--err-ln);
  animation-duration: 1.4s;
}
.beacon.off { background: var(--beacon-off); box-shadow: none; animation: none; }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@media (prefers-reduced-motion: reduce) { .beacon { animation: none; } }
.watch h2 { font-size: 1.3rem; font-weight: 600; margin-bottom: .2rem; }
.watch p { color: var(--text2); font-size: .87rem; }
.watch .since { margin-left: auto; text-align: right; font-size: .78rem; color: var(--text2); }
.watch .since b { display: block; color: var(--text); font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* ═══ Tuiles ════════════════════════════════════════════════════════════════ */

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.1rem; margin-bottom: 1.2rem; }
.grid.g4 { grid-template-columns: repeat(4, 1fr); }
.tile {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 1.15rem 1.3rem;
}
.tile.click { cursor: pointer; transition: border-color .15s; text-decoration: none; color: inherit; display: block; }
.tile.click:hover { border-color: var(--amber-ln); }
.tile .l {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--text2); margin-bottom: .55rem;
}
.tile .v { font-size: 1.65rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .v small { font-size: .85rem; color: var(--text2); font-weight: 500; }
.tile .v.ok { color: var(--ok); } .tile .v.err { color: var(--err); } .tile .v.amber { color: var(--amber); }
.tile .s { font-size: .78rem; color: var(--text2); margin-top: .35rem; }

/* ═══ Panneaux / cartes ═════════════════════════════════════════════════════ */

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 1.3rem 1.5rem; margin-bottom: 1.2rem;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap;
}
.panel-head .l { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--text2); }
.panel-head h2 { font-size: 1rem; font-weight: 600; }
.panel-head .sub { font-size: .8rem; color: var(--text2); margin-top: .15rem; }

/* ═══ Pastilles d'état ══════════════════════════════════════════════════════ */

.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .28rem .75rem; border-radius: 99px;
  font-size: .78rem; font-weight: 600;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok   { background: var(--ok-bg);   color: var(--ok);   border: 1px solid var(--ok-ln); }
.pill.err  { background: var(--err-bg);  color: var(--err);  border: 1px solid var(--err-ln); }
.pill.off  { background: var(--panel2);  color: var(--text2); border: 1px solid var(--line); }
.pill.maj  { background: var(--amber-bg); color: var(--amber); border: 1px dashed var(--amber-ln); }
.pill.ok .dot { animation: blink 2.4s infinite; }
.pill.err .dot { animation: blink 1.1s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.src {
  font-size: .68rem; color: var(--text2);
  border: 1px solid var(--line); border-radius: 5px;
  padding: .12rem .5rem; white-space: nowrap;
}
.src.cap { color: var(--amber); border-color: var(--amber-ln); }

/* ═══ Boutons ═══════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem 1.2rem; border-radius: 10px;
  font-family: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  text-decoration: none; transition: opacity .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--btn-bg); color: var(--btn-tx); }
.btn-primary:hover { opacity: .88; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text2); }
.btn-ghost:hover { border-color: var(--amber); color: var(--amber); }
.btn-danger { background: transparent; border-color: var(--err-ln); color: var(--err); }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { padding: .38rem .85rem; font-size: .8rem; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; padding: .8rem; font-size: .95rem; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--amber); outline-offset: 2px;
}

/* ═══ Formulaires ═══════════════════════════════════════════════════════════ */

.form-row { margin-bottom: 1.1rem; }
.form-row label, .flabel {
  display: block; font-size: .74rem; color: var(--text2);
  text-transform: uppercase; letter-spacing: .09em; margin-bottom: .45rem;
}
input[type="text"], input[type="email"], input[type="password"], select {
  width: 100%; background: var(--input); border: 1px solid var(--line);
  border-radius: 9px; color: var(--text); font-family: inherit;
  font-size: .92rem; padding: .62rem .9rem; outline: none;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--amber); }
input::placeholder { color: var(--text2); opacity: .55; }
.hint { font-size: .75rem; color: var(--text2); margin-top: .35rem; }

/* Interrupteur */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 24px; transition: .22s;
}
.slider::before {
  content: ''; position: absolute; width: 16px; height: 16px;
  left: 3px; top: 3px; background: var(--text2); border-radius: 50%;
  transition: .22s;
}
.switch input:checked + .slider { background: var(--amber); border-color: var(--amber); }
.switch input:checked + .slider::before { transform: translateX(18px); background: #FFF; }

/* ═══ Alertes ═══════════════════════════════════════════════════════════════ */

.alert {
  padding: .85rem 1.1rem; border-radius: 10px; font-size: .88rem;
  margin-bottom: 1.2rem; display: flex; align-items: flex-start;
  gap: .6rem; line-height: 1.5;
}
.alert-ok  { background: var(--ok-bg);  border: 1px solid var(--ok-ln);  color: var(--ok); }
.alert-err { background: var(--err-bg); border: 1px solid var(--err-ln); color: var(--err); }

.info-box {
  background: var(--amber-bg); border: 1px solid var(--amber-ln);
  border-radius: 10px; padding: .9rem 1.1rem;
  font-size: .8rem; color: var(--text2); line-height: 1.65; margin-bottom: 1.1rem;
}
.info-box strong { color: var(--text); }

/* ═══ Tableaux ══════════════════════════════════════════════════════════════ */

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead th {
  color: var(--text2); font-weight: 600; text-align: left;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  padding: .55rem .75rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel2); }
.empty-row td { text-align: center; color: var(--text2); padding: 2.6rem; }

/* ═══ Chronologie ═══════════════════════════════════════════════════════════ */

.tl { position: relative; padding-left: 1.4rem; }
.tl::before {
  content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line); border-radius: 2px;
}
.ev { position: relative; padding-bottom: 1.15rem; }
.ev:last-child { padding-bottom: 0; }
.ev::before {
  content: ''; position: absolute; left: -1.4rem; top: 5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--err); border: 2.5px solid var(--bg);
}
.ev.short::before { background: var(--amber); }
.ev .t { font-size: .9rem; font-weight: 600; }
.ev .d { font-size: .78rem; color: var(--text2); margin-top: .1rem; }

/* ═══ Modales ═══════════════════════════════════════════════════════════════ */

.modal-bg {
  display: none; position: fixed; inset: 0;
  background: rgba(8,10,16,.72); z-index: 200;
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 1.9rem; width: 100%; max-width: 380px;
  box-shadow: 0 22px 60px var(--shadow);
}
.modal h2 { font-size: 1.1rem; margin-bottom: 1.1rem; font-weight: 600; }
.modal-btns { display: flex; gap: .6rem; margin-top: 1.1rem; }
.modal-btns .btn { flex: 1; justify-content: center; }

/* ═══ Pages d'authentification (sans coquille) ══════════════════════════════ */

.auth-body {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100vh; padding: 1.2rem;
}
.auth-logo {
  display: flex; flex-direction: column; align-items: center;
  gap: .7rem; margin-bottom: 1.8rem; text-align: center;
}
.auth-logo .lamp { width: 46px; height: 46px; }
.auth-logo .name { font-weight: 700; font-size: 1.25rem; }
.auth-logo .tag { font-size: .8rem; color: var(--text2); margin-top: -0.4rem; }
.auth-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 2.2rem 2rem;
  width: 100%; max-width: 420px;
  box-shadow: 0 22px 60px var(--shadow);
}
.auth-foot { margin-top: 1.4rem; font-size: .8rem; color: var(--text2); text-align: center; }
.auth-theme { position: fixed; top: 1rem; right: 1rem; }

.tabs2 {
  display: flex; background: var(--input); border: 1px solid var(--line);
  border-radius: 11px; padding: .25rem; margin-bottom: 1.6rem;
}
.tabs2 .tab-btn {
  flex: 1; padding: .55rem; background: transparent; border: none;
  border-radius: 8px; color: var(--text2); font-size: .88rem;
  font-family: inherit; cursor: pointer; transition: all .18s;
}
.tabs2 .tab-btn.active { background: var(--panel2); color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--amber); }

/* ═══ Responsive ════════════════════════════════════════════════════════════ */

@media (max-width: 840px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: static; height: auto;
    flex-direction: row; align-items: center; flex-wrap: wrap;
    padding: .7rem .9rem; gap: .3rem;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .logo { padding: 0 .6rem 0 0; }
  .nav-it { padding: .45rem .7rem; font-size: .82rem; }
  .nav-it .ic { display: none; }
  .nav-it.nav-sub { margin-left: 0; }
  .side-foot {
    margin-top: 0; margin-left: auto; padding-top: 0; border-top: none;
    flex-direction: row; align-items: center;
  }
  .side-user { display: none; }
  .main { padding: 1.4rem 1rem 2.5rem; }
  .grid, .grid.g4 { grid-template-columns: 1fr 1fr; }
  .watch { padding: 1.2rem 1.3rem; }
  .watch .since { margin-left: 0; text-align: left; }
}
@media (max-width: 480px) {
  .grid, .grid.g4 { grid-template-columns: 1fr; }
}
