:root {
  --bg: #0C1524;
  --rail-bg: #101A2C;
  --top-bg: #101A2C;
  --panel: #172338;
  --line: #2A3C56;
  --primary: #3B82F6;
  --primary-hover: #4F8FF7;
  --ai: #22D3EE;
  --text: #EEF3F9;
  --muted: #9AADC2;
  --ok: #34D399;
  --warn: #FBBF24;
  --crit: #F87171;
  --badge: #ED4245;
  --rail: 272px;
  --top: 58px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { zoom: var(--ui-zoom, 1); }
body {
  font-family: Outfit, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul, ol { margin: 0; padding: 0; }
h1, h2, p { margin: 0; }
input, select {
  font: inherit;
  color: var(--text);
  background: #101A2C;
  border: 1px solid var(--line);
  border-radius: 10px;
  height: 38px;
  padding: 0 12px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid rgba(59, 130, 246, 0.45); border-color: var(--primary); }
input::placeholder { color: #6B8098; }
.hidden { display: none !important; }

.app {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  grid-template-rows: var(--top) minmax(0, 1fr);
  height: 100%;
  overflow: hidden;
}

.top {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px 0 0;
  background: var(--top-bg);
  min-width: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  width: var(--rail);
  flex-shrink: 0;
  height: 100%;
  padding: 0 18px;
}
.brand-mark-wrap { width: 26px; height: 26px; display: grid; place-items: center; }
.brand-mark { width: 20px; height: 20px; }
.brand-name { font-size: 15px; font-weight: 700; }
.brand-sub { font-size: 13px; color: var(--muted); margin-left: 2px; }
.top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
.top-meta { font-size: 13px; color: var(--muted); white-space: nowrap; }
.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.live i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.16);
}
.live.is-hot i { animation: livepulse 0.8s ease; }
@keyframes livepulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  100% { box-shadow: 0 0 0 9px rgba(52, 211, 153, 0); }
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; padding: 0 14px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.btn-ghost:hover { background: rgba(59, 130, 246, 0.16); }
.btn-danger { background: rgba(248, 113, 113, 0.12); color: #FECACA; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }

/* Menu */
.rail {
  display: flex;
  flex-direction: column;
  background: var(--rail-bg);
  min-height: 0;
  overflow: auto;
  padding: 4px 0 0;
  box-shadow: 1px 0 0 rgba(42, 60, 86, 0.55);
}
.rail-org { padding: 8px 20px 16px; }
.rail-org span { display: block; font-size: 12px; color: var(--muted); }
.rail-org strong {
  display: block;
  font-size: 16px;
  font-weight: 650;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-org em { font-style: normal; color: var(--muted); font-size: 12px; }
.rail nav { padding: 0 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.cat { border-radius: 12px; }
.cat-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  border-radius: 10px;
  text-align: left;
}
.cat-btn span:not(.badge):not(.chev) { min-width: 0; }
.cat-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.cat.is-open > .cat-btn,
.cat.is-current > .cat-btn { color: var(--text); }
.cat.is-open > .cat-btn .badge { display: none !important; }
.cat.is-current { background: rgba(59, 130, 246, 0.1); }
.cat-btn .chev {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  flex-shrink: 0;
}
.cat-btn .chev:hover { background: rgba(255, 255, 255, 0.08); }
.cat-btn .chev::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.7px solid currentColor;
  border-bottom: 1.7px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
.cat.is-open .cat-btn .chev::before { transform: rotate(45deg); }
.sub { display: none; padding: 0 4px 8px 22px; }
.cat.is-open .sub { display: flex; flex-direction: column; gap: 1px; }
.rail nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 14px;
  border-radius: 9px;
}
.rail nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.rail nav a.is-on {
  color: var(--text);
  background: rgba(59, 130, 246, 0.22);
  box-shadow: inset 3px 0 0 var(--primary);
}
.rail nav a.is-on .badge.is-on { background: var(--badge); color: #fff; }
.badge {
  display: none;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--badge);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.badge.is-on { display: inline-flex; align-items: center; justify-content: center; }
.rail-user {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 16px 16px;
}
.avatar {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 10px;
  font-size: 11px; font-weight: 700;
  background: #1E3350;
}
.rail-user strong { display: block; font-size: 13px; }
.rail-user em { font-style: normal; color: var(--muted); font-size: 12px; }

/* Contenu : cartes, pas de grille collée */
.main {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}
.panel { min-height: 100%; display: flex; flex-direction: column; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 8px;
}
.page-head h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.03em; }
.page-head p { margin-top: 6px; color: var(--muted); font-size: 14px; max-width: 46em; }
.page-head-meta { flex-shrink: 0; }

.stat-bar,
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  padding: 12px 28px 8px;
  background: transparent;
  border: 0;
}
.stat-bar > div,
.metrics > div {
  min-width: 0;
  padding: 14px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--panel);
}
.stat-bar span,
.metrics span { display: block; color: var(--muted); font-size: 12px; }
.stat-bar b {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  font-weight: 650;
}
.metrics b {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.25;
}

.node-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 10px 28px 28px;
  flex: 1;
  min-height: 0;
}
.node-body .metrics { padding: 0; }
.node-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-areas:
    "diag side"
    "incs side";
  gap: 14px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}
#node-diag { grid-area: diag; min-height: 0; }
.node-incs { grid-area: incs; min-height: 0; overflow: auto; }
.node-rail {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}
.sheet {
  background: var(--panel);
  border-radius: 16px;
  min-width: 0;
  overflow: auto;
}
.sheet-grow { flex: 1; min-height: 160px; }
.diag {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr;
  gap: 10px;
  padding: 4px 14px 16px;
}
.diag > div {
  padding: 12px 14px;
  background: rgba(8, 16, 28, 0.4);
  border-radius: 12px;
  min-width: 0;
}
.diag h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}
.diag .kicker {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--ai);
}
.diag p, .diag li {
  font-size: 14px;
  line-height: 1.45;
}
.diag ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  color: var(--muted);
}
.diag li em { font-style: normal; font-size: 12px; }
.acts-stack { padding: 4px 14px 14px; display: grid; gap: 10px; }
.act-item {
  padding: 10px 12px;
  background: rgba(8, 16, 28, 0.4);
  border-radius: 10px;
}
.act-item p { font-size: 13px; line-height: 1.4; margin: 0 0 8px; }
.act-hint { padding: 0 14px 14px; color: var(--muted); font-size: 12px; line-height: 1.4; }

.work,
.setup {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  min-height: 0;
  padding: 12px 28px 28px;
  align-items: stretch;
}
.work-main,
.fill,
.work-side,
.setup-copy,
.setup-form {
  background: var(--panel);
  border-radius: 16px;
  min-height: 0;
  min-width: 0;
  border: 0;
}
.fill {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 12px 28px 28px;
  overflow: auto;
}
.work .fill,
.work-main.fill {
  margin: 0;
}
.work-main {
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.work-side {
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.pane-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 18px 8px;
  background: transparent;
  border: 0;
  height: auto;
}
.pane-bar h2 { font-size: 14px; font-weight: 650; }
.pane-tools { display: flex; align-items: center; gap: 10px; }
.pane-bar > span:not(.tag),
.pane-tools > span {
  min-width: 22px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
input.filter {
  width: 200px;
  max-width: 46vw;
  height: 32px;
  font-size: 13px;
  border-radius: 8px;
}

.grid { width: 100%; border-collapse: separate; border-spacing: 0; }
.grid th, .grid td {
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid rgba(42, 60, 86, 0.45);
  font-size: 14px;
  vertical-align: middle;
  line-height: 1.35;
}
.grid th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 1;
}
.grid td.acts {
  width: 1%;
  white-space: nowrap;
  padding-top: 8px;
  padding-bottom: 8px;
}
.btns {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
}
.grid tbody tr.row-link { cursor: pointer; }
.grid tbody tr.row-link:hover { background: rgba(59, 130, 246, 0.1); }
.linkish { color: var(--primary); font-weight: 650; padding: 0; height: auto; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.crumb button { color: var(--primary); font-weight: 650; padding: 0; height: auto; }

.feed-item { padding: 14px 18px; }
.feed-item + .feed-item { box-shadow: inset 0 1px 0 rgba(42, 60, 86, 0.45); }
.feed-item time { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.feed-item p { line-height: 1.45; }
.feed-empty { padding: 18px; color: var(--muted); font-size: 13px; }

.sev, .st { font-weight: 650; font-size: 13px; }
.sev-crit, .st-down { color: #F87171; }
.sev-high { color: #FB923C; }
.sev-med, .st-warn { color: #FBBF24; }
.sev-low { color: #93C5FD; }
.st-ok { color: #34D399; }
.empty-row td { padding: 0; border-bottom: 0; }
.empty-work { padding: 40px 24px; text-align: center; max-width: 420px; margin: 0 auto; }
.empty-work strong { display: block; font-size: 15px; }
.empty-work p { margin: 8px 0 16px; color: var(--muted); line-height: 1.45; }

.side-block { padding: 4px 18px 16px; border: 0; }
.side-block h3 { font-size: 12px; font-weight: 650; color: var(--muted); margin: 10px 0 8px; }
.steps { display: grid; gap: 8px; }
.steps a, .steps button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: rgba(8, 16, 28, 0.45);
  text-align: left;
  color: var(--text);
  font-size: 13px;
}
.steps a:hover, .steps button:hover { background: rgba(59, 130, 246, 0.16); }
.steps small { color: var(--muted); font-size: 12px; }
.facts { display: grid; gap: 8px; }
.facts div { display: flex; justify-content: space-between; font-size: 13px; }
.facts span:first-child { color: var(--muted); }
.note {
  margin-top: auto;
  padding: 14px 18px 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  border: 0;
}
.note b { color: var(--text); font-weight: 600; }

.setup-copy { padding: 22px 24px 28px; max-width: none; }
.setup-copy h2 { font-size: 15px; margin-bottom: 8px; }
.setup-copy p { color: var(--muted); line-height: 1.5; margin-bottom: 12px; }
.setup-copy ol { margin: 0 0 16px 18px; display: grid; gap: 8px; }
.setup-copy li { color: var(--muted); }
.setup-copy li b { color: var(--text); }
.cmd {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  padding: 12px 14px;
  background: #0C1522;
  border-radius: 10px;
  color: var(--ai);
  overflow-x: auto;
}
.setup-form { padding: 22px 22px 28px; }
.field { display: grid; gap: 6px; margin: 0 0 14px; }
.field label { font-size: 12px; font-weight: 650; color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
td.row { display: table-cell; }
.table-wrap { overflow-x: auto; flex: 1; }

.err, .ok { padding: 10px 12px; border-radius: 10px; margin: 0 0 10px; font-size: 13px; border: 0; }
.err { background: rgba(248, 113, 113, 0.12); color: #FCA5A5; }
.ok { background: rgba(52, 211, 153, 0.12); color: #6EE7B7; }
.link-url { font-family: ui-monospace, monospace; font-size: 12px; color: var(--ai); word-break: break-all; }
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 650;
  background: rgba(59, 130, 246, 0.18);
}
.tag-ok { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.tag-off { background: rgba(143, 163, 187, 0.12); color: var(--muted); }

body:not(.app) {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(240px, 40%) minmax(0, 1fr);
  background: var(--bg);
}
.auth-aside {
  background: var(--rail-bg);
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
}
.auth-aside .brand-mark { width: 28px; height: 28px; }
.auth-aside h1 { font-size: 28px; font-weight: 650; margin: 16px 0 8px; }
.auth-aside p { color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 28em; }
.auth-aside .foot { font-size: 13px; color: #6E8299; }
.auth-main { display: grid; place-items: center; padding: 32px 16px; }
.auth { width: 100%; max-width: 360px; display: grid; gap: 12px; }
.auth h1 { font-size: 22px; font-weight: 650; }
.auth .lede { color: var(--muted); font-size: 14px; line-height: 1.45; }
.auth .btn-primary { height: 40px; width: 100%; }
.auth-brand { font-size: 13px; font-weight: 600; color: var(--muted); }
.qr { display: grid; place-items: center; min-height: 180px; padding: 12px; background: #fff; border-radius: 12px; color: #080D18; }
.qr svg { width: 180px; height: 180px; }

@media (max-width: 800px) {
  body:not(.app) { grid-template-columns: 1fr; }
  .auth-aside { min-height: 0; padding: 24px 20px; }
}
@media (min-device-width: 1800px) { :root { --rail: 292px; } }
@media (max-width: 1100px) {
  .work, .setup { grid-template-columns: 1fr; }
  .node-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "diag"
      "incs"
      "side";
  }
  .diag { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: var(--top) auto minmax(0, 1fr); }
  .brand { width: auto; }
  .rail { grid-row: 2; max-height: 240px; }
  .main { grid-row: 3; }
  .brand-sub { display: none; }
}
