:root {
  /* Amber Peak Room — light theme */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --panel: #eef2f6;
  --border: #d5dde8;
  --ink: #1a2332;
  --muted: #5c6b7a;
  --peak: #c47b0a;
  --peak-soft: #f5a524;
  --telem: #0e7490;
  --telem-bright: #0891b2;
  --stage-1: #0f766e;
  --stage-2: #c47b0a;
  --stage-3: #dc2626;
  --ok: #15803d;
  --danger: #dc2626;
  --on-peak: #1a1205;
  --shadow: 0 10px 30px rgba(26, 35, 50, 0.08);
  --font: "IBM Plex Sans KR", "Public Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button {
  cursor: pointer;
  border: 0;
  border-radius: var(--radius);
  background: var(--peak-soft);
  color: var(--on-peak);
  font-weight: 600;
  padding: 10px 16px;
}
button.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}
button.ghost { background: var(--panel); color: var(--ink); }
button.danger { background: var(--stage-3); color: #fff; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:active:not(:disabled) {
  transform: scale(0.98);
  filter: brightness(0.96);
}
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--telem);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  button:active:not(:disabled) {
    transform: none;
  }
  .node-card:hover {
    transform: none;
  }
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Public landing */
.public-page {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 70% -10%, rgba(245,165,36,0.16), transparent),
    radial-gradient(ellipse 50% 40% at 10% 20%, rgba(8,145,178,0.08), transparent),
    var(--bg);
}
.public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
}
.public-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: max-content;
}
.btn-compact {
  white-space: nowrap;
  word-break: keep-all;
  flex-shrink: 0;
  padding: 10px 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
  min-width: 0;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--peak-soft), var(--peak));
  display: grid; place-items: center;
  color: var(--on-peak);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}
.hero {
  padding: 64px clamp(20px, 5vw, 72px) 40px;
  max-width: 1180px;
}
.hero-split {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 28px;
  align-items: start;
}
.hero-copy { min-width: 0; }
.section-lead { margin: -4px 0 16px; max-width: 62ch; }
.explain-flow-head {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 32px;
  align-items: end;
  margin-bottom: 20px;
}
.explain-flow-head h2 { margin-bottom: 0; }
.explain-flow-head .section-lead { margin: 0; }
.explain-ledger {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--ink);
}
.explain-ledger li {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) minmax(150px, 0.28fr);
  gap: 16px;
  align-items: center;
  padding: 18px 4px;
  border-bottom: 1px solid var(--border);
}
.flow-index { color: var(--peak); font-weight: 700; }
.explain-ledger strong { display: block; margin-bottom: 3px; }
.explain-ledger p { margin: 0; color: var(--muted); font-size: 0.94rem; }
.flow-proof {
  justify-self: end;
  color: var(--telem);
  font-family: var(--mono);
  font-size: 0.78rem;
  text-align: right;
}
.explain-boundary {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 18px;
  margin-top: 20px;
  padding: 16px 18px;
  background: var(--panel);
  border-left: 3px solid var(--peak);
  font-size: 0.9rem;
}
@media (max-width: 720px) {
  .explain-flow-head { grid-template-columns: 1fr; gap: 10px; }
  .explain-ledger li { grid-template-columns: 38px minmax(0, 1fr); gap: 10px; }
  .flow-proof { grid-column: 2; justify-self: start; text-align: left; }
  .explain-boundary { grid-template-columns: 1fr; gap: 4px; }
  .explain-boundary strong:not(:first-child) { margin-top: 8px; }
}
.hero-diagram {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.arch-full-wrap {
  margin-top: 8px;
}
@media (max-width: 960px) {
  .hero-split { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  /* Keep CTA on one line at 390px; do not wrap mid-phrase */
  .public-header {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 14px 16px;
  }
  .public-header-actions {
    width: auto;
    flex-shrink: 0;
    justify-content: flex-end;
  }
  .public-header .badge.sim {
    display: none; /* free horizontal room for single-line CTA */
  }
  .brand {
    gap: 8px;
    font-size: 0.92rem;
  }
  .btn-compact {
    padding: 9px 12px;
    font-size: 0.875rem;
    white-space: nowrap;
    word-break: keep-all;
  }
  .hero-actions button {
    white-space: nowrap;
    word-break: keep-all;
  }
}

/* ── System map (high-quality architecture diagram) ── */
.sysmap {
  position: relative;
  background:
    radial-gradient(ellipse 90% 60% at 50% 0%, rgba(245,165,36,0.10), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(14,116,144,0.08), transparent 50%),
    linear-gradient(165deg, #ffffff 0%, #f7f9fc 48%, #eef3f8 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 16px 14px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.9) inset,
    0 18px 40px rgba(26, 35, 50, 0.08);
  overflow: hidden;
}
.sysmap::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(26,35,50,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26,35,50,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 20%, transparent 75%);
  pointer-events: none;
}
.sysmap-full {
  padding: 22px 22px 18px;
  border-radius: 18px;
}
.sysmap-header {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.sysmap-eyebrow {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--peak);
  margin-bottom: 4px;
}
.sysmap-title {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  word-break: keep-all;
}
.sysmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.leg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}
.leg i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.leg-vtn i { background: #0e7490; box-shadow: 0 0 0 3px rgba(14,116,144,0.15); }
.leg-ven i { background: #c47b0a; box-shadow: 0 0 0 3px rgba(196,123,10,0.15); }
.leg-field i { background: #5c6b7a; box-shadow: 0 0 0 3px rgba(92,107,122,0.12); }

.sysmap-canvas {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0;
}
.sysmap-layer {
  position: relative;
}
.layer-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--border);
}
.layer-tag.accent {
  color: var(--peak);
  border-color: rgba(196,123,10,0.35);
  background: rgba(245,165,36,0.12);
}
.layer-tag.field {
  color: var(--telem);
  border-color: rgba(14,116,144,0.3);
  background: rgba(8,145,178,0.08);
}

.node-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px 14px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.88);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(26,35,50,0.05);
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
}
.node-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(26,35,50,0.08);
}
.node-vtn {
  border-color: rgba(14,116,144,0.35);
  background: linear-gradient(145deg, rgba(224,247,250,0.95), rgba(255,255,255,0.96) 55%);
}
.node-ven {
  border-color: rgba(196,123,10,0.4);
  background: linear-gradient(145deg, rgba(255,247,230,0.98), rgba(255,255,255,0.98) 50%);
  box-shadow:
    0 0 0 1px rgba(245,165,36,0.12),
    0 14px 32px rgba(196,123,10,0.1);
}
.node-ems, .node-field {
  border-color: rgba(14,116,144,0.22);
}
.node-glow {
  position: absolute;
  width: 120px;
  height: 80px;
  right: -20px;
  top: -30px;
  background: radial-gradient(circle, rgba(14,116,144,0.16), transparent 70%);
  pointer-events: none;
}
.node-glow.amber {
  background: radial-gradient(circle, rgba(245,165,36,0.22), transparent 70%);
}
.node-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--telem);
  background: rgba(8,145,178,0.1);
  border: 1px solid rgba(14,116,144,0.18);
  flex-shrink: 0;
}
.node-icon.amber {
  color: var(--peak);
  background: rgba(245,165,36,0.16);
  border-color: rgba(196,123,10,0.25);
}
.node-icon.teal {
  color: var(--telem);
  background: rgba(8,145,178,0.08);
}
.node-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.role-pill {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.role-pill.vtn {
  color: #0e7490;
  background: rgba(8,145,178,0.12);
  border-color: rgba(14,116,144,0.25);
}
.role-pill.ven {
  color: #9a5b08;
  background: rgba(245,165,36,0.18);
  border-color: rgba(196,123,10,0.3);
}
.role-pill.core {
  color: #1a1205;
  background: var(--peak-soft);
  border-color: transparent;
}
.role-pill.field {
  color: var(--muted);
  background: var(--panel);
  border-color: var(--border);
}
.role-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}
.node-name {
  margin: 0 0 4px;
  font-size: 1rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  word-break: keep-all;
}
.node-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
  word-break: keep-all;
}
.node-chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
}
.node-chips li {
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(14,116,144,0.08);
  color: var(--telem);
  border: 1px solid rgba(14,116,144,0.12);
}
.node-chips.quiet li {
  background: var(--panel);
  color: var(--muted);
  border-color: var(--border);
}
.node-pipeline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 2px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(26,35,50,0.03);
  border: 1px dashed rgba(196,123,10,0.28);
}
.node-pipeline span {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink);
  padding: 2px 6px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid var(--border);
}
.node-pipeline i {
  width: 10px;
  height: 1.5px;
  background: var(--peak-soft);
  display: inline-block;
  border-radius: 1px;
}
.node-stack {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--telem);
}

.sysmap-link {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 6px 0 8px;
  position: relative;
}
.link-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  height: 28px;
}
.link-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--telem);
  box-shadow: 0 0 0 4px rgba(14,116,144,0.12);
}
.link-line {
  width: 2px;
  flex: 1;
  background: linear-gradient(180deg, var(--telem), var(--peak));
  border-radius: 2px;
}
.link-arrow {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--peak);
}
.link-label-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(14,116,144,0.28);
  box-shadow: 0 6px 16px rgba(14,116,144,0.08);
}
.link-label-card.openadr .link-proto {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--telem);
  letter-spacing: 0.04em;
}
.link-flow {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  word-break: keep-all;
}

.sysmap-link.fork {
  padding: 2px 0 4px;
}
.fork-svg {
  display: block;
  max-width: 420px;
  margin: 0 auto;
}
.fork-labels {
  display: flex;
  justify-content: space-between;
  max-width: 420px;
  width: 100%;
  margin: -4px auto 0;
  padding: 0 8px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}
.fork-lab.left { color: var(--telem); }
.fork-lab.right { color: var(--telem); text-align: right; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 640px) {
  .field-grid { grid-template-columns: 1fr; }
  .node-card { grid-template-columns: 1fr; }
  .fork-labels { flex-direction: column; gap: 2px; align-items: center; }
  .fork-lab.right { text-align: center; }
}

.sysmap-mini-note {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.75);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  word-break: keep-all;
}
.sysmap-mini-note .mono {
  color: var(--ink);
  font-weight: 600;
}
.sysmap-footnote {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
@media (max-width: 800px) {
  .sysmap-footnote { grid-template-columns: 1fr; }
}
.fn-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--border);
}
.fn-item strong {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.fn-item span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  word-break: keep-all;
}

.sysmap-compact .node-desc { font-size: 12px; }
.sysmap-compact .node-chips li { font-size: 9.5px; }
.sysmap-compact .node-name { font-size: 0.95rem; }
.hero .eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--peak);
  margin-bottom: 16px;
}
.hero h1 {
  font-size: clamp(2rem, 4.5vw, 3.1rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  word-break: keep-all;
  margin: 0 0 18px;
  max-width: 16ch;
}
.hero .lead {
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 52ch;
  margin-bottom: 28px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.section {
  padding: 28px clamp(20px, 5vw, 72px) 8px;
  max-width: 1100px;
}
.section h2 {
  font-size: 1.45rem;
  line-height: 1.12;
  word-break: keep-all;
  margin: 0 0 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 900px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.card h3 { margin: 0 0 8px; font-size: 1.05rem; word-break: keep-all; }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.demo-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.demo-card .creds {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--panel);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--telem);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--panel);
}
.badge.sim { color: var(--telem); border-color: rgba(14,116,144,0.35); background: rgba(8,145,178,0.06); }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--peak); }
.badge.crit { color: var(--stage-3); }
.footer-note {
  padding: 40px clamp(20px, 5vw, 72px) 56px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(245,165,36,0.18), transparent),
    var(--bg);
}
.login-panel {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}
.login-panel h1 {
  font-size: 1.5rem;
  line-height: 1.15;
  word-break: keep-all;
  margin: 0 0 8px;
}
.login-panel form { display: grid; gap: 12px; margin-top: 18px; }
.login-panel label { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.login-panel input {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  padding: 12px;
}
.autofill-row { display: grid; gap: 8px; margin-top: 8px; }
.autofill-row button { width: 100%; justify-content: center; }

/* App shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 76px 1fr;
}
.nav {
  background: #e8edf3;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 6px;
}
.nav a, .nav button.linkish {
  width: 52px;
  height: 48px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 11px;
  text-align: center;
  line-height: 1.15;
  position: relative;
  box-shadow: none;
}
.nav a:hover {
  background: var(--panel);
  color: var(--ink);
}
.nav a.active {
  background: rgba(245, 165, 36, 0.16);
  color: var(--ink);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--peak);
}
.nav a.active::after {
  content: "";
  position: absolute;
  bottom: 6px;
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--peak);
}
.nav .spacer { flex: 1; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.92);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(8px);
}
.topbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.workspace {
  padding: 18px 20px 40px;
  flex: 1;
}
.workspace h1 {
  font-size: 1.55rem;
  line-height: 1.12;
  word-break: keep-all;
  margin: 0 0 6px;
}
.workspace .sub { color: var(--muted); margin-bottom: 18px; }
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.kpi .label { color: var(--muted); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; font-family: var(--mono); }
.kpi .value { font-family: var(--mono); font-size: 1.55rem; margin-top: 6px; color: var(--telem-bright); }
.kpi .value.peak { color: var(--peak); }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
}
@media (max-width: 1000px) {
  .dash-grid { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .nav {
    flex-direction: row;
    overflow-x: auto;
    justify-content: flex-start;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .nav a.active {
    box-shadow: inset 0 -3px 0 var(--peak);
  }
  .nav a.active::after {
    display: none;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.panel h2 {
  font-size: 1rem;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.gauge-wrap {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 12px 0 4px;
}
.gauge {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  /* live fill vs remainder; over-threshold uses peak/danger */
  background:
    conic-gradient(
      var(--gauge-fill, var(--telem-bright)) calc(var(--pct) * 1%),
      var(--panel) 0
    );
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: 0 0 0 1px var(--border);
}
.gauge.over {
  --gauge-fill: var(--peak);
  box-shadow: 0 0 0 2px rgba(196, 123, 10, 0.35);
}
.gauge.ok {
  --gauge-fill: var(--telem-bright);
}
.gauge::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: var(--surface);
}
/* Threshold reference ring (full circle mark) */
.gauge::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px dashed rgba(196, 123, 10, 0.45);
  pointer-events: none;
}
.gauge-inner {
  position: relative;
  text-align: center;
  z-index: 1;
}
.gauge-inner .num {
  font-family: var(--mono);
  font-size: 1.8rem;
  color: var(--telem);
}
.gauge.over .gauge-inner .num { color: var(--peak); }
.gauge-inner .unit { color: var(--muted); font-size: 12px; }
.gauge-status {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  display: inline-block;
}
.gauge-status.ok {
  color: var(--ok);
  background: rgba(21, 128, 61, 0.1);
}
.gauge-status.over {
  color: #9a5b08;
  background: rgba(245, 165, 36, 0.18);
}
.gauge-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  font-size: 12px;
  color: var(--muted);
}
.gauge-meta b {
  font-family: var(--mono);
  color: var(--ink);
  font-weight: 600;
}
.ribbon-idle .ribbon-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.ribbon-idle .ribbon-cta .v {
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: keep-all;
}

.spark {
  width: 100%;
  height: 72px;
  display: block;
}
.ribbon {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(245,165,36,0.14), rgba(8,145,178,0.06));
  border: 1px solid rgba(196,123,10,0.35);
  margin-bottom: 12px;
  align-items: center;
}
.ribbon-idle {
  background: linear-gradient(90deg, rgba(213,221,232,0.65), rgba(8,145,178,0.05));
  border-color: var(--border);
}
.ribbon .item { min-width: 120px; }
.ribbon .item .k { color: var(--muted); font-size: 11px; font-family: var(--mono); text-transform: uppercase; }
.ribbon .item .v { font-family: var(--mono); margin-top: 2px; }
.btn-inline {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
}

/* EMS adapter rail + DR pipeline on dashboard */
.adapter-rail,
.pipeline-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.adapter-rail-head,
.pipeline-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.adapter-rail-head strong,
.pipeline-head strong {
  font-size: 0.95rem;
}
.adapter-rail-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 1100px) {
  .adapter-rail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .adapter-rail-grid { grid-template-columns: 1fr; }
}
.adapter-chip {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  min-height: 96px;
}
.adapter-chip-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}
.adapter-name {
  font-weight: 600;
  font-size: 0.9rem;
  word-break: keep-all;
}
.adapter-status {
  color: var(--ok);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.adapter-chip.status-empty .adapter-status,
.adapter-chip.status-TBD .adapter-status,
.adapter-chip.status-unconfigured .adapter-status {
  color: var(--peak);
}
.adapter-detail { font-size: 12px; margin-top: 2px; }
.adapter-tbd {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.pipeline-steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
}
@media (max-width: 1000px) {
  .pipeline-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.pipe-step {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 10px 12px;
  min-height: 92px;
}
.pipe-step.done {
  border-color: rgba(34,197,94,0.45);
  box-shadow: inset 0 0 0 1px rgba(34,197,94,0.12);
}
.pipe-step.idle {
  opacity: 0.92;
}
.pipe-idx {
  display: inline-flex;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg);
  color: var(--peak);
  margin-bottom: 6px;
}
.pipe-step.done .pipe-idx {
  background: rgba(34,197,94,0.18);
  color: var(--ok);
}
.pipe-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  word-break: keep-all;
}
.pipe-hint {
  display: block;
  font-size: 11px;
  margin-top: 4px;
  line-height: 1.35;
}
.pipe-state {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}
.pipe-step.done .pipe-state { color: var(--ok); }
.pipeline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tree-list { display: grid; gap: 8px; }
.tree-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.stage-dot {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff;
}
.stage-dot.s1 { background: var(--stage-1); }
.stage-dot.s2 { background: var(--stage-2); color: var(--on-peak); }
.stage-dot.s3 { background: var(--stage-3); color: #fff; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.table th, .table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: 10px;
  z-index: 50;
  max-width: 360px;
  box-shadow: var(--shadow);
}
.toast.error { border-color: var(--stage-3); }
.role-home-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.role-home-actions a {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  transition: border-color 0.15s;
}
.role-home-actions a:hover { border-color: var(--peak); }
.role-home-actions strong { display: block; margin-bottom: 6px; }
.role-home-actions span { color: var(--muted); font-size: 0.9rem; }

.empty {
  color: var(--muted);
  padding: 20px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

/* Customer-operated, offline-first DR decision playground */
.playground {
  border: 1px solid color-mix(in srgb, var(--peak) 38%, var(--border));
  border-radius: 18px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--peak) 7%, var(--surface)), var(--surface) 52%);
  box-shadow: var(--shadow);
}
.playground-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.playground-head h2 { margin-top: 6px; }
.playground-layout { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(280px, 1fr) minmax(280px, 1.15fr); gap: 14px; margin-top: 22px; }
.playground-inputs, .playground-run, .playground-output { padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.playground-inputs fieldset { margin: 0 0 16px; padding: 0; border: 0; }
.playground-inputs legend { margin-bottom: 10px; font-weight: 700; }
.playground-inputs label { display: grid; gap: 5px; margin-bottom: 9px; color: var(--muted); font-size: .84rem; }
.playground-inputs input[type="number"] { width: 100%; }
.stage-choice { display: grid; gap: 6px; }
.stage-choice label { grid-template-columns: auto 1fr; align-items: center; color: var(--ink); }
.input-hint { margin: 8px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.playground-guide { padding: 13px; background: var(--panel); border-radius: 9px; }
.playground-guide ol { margin: 8px 0; padding-left: 20px; color: var(--muted); font-size: .86rem; }
.playground-guide p { margin: 10px 0 0; color: var(--peak); font-weight: 650; font-size: .84rem; }
.playground-actions { display: grid; gap: 7px; margin-top: 12px; }
.playground-actions button:disabled { opacity: .42; cursor: not-allowed; }
.playground-failures { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.playground-failures span { grid-column: 1 / -1; color: var(--muted); font-size: .78rem; font-weight: 700; }
.playground-output { display: flex; flex-direction: column; align-items: flex-start; }
.playground-status { padding: 4px 8px; border-radius: 999px; background: var(--panel); color: var(--telem); font: 700 .72rem var(--mono); }
.playground-output.is-failure { border-color: var(--stage-3); }
.playground-output.is-failure .playground-status { color: var(--stage-3); }
.playground-output h3 { margin: 14px 0 8px; font-size: 1.15rem; }
.playground-output dl { width: 100%; display: grid; gap: 8px; margin: 14px 0; }
.playground-output dl div { padding: 10px; border-left: 3px solid var(--peak); background: var(--panel); }
.playground-output dt { color: var(--muted); font-size: .75rem; }
.playground-output dd { margin: 4px 0 0; font-weight: 650; }
.playground-explain { margin-top: auto; color: var(--muted); font-size: .82rem; }
#pg-recover { margin-top: 12px; }

@media (max-width: 1040px) {
  .playground-layout { grid-template-columns: 1fr 1fr; }
  .playground-output { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .playground-head { display: grid; }
  .playground-layout { grid-template-columns: 1fr; }
  .playground-output { grid-column: auto; min-height: 330px; }
}
@media (max-width: 420px) {
  .playground { padding-left: 14px; padding-right: 14px; }
  .playground-inputs, .playground-run, .playground-output { padding: 14px; }
  .playground-failures { grid-template-columns: 1fr; }
  .playground-failures span { grid-column: auto; }
}
