:root {
  color-scheme: dark;
  --bg: #0c1118;
  --bg2: #111923;
  --raise: #172130;
  --line: #233042;
  --line2: #31435a;
  --text: #ebe6da;
  --muted: #8f9aab;
  --faint: #5f6b7d;
  --accent: #e8b24f;
  --accent-ink: #1b1305;
  --ok: #47c58b;
  --bad: #ef6b5f;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  background: radial-gradient(1100px 420px at 10% -8%, rgba(232, 178, 79, .05), transparent 65%), var(--bg);
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 64px; }

/* ── En-tête ── */
.top { display: flex; align-items: center; gap: 20px; padding: 22px 0 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 1.05rem; text-decoration: none; letter-spacing: .01em; }
.brand svg { width: 26px; height: 26px; }
.spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; }
.who .email { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 6px; }

.stats { display: flex; gap: 16px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.meter { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.m-bar { width: 44px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.m-bar i { display: block; height: 100%; width: calc(var(--p) * 1%); background: var(--muted); border-radius: 4px; transition: width .6s ease; }
.meter.warn .m-bar i { background: var(--accent); }
.meter.crit .m-bar i { background: var(--bad); }

/* ── Boutons et champs ── */
.btn {
  border: 1px solid var(--line2); background: transparent; color: var(--text);
  padding: 8px 14px; border-radius: 10px; font-size: 14px; transition: background .15s, border-color .15s;
  display: inline-block; text-decoration: none; text-align: center; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--raise); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover:not(:disabled) { background: #f0c068; }
.btn.danger { border-color: rgba(239, 107, 95, .5); color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: rgba(239, 107, 95, .12); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--text); }
.btn.on { color: var(--accent); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; padding: 12px; }
.icon-btn { width: 28px; height: 24px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); line-height: 1; }
.icon-btn:hover:not(:disabled) { background: var(--raise); color: var(--text); }
.icon-btn:disabled { opacity: .25; cursor: default; }

input[type=text], input[type=email], input[type=password], input[type=search], input[type=url] {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--faint); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232, 178, 79, .16); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.f-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.f-hint, .hint { font-size: 12.5px; color: var(--faint); margin: 0; }
.form-err { color: var(--bad); min-height: 1.4em; margin: 0 0 8px; font-size: 14px; }

/* ── Recherche ── */
.finder { position: relative; margin: 34px 0 6px; }
.finder input {
  height: 58px; padding: 0 64px 0 56px; font-size: 1.12rem; border-radius: 999px; background: var(--bg2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f9aab' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 20px center; background-size: 20px;
}
.finder input::-webkit-search-cancel-button { display: none; }
.finder kbd {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%); font: 13px var(--font); color: var(--faint);
  border: 1px solid var(--line2); border-radius: 7px; padding: 1px 8px; pointer-events: none;
}

/* ── Catégories et tuiles ── */
.enter { animation: fade .5s ease both; }
@keyframes fade { from { opacity: 0; } }
.cat { display: grid; grid-template-columns: 9.5rem 1fr; gap: 12px 20px; margin-top: 34px; }
.cat-name { position: sticky; top: 18px; align-self: start; margin: 12px 0 0; font-size: .95rem; font-weight: 650; color: var(--muted); }
.cat-n { color: var(--faint); font-weight: 400; margin-left: 4px; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 10px; }

.tile {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; text-decoration: none;
  padding: 14px 38px 14px 14px; border-radius: 18px; background: var(--bg2); border: 1px solid var(--line); color: inherit;
  transition: background .18s, border-color .18s;
}
.tile:hover { background: var(--raise); border-color: var(--line2); }
.ico {
  flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; overflow: hidden;
  font-size: 1.45rem; font-weight: 650; background: hsl(var(--h, 210) 36% 21%); color: hsl(var(--h, 210) 75% 84%);
}
.ico.img { background: rgba(255, 255, 255, .07); }
.ico img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.t-text { display: grid; min-width: 0; }
.t-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-desc, .t-count { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-count { color: var(--faint); }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.dot.up { background: var(--ok); box-shadow: 0 0 0 3px rgba(71, 197, 139, .18); }
.dot.down { background: var(--bad); box-shadow: 0 0 0 3px rgba(239, 107, 95, .18); }
.tile .dot { position: absolute; top: 15px; right: 15px; }

.empty { margin: 70px 0; color: var(--muted); max-width: 46ch; }
.empty h2 { margin: 0 0 6px; color: var(--text); font-size: 1.15rem; }
.empty p { margin: 0 0 16px; }

/* ── Boîtes de dialogue ── */
dialog {
  padding: 0; border: 1px solid var(--line2); border-radius: 22px; background: var(--bg2); color: var(--text);
  width: min(480px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow: auto;
}
dialog.wide { width: min(720px, calc(100vw - 28px)); }
dialog[open] { animation: pop .2s ease both; }
dialog::backdrop { background: rgba(5, 8, 12, .66); backdrop-filter: blur(6px); animation: fade .2s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.d-head { display: flex; align-items: center; gap: 14px; padding: 18px 18px 16px 20px; }
.d-head h3 { margin: 0; font-size: 1.1rem; }
.d-head p { margin: 0; color: var(--muted); font-size: 13.5px; }
.d-head .grow { flex: 1; min-width: 0; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 1.5rem; line-height: 1; width: 34px; height: 34px; border-radius: 10px; }
.x:hover { background: var(--raise); color: var(--text); }
.inst { list-style: none; margin: 0; padding: 0 0 8px; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; text-decoration: none; border-top: 1px solid var(--line); transition: background .15s; }
.row:hover { background: var(--raise); }
.r-main { display: grid; flex: 1; min-width: 0; }
.r-label { font-weight: 650; }
.r-url { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-go { font-size: 13px; color: var(--muted); }
.row:hover .r-go { color: var(--accent); }

.form { padding: 4px 20px 20px; }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.ask { padding: 22px 20px 18px; }
.ask p { margin: 0 0 18px; }
.ask-act { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Sélecteurs de groupes ── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 5px 11px; border-radius: 9px; border: 1px solid var(--line2); color: var(--muted); font-size: 13.5px; cursor: pointer; transition: all .15s; }
.chip input:checked + span { background: rgba(232, 178, 79, .14); border-color: var(--accent); color: var(--text); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.check small { display: block; color: var(--faint); }

/* ── Administration ── */
.admin { margin-top: 30px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 10px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; }
.mv { display: grid; gap: 2px; }
.i-main { flex: 1; min-width: 0; }
.i-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.i-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.i-act { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 7px; background: rgba(232, 178, 79, .14); color: var(--accent); margin-left: 6px; }
.inst-ed { border: 1px solid var(--line); border-radius: 14px; margin: 0 0 10px; padding: 14px 14px 6px; min-width: 0; }
.inst-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: start; }
.inst-grid .field:last-child { grid-column: 1 / -1; }
.inst-foot { display: flex; justify-content: flex-end; margin: -4px 0 6px; }
.pw-row { display: flex; gap: 8px; }

/* ── Connexion ── */
.login { max-width: 380px; margin: 16vh auto 0; padding: 0 20px; }
.login .brand { margin-bottom: 22px; }
.login h1 { font-size: 1.9rem; margin: 0 0 24px; letter-spacing: -.01em; }
.login p.note { color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--raise); border: 1px solid var(--line2); padding: 10px 16px; border-radius: 12px; transition: all .25s; z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: var(--bad); color: var(--bad); }

@media (max-width: 760px) {
  .cat { grid-template-columns: 1fr; gap: 10px; margin-top: 26px; }
  .cat-name { position: static; margin: 0; }
  .finder kbd { display: none; }
  .stats { order: 5; width: 100%; justify-content: space-between; }
  .who .email { display: none; }
  .inst-grid { grid-template-columns: 1fr; }
  .item { flex-wrap: wrap; }
  .i-act { width: 100%; justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
