:root {
  color-scheme: dark;
  --bg: #07110f;
  --surface: #0d1916;
  --surface-2: #12211d;
  --line: #20332d;
  --line-strong: #315146;
  --text: #f3f7f5;
  --muted: #8fa49d;
  --green: #60d394;
  --green-dark: #153d2b;
  --amber: #f1bb61;
  --red: #ff7b72;
  --red-dark: #44211f;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); min-width: 320px; }
button, textarea { font: inherit; }
button { color: inherit; }
.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 20; background: white; color: #07110f; padding: .7rem 1rem; border-radius: 8px; }
.skip-link:focus { top: 1rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); background: #091512; padding: 28px 18px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 28px; font-size: 17px; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--green); color: #06110d; font-weight: 900; }
.brand small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 5px; }
.nav-link { display: flex; gap: 12px; align-items: center; padding: 11px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-size: 14px; }
.nav-link span { font: 10px ui-monospace, monospace; color: #5c766d; }
.nav-link:hover, .nav-link:focus-visible { background: var(--surface-2); color: var(--text); outline: none; }
.nav-link.active { color: var(--text); background: #14251f; box-shadow: inset 2px 0 var(--green); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 18px 10px 0; }
.sidebar-foot p { color: var(--muted); font-size: 12px; margin: 8px 0 0 16px; }
.mini-status, .market-state { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot.healthy { background: var(--green); box-shadow: 0 0 0 4px rgba(96, 211, 148, .08); }
.dot.idle { background: var(--amber); }

main { min-width: 0; padding: 0 34px 48px; }
.topbar { min-height: 102px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 22px; margin: 4px 0 0; letter-spacing: -.02em; }
.eyebrow { margin: 0; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface-2); font-size: 12px; font-weight: 700; }

.safety-banner { margin: 24px 0 18px; min-height: 70px; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border: 1px solid #6c3934; background: linear-gradient(90deg, rgba(92, 39, 35, .52), rgba(19, 31, 27, .55)); border-radius: var(--radius); }
.safety-banner > div { display: flex; align-items: center; gap: 12px; }
.status-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--red-dark); color: var(--red); font-weight: 800; }
.safety-banner strong, .safety-banner small { display: block; }
.safety-banner strong { font-size: 14px; }
.safety-banner small { color: #b99a96; margin-top: 3px; }
.safety-banner.permitted { border-color: #2e6a4b; background: linear-gradient(90deg, rgba(28, 78, 52, .45), rgba(19, 31, 27, .55)); }
.safety-banner.permitted .status-icon { background: var(--green-dark); color: var(--green); }

.button { border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 13px; background: var(--surface-2); cursor: pointer; font-size: 12px; font-weight: 700; }
.button:hover, .button:focus-visible { border-color: var(--green); outline: none; }
.button:disabled { cursor: not-allowed; opacity: .58; border-color: var(--line-strong); }
.button.danger { border-color: #75413c; background: #2b1b19; color: #ffd0cc; }
.button.ghost { background: transparent; }
.text-button { border: 0; background: transparent; color: var(--green); cursor: pointer; font-size: 12px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.metric-card { padding: 18px 20px; background: var(--surface); border-right: 1px solid var(--line); }
.metric-card:last-child { border-right: 0; }
.metric-card p { color: var(--muted); font-size: 11px; margin: 0 0 8px; }
.metric-card strong { display: block; font-size: 20px; letter-spacing: -.02em; }
.metric-card small { display: block; color: #698078; font-size: 10px; margin-top: 5px; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(290px, .75fr); gap: 18px; margin-top: 18px; }
.primary-column, .right-rail { display: grid; align-content: start; gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel.compact { padding-bottom: 4px; }
.panel-heading { min-height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 4px 0 0; font-size: 15px; letter-spacing: -.01em; }
.tag { border-radius: 999px; padding: 5px 8px; font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.tag.muted { background: #282f2d; color: #b7c1be; }
.tag.safe { background: var(--green-dark); color: var(--green); }
.market-tape { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.market-tape div { padding: 14px 20px; border-right: 1px solid var(--line); }
.market-tape div:last-child { border-right: 0; }
.market-tape span, .market-tape strong, .market-tape small { display: block; }
.market-tape span { color: var(--muted); font-size: 10px; }
.market-tape strong { margin: 6px 0 4px; font-size: 13px; }
.market-tape small { color: #61776f; font-size: 9px; }
.empty-state { min-height: 250px; display: grid; place-items: center; align-content: center; text-align: center; padding: 30px; }
.empty-state h3 { margin: 14px 0 6px; font-size: 15px; }
.empty-state p { max-width: 510px; margin: 0; color: var(--muted); line-height: 1.6; font-size: 12px; }
.empty-glyph { display: grid; place-items: center; width: 50px; height: 50px; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--green); font-size: 24px; }

.timeline { list-style: none; margin: 0; padding: 8px 20px 18px; }
.timeline li { display: grid; grid-template-columns: 16px 1fr auto; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: #50665e; }
.timeline-dot.safe { background: var(--green); }
.timeline strong { font-size: 12px; }
.timeline p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.timeline time { color: #60756e; font: 9px ui-monospace, monospace; }

.gate-list { list-style: none; padding: 8px 20px; margin: 0; }
.gate-list li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.gate-list li:last-child { border-bottom: 0; }
.gate-list span { color: var(--muted); }
.gate-list strong { font-size: 10px; }
.blocked { color: var(--red); }.pending { color: var(--amber); }.passed { color: var(--green); }
.agent-stack { padding: 8px 20px; }
.agent-stack > div { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 9px 0; }
.agent-initial { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: #1c302a; color: #9fb5ad; font-size: 10px; font-weight: 800; }
.agent-initial.risk { background: var(--green-dark); color: var(--green); }
.agent-stack p, .agent-stack strong, .agent-stack small { display: block; margin: 0; }
.agent-stack strong { font-size: 11px; }.agent-stack small { color: var(--muted); margin-top: 2px; font-size: 9px; }
.system-card { padding: 18px 20px; }
.system-card dl { margin: 12px 0 0; }
.system-card dl div { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 10px; }
.system-card dl div:last-child { border-bottom: 0; }
.system-card dt { color: var(--muted); }.system-card dd { margin: 0; font-weight: 700; }

.capability-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.capability-body { padding: 18px 20px 20px; }
.capability-body > p { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 0 0 14px; }
.validation-chart { margin: 0 0 16px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #091411; }
.validation-chart figcaption { color: var(--muted); font-size: 9px; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .1em; }
.validation-chart svg { display: block; width: 100%; height: 112px; }
.chart-axis { stroke: var(--line-strong); stroke-width: 1; }.chart-line { fill: none; stroke: var(--green); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-empty { fill: #60756e; font: 11px ui-sans-serif, system-ui; }
.feature-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; list-style: none; margin: 0; padding: 0; }
.feature-list li { position: relative; padding-left: 15px; color: #bed0ca; font-size: 10px; line-height: 1.45; }
.feature-list li::before { content: ""; position: absolute; top: .47em; left: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.notification-list { list-style: none; margin: 0; padding: 0; max-height: 270px; overflow: auto; }
.notification-list li { display: grid; gap: 4px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.notification-list li:last-child { border-bottom: 0; }
.notification-list strong { font-size: 11px; }.notification-list small { color: var(--muted); font-size: 9px; line-height: 1.45; }
.notification.critical { border-left: 2px solid var(--red); padding-left: 10px; }
.notification.warning { border-left: 2px solid var(--amber); padding-left: 10px; }
.notification.info { border-left: 2px solid var(--green); padding-left: 10px; }

dialog { width: min(480px, calc(100% - 32px)); border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; box-shadow: 0 24px 80px rgba(0,0,0,.55); }
dialog::backdrop { background: rgba(0, 7, 5, .78); backdrop-filter: blur(3px); }
dialog form { padding: 24px; }
.dialog-heading h2 { margin: 6px 0 0; font-size: 20px; }
dialog form > p { color: var(--muted); line-height: 1.55; font-size: 12px; }
dialog label { display: block; font-size: 11px; font-weight: 700; margin: 18px 0 7px; }
dialog textarea { width: 100%; min-height: 100px; resize: vertical; border: 1px solid var(--line-strong); border-radius: 9px; background: #091411; color: var(--text); padding: 12px; }
dialog textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@media (max-width: 1040px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card:nth-child(2) { border-right: 0; }.metric-card:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .content-grid { grid-template-columns: 1fr; }
  .capability-layout { grid-template-columns: 1fr; }
  .right-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .system-card { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 16px; }
  .sidebar nav { grid-template-columns: repeat(3, 1fr); }.sidebar-foot { display: none; }
  .brand { padding-bottom: 16px; }
  .nav-link { justify-content: center; }.nav-link span { display: none; }
  main { padding: 0 16px 32px; }.topbar { min-height: 82px; }.topbar .eyebrow { display: none; }
  .market-state { display: none; }.safety-banner { align-items: flex-start; gap: 14px; flex-direction: column; }
  .metric-grid, .right-rail { grid-template-columns: 1fr; }.metric-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric-card:last-child { border-bottom: 0; }.market-tape { grid-template-columns: repeat(2, 1fr); }
  .market-tape div:nth-child(2) { border-right: 0; }.market-tape div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .system-card { grid-column: auto; }.timeline li { grid-template-columns: 14px 1fr; }.timeline time { display: none; }
  .feature-list { grid-template-columns: 1fr; }
}
