/* ==========================================================================
   IntelliControl — 기업 전산 콘솔 (Enterprise Control Plane UI)
   라이트 슬레이트 기본 · 다크 콘솔 옵션 · 1px hairline · tabular-nums
   ========================================================================== */

@font-face {
  font-family: "Pretendard Variable";
  src: url("/fonts/PretendardVariable.woff2") format("woff2-variations");
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef1f5;

  --line: #e2e5ea;
  --line-2: #edeff3;
  --line-strong: #ccd2db;

  --text: #151a20;
  --text-2: #39424e;
  --muted: #5b6675;
  --dim: #8a93a0;

  --accent: #1c4b96;
  --accent-strong: #143a75;
  --accent-soft: #eaf0f9;
  --accent-line: #c6d6ec;

  --ok: #146c43;
  --ok-soft: #e9f5ee;
  --ok-line: #c2e2d0;

  --warn: #8a5a00;
  --warn-soft: #fdf4e0;
  --warn-line: #efdcae;

  --danger: #b02a20;
  --danger-soft: #fceceb;
  --danger-line: #f1cbc7;

  --info: #0b5cad;
  --info-soft: #e9f1fb;

  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Liberation Mono", Menlo, Consolas, monospace;

  --rail-w: 238px;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent-line);
}

html[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #131920;
  --surface-2: #0f151c;
  --surface-3: #1a222b;

  --line: #242d37;
  --line-2: #1d252e;
  --line-strong: #3a4652;

  --text: #e6ebf0;
  --text-2: #c4cdd6;
  --muted: #95a1ae;
  --dim: #6d7a87;

  --accent: #2f6bb8;
  --accent-strong: #3d7dcc;
  --accent-soft: #152638;
  --accent-line: #294568;

  --ok: #4fa876;
  --ok-soft: #11251a;
  --ok-line: #1e3f2d;

  --warn: #d0a34c;
  --warn-soft: #291f10;
  --warn-line: #46351a;

  --danger: #d9665c;
  --danger-soft: #2a1513;
  --danger-line: #4d2622;

  --info: #63aaea;
  --info-soft: #11253a;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans KR", "Noto Sans CJK KR", "Malgun Gothic", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  font-feature-settings: "ss01" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
[hidden] { display: none !important; }

/* 왼쪽 레일 열은 문서 끝까지 같은 면으로 이어진다(스티키 레일 아래 빈 여백 방지).
   .shell 이 있는 콘솔 페이지에만 적용한다(결제 등 단독 페이지에는 레일 열이 없다). */
.shell::before {
  content: "";
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--rail-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: -1;
  pointer-events: none;
}

.mono, code, .sig { font-family: var(--mono); font-variant-numeric: tabular-nums; }
code {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 11.5px;
}

/* ── Shell ───────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ── Left rail ───────────────────────────────────────────── */
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 40;
}

.rail__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  flex: none;
}
.rail__brandtext { display: flex; flex-direction: column; min-width: 0; }
.rail__brandtext strong { font-size: 13.5px; font-weight: 650; letter-spacing: -0.01em; }
.rail__brandtext small {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 1px;
}

.rail__tenant {
  display: grid;
  gap: 1px;
  margin: 12px 12px 4px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-2);
}
.rail__tenant-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--dim);
  font-weight: 600;
}
.rail__tenant-id {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail__tenant-meta { font-size: 11px; color: var(--muted); }

.rail__nav { padding: 8px 8px 12px; overflow-y: auto; flex: 1 1 auto; }
.nav__group {
  margin: 14px 8px 5px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}
.nav__group:first-child { margin-top: 4px; }
.nav__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px 7px 8px;
  margin: 1px 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: none;
  color: var(--text-2);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  position: relative;
}
.nav__item svg { width: 15px; height: 15px; flex: none; color: var(--muted); }
.nav__item span:not(.nav__count) { flex: 1 1 auto; }
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 600;
}
.nav__item.is-active svg { color: var(--accent); }
.nav__short { display: none; }
.nav__count {
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rail__foot {
  border-top: 1px solid var(--line);
  padding: 10px 16px 14px;
  display: grid;
  gap: 6px;
}
.rail__stat { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.rail__stat strong { color: var(--text-2); font-weight: 600; }
.rail__link { font-size: 11.5px; margin-top: 4px; }

/* ── Status bar ──────────────────────────────────────────── */
.workspace { display: flex; flex-direction: column; min-width: 0; }

.statusbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 50px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.statusbar__left { display: flex; align-items: center; gap: 7px; font-size: 12px; min-width: 0; }
.crumb { color: var(--muted); }
.crumb__sep { color: var(--dim); }
.crumb--now { color: var(--text); font-weight: 600; white-space: nowrap; }

.tenant-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-2);
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
}
.tenant-chip__dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

.statusbar__mid { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.stat { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.stat__label { color: var(--dim); }
.stat b { color: var(--text-2); font-weight: 600; font-size: 11.5px; }
.stat__sep { width: 1px; height: 18px; background: var(--line); }
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  display: inline-block;
  flex: none;
}
.dot.is-off { background: var(--danger); }
.dot.is-idle { background: var(--dim); }

.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-2);
}
.seg__btn {
  border: 0;
  background: none;
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  cursor: pointer;
}
.seg__btn + .seg__btn { border-left: 1px solid var(--line); }
.seg__btn:hover { color: var(--text); background: var(--surface-3); }
.seg__btn.is-on { background: var(--accent); color: #fff; }

.statusbar__right { display: flex; align-items: center; gap: 8px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { background: var(--surface-3); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn--quiet { color: var(--text-2); font-weight: 500; }
.btn--quiet:hover { color: var(--text); }
.btn--sm { height: 24px; padding: 0 8px; font-size: 11.5px; }
.btn--danger {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
}
.btn--danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn--danger-solid:hover { background: var(--danger); filter: brightness(0.94); }
.btn--ok { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.btn--ok:hover { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }

/* ── Halt bar ────────────────────────────────────────────── */
.haltbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 20px;
  background: var(--danger-soft);
  border-bottom: 1px solid var(--danger-line);
  color: var(--danger);
}
.haltbar__text { display: flex; align-items: center; gap: 12px; flex: 1 1 auto; min-width: 0; }
.haltbar__text strong {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  border: 1px solid var(--danger-line);
  background: var(--surface);
  padding: 2px 7px;
  border-radius: 3px;
}
.haltbar__text span { font-size: 12px; color: var(--text-2); }

/* ── Main / views ────────────────────────────────────────── */
.main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1600px;
  padding: 20px 24px 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.view { display: flex; flex-direction: column; gap: 16px; }

.pagehead { display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.pagehead > div:first-child { flex: 1 1 380px; min-width: 0; }
.pagehead h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.h1-sub {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 3px;
  padding: 2px 6px;
}
.pagehead p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; max-width: 76ch; }
.pagehead__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  font-size: 11.5px;
  color: var(--muted);
}
.meta b { color: var(--text); font-weight: 600; }

.live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  font-size: 11.5px;
  color: var(--text-2);
}
.live.is-off .dot { background: var(--danger); }

/* ── Metrics ─────────────────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.metrics--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 16px 11px;
  border-left: 1px solid var(--line-2);
  min-width: 0;
}
.metric:first-child { border-left: 0; }
.metric__label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.metric__value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
}
.metric__value--text { font-size: 14px; font-family: inherit; letter-spacing: -0.01em; }
.metric__value--mono { font-size: 13px; }
.metric__note { font-size: 11px; color: var(--dim); }
.metric--warn .metric__value { color: var(--warn); }
.metric--danger .metric__value { color: var(--danger); }
.metric--ok .metric__value { color: var(--ok); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}
.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.card__head--row { align-items: center; }
.card__head > div:first-child { min-width: 0; }
.card__head h2 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card__head p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--muted);
}
.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 3px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}

.grid-split {
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(300px, 0.9fr);
  gap: 16px;
  align-items: stretch;
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(260px, 0.75fr);
  gap: 16px;
  align-items: start;
}
.card--side { align-self: start; }

/* ── Legend / swatches ───────────────────────────────────── */
.legend { display: flex; gap: 12px; align-items: center; font-size: 11px; color: var(--muted); white-space: nowrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.sw--allow { background: var(--ok); }
.sw--pending { background: var(--warn); }
.sw--block { background: var(--danger); }

/* ── Topology (SVG) ──────────────────────────────────────── */
.topo { padding: 10px 12px 6px; overflow-x: auto; background: var(--surface); }
.topo svg { display: block; width: 100%; height: auto; }
.topo .zone {
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  fill: var(--dim);
}
.topo .edge {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1;
  transition: stroke 0.18s ease, stroke-width 0.18s ease;
}
.topo .edge--active { stroke: var(--accent); stroke-width: 1.6; }
.topo .tn { cursor: pointer; }
.topo .tn__box {
  fill: var(--surface);
  stroke: var(--line-strong);
  stroke-width: 1;
  transition: stroke 0.18s ease, fill 0.18s ease;
}
.topo .tn:hover .tn__box { stroke: var(--accent); }
.topo .tn.is-hot .tn__box { stroke: var(--accent); fill: var(--accent-soft); }
.topo .tn.is-selected .tn__box { stroke: var(--accent); stroke-width: 1.6; }
.topo .tn__bar { rx: 1; }
.topo .tn__title { font-size: 11.5px; font-weight: 600; fill: var(--text); }
.topo .tn__sub { font-size: 9.5px; fill: var(--muted); font-family: var(--mono); }
.topo .tn__count { font-size: 9.5px; font-family: var(--mono); font-weight: 600; }
.topo .tn--pdp .tn__box { fill: var(--surface-2); stroke: var(--accent-line); stroke-width: 1.2; }
.topo .pdp__title { font-size: 12px; font-weight: 650; fill: var(--text); }
.topo .pdp__sub { font-size: 9.5px; fill: var(--muted); font-family: var(--mono); }
.topo .pdp__mode { font-size: 10px; font-weight: 650; font-family: var(--mono); }
.topo .edge__label { font-size: 9.5px; fill: var(--dim); font-family: var(--mono); }
.topo .hit { fill: transparent; cursor: pointer; }

/* ── Agents list ─────────────────────────────────────────── */
.agentlist { list-style: none; margin: 0; padding: 0; }
.agent {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-2);
}
.agent:last-child { border-bottom: 0; }
.agent__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.agent.is-paused .agent__dot { background: var(--warn); }
.agent.is-killed .agent__dot { background: var(--danger); }
.agent__body { min-width: 0; }
.agent__name { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.agent__id { font-family: var(--mono); font-size: 10.5px; color: var(--dim); font-weight: 500; }
.agent__meta { font-size: 11px; color: var(--muted); margin-top: 1px; display: flex; gap: 8px; flex-wrap: wrap; }
.agent__meta b { font-family: var(--mono); font-weight: 600; color: var(--text-2); }
.agent__state {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.03em;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-2);
}
.agent.is-paused .agent__state { color: var(--warn); border-color: var(--warn-line); background: var(--warn-soft); }
.agent.is-killed .agent__state { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.agent__btns { display: flex; gap: 4px; grid-column: 2 / span 2; }
.agent__btns .btn { height: 23px; padding: 0 8px; font-size: 11px; }

/* ── Tables ──────────────────────────────────────────────── */
.tablewrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.table th {
  text-align: left;
  padding: 8px 14px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
  color: var(--text-2);
}
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .c, .table th.c { text-align: center; }
.table .nowrap { white-space: nowrap; }
.table__empty td { color: var(--dim); padding: 22px 14px; text-align: center; }

.w-time { width: 88px; }
.w-agent { width: 132px; }
.w-action { width: 112px; }
.w-risk { width: 84px; }
.w-verdict { width: 92px; }
.w-sig { width: 160px; }
.w-seq { width: 62px; }
.w-type { width: 132px; }
.w-actor { width: 112px; }
.w-hash { width: 118px; }
.w-wait { width: 76px; }
.w-actions { width: 132px; }
.w-route { width: 150px; }
.w-cta { width: 132px; }

.cell-time { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.cell-agent { display: flex; align-items: center; gap: 7px; min-width: 0; }
.cell-agent i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); flex: none; }
.cell-agent span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-agent small { font-family: var(--mono); font-size: 10px; color: var(--dim); }
.cell-action { font-weight: 550; color: var(--text); white-space: nowrap; }
.cell-target {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-2);
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-reason { font-size: 11.5px; color: var(--muted); }

.tablefoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--muted);
}

/* verdict pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 19px;
  padding: 0 7px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill--allowed { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.pill--pending { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.pill--blocked { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
.pill--halted { color: var(--muted); background: var(--surface-3); border-color: var(--line-strong); }
.pill--audit { border-style: dashed; }

/* risk meter */
.risk { display: inline-flex; align-items: center; gap: 6px; }
.risk__bars { display: inline-flex; gap: 1.5px; }
.risk__bars i { width: 3px; height: 9px; border-radius: 1px; background: var(--line); }
.risk__label { font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--muted); }
.risk[data-level="1"] i.on, .risk[data-level="2"] i.on { background: var(--dim); }
.risk[data-level="3"] i.on { background: var(--warn); }
.risk[data-level="4"] i.on, .risk[data-level="5"] i.on { background: var(--danger); }

/* signature cell */
.sig { display: inline-flex; align-items: center; gap: 4px; }
.sig code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: -0.01em;
}
.copybtn {
  border: 0;
  background: none;
  color: var(--dim);
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
  display: inline-flex;
  opacity: 0;
  transition: opacity 0.12s ease;
}
tr:hover .copybtn, .copybtn:focus-visible { opacity: 1; }
.copybtn:hover { color: var(--accent); background: var(--accent-soft); }
.copybtn svg { width: 12px; height: 12px; }

/* ── Filters / chips ─────────────────────────────────────── */
.filters { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { color: var(--text); background: var(--surface-2); }
.chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 600;
}

/* ── Matrix ──────────────────────────────────────────────── */
.table--matrix td { padding: 9px 14px; }
.table--matrix { table-layout: fixed; }
.table--matrix th.c, .table--matrix td.c { width: 116px; }
.matrix__name { display: flex; flex-direction: column; gap: 1px; }
.matrix__name strong { font-size: 12.5px; font-weight: 600; color: var(--text); }
.matrix__name code { align-self: flex-start; font-size: 10.5px; color: var(--muted); background: none; border: 0; padding: 0; }
.matrix__risk { display: none; margin-top: 3px; }
.matrix__route { font-size: 11.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.table--matrix tr.is-flash td { background: var(--accent-soft); }

.radio {
  width: 20px;
  height: 20px;
  margin: 0 auto;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.radio:hover { border-color: var(--accent); }
.radio::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: transparent; }
.radio[aria-checked="true"] { border-color: var(--accent); border-width: 1.5px; }
.radio[aria-checked="true"]::after { background: var(--accent); }
.radio[data-mode="block"][aria-checked="true"] { border-color: var(--danger); }
.radio[data-mode="block"][aria-checked="true"]::after { background: var(--danger); }
.radio[data-mode="approve"][aria-checked="true"] { border-color: var(--warn); }
.radio[data-mode="approve"][aria-checked="true"]::after { background: var(--warn); }

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge--mode { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.badge--audit { color: var(--warn); border-color: var(--warn-line); background: var(--warn-soft); }
.badge--ok { color: var(--ok); border-color: var(--ok-line); background: var(--ok-soft); }

/* ── Timeline ────────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 8px 16px 14px; }
.timeline li {
  position: relative;
  padding: 8px 0 8px 16px;
  border-left: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -3.5px;
  top: 13px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
}
.timeline li:first-child::before { background: var(--accent); }
.timeline time { display: block; font-family: var(--mono); font-size: 10.5px; color: var(--dim); }
.timeline b { color: var(--text-2); font-weight: 600; }
.timeline .empty { border-left: 0; padding-left: 0; color: var(--dim); }
.timeline .empty::before { display: none; }

/* ── Key/value, code, checklist ──────────────────────────── */
.kv { margin: 0; padding: 6px 16px 12px; }
.kv > div {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 12px;
}
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); font-size: 11.5px; }
.kv dd { margin: 0; color: var(--text-2); font-size: 12px; overflow-wrap: anywhere; }

.code {
  margin: 4px 16px 16px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-2);
  overflow-x: auto;
  white-space: pre;
}

.cklist { list-style: none; margin: 0; padding: 8px 16px 14px; display: grid; gap: 7px; }
.cklist li { display: flex; gap: 8px; font-size: 11.5px; color: var(--text-2); line-height: 1.45; }
.cklist li svg { width: 13px; height: 13px; flex: none; margin-top: 2px; color: var(--ok); }
.cklist li small { display: block; color: var(--dim); font-family: var(--mono); font-size: 10.5px; }

/* ── Plans table ─────────────────────────────────────────── */
.table--plans td { padding: 11px 14px; }
.plan__name { font-weight: 600; color: var(--text); }
.plan__name small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.plan__price { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.plan__features { display: flex; flex-wrap: wrap; gap: 5px; }
.plan__features span {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 6px;
  background: var(--surface-2);
}

/* ── Toasts ──────────────────────────────────────────────── */
.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 36px));
}
.toast {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.12);
  font-size: 12px;
  color: var(--text-2);
}
.toast strong { color: var(--text); font-weight: 600; }
.toast--ok { border-left-color: var(--ok); }
.toast--warn { border-left-color: var(--warn); }
.toast--danger { border-left-color: var(--danger); }
.toast.is-out { opacity: 0; transform: translateY(4px); transition: opacity 0.25s ease, transform 0.25s ease; }

/* ── Footer ──────────────────────────────────────────────── */
.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-size: 11px;
  color: var(--dim);
}
.foot__left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.foot__left strong { color: var(--text-2); font-weight: 650; }
.foot__tenant { color: var(--dim); font-size: 10.5px; }
.foot__tenant b { color: var(--muted); font-weight: 600; }
.foot__right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.empty { color: var(--dim); font-size: 12px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 430px) {
  .rail__brandtext { display: none; }
  .rail__brand { padding: 8px; }
}
@media (max-width: 1320px) {
  .grid-split { grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr); }
  .metric { padding: 11px 13px 10px; }
  .metric__value { font-size: 20px; }
}

@media (max-width: 1080px) {
  .grid-split, .split { grid-template-columns: minmax(0, 1fr); }
  .card--side { align-self: stretch; }
  .statusbar__mid .stat--mode .stat__label { display: none; }
  .tenant-chip { display: none; }
}

@media (max-width: 860px) {
  :root { --rail-w: 0px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    z-index: 50;
  }
  .rail::-webkit-scrollbar { display: none; }
  .rail__brand { border-bottom: 0; padding: 8px 10px; flex: none; }
  .rail__brandtext strong { font-size: 12.5px; }
  .rail__brandtext small { display: none; }  .rail__tenant, .rail__foot, .nav__group { display: none; }
  .rail__nav { display: flex; align-items: center; gap: 2px; padding: 0 10px 0 0; flex: none; }
  .nav__item {
    padding: 7px 8px;
    margin: 0;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    white-space: nowrap;
    color: var(--muted);
    font-size: 12px;
  }
  .nav__item svg { display: none; }
  .nav__long { display: none; }
  .nav__short { display: inline; }
  .nav__item.is-active {
    background: none;
    border-color: transparent;
    border-bottom-color: var(--accent);
    color: var(--accent);
  }
  .nav__count { font-size: 10px; }

  .statusbar {
    flex-wrap: nowrap;
    min-height: 0;
    height: 48px;
    padding: 0 12px;
    gap: 8px;
  }
  .statusbar__left { display: none; }
  .statusbar__mid {
    order: 1;
    flex: 1 1 auto;
    margin-left: 0;
    padding: 0;
    border-top: 0;
    gap: 8px;
    overflow: hidden;
  }
  .statusbar__mid .stat--ledger,
  .statusbar__mid .stat__sep { display: none; }
  .statusbar__right { order: 2; }
  #kill-btn { height: 27px; font-size: 11.5px; padding: 0 9px; }

  .main { padding: 14px 12px 28px; gap: 12px; }
  .pagehead { gap: 10px; }
  .pagehead h1 { font-size: 17px; }
  .pagehead p { font-size: 12px; }
  .pagehead__actions { gap: 6px; }

  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: 10px 12px; }
  .metric:nth-child(odd) { border-left: 0; }
  .metric:nth-child(even) { border-left: 1px solid var(--line-2); }
  .metric:nth-child(n + 3) { border-top: 1px solid var(--line-2); }
  .metric:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .metric__value { font-size: 19px; }
  .metrics--4 .metric:nth-child(4) { border-left: 1px solid var(--line-2); }

  .card__head { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .legend { display: none; }
  .table th { padding: 7px 10px; }
  .table td { padding: 7px 10px; }
  .table { font-size: 11.5px; }
  .w-agent { width: 104px; }
  .w-action { width: 92px; }
  .w-sig { width: 108px; }
  .w-risk { width: 70px; }
  .cell-target { max-width: 160px; }
  .tablefoot { padding: 8px 12px; flex-wrap: wrap; gap: 4px; }
  .kv { padding: 4px 12px 10px; }
  .kv > div { grid-template-columns: 92px minmax(0, 1fr); }
  .code { margin: 4px 12px 12px; font-size: 10.5px; }
  .foot { padding: 12px; }
  .toasts { right: 10px; left: 10px; bottom: 10px; max-width: none; }
}

@media (max-width: 560px) {
  .w-sig { display: none; }
  .table--verdicts .w-sig + * { display: none; }
  .pagehead__actions .btn { height: 26px; padding: 0 9px; font-size: 11.5px; }
  .metric__value--text { font-size: 12.5px; }
  .agent { grid-template-columns: 8px minmax(0, 1fr); }
  .agent__btns { grid-column: 2; }
}

/* 좁은 화면: 넓은 원장·승인·플랜 표는 핵심 열만 남긴다. */
@media (max-width: 700px) {
  /* 감사 원장: 표 → 항목 카드(한 줄에 #·시각·유형, 아래 액터·내용) */
  .table--ledger thead { display: none; }
  .table--ledger,
  .table--ledger tbody { display: block; width: 100%; }
  .table--ledger tr {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto;
    grid-template-areas:
      "seq time type"
      "actor actor actor"
      "summary summary summary";
    gap: 2px 8px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line-2);
  }
  .table--ledger tr:hover td,
  .table--ledger tbody tr:hover td { background: none; }
  .table--ledger td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
    white-space: normal;
  }
  .table--ledger td:nth-child(1) { grid-area: seq; color: var(--dim); font-size: 11px; }
  .table--ledger td:nth-child(2) { grid-area: time; font-size: 11px; }
  .table--ledger td:nth-child(3) { grid-area: type; justify-self: end; }
  .table--ledger td:nth-child(4) { grid-area: actor; color: var(--dim); font-size: 10.5px; }
  .table--ledger td:nth-child(5) { grid-area: summary; margin-top: 3px; }
  .table--ledger td:nth-child(6),
  .table--ledger td:nth-child(7) { display: none; }
  .table--ledger .cell-target { white-space: normal; max-width: none; font-size: 11.5px; line-height: 1.5; overflow-wrap: anywhere; }
  .table--ledger .badge { height: 18px; font-size: 10px; }
}

/* 좁은 화면: 판정·승인 표는 두 줄 카드로(시각·에이전트·판정 / 액션·대상) */
@media (max-width: 700px) {
  .table--verdicts thead, .table--approvals thead { display: none; }
  .table--verdicts, .table--verdicts tbody,
  .table--approvals, .table--approvals tbody { display: block; width: 100%; }
  .table--verdicts tr,
  .table--approvals tr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 3px 8px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line-2);
  }
  .table--verdicts tr { grid-template-areas: "time agent verdict" "act target target"; }
  .table--approvals tr { grid-template-areas: "time agent actions" "act target target"; }
  .table--verdicts td,
  .table--approvals td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
    white-space: normal;
  }
  .table--verdicts td:nth-child(1), .table--approvals td:nth-child(1) { grid-area: time; font-size: 11px; }
  .table--verdicts td:nth-child(2), .table--approvals td:nth-child(2) { grid-area: agent; }
  .table--verdicts td:nth-child(3), .table--approvals td:nth-child(3) { grid-area: act; }
  .table--verdicts td:nth-child(4), .table--approvals td:nth-child(4) { grid-area: target; }
  .table--verdicts td:nth-child(5), .table--verdicts td:nth-child(7),
  .table--approvals td:nth-child(5), .table--approvals td:nth-child(6) { display: none; }
  .table--verdicts td:nth-child(6) { grid-area: verdict; justify-self: end; }
  .table--approvals td:nth-child(7) { grid-area: actions; justify-self: end; }
  .table--verdicts .cell-target, .table--approvals .cell-target {
    max-width: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
  }
  .table--approvals td:nth-child(3) { font-size: 12px; }
  .table--approvals .cell-agent small { display: none; }
  .table--approvals td:nth-child(1) { font-size: 10.5px; }
}

@media (max-width: 700px) {
  .view[data-view="approvals"] .table th:nth-child(5),
  .view[data-view="approvals"] .table td:nth-child(5),
  .view[data-view="approvals"] .table th:nth-child(6),
  .view[data-view="approvals"] .table td:nth-child(6) { display: none; }

  .table--plans th:nth-child(3), .table--plans td:nth-child(3) { display: none; }
  .table--plans .w-cta { width: 104px; }
  .table--matrix th:nth-child(5), .table--matrix td:nth-child(5) { display: none; }
  .table--matrix { table-layout: auto; }
  .table--matrix th.c, .table--matrix td.c { width: 60px; }
  .matrix__risk { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
