/* ============================================================
   ADMIN /admin — très fortement inspiré d'iOS (Réglages, thème sombre)
   ============================================================ */
:root {
  --fond: #000; --fond2: #1c1c1e; --fond3: #2c2c2e; --sep: #38383a;
  --texte: #fff; --texte2: #8e8e93; --texte3: #636366;
  --bleu: #0a84ff; --vert: #30d158; --rouge: #ff453a; --orange: #ff9f0a; --violet: #bf5af2; --gris: #8e8e93;
  --r: 12px; --rl: 16px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--fond); color: var(--texte);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--bleu); text-decoration: none; }
.plein { position: fixed; inset: 0; }

/* ---------- Connexion ---------- */
#ecran-login { display: grid; place-items: center; padding: 20px;
  background: radial-gradient(800px 500px at 50% -10%, rgba(10,132,255,.22), transparent 60%), #000; }
.carte-login { width: min(420px, 100%); }
.logo { text-align: center; margin-bottom: 26px; }
.logo-ic { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 18px; font-size: 36px;
  background: linear-gradient(145deg, #0a84ff, #5e5ce6); box-shadow: 0 10px 30px rgba(10,132,255,.35); }
.logo-ic.petit { width: 36px; height: 36px; border-radius: 9px; font-size: 18px; box-shadow: none; }
.logo h1 { margin: 14px 0 2px; font-size: 28px; font-weight: 700; letter-spacing: -.3px; }
.logo p { margin: 0; color: var(--texte2); }
.etape { display: flex; flex-direction: column; gap: 14px; }
.note { margin: 0 4px; color: var(--texte2); text-align: center; line-height: 1.45; }
.erreur { margin: 0 4px; color: var(--rouge); text-align: center; font-size: 15px; }

/* ---------- Groupes « Réglages » ---------- */
.groupe { background: var(--fond2); border-radius: var(--r); overflow: hidden; }
.ligne { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 16px; }
.ligne + .ligne { border-top: 1px solid var(--sep); margin-left: 16px; padding-left: 0; }
.ligne .lib { flex: 0 0 150px; color: var(--texte); }
.ligne input, .ligne select, .ligne textarea { flex: 1; min-width: 0; background: transparent; border: none; outline: none;
  text-align: right; color: var(--texte); padding: 6px 0; }
.ligne input::placeholder { color: var(--texte3); }
.ligne.code input { text-align: center; font-size: 30px; letter-spacing: 10px; font-weight: 700; }
.ligne .val { margin-left: auto; color: var(--texte2); text-align: right; }
/* sélecteur de colonne (Panneau v2) : compact, à droite, bleu iOS */
.ligne select[data-col] { flex: 0 0 auto; max-width: 200px; margin-left: auto; color: var(--bleu); background: var(--fond3);
  border-radius: 8px; padding: 6px 10px; text-align: left; }
.ligne select[data-col] + .switch { margin-left: 12px; }
.ligne .chev { color: var(--texte3); font-size: 22px; line-height: 1; }
.ligne.clic { cursor: pointer; }
.ligne.clic:active { background: var(--fond3); }
.ligne.danger { color: var(--rouge); justify-content: center; }
.titre-groupe { margin: 22px 16px 8px; color: var(--texte2); font-size: 13px; text-transform: uppercase; letter-spacing: .6px; }
.titre-groupe.titre-edit { display: flex; align-items: center; gap: 8px; }
.titre-groupe.titre-edit .col-nom { flex: 0 1 auto; max-width: 260px; background: transparent; border: none; border-bottom: 1px dashed var(--texte3); outline: none; color: var(--texte); font: inherit; text-transform: uppercase; letter-spacing: .6px; padding: 2px 0; }
.titre-groupe.titre-edit .col-nom:focus { border-bottom-color: var(--bleu); color: var(--bleu); }
.titre-groupe.titre-edit .col-def { background: transparent; border: none; color: var(--texte2); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.ligne .btn-oublier { flex: 0 0 auto; background: transparent; border: none; color: var(--texte2); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 6px; }
.ligne .btn-oublier:hover { color: var(--rouge); }
.pied-groupe { margin: 8px 16px 0; color: var(--texte2); font-size: 13px; line-height: 1.4; }

.btn-ios { border: none; border-radius: var(--r); background: var(--bleu); color: #fff; padding: 14px; font-weight: 600; cursor: pointer; }
.btn-ios:active { filter: brightness(.85); }
.btn-ios.sec { background: var(--fond3); }
.btn-ios.danger { background: var(--rouge); }
.btn-ios.vert { background: var(--vert); color: #000; }
.btn-ios:disabled { opacity: .5; }
.btn-lien { background: none; border: none; color: var(--bleu); padding: 10px; cursor: pointer; }
.btn-petit { border: none; border-radius: 9px; background: var(--fond3); color: var(--bleu); padding: 7px 12px; font-size: 15px; cursor: pointer; }
.btn-petit.rouge { color: var(--rouge); }
.btn-petit.vert { color: var(--vert); }

/* interrupteur iOS */
.switch { position: relative; width: 51px; height: 31px; flex: 0 0 51px; margin-left: auto; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 31px; background: var(--fond3); transition: .2s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 2px 5px rgba(0,0,0,.4); }
.switch input:checked + i { background: var(--vert); }
.switch input:checked + i::after { transform: translateX(20px); }

/* segmented control */
.segment { display: inline-flex; background: var(--fond3); border-radius: 9px; padding: 2px; margin-left: auto; }
.segment button { border: none; background: transparent; color: var(--texte); padding: 6px 14px; border-radius: 7px; cursor: pointer; font-size: 15px; }
.segment button.on { background: #636366; font-weight: 600; }

/* pastilles */
.pastille { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--fond3); color: var(--texte2); }
.pastille.vert { background: rgba(48,209,88,.18); color: var(--vert); }
.pastille.rouge { background: rgba(255,69,58,.18); color: var(--rouge); }
.pastille.bleu { background: rgba(10,132,255,.18); color: var(--bleu); }
.pastille.orange { background: rgba(255,159,10,.18); color: var(--orange); }

/* ---------- Application : barre latérale + contenu ---------- */
#ecran-app { display: grid; grid-template-columns: 320px 1fr; }
.barre { background: var(--fond2); border-right: 1px solid var(--sep); display: flex; flex-direction: column; min-height: 0; }
.barre-tete { display: flex; align-items: center; gap: 10px; padding: 18px 16px 10px; }
.barre-tete small { display: block; color: var(--texte2); font-size: 13px; }
.menu { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }
.menu-titre { margin: 18px 12px 6px; color: var(--texte2); font-size: 13px; text-transform: uppercase; letter-spacing: .6px; }
.menu-groupe { background: var(--fond3); border-radius: var(--r); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; cursor: pointer; color: var(--texte); }
.item + .item { border-top: 1px solid var(--sep); }   /* onglets tous alignés à gauche, séparateur pleine largeur */
.item.on { background: var(--bleu); color: #fff; }
.item.on .chev { color: rgba(255,255,255,.7); }
.item .ic { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; font-size: 15px; color: #fff; flex: 0 0 30px; }
.ic.bleu { background: var(--bleu); } .ic.vert { background: var(--vert); } .ic.rouge { background: var(--rouge); }
.ic.orange { background: var(--orange); } .ic.violet { background: var(--violet); } .ic.gris { background: var(--gris); }
.item .chev { margin-left: auto; color: var(--texte3); font-size: 20px; }
.barre-pied { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--sep); color: var(--texte2); font-size: 15px; }

.contenu { min-height: 0; overflow-y: auto; padding: 0 32px 40px; }
.grand-titre { padding: 26px 0 10px; }
.grand-titre h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -.5px; }
.sous { color: var(--texte2); }
.vue { max-width: 900px; }

/* cartes du tableau de bord */
.cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.carte { background: var(--fond2); border-radius: var(--rl); padding: 16px; }
.carte .k { color: var(--texte2); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.carte .v { font-size: 30px; font-weight: 700; margin-top: 4px; }
.carte .v small { font-size: 14px; color: var(--texte2); font-weight: 500; }

/* listes */
.liste .ligne .lib { flex: 1; }
.liste .lib small { display: block; color: var(--texte2); font-size: 13px; margin-top: 2px; }
.vide { color: var(--texte2); padding: 16px; text-align: center; }

/* feuille modale (bottom sheet façon iOS) */
.feuille-fond { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: end center; z-index: 50; }
.feuille { width: min(680px, 100%); max-height: 88vh; overflow-y: auto; background: var(--fond2); border-radius: 16px 16px 0 0; padding: 12px 16px 28px; }
.feuille-tete { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 12px; }
.feuille-tete h2 { margin: 0; font-size: 20px; }
.poignee { width: 36px; height: 5px; border-radius: 3px; background: var(--texte3); margin: 0 auto 8px; }
.actions-feuille { display: flex; gap: 10px; margin-top: 16px; }
.actions-feuille .btn-ios { flex: 1; }

/* éditeur d'actions d'automatisme */
.action-bloc { background: var(--fond3); border-radius: var(--r); padding: 10px 12px; margin-top: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; }
.action-bloc select, .action-bloc input { background: var(--fond2); border: none; border-radius: 8px; padding: 8px 10px; color: var(--texte); min-width: 0; }
.action-bloc .plein-l { grid-column: 1 / -1; }
.jours { display: flex; gap: 6px; margin-left: auto; }
.jours label { background: var(--fond3); border-radius: 8px; padding: 6px 9px; font-size: 14px; cursor: pointer; }
.jours input { display: none; }
.jours input:checked + span { color: var(--bleu); font-weight: 700; }
.chips-droits { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-droits label { background: var(--fond3); border-radius: 999px; padding: 6px 11px; font-size: 14px; cursor: pointer; }
.chips-droits input { display: none; }
.chips-droits input:checked + span { color: var(--bleu); font-weight: 700; }

/* ---------- Santé serveur ---------- */
.sante-verdict { background: var(--fond2); border-radius: var(--rl); padding: 16px; margin-bottom: 16px; border-left: 4px solid var(--vert); }
.sante-verdict.alerte { border-left-color: var(--orange); }
.sante-verdict.critique { border-left-color: var(--rouge); }
.sv-tete { display: flex; align-items: center; gap: 10px; font-size: 18px; margin-bottom: 12px; }
.sv-details { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.sv-item { background: var(--fond3); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; border-left: 3px solid var(--vert); }
.sv-item.alerte { border-left-color: var(--orange); }
.sv-item.critique { border-left-color: var(--rouge); }
.sv-res { font-weight: 600; }
.sv-val { color: var(--texte2); font-size: 14px; }
.sv-txt { font-size: 14px; }
.sv-ouverts { margin-top: 10px; color: var(--orange); font-weight: 600; }
.carte.sante { border-left: 3px solid var(--vert); }
.carte.sante.alerte { border-left-color: var(--orange); }
.carte.sante.critique { border-left-color: var(--rouge); }
.carte .k { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.carte .sous-carte { color: var(--texte2); font-size: 13px; margin-top: 4px; line-height: 1.35; }
.gauge { height: 6px; border-radius: 3px; background: var(--fond3); margin-top: 8px; overflow: hidden; }
.gauge i { display: block; height: 100%; background: var(--vert); border-radius: 3px; transition: width .4s; }
.gauge i.alerte { background: var(--orange); }
.gauge i.critique { background: var(--rouge); }
.spark { width: 100%; height: 46px; margin-top: 8px; display: block; }
.spark path { fill: none; stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark-seuil { stroke: var(--rouge); stroke-width: 1; stroke-dasharray: 4 3; opacity: .7; vector-effect: non-scaling-stroke; }
.ligne.evt.encours { background: rgba(255,159,10,.10); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: rgba(44,44,46,.96); color: #fff;
  padding: 12px 18px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 60; font-size: 15px; }
.toast.rouge { background: rgba(255,69,58,.95); }

@media (max-width: 900px) {
  #ecran-app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .barre { border-right: none; border-bottom: 1px solid var(--sep); max-height: 44vh; }
  .contenu { padding: 0 16px 30px; }
  .ligne .lib { flex-basis: 110px; }
}


/* ---- console en ligne (glocauxitec.fr) : liaison au serveur local ---- */
.barre-liaison{padding:8px 16px 0;font-size:12px;color:var(--gris,#8e8e93);display:flex;align-items:center;gap:8px}
.hors-ligne{margin:24px auto;max-width:560px;text-align:center;padding:34px 26px;border-radius:18px;background:var(--fond2,var(--carte,#1c1c1e));border:1px solid var(--sep,#2c2c2e)}
.hors-ligne .hl-ic{font-size:42px;margin-bottom:8px}
.hors-ligne h2{margin:0 0 10px;font-size:20px}
.hors-ligne p{margin:0 0 8px;color:var(--gris,#8e8e93);line-height:1.5}
.hors-ligne .hl-sous{font-size:12px;opacity:.85}
.carte .v small.nr{color:var(--orange,#ff9f0a)}
