:root {
  color-scheme: dark;
  --bg: #0c0e0d;
  --bg-grid: rgba(189, 176, 145, 0.045);
  --rail: #111413;
  --panel: #171b19;
  --panel-raised: #1d231f;
  --panel-soft: #222822;
  --line: #303730;
  --line-strong: #485147;
  --text: #eee9dc;
  --muted: #aaa392;
  --soft: #777c73;
  --brass: #c3a052;
  --blue: #6e9bb3;
  --green: #68ae7a;
  --red: #d16b5f;
  --amber: #d2a84a;
  --shadow: rgba(0, 0, 0, 0.32);
  --focus: #dbc36d;
  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;
  min-width: 320px;
  color: var(--text);
  letter-spacing: 0;
  background:
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px),
    linear-gradient(0deg, var(--bg-grid) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
}

a {
  color: inherit;
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

.app-frame {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--rail) 94%, black);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #222315;
  color: var(--brass);
  font-family: "Segoe UI", sans-serif;
  font-weight: 800;
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
  line-height: 1.15;
}

.brand-lockup strong {
  font-size: 15px;
}

.brand-lockup span {
  color: var(--muted);
  font-size: 12px;
}

.rail-nav {
  display: grid;
  gap: 4px;
  margin-top: 22px;
}

.rail-link {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.rail-link svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-link.active,
.rail-link:hover,
.rail-link:focus-visible {
  color: var(--text);
  border-color: var(--line);
  background: #191e1a;
  outline: none;
}

.rail-link.active {
  border-left-color: var(--brass);
}

.rail-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #151917;
}

.rail-footer span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #263126;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
}

.rail-footer strong {
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(250px, 0.9fr) minmax(360px, 1.4fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 82px;
  padding: 14px clamp(18px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(13, 16, 14, 0.94);
  backdrop-filter: blur(14px);
}

.eyebrow,
.label,
.section-kicker {
  color: var(--soft);
  font-size: 11px;
  text-transform: uppercase;
}

h1 {
  margin-top: 3px;
  font-size: 24px;
  line-height: 1.12;
  font-weight: 760;
}

h2 {
  font-size: 15px;
  line-height: 1.25;
  font-weight: 720;
}

.phase-rail {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  min-height: 46px;
}

.phase-step {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  background: #131715;
  color: var(--soft);
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.phase-step.active {
  color: var(--text);
  border-color: rgba(195, 160, 82, 0.72);
  background: #242114;
}

.phase-step.past {
  color: var(--green);
  border-color: rgba(104, 174, 122, 0.35);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.icon-button,
.text-link {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.text-link {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  text-decoration: none;
  font-size: 13px;
}

.icon-button:hover,
.icon-button:focus-visible,
.text-link:hover,
.text-link:focus-visible {
  border-color: var(--focus);
  outline: none;
}

.shell {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 22px clamp(16px, 3vw, 34px) 48px;
}

.command-deck {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(420px, 1.3fr) minmax(270px, 0.65fr);
  gap: 12px;
}

.action-panel,
.status-strip,
.permission-stack,
.operations-panel,
.action-row,
.track-card,
.table-wrap,
.gate-list,
.evidence-grid {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 94%, black);
  box-shadow: 0 18px 36px var(--shadow);
}

.action-panel {
  min-height: 132px;
  padding: 16px;
  border-left: 3px solid var(--brass);
}

.action-panel strong {
  display: block;
  margin-top: 11px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  overflow: hidden;
}

.status-strip > div {
  min-height: 132px;
  padding: 16px 14px;
  border-right: 1px solid var(--line);
}

.status-strip > div:last-child {
  border-right: 0;
}

.status-strip strong {
  display: block;
  margin-top: 11px;
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.permission-stack {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.pill {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
}

.pill strong {
  font-size: 12px;
}

.pill.ok strong {
  color: var(--green);
}

.pill.blocked strong {
  color: var(--red);
}

.ops-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 1.05fr);
  gap: 14px;
}

.section-head.compact {
  margin-bottom: 8px;
}

.operations-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  cursor: pointer;
}

.operation-cell {
  min-height: 72px;
  padding: 13px;
  border-right: 1px solid var(--line);
}

.operation-cell:last-child {
  border-right: 0;
}

.operation-cell span,
.operation-cell strong {
  display: block;
}

.operation-cell span {
  color: var(--soft);
  font-size: 10px;
  text-transform: uppercase;
}

.operation-cell strong {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}

.action-button {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #141816;
  color: var(--text);
  text-align: left;
  cursor: not-allowed;
  opacity: 0.92;
}

.action-button:hover,
.action-button:focus-visible,
.operations-panel:hover,
.operations-panel:focus-visible {
  border-color: var(--focus);
  outline: none;
}

.action-button span {
  font-size: 12px;
  color: var(--muted);
}

.action-button strong {
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.action-button.bad strong,
.action-button.blocked strong {
  color: var(--red);
}

.action-button.warn strong {
  color: var(--amber);
}

.action-button.ok strong {
  color: var(--green);
}

section {
  margin-top: 24px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  min-height: 28px;
  margin-bottom: 10px;
}

.track-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.track-card {
  min-height: 320px;
  padding: 16px;
  border-top-color: var(--line-strong);
  cursor: pointer;
}

.track-card:hover,
.track-card:focus-visible {
  border-color: var(--focus);
  outline: none;
}

.track-card.warn {
  border-top-color: rgba(210, 168, 74, 0.72);
}

.track-card.bad {
  border-top-color: rgba(209, 107, 95, 0.76);
}

.track-card.ok {
  border-top-color: rgba(104, 174, 122, 0.72);
}

.card-head {
  min-height: 50px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.track-name {
  font-size: 15px;
  font-weight: 760;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.badge {
  flex: 0 0 auto;
  max-width: 172px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
  text-align: right;
  overflow-wrap: anywhere;
}

.badge.ok {
  color: var(--green);
  border-color: rgba(104, 174, 122, 0.46);
}

.badge.warn {
  color: var(--amber);
  border-color: rgba(210, 168, 74, 0.46);
}

.badge.bad {
  color: var(--red);
  border-color: rgba(209, 107, 95, 0.5);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 15px;
}

.metrics div {
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #151a17;
}

.metrics dt {
  color: var(--soft);
  font-size: 10px;
  text-transform: uppercase;
}

.metrics dd {
  margin-top: 5px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.blocker-panel {
  min-height: 98px;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid rgba(209, 107, 95, 0.24);
  border-radius: 6px;
  background: rgba(65, 31, 27, 0.24);
}

.blockers {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.blockers li {
  margin-top: 6px;
  color: #e09990;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.next {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(330px, 0.55fr);
  gap: 14px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}

th {
  color: var(--soft);
  background: #121614;
  font-size: 10px;
  text-transform: uppercase;
}

td {
  color: var(--text);
  line-height: 1.35;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover td,
tbody tr:focus-visible td {
  background: rgba(195, 160, 82, 0.06);
}

tr.warn td:first-child {
  border-left: 2px solid var(--amber);
}

tr.bad td:first-child {
  border-left: 2px solid var(--red);
}

tr.ok td:first-child {
  border-left: 2px solid var(--green);
}

.gate-list {
  padding: 8px;
}

.gate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 54px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.gate-row:last-child {
  border-bottom: 0;
}

.gate-row.warn {
  border-left: 2px solid var(--amber);
}

.gate-row.bad {
  border-left: 2px solid var(--red);
}

.gate-row.ok {
  border-left: 2px solid var(--green);
}

.gate-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.gate-row strong {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.evidence-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}

.evidence-grid a,
.evidence-button {
  min-height: 52px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: var(--panel-soft);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.evidence-grid a:hover,
.evidence-grid a:focus-visible,
.evidence-button:hover,
.evidence-button:focus-visible {
  border-color: var(--focus);
  outline: none;
}

.evidence-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  background: rgba(0, 0, 0, 0.52);
}

.drawer-backdrop.open {
  display: block;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 31;
  width: min(760px, 92vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-left: 1px solid var(--line-strong);
  background: #101311;
  box-shadow: -24px 0 52px rgba(0, 0, 0, 0.42);
  transform: translateX(100%);
  transition: transform 160ms ease;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-head strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.drawer pre {
  margin: 0;
  padding: 16px;
  overflow: auto;
  color: #e4dcc8;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.error {
  color: var(--red);
}

@media (max-width: 1320px) {
  .app-frame {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .brand-lockup div,
  .rail-link span,
  .rail-footer strong {
    display: none;
  }

  .brand-lockup,
  .rail-link {
    justify-content: center;
  }

  .topbar {
    grid-template-columns: minmax(220px, 1fr) auto;
  }

  .phase-rail {
    grid-column: 1 / -1;
    order: 3;
  }

  .command-deck,
  .track-grid,
  .ops-grid,
  .evidence-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-frame,
  .two-col {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .rail-nav {
    display: flex;
    margin: 0 0 0 12px;
  }

  .rail-footer {
    margin: 0 0 0 auto;
  }

  .topbar,
  .status-strip,
  .operations-panel,
  .action-row {
    grid-template-columns: 1fr;
  }

  .status-strip > div {
    min-height: 74px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .status-strip > div:last-child {
    border-bottom: 0;
  }

  .operation-cell {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .operation-cell:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: start;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .phase-rail,
  .metrics {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 21px;
  }
}
