:root {
  color-scheme: light;
  --ink: #101a2c;
  --muted: #667085;
  --line: #dfe5ec;
  --surface: #ffffff;
  --canvas: #f4f7fa;
  --blue: #1677ff;
  --purple: #7c4dff;
  --teal: #009e9a;
  --orange: #e87d12;
  --red: #c43d4b;
  --green: #087f5b;
  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; color: var(--ink); background: var(--canvas); min-width: 320px; }
button, a { font: inherit; }
a { color: inherit; }
.mail-flow { position: fixed; inset: 0; pointer-events: none; opacity: .45; background-image: linear-gradient(90deg, transparent 0 49%, rgba(22,119,255,.04) 50%, transparent 51%); background-size: 180px 100%; animation: flow 18s linear infinite; }
@keyframes flow { to { background-position: 180px 0; } }

.topbar { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; min-height: 72px; padding: 12px clamp(20px, 4vw, 64px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); }
.brand { display: inline-flex; align-items: center; gap: 12px; width: fit-content; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; background: var(--ink); color: white; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.system-state { display: flex; align-items: center; gap: 9px; color: #7a4b00; font-size: 13px; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; }
.state-dot--warning { background: #f2a71b; box-shadow: 0 0 0 5px rgba(242,167,27,.14); }
.repo-link { justify-self: end; font-size: 13px; font-weight: 650; text-underline-offset: 4px; }

main { position: relative; width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 42px; }
.command-bar { display: flex; justify-content: space-between; align-items: end; gap: 36px; padding-bottom: 30px; }
.eyebrow { margin: 0 0 10px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: 1.4px; }
h1, h2, p { letter-spacing: 0; }
h1 { max-width: 850px; margin: 0; font-size: clamp(38px, 5vw, 72px); line-height: .98; }
.lede { max-width: 760px; margin: 20px 0 0; color: var(--muted); font-size: 17px; line-height: 1.65; }
.gate-status { display: grid; grid-template-columns: auto auto; align-items: center; gap: 5px 12px; min-width: 220px; padding: 15px 0 5px 22px; border-left: 3px solid var(--green); }
.gate-status span:first-child { color: var(--muted); font-size: 12px; }
.gate-status strong { grid-column: 1; font-size: 18px; }
.gate-switch { grid-column: 2; grid-row: 1 / 3; display: block; width: 48px; height: 26px; padding: 3px; border-radius: 14px; background: var(--green); }
.gate-switch i { display: block; width: 20px; height: 20px; margin-left: 22px; border-radius: 50%; background: white; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); background: var(--surface); }
.metrics div { min-height: 118px; padding: 22px; border-right: 1px solid var(--line); }
.metrics div:last-child { border-right: 0; }
.metrics span, .metrics strong, .metrics small { display: block; }
.metrics span { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.metrics strong { margin: 13px 0 7px; font-size: 17px; }
.metrics small { color: var(--muted); }
.warning { color: var(--red); }
.healthy { color: var(--green); }

.workspace { display: grid; grid-template-columns: 150px minmax(0, 1.55fr) minmax(320px, .85fr); min-height: 560px; margin-top: 22px; border: 1px solid var(--line); background: var(--surface); }
.agent-tabs { border-right: 1px solid var(--line); }
.agent-tab { display: flex; align-items: center; gap: 12px; width: 100%; height: 78px; padding: 0 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--muted); text-align: left; cursor: pointer; }
.agent-tab:hover { background: #f8fafc; }
.agent-tab.active { border-left: 4px solid var(--agent-color, var(--blue)); background: #f3f7fb; color: var(--ink); font-weight: 750; }
.tab-index { font-size: 10px; font-variant-numeric: tabular-nums; }
.agent-detail { display: grid; grid-template-columns: minmax(250px, .9fr) minmax(280px, 1fr); gap: 40px; padding: 42px; border-right: 1px solid var(--line); }
.agent-visual { position: relative; min-height: 390px; overflow: hidden; background: #edf5ff; }
.agent-visual img { width: 100%; height: 100%; object-fit: cover; transition: opacity .18s ease; }
.authority { position: absolute; left: 18px; bottom: 18px; padding: 8px 11px; background: rgba(16,26,44,.9); color: white; font-size: 10px; font-weight: 800; letter-spacing: 1px; }
.agent-copy { align-self: center; }
.agent-copy h2, .decision-queue h2, .pipeline h2 { margin: 0; font-size: 27px; }
.agent-copy > p:not(.eyebrow) { margin: 14px 0 25px; color: var(--muted); line-height: 1.65; }
.contract-list { margin: 0; }
.contract-list div { padding: 15px 0; border-top: 1px solid var(--line); }
.contract-list dt { margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.contract-list dd { margin: 0; font-size: 14px; line-height: 1.5; }
.decision-queue { display: flex; flex-direction: column; padding: 28px; }
.queue-heading { display: flex; justify-content: space-between; align-items: start; gap: 18px; }
.queue-heading > span { color: var(--muted); font-size: 12px; }
.queue-empty { display: grid; place-items: center; align-content: center; flex: 1; padding: 40px 10px; text-align: center; }
.mail-icon { display: grid; place-items: center; width: 58px; height: 44px; margin-bottom: 18px; border: 2px solid var(--line); color: var(--blue); font-weight: 850; }
.queue-empty p { max-width: 260px; margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.approval-chain { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; text-transform: uppercase; }
.approval-chain i { flex: 1; height: 1px; background: var(--line); }

.pipeline { margin-top: 22px; padding: 34px; border: 1px solid var(--line); background: var(--surface); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 30px; }
.section-heading > p { max-width: 420px; margin: 0; color: var(--muted); font-size: 14px; }
.pipeline ol { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; margin: 30px 0 0; padding: 0; background: var(--line); list-style: none; }
.pipeline li { min-height: 130px; padding: 20px; background: white; }
.pipeline li.human { background: #effaf6; }
.pipeline span, .pipeline strong, .pipeline small { display: block; }
.pipeline span { color: var(--blue); font-size: 11px; font-weight: 800; }
.pipeline strong { margin: 28px 0 8px; font-size: 14px; }
.pipeline small { color: var(--muted); }

footer { position: relative; display: flex; justify-content: space-between; gap: 20px; padding: 26px clamp(20px, 4vw, 64px); border-top: 1px solid var(--line); color: var(--muted); background: white; font-size: 10px; letter-spacing: .6px; }

@media (max-width: 1100px) {
  .topbar { grid-template-columns: 1fr auto; }
  .system-state { grid-column: 1 / -1; grid-row: 2; padding-top: 8px; border-top: 1px solid var(--line); }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics div:nth-child(2) { border-right: 0; }
  .metrics div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .workspace { grid-template-columns: 120px 1fr; }
  .agent-detail { border-right: 0; }
  .decision-queue { grid-column: 1 / -1; min-height: 340px; border-top: 1px solid var(--line); }
}

@media (max-width: 720px) {
  .topbar { padding: 12px 18px; }
  .brand small, .repo-link { display: none; }
  main { width: min(100% - 24px, 1480px); padding-top: 32px; }
  .command-bar, .section-heading { display: block; }
  h1 { font-size: 43px; }
  .gate-status { margin-top: 28px; padding-left: 16px; }
  .metrics { grid-template-columns: 1fr; }
  .metrics div { min-height: 95px; border-right: 0; border-bottom: 1px solid var(--line); }
  .workspace { display: block; }
  .agent-tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-right: 0; border-bottom: 1px solid var(--line); }
  .agent-tab { justify-content: center; gap: 5px; height: 62px; padding: 0 5px; }
  .agent-tab.active { border-left: 0; border-bottom: 4px solid var(--agent-color, var(--blue)); }
  .agent-detail { display: block; padding: 18px; }
  .agent-visual { min-height: 330px; margin-bottom: 28px; }
  .decision-queue { padding: 22px; }
  .pipeline { padding: 24px 18px; }
  .section-heading > p { margin-top: 12px; }
  .pipeline ol { grid-template-columns: 1fr; }
  .pipeline li { min-height: 95px; }
  .pipeline strong { margin-top: 15px; }
  footer { display: block; line-height: 1.8; }
}
