:root {
  --ink: #1b1b3a;
  --paper: #fbfefb;
  --coral: #ff6b6b;
  --mint: #4ecdc4;
  --line: #d9e2df;
  --muted: #667371;
  --panel: #ffffff;
  --shadow: 0 18px 45px rgba(27, 27, 58, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(78, 205, 196, 0.11) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(27, 27, 58, 0.06) 0 1px, transparent 1px 100%),
    var(--paper);
  background-size: 38px 38px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-weight: 850;
  font-size: 1.05rem;
}

.brand img {
  flex: 0 0 auto;
}

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

.nav-tab,
.primary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.nav-tab {
  width: 100%;
  padding: 11px 12px;
  background: transparent;
  color: rgba(251, 254, 251, 0.76);
  text-align: left;
}

.nav-tab:hover,
.nav-tab.is-active {
  background: rgba(78, 205, 196, 0.15);
  color: var(--paper);
}

.rail-note {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(251, 254, 251, 0.14);
}

.rail-note p {
  margin: 10px 0 0;
  color: rgba(251, 254, 251, 0.72);
  font-size: 0.84rem;
  line-height: 1.5;
}

.signal {
  display: block;
  width: 38px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--coral) 0 48%, transparent 48% 52%, var(--mint) 52% 100%);
}

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

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 2.8vw, 3rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.05rem;
  line-height: 1.2;
}

h3 {
  margin-bottom: 10px;
  font-size: 0.82rem;
  text-transform: uppercase;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button {
  padding: 0 16px;
  background: var(--coral);
  color: #210b15;
  font-weight: 800;
}

.primary-button:hover,
.icon-button:hover,
.ghost-button:hover,
.route-card:hover {
  transform: translateY(-1px);
}

.icon-button {
  width: 42px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 1.2rem;
}

.ghost-button {
  padding: 0 14px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 750;
}

.ghost-button.danger {
  color: #9f1e35;
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.metrics-strip article {
  min-width: 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.86);
}

.metrics-strip span,
.filters span,
.forge-form span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metrics-strip strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(1.35rem, 2vw, 2.05rem);
  line-height: 1.05;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
  animation: riseIn 260ms ease both;
}

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

.filters label,
.forge-form label {
  min-width: 0;
}

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

input:focus,
select:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.2);
}

.split-pane {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.portfolio,
.inspector,
.forge-form,
.forge-preview,
.documents-view,
.finance-view {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.portfolio {
  overflow: hidden;
}

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

.portfolio-head h2 {
  margin: 0;
}

.portfolio-head span {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  min-height: 340px;
  background: var(--line);
}

.route-grid.is-loading {
  opacity: 0.62;
}

.route-card {
  display: grid;
  gap: 10px;
  min-height: 164px;
  border: 0;
  border-radius: 0;
  padding: 16px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.route-card.is-selected {
  background: #f3fffd;
  box-shadow: inset 3px 0 0 var(--mint);
}

.route-card strong {
  min-height: 44px;
  line-height: 1.22;
}

.route-topline,
.route-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.route-topline b,
.route-meta,
.route-bottom span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-meta,
.route-bottom {
  color: var(--muted);
  font-size: 0.82rem;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  border-radius: 999px;
  padding: 0 9px;
  background: #ecf5f3;
  color: var(--ink);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 850;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-risk,
.status-blocked {
  background: rgba(255, 107, 107, 0.18);
  color: #9f1e35;
}

.status-active {
  background: rgba(78, 205, 196, 0.24);
}

.status-closed {
  background: rgba(27, 27, 58, 0.12);
}

.progress-line {
  display: block;
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eeee;
}

.progress-line i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--coral));
}

.progress-line.large {
  height: 10px;
}

.inspector {
  position: sticky;
  top: 18px;
  overflow: hidden;
}

.inspector-head,
.progress-block,
.inspector-actions,
.timeline,
.people,
.proofs {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.proofs {
  border-bottom: 0;
}

.inspector-head h2 {
  margin: 12px 0 8px;
  font-size: 1.35rem;
}

.inspector-head p,
.documents-view p,
.finance-view p,
.muted {
  color: var(--muted);
  line-height: 1.45;
}

.progress-block div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.progress-block span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.progress-block strong {
  font-size: 1.6rem;
}

.inspector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.stop {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.stop > span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #edf3f2;
  font-weight: 850;
}

.stop-done > span {
  background: var(--mint);
}

.stop-active > span {
  background: var(--coral);
  color: #210b15;
}

.stop b {
  display: block;
  line-height: 1.25;
}

.stop p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.stop em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  white-space: nowrap;
}

.driver-list,
.proof-list {
  display: grid;
  gap: 10px;
}

.driver-list article,
.proof-list article,
.finance-rows article {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 254, 251, 0.62);
}

.driver-list span,
.proof-list em,
.proof-kind,
.finance-rows span {
  color: var(--muted);
  font-size: 0.8rem;
  font-style: normal;
}

.proof-list article {
  grid-template-columns: minmax(0, 1fr) auto;
}

.proof-list b,
.proof-list em,
.proof-kind {
  grid-column: 1;
  overflow-wrap: anywhere;
}

.proof-list strong {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
  white-space: nowrap;
}

.empty-state,
.empty-inline {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 28px;
  text-align: center;
}

.empty-state p,
.empty-inline {
  color: var(--muted);
  line-height: 1.45;
}

.empty-glyph {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background:
    linear-gradient(90deg, var(--coral) 0 46%, transparent 46% 54%, var(--mint) 54% 100%),
    var(--ink);
  box-shadow: inset 0 0 0 12px var(--paper);
}

.request-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 16px;
}

.forge-form,
.forge-preview,
.documents-view,
.finance-view {
  padding: 18px;
}

.forge-form {
  display: grid;
  gap: 13px;
}

.forge-form h2,
.forge-preview h2,
.documents-view h2,
.finance-view h2 {
  margin-bottom: 2px;
  font-size: 1.35rem;
}

.forge-form .primary-button {
  margin-top: 4px;
}

.forge-preview {
  background: var(--ink);
  color: var(--paper);
}

.forge-preview h2 {
  color: var(--paper);
}

.forge-preview ol {
  display: grid;
  gap: 14px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.forge-preview li {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid rgba(251, 254, 251, 0.16);
}

.forge-preview li span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mint), var(--coral));
  color: var(--ink);
  font-weight: 900;
}

.documents-view header,
.finance-view header {
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.context-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 14px;
  color: var(--muted);
}

.context-row b {
  color: var(--ink);
}

.finance-board {
  display: grid;
  gap: 14px;
}

.finance-total {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
}

.finance-total span {
  color: rgba(251, 254, 251, 0.72);
  font-weight: 800;
  text-transform: uppercase;
}

.finance-total strong {
  font-size: clamp(1.7rem, 4vw, 3.2rem);
}

.finance-rows {
  display: grid;
  gap: 10px;
}

.finance-rows article {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.finance-rows .progress-line {
  grid-column: 1 / -1;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

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

  .rail {
    position: static;
    height: auto;
    padding: 14px;
  }

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

  .nav-tab {
    text-align: center;
  }

  .rail-note {
    display: none;
  }

  .split-pane,
  .request-layout {
    grid-template-columns: 1fr;
  }

  .inspector {
    position: static;
  }
}

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

  .topbar,
  .topbar-actions,
  .route-topline,
  .route-bottom {
    align-items: stretch;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .primary-button {
    flex: 1;
  }

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

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

  .route-topline,
  .route-bottom,
  .finance-total {
    flex-direction: column;
  }

  .route-topline b,
  .route-meta,
  .route-bottom span {
    white-space: normal;
  }

  .stop {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .stop em {
    grid-column: 2;
    white-space: normal;
  }

  .proof-list article,
  .finance-rows article {
    grid-template-columns: 1fr;
  }

  .proof-list strong {
    grid-column: 1;
    grid-row: auto;
  }
}
