:root {
  --bg: #15110c;
  --bg-2: #1d1812;
  --card: #211b14;
  --card-hi: #2a2219;
  --line: #3a3024;
  --text: #efe4d0;
  --muted: #9c8c74;
  --amber: #f2a93b;
  --amber-soft: rgba(242, 169, 59, .14);
  --down: #e5604a;
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, .8);
  --display: 'Bricolage Grotesque', 'Trebuchet MS', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4ecdd;
    --bg-2: #ebe1cd;
    --card: #fbf6ec;
    --card-hi: #fffaf1;
    --line: #dccfb6;
    --text: #2a2016;
    --muted: #85735a;
    --amber: #c9770e;
    --amber-soft: rgba(201, 119, 14, .12);
    --down: #c8442f;
    --shadow: 0 18px 36px -24px rgba(90, 60, 20, .45);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--amber-soft), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, var(--amber-soft), transparent 60%),
    linear-gradient(color-mix(in srgb, var(--line) 30%, transparent) 1px, transparent 1px) 0 0 / 100% 48px,
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--display);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- En-tête ---------- */
.top {
  max-width: 1320px;
  margin: 0 auto;
  padding: 48px 32px 20px;
  display: grid;
  grid-template-columns: auto 1fr minmax(260px, 360px);
  gap: 32px;
  align-items: end;
}

.brand { display: flex; gap: 18px; align-items: center; }

.brand-mark {
  width: 54px; height: 54px;
  border-radius: 14px;
  background:
    linear-gradient(var(--amber), var(--amber)) 9px 9px / 16px 16px no-repeat,
    linear-gradient(var(--amber), var(--amber)) 29px 29px / 16px 16px no-repeat,
    linear-gradient(var(--line), var(--line)) 29px 9px / 16px 16px no-repeat,
    linear-gradient(var(--line), var(--line)) 9px 29px / 16px 16px no-repeat,
    var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: .9;
}
h1 span { color: var(--amber); }

.meta {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--muted);
  text-transform: lowercase;
}
#clock { color: var(--text); }

.stats {
  display: flex;
  gap: 28px;
  justify-content: center;
  font-family: var(--mono);
}
.stats div { display: flex; flex-direction: column; }
.stats strong {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stats div:nth-child(2) strong { color: var(--amber); }
.stats span { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; margin-top: 6px; }

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}
.search input::-webkit-search-cancel-button { display: none; }
kbd {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 7px;
}

/* ---------- Puces de catégories ---------- */
.chips {
  position: sticky;
  top: 0;
  z-index: 10;
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chips a {
  flex: none;
  font-family: var(--mono);
  font-size: .76rem;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  transition: color .2s, border-color .2s;
}
.chips a:hover { color: var(--amber); border-color: var(--amber); }
.chips a b { color: var(--text); font-weight: 500; margin-left: 6px; }

/* ---------- Tableau ---------- */
.board {
  max-width: 1320px;
  margin: 0 auto;
  padding: 8px 32px 40px;
}

.loading, .empty, .error {
  font-family: var(--mono);
  color: var(--muted);
  padding: 60px 0;
  text-align: center;
}
.error { color: var(--down); }

.category { margin-top: 36px; scroll-margin-top: 70px; }
.category[hidden] { display: none; }

.cat-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.cat-head .num { font-family: var(--mono); font-size: .8rem; color: var(--amber); }
.cat-head h2 { margin: 0; font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; }
.cat-head .count { margin-left: auto; font-family: var(--mono); font-size: .75rem; color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.card {
  --i: 0;
  position: relative;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px 16px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  overflow: hidden;
  opacity: 0;
  animation: rise .5s cubic-bezier(.2, .7, .2, 1) forwards;
  animation-delay: calc(var(--i) * 28ms);
  transition: transform .25s cubic-bezier(.2, .7, .2, 1), border-color .25s, background .25s;
}
.card::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: var(--amber);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .35s cubic-bezier(.2, .7, .2, 1);
}
.card:hover, .card:focus-visible {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--amber) 55%, var(--line));
  background: var(--card-hi);
  outline: none;
}
.card:hover::after, .card:focus-visible::after { transform: scaleX(1); }
.card[hidden] { display: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.icon {
  width: 56px; height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.icon img { width: 34px; height: 34px; object-fit: contain; }
.icon.letter {
  font-size: 1.6rem;
  font-weight: 800;
  color: #1b150e;
  background: hsl(var(--h) 65% 62%);
  border-color: transparent;
}

.body { min-width: 0; }
.name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -.01em;
}
.name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lock { width: 13px; height: 13px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.2; }

.desc {
  margin: 2px 0 6px;
  font-size: .85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.desc:empty { display: none; }

.host {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

mark { background: var(--amber-soft); color: var(--amber); border-radius: 3px; }

/* ---------- Pied ---------- */
.foot {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 32px 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--muted);
  border-top: 1px dashed var(--line);
}
.foot button {
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
}
.foot button:hover { border-color: var(--amber); color: var(--amber); }
.foot button[aria-busy='true'] { opacity: .5; pointer-events: none; }

/* ---------- Sonde système ---------- */
.sys {
  max-width: 1320px;
  margin: 0 auto;
  padding: 4px 32px 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.sys:empty { display: none; }

.gauge {
  --fill: color-mix(in srgb, var(--text) 72%, transparent);
  padding: 12px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) 80%, transparent);
  min-width: 0;
}
.gauge.warn { --fill: var(--amber); }
.gauge.crit { --fill: var(--down); }

.g-head { display: flex; align-items: center; gap: 8px; min-height: 18px; }
.g-label {
  font-family: var(--mono);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.g-flag {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .66rem;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--fill);
  border: 1px solid currentColor;
  white-space: nowrap;
}
.g-value {
  display: block;
  margin: 4px 0 8px;
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.g-value small { font-size: .9rem; font-weight: 400; color: var(--muted); margin-left: 2px; }

.bar {
  display: flex;
  gap: 2px;
  height: 6px;
  border-radius: 4px;
  background: var(--bg-2);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  background: var(--fill);
  border-radius: 4px;
  transition: width .6s cubic-bezier(.2, .7, .2, 1);
}
.bar i.cache,
.swatch {
  background: repeating-linear-gradient(135deg, var(--muted) 0 2px, transparent 2px 5px);
  opacity: .7;
}
.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -1px;
}

.g-sub {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Conteneurs ---------- */
.bar i.ok { background: color-mix(in srgb, var(--text) 72%, transparent); }
.bar i.starting { background: var(--amber); }
.bar i.problem { background: var(--down); }

.docker {
  max-width: 1320px;
  margin: 0 auto;
  padding: 4px 32px 8px;
}
.docker:empty { display: none; }

.docker details {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) 80%, transparent);
}
.docker summary {
  cursor: pointer;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  list-style: none;
}
.docker summary::-webkit-details-marker { display: none; }
.docker summary::before { content: '▸ '; }
.docker details[open] summary::before { content: '▾ '; }
.docker summary b { color: var(--text); font-weight: 500; margin-left: 4px; }
.docker summary:hover { color: var(--amber); }

.ct-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 6px 20px;
  padding: 4px 14px 14px;
}
.ct-group h3 {
  margin: 8px 0 4px;
  font-size: .85rem;
  font-weight: 600;
}

.ct-list { list-style: none; margin: 0; padding: 0; }
.ct-list.alerts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.ct-list.alerts .ct {
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--ct) 55%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--ct) 8%, var(--card));
}

.ct {
  --ct: var(--muted);
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  column-gap: 8px;
  padding: 3px 0;
  font-size: .82rem;
}
.ct.ok { --ct: color-mix(in srgb, var(--text) 72%, transparent); }
.ct.starting { --ct: var(--amber); }
.ct.problem { --ct: var(--down); }
.ct-icon { grid-row: span 2; color: var(--ct); font-size: .8rem; line-height: 1.5; text-align: center; }
.ct-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-status {
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ct.problem .ct-status, .ct.starting .ct-status { color: var(--ct); }

/* ---------- Formulaires, boutons, dialogue ---------- */
.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--text);
}

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span { font-family: var(--mono); font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.field input {
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  outline: 0;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }
.field input.code { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .4em; text-align: center; }

.form-error { min-height: 1.2em; margin: 0 0 12px; font-size: .85rem; color: var(--down); }
.form-error:empty { min-height: 0; margin: 0; }
.hint { margin: 0 0 14px; font-size: .9rem; color: var(--muted); line-height: 1.45; }
.hint.ok { color: var(--text); }

button.primary, button.danger {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--amber);
  color: #1b150e;
  transition: filter .2s;
}
button.danger { background: var(--down); color: #fff; }
button.primary:hover, button.danger:hover { filter: brightness(1.08); }
button[aria-busy='true'] { opacity: .55; pointer-events: none; }
button.link {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
  padding: 6px;
}
button.link:hover { color: var(--amber); }

.foot-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 22px 24px 24px;
}
.dialog::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dialog-head h2 { margin: 0; font-size: 1.25rem; font-weight: 600; letter-spacing: -.01em; }

.status-line { margin: 0 0 12px; }
.badge {
  font-family: var(--mono);
  font-size: .72rem;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.on { color: var(--amber); border-color: var(--amber); }
.badge.on::before { content: '✓ '; }

.steps { margin: 0 0 14px; padding-left: 1.2em; font-size: .9rem; line-height: 1.5; }
.qr {
  width: 200px;
  margin: 0 auto 14px;
  padding: 8px;
  background: #fff;
  border-radius: 12px;
}
.qr svg { display: block; width: 100%; height: auto; }
.secret { font-family: var(--mono); color: var(--text); word-break: break-all; }

/* ---------- Page de connexion ---------- */
.login-page { display: grid; place-items: center; padding: 24px 16px; }
.login { width: min(400px, 100%); }
.login .brand { margin-bottom: 24px; }
.login .panel { padding: 24px; }
.login #back { display: block; margin: 10px auto 0; }
.login #back[hidden] { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .top { grid-template-columns: 1fr auto; padding-top: 32px; }
  .search { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .top { grid-template-columns: 1fr; gap: 20px; padding: 24px 16px 12px; }
  .stats { justify-content: flex-start; }
  .chips, .board, .sys, .docker { padding-left: 16px; padding-right: 16px; }
  .sys { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .foot { flex-direction: column; align-items: flex-start; }
  .foot { padding: 20px 16px 32px; }
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .card { grid-template-columns: 48px 1fr; }
  .icon { width: 48px; height: 48px; }
  .icon img { width: 30px; height: 30px; }
  kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; opacity: 1; }
  .card, .card::after, .bar i { transition: none; }
}
