/* Panneau Supabase — une baie d'emplacements : chaque ligne est une instance,
   le voyant est la seule couleur vive, tout le reste est encre et gris. */
:root {
  --bg: #e8edf1;
  --surface: #f7f9fb;
  --surface-2: #eef2f6;
  --ink: #14233a;
  --ink-2: #4b5b70;
  --ink-3: #7a8798;
  --line: #cbd4de;
  --line-strong: #9fadbd;
  --accent: #0e5f7e;
  --accent-ink: #ffffff;
  --danger: #b4321f;
  --led-run: #12a150;
  --led-start: #d4a017;
  --led-warn: #d9622b;
  --led-stop: #8a96a5;
  --led-fail: #c0392b;
  --log-bg: #101b2a;
  --log-ink: #d8e2ec;
  --radius: 6px;
  --shadow: 0 1px 0 rgba(20, 35, 58, .06), 0 8px 24px -12px rgba(20, 35, 58, .25);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1620;
    --surface: #152030;
    --surface-2: #1b2839;
    --ink: #e4ebf2;
    --ink-2: #a9b6c5;
    --ink-3: #7b899b;
    --line: #2a3a4e;
    --line-strong: #3d5068;
    --accent: #4fb0d6;
    --accent-ink: #08202b;
    --danger: #f07a64;
    --log-bg: #0a121c;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: 13px; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
.muted { color: var(--ink-2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------- boutons et champs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4em;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 550; padding: .45em .9em; border-radius: var(--radius);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.small { font-size: 13px; padding: .3em .65em; }
input[type=text], input[type=password], input:not([type]), textarea, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: .5em .7em; width: 100%;
}
textarea { min-height: 5em; resize: vertical; font-family: var(--mono); font-size: 13px; }
label { display: block; font-weight: 600; margin: 1em 0 .35em; }
label.check { display: flex; gap: .55em; align-items: flex-start; font-weight: 450; margin: .6em 0; }
label.check input { margin-top: .3em; }
.hint { color: var(--ink-3); font-size: 13px; margin: .35em 0 0; }
.form-error { color: var(--danger); min-height: 1.2em; margin: .6em 0 0; font-size: 14px; }

/* ---------- connexion ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-box {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 32px; box-shadow: var(--shadow);
}
.login-box h1 { font-size: 24px; margin: 18px 0 6px; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 8px; padding: .65em; }

/* Marque : trois tiroirs de baie, un voyant allumé */
.brand-mark, .login-mark { display: grid; gap: 3px; width: 30px; }
.brand-mark span, .login-mark span {
  display: block; height: 7px; border-radius: 2px; background: var(--ink); position: relative;
}
.brand-mark span:first-child::after, .login-mark span:first-child::after {
  content: ""; position: absolute; right: 3px; top: 2px; width: 3px; height: 3px;
  border-radius: 50%; background: var(--led-run);
}

/* ---------- en-tête ---------- */
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 18px 32px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-title { font-weight: 700; font-size: 17px; }
.brand-sub { color: var(--ink-2); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.health { display: flex; gap: 6px; list-style: none; margin: 0 6px 0 0; padding: 0; flex-wrap: wrap; }
.health li {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px 2px 8px; background: var(--surface-2);
}

/* ---------- onglets ---------- */
.tabs { display: flex; gap: 4px; padding: 0 32px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tab {
  font: inherit; font-weight: 600; color: var(--ink-2); background: none; border: 0;
  border-bottom: 2px solid transparent; padding: 12px 14px 10px; cursor: pointer;
}
.tab[aria-current=page] { color: var(--ink); border-bottom-color: var(--ink); }
.count {
  display: inline-block; min-width: 1.6em; text-align: center; font-size: 12px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; margin-left: 4px; padding: 0 6px;
}
.banner {
  margin: 16px 32px 0; padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--led-warn); background: color-mix(in srgb, var(--led-warn) 10%, var(--surface));
}
.content { padding: 20px 32px 140px; max-width: 1280px; }
.lede { color: var(--ink-2); max-width: 70ch; margin: 0 0 16px; }

/* ---------- la baie ---------- */
.rack-head, .unit {
  display: grid;
  grid-template-columns: 64px minmax(200px, 1.5fr) minmax(200px, 1fr) minmax(130px, .7fr) 290px;
  align-items: center; gap: 16px;
}
.rack-head { padding: 0 16px 8px 0; color: var(--ink-3); font-size: 13px; }
.rack-head span:first-child { text-align: center; }
.rack { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.unit {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0 16px 0 0; min-height: 68px; overflow: hidden;
}
.unit.is-free { background: transparent; border-style: dashed; color: var(--ink-3); }
.ear {
  align-self: stretch; display: grid; place-items: center;
  font-size: 26px; font-weight: 300; color: var(--ink-2); letter-spacing: -.02em;
  background: var(--surface-2); border-right: 1px solid var(--line); min-height: 68px;
}
.is-free .ear { background: transparent; border-right-style: dashed; }
.unit-name { font-weight: 650; font-size: 16px; }
.url { font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
a.url:hover { color: var(--accent); }
.state { display: flex; align-items: center; gap: 10px; }
.state-text { line-height: 1.25; }
.state-text small { display: block; color: var(--ink-3); font-size: 12px; }
.ports { color: var(--ink-2); font-size: 14px; }
.ports small { display: block; color: var(--ink-3); font-size: 12px; }
.unit-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; padding: 10px 0; }

/* Voyant */
.led {
  width: 11px; height: 11px; border-radius: 50%; flex: none;
  background: var(--led-stop); box-shadow: 0 0 0 3px color-mix(in srgb, var(--led-stop) 18%, transparent);
}
.led.run   { background: var(--led-run);   box-shadow: 0 0 0 3px color-mix(in srgb, var(--led-run) 22%, transparent); }
.led.start { background: var(--led-start); box-shadow: 0 0 0 3px color-mix(in srgb, var(--led-start) 25%, transparent); animation: pulse 1.4s ease-in-out infinite; }
.led.warn  { background: var(--led-warn);  box-shadow: 0 0 0 3px color-mix(in srgb, var(--led-warn) 25%, transparent); }
.led.fail  { background: var(--led-fail);  box-shadow: 0 0 0 3px color-mix(in srgb, var(--led-fail) 25%, transparent); }
.led.off   { background: transparent; border: 2px solid var(--led-stop); box-shadow: none; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .led.start { animation: none; } }

.empty {
  border: 1px dashed var(--line-strong); border-radius: 10px; padding: 40px 32px; text-align: center;
  color: var(--ink-2); background: var(--surface);
}
.empty h2 { color: var(--ink); font-size: 20px; margin-bottom: 8px; }
.empty .btn { margin-top: 14px; }

/* ---------- tâches ---------- */
.jobs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.job {
  display: grid; grid-template-columns: 20px 1fr auto auto; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px;
}
.job small { color: var(--ink-3); }
.job .err { color: var(--danger); font-size: 13px; display: block; }

/* ---------- barre de tâche ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line-strong); box-shadow: 0 -8px 24px -16px rgba(0,0,0,.35);
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .dock { animation: none; } }
.dock-bar { display: flex; align-items: center; gap: 14px; padding: 12px 32px; }
.dock-text { flex: 1; min-width: 0; display: flex; gap: 12px; align-items: baseline; }
.dock-last { color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); }
.log {
  margin: 0; background: var(--log-bg); color: var(--log-ink); padding: 14px 32px;
  max-height: 42vh; overflow: auto; white-space: pre-wrap; word-break: break-word; line-height: 1.45;
}
.log .l-step { color: #8cc8ff; font-weight: 600; }
.log .l-ok { color: #6fdc9a; }
.log .l-warn { color: #f3c969; }
.log .l-err { color: #ff8f80; font-weight: 600; }
.log .l-out { color: #b9c6d4; }
.log .ts { color: #5f7186; }

/* ---------- notifications ---------- */
.toasts { position: fixed; right: 20px; top: 84px; display: grid; gap: 8px; z-index: 60; }
.toast {
  background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: var(--radius);
  box-shadow: var(--shadow); max-width: 380px; font-size: 14px;
}
.toast.bad { background: var(--danger); color: #fff; }

/* ---------- tiroir ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 18, 30, .35); z-index: 45; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); z-index: 50;
  background: var(--bg); border-left: 1px solid var(--line-strong); box-shadow: var(--shadow);
  display: flex; flex-direction: column; animation: slide .2s ease-out;
}
@keyframes slide { from { transform: translateX(40px); opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }
.drawer-head {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center;
  background: var(--surface); border-bottom: 1px solid var(--line); padding-right: 16px;
}
.drawer-head .ear { min-height: 76px; }
.drawer-head h2 { font-size: 20px; }
.subtabs { display: flex; gap: 2px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.subtabs button {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-2); background: none; border: 0;
  border-bottom: 2px solid transparent; padding: 10px 10px 8px; cursor: pointer; white-space: nowrap;
}
.subtabs button[aria-current=page] { color: var(--ink); border-bottom-color: var(--ink); }
.drawer-body { padding: 20px 24px 40px; overflow: auto; flex: 1; }
.drawer-body h3 { font-size: 15px; margin: 22px 0 10px; }
.drawer-body h3:first-child { margin-top: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.secret { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions.spaced { margin-top: 14px; }
.zone {
  margin-top: 26px; border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line)); border-radius: var(--radius);
  padding: 14px 16px; background: var(--surface);
}
.zone h3 { margin-top: 0; }
.zone p { color: var(--ink-2); margin: 0 0 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.svc-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.svc-list li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; border-bottom: 1px solid var(--line); padding: 4px 0; }
.svc-list li span:last-child { color: var(--ink-2); text-align: right; }
.logs-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.logs-bar select { width: auto; }
.drawer .log { border-radius: var(--radius); max-height: 60vh; padding: 12px 14px; font-size: 12px; }
.backup { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.backup small { color: var(--ink-3); display: block; }
.check-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.check-list li { display: flex; gap: 10px; align-items: center; }
pre.code {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; overflow: auto; max-height: 260px; font-size: 12px;
}

/* ---------- fenêtres ---------- */
.dialog {
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 0; width: min(520px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(10, 18, 30, .45); }
.dialog form { padding: 24px 26px; }
.dialog h2 { font-size: 20px; margin-bottom: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.name-field { display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.name-field:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.name-field input { border: 0; outline: none; font-size: 17px; font-weight: 600; }
.name-field .suffix { display: grid; place-items: center; padding: 0 12px; color: var(--ink-2); background: var(--surface-2); border-left: 1px solid var(--line); border-radius: 0 var(--radius) var(--radius) 0; }
.preview { margin-top: 14px; display: grid; grid-template-columns: 64px 1fr; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.preview .ear { min-height: 0; font-size: 22px; }
.preview-body { padding: 10px 14px; font-size: 14px; }
.preview-body div + div { margin-top: 2px; }
.preview-body .dns-ok { color: var(--led-run); }
.preview-body .dns-warn { color: var(--led-warn); }

/* ---------- petits écrans ---------- */
@media (max-width: 900px) {
  .top, .tabs, .dock-bar { padding-left: 16px; padding-right: 16px; }
  .content { padding: 16px 16px 140px; }
  .banner { margin: 12px 16px 0; }
  .rack-head { display: none; }
  .unit { grid-template-columns: 56px 1fr; gap: 6px 14px; padding: 10px 14px 10px 0; }
  .unit .ear { grid-row: span 4; margin: -10px 0; }
  .unit-actions { justify-content: flex-start; padding: 4px 0 0; }
  .log { padding: 12px 16px; }
  .toasts { left: 16px; right: 16px; }
}
