:root {
  color-scheme: light;
  --ink: #22223b;
  --paper: #fefae0;
  --olive: #606c38;
  --ochre: #dda15e;
  --line: rgba(34, 34, 59, 0.16);
  --muted: rgba(34, 34, 59, 0.62);
  --surface: #fffdf0;
  --white: #ffffff;
  --danger: #a33f32;
  --blueprint: #335c67;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background:
    linear-gradient(90deg, rgba(34, 34, 59, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(34, 34, 59, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.rail {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px;
  background: var(--ink);
  color: var(--paper);
}

.brand {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand strong {
  display: block;
  font-size: 18px;
  letter-spacing: 0;
}

.brand small,
.rail-ledger,
.eyebrow,
.mono,
.ledger-cell small,
.task-row small,
.canvas-head p,
.section-head span,
.inspector p,
.event-row small,
.doc-row small {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.brand small {
  display: block;
  color: rgba(254, 250, 224, 0.68);
  margin-top: 2px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  border: 1px solid rgba(254, 250, 224, 0.18);
  background: transparent;
  color: rgba(254, 250, 224, 0.76);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius);
  text-align: left;
}

.tab.is-active {
  background: var(--paper);
  color: var(--ink);
}

.rail-ledger {
  margin-top: auto;
  border-top: 1px solid rgba(254, 250, 224, 0.2);
  padding-top: 18px;
}

.rail-ledger strong {
  display: block;
  margin-top: 6px;
  color: var(--ochre);
}

.workspace {
  padding: 24px;
  min-width: 0;
}

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

.eyebrow,
.mono {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 58px);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.toolbar,
.inspector-actions,
.stamp-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-button,
.primary-button,
.secondary-button {
  border: 1px solid var(--line);
  min-height: 42px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 20px;
}

.primary-button {
  background: var(--olive);
  color: var(--paper);
  border-color: var(--olive);
  font-weight: 700;
}

.secondary-button:hover,
.icon-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
}

.ledger-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(255, 253, 240, 0.82);
  margin-bottom: 18px;
}

.ledger-cell {
  padding: 16px;
  min-width: 0;
  border-right: 1px solid var(--line);
}

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

.ledger-cell strong {
  display: block;
  font-size: clamp(22px, 3vw, 36px);
  line-height: 1;
  white-space: nowrap;
}

.ledger-cell small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.ledger-cell.is-alert {
  background: rgba(221, 161, 94, 0.26);
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
  animation: rise 180ms ease-out;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(150px, 0.7fr) minmax(150px, 0.7fr);
  gap: 10px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  padding: 0 12px;
}

.route-canvas,
.queue-panel,
.inspector,
.request-form,
.draft-preview,
.document-list,
.finance-table,
.audit-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 240, 0.86);
}

.route-canvas {
  padding: 18px;
  margin-bottom: 14px;
}

.canvas-head,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.canvas-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.stage-column {
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(96, 108, 56, 0.09), transparent 46%),
    rgba(255, 255, 255, 0.52);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.stage-column header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}

.stage-column header strong {
  color: var(--ink);
}

.stage-track {
  display: grid;
  gap: 8px;
  min-height: 168px;
}

.route-node {
  position: relative;
  display: grid;
  gap: 4px;
  text-align: left;
  border: 1px solid rgba(34, 34, 59, 0.18);
  border-left: 5px solid var(--olive);
  background: var(--white);
  border-radius: var(--radius);
  padding: 10px;
  min-width: 0;
}

.route-node span,
.route-node small {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  color: var(--muted);
  font-size: 11px;
}

.route-node strong {
  overflow-wrap: anywhere;
}

.risk-watch {
  border-left-color: var(--ochre);
}

.risk-alert {
  border-left-color: var(--danger);
}

.work-grid,
.finance-layout,
.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
  gap: 14px;
  align-items: start;
}

.queue-panel,
.inspector,
.request-form,
.draft-preview,
.audit-panel {
  padding: 16px;
}

.task-list {
  display: grid;
  gap: 8px;
}

.task-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) minmax(92px, auto);
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  text-align: left;
}

.task-row.is-selected {
  border-color: var(--olive);
  box-shadow: inset 0 0 0 1px var(--olive);
}

.task-main,
.task-meta {
  min-width: 0;
}

.task-main strong,
.task-main small,
.task-meta strong,
.task-meta small {
  display: block;
  overflow-wrap: anywhere;
}

.task-meta {
  text-align: right;
}

.task-priority,
.doc-type,
.stamp-row span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  background: rgba(34, 34, 59, 0.08);
  color: var(--ink);
}

.task-priority.critical {
  background: rgba(163, 63, 50, 0.16);
  color: var(--danger);
}

.task-priority.high {
  background: rgba(221, 161, 94, 0.22);
}

.inspector {
  position: sticky;
  top: 24px;
}

.inspector h2 {
  font-size: 24px;
  line-height: 1.05;
}

.inspector p {
  margin: 12px 0;
  color: var(--muted);
  line-height: 1.45;
}

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

dt,
dd {
  margin: 0;
}

dl div {
  border-top: 1px solid var(--line);
  padding-top: 9px;
  min-width: 0;
}

dt {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
}

dd {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.request-form {
  display: grid;
  gap: 12px;
}

.draft-preview {
  min-height: 360px;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(34, 34, 59, 0.95), rgba(51, 92, 103, 0.88)),
    var(--ink);
  color: var(--paper);
}

.draft-preview .mono,
.draft-preview p {
  color: rgba(254, 250, 224, 0.72);
}

.draft-preview h2 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
  margin: 16px 0 14px;
}

.stamp-row {
  margin-top: 28px;
}

.stamp-row span {
  background: rgba(254, 250, 224, 0.12);
  color: var(--paper);
}

.document-list {
  display: grid;
  overflow: hidden;
}

.doc-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 132px 92px;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

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

.doc-row strong,
.doc-row small {
  display: block;
  overflow-wrap: anywhere;
}

.doc-row em {
  font-style: normal;
  text-align: right;
  color: var(--muted);
}

.finance-table {
  overflow: hidden;
}

.finance-head,
.finance-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 70px 130px 130px 100px 80px;
  gap: 8px;
  align-items: center;
  padding: 13px 16px;
}

.finance-head {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  background: rgba(34, 34, 59, 0.06);
}

.finance-row {
  border-top: 1px solid var(--line);
}

.positive {
  color: var(--olive);
}

.negative {
  color: var(--danger);
}

.timeline {
  display: grid;
  gap: 10px;
}

.event-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.event-row p {
  margin: 4px 0;
  color: var(--muted);
  line-height: 1.35;
}

.empty {
  color: var(--muted);
  margin: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .rail {
    position: relative;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    flex: 1;
  }

  .rail-ledger {
    margin: 0;
    padding-top: 0;
    border-top: 0;
  }

  .stage-grid,
  .work-grid,
  .finance-layout,
  .form-layout {
    grid-template-columns: 1fr;
  }

  .inspector {
    position: static;
  }
}

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

  .topbar {
    display: grid;
  }

  .ledger-strip,
  .filters {
    grid-template-columns: 1fr;
  }

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

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

  .tabs {
    flex: 0 0 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .task-row,
  .doc-row,
  .finance-head,
  .finance-row {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .task-meta,
  .doc-row em {
    text-align: left;
  }

  dl {
    grid-template-columns: 1fr;
  }
}
