:root {
  color-scheme: light;
  --ink: #15140f;
  --muted: #66645b;
  --paper: #f6f4ef;
  --panel: #fffdf7;
  --line: #d8d0bf;
  --line-strong: #a69b84;
  --signal: #f0b429;
  --signal-dark: #8f5f00;
  --go: #167a4a;
  --stop: #bf3d32;
  --data: #276b8d;
  --steel: #353b3f;
  --black: #0d0d0b;
  --radius: 8px;
  --shadow: 0 20px 60px rgba(21, 20, 15, 0.12);
  --mono: "Cascadia Mono", "Consolas", monospace;
  --display: "Bahnschrift", "Aptos Display", "Segoe UI", sans-serif;
  --body: "Aptos", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(90deg, rgba(21, 20, 15, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(21, 20, 15, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: var(--body);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(240, 180, 41, 0.14), transparent 34%),
    #15140f;
  color: #fffdf7;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 253, 247, 0.28);
  background: var(--signal);
  color: var(--black);
  font-family: var(--display);
  font-weight: 800;
}

.brand strong {
  display: block;
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: 0;
}

.brand small {
  color: rgba(255, 253, 247, 0.68);
  font-size: 12px;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 34px;
}

.nav-link {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 12px;
  background: transparent;
  color: rgba(255, 253, 247, 0.82);
  text-align: left;
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  border-color: rgba(255, 253, 247, 0.18);
  background: rgba(255, 253, 247, 0.08);
  color: #fffdf7;
}

.nav-count {
  min-width: 28px;
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(255, 253, 247, 0.12);
  color: rgba(255, 253, 247, 0.76);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
}

.rail-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  border-top: 1px solid rgba(255, 253, 247, 0.14);
  padding-top: 16px;
  color: rgba(255, 253, 247, 0.74);
  font-size: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--signal);
  box-shadow: 0 0 0 4px rgba(240, 180, 41, 0.18);
}

.workspace {
  min-width: 0;
  padding: 28px clamp(18px, 3vw, 42px) 56px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--signal-dark);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--display);
  letter-spacing: 0;
}

h1 {
  max-width: 820px;
  font-size: clamp(34px, 4.2vw, 64px);
  line-height: 0.93;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 17px;
}

.topbar-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid var(--ink);
  padding: 10px 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--ink);
  color: #fffdf7;
}

.primary-button:hover {
  background: var(--steel);
}

.secondary-button {
  background: var(--panel);
  color: var(--ink);
}

.secondary-button:hover {
  border-color: var(--signal-dark);
  color: var(--signal-dark);
}

.secondary-button.danger {
  border-color: rgba(191, 61, 50, 0.42);
  color: var(--stop);
}

.text-button {
  border-color: transparent;
  background: transparent;
  color: var(--data);
  padding-inline: 4px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.metric-strip article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.76);
  padding: 16px;
}

.metric-strip span {
  display: block;
  font-family: var(--display);
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

.metric-strip p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.surface {
  grid-column: span 6;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.surface.full {
  grid-column: 1 / -1;
}

.surface.third {
  grid-column: span 4;
}

.surface-body {
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.section-head p:not(.eyebrow) {
  max-width: 740px;
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.stack-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stack-list li {
  border-left: 4px solid var(--signal);
  padding: 8px 10px;
  background: rgba(240, 180, 41, 0.11);
}

.stack-list strong {
  display: block;
}

.stack-list span {
  color: var(--muted);
}

.boundary-list li {
  border-left-color: var(--stop);
  background: rgba(191, 61, 50, 0.08);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  color: var(--steel);
  font-size: 13px;
  font-weight: 800;
}

.helper {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(240, 180, 41, 0.28);
  border-color: var(--signal-dark);
}

.checkbox-field {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.decision-output {
  display: grid;
  gap: 8px;
  min-height: 128px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f9f8f3;
  padding: 14px;
}

.decision-output strong {
  font-family: var(--display);
  font-size: 22px;
}

.decision-output.authorized {
  border-color: rgba(22, 122, 74, 0.35);
  background: rgba(22, 122, 74, 0.08);
}

.decision-output.denied {
  border-color: rgba(191, 61, 50, 0.35);
  background: rgba(191, 61, 50, 0.07);
}

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

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

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

th {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  padding: 3px 9px;
  background: #fff;
  color: var(--steel);
  font-size: 12px;
  font-weight: 800;
}

.badge.good {
  border-color: rgba(22, 122, 74, 0.34);
  color: var(--go);
}

.badge.warn {
  border-color: rgba(240, 180, 41, 0.55);
  color: var(--signal-dark);
}

.badge.stop {
  border-color: rgba(191, 61, 50, 0.36);
  color: var(--stop);
}

.empty-state {
  display: grid;
  gap: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.66);
  padding: 18px;
}

.empty-state strong {
  font-family: var(--display);
}

.empty-state span {
  color: var(--muted);
}

.record-title {
  display: grid;
  gap: 3px;
}

.record-title small,
.timestamp {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.notice {
  border-left: 4px solid var(--data);
  background: rgba(39, 107, 141, 0.1);
  padding: 12px;
  color: var(--steel);
}

.notice strong {
  display: block;
  margin-bottom: 4px;
}

.live-feed {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
}

.event-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.event-line.allowed {
  border-left-color: var(--go);
}

.event-line.denied {
  border-left-color: var(--stop);
}

.event-line div {
  display: grid;
  gap: 4px;
}

.event-line div:last-child {
  text-align: right;
}

.event-line span,
.event-line small {
  color: var(--muted);
}

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

.topology article {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
}

.topology article:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -13px;
  width: 13px;
  border-top: 2px solid var(--signal-dark);
}

.topology span {
  color: var(--signal-dark);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topology strong {
  font-family: var(--display);
  font-size: 20px;
  line-height: 1.1;
}

.topology small {
  color: var(--muted);
  line-height: 1.35;
}

.split-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.file-input {
  border: 1px dashed var(--line-strong);
  background: #fff;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rail-status {
    margin-top: 18px;
  }

  .surface,
  .surface.third {
    grid-column: 1 / -1;
  }

  .topology {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topology article::after {
    display: none;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding-inline: 14px;
  }

  .topbar,
  .section-head {
    display: grid;
  }

  .metric-strip,
  .form-grid,
  .form-grid.compact,
  .topology,
  .nav-list {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 38px;
  }
}
