:root {
  --ink: #252422;
  --paper: #fffcf2;
  --line: #ded8c8;
  --accent: #eb5e28;
  --blue: #4f6d7a;
  --green: #587b55;
  --amber: #b9892b;
  --muted: #6e6960;
  --white: #fffefa;
  --shadow: 0 18px 44px rgba(37, 36, 34, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(79, 109, 122, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(37, 36, 34, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 42px 42px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px 18px;
  background: rgba(255, 252, 242, 0.92);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.brand span {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
}

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

.nav__item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  text-align: left;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav__item:hover,
.nav__item.is-active {
  color: var(--ink);
  background: var(--white);
  border-color: var(--line);
  transform: translateX(2px);
}

.rail__note {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  line-height: 1.45;
}

.rail__label,
.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

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

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

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

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

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.1;
}

.metric {
  display: grid;
  gap: 2px;
  min-width: 160px;
  padding: 10px 12px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric span {
  font-size: 26px;
  font-weight: 800;
}

.metric small {
  color: rgba(255, 252, 242, 0.74);
}

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

.kpis div {
  display: grid;
  gap: 7px;
  padding: 14px;
  background: rgba(255, 254, 250, 0.9);
}

.kpis span {
  color: var(--muted);
  font-size: 13px;
}

.kpis strong {
  font-size: 25px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
  animation: rise 220ms ease both;
}

.triad {
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(340px, 1.35fr) minmax(260px, 0.9fr);
  gap: 14px;
  min-height: 620px;
}

.pane {
  min-width: 0;
  background: rgba(255, 254, 250, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

select,
input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
  color: var(--ink);
  padding: 0 10px;
}

.search {
  display: grid;
  gap: 6px;
  padding: 12px 16px;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}

.case-list {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.case-row {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 254, 250, 0.96);
  border: 0;
  transition: background 150ms ease, transform 150ms ease;
}

.case-row:hover,
.case-row.is-active {
  background: #f4efe1;
}

.case-row.is-active {
  transform: translateX(3px);
  box-shadow: inset 3px 0 0 var(--accent);
}

.case-row__top,
.case-row__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.case-row strong,
.doc-row strong {
  line-height: 1.2;
}

.case-row em,
.case-row small,
.case-row__meta,
.doc-row p,
.doc-row small,
.finance-row small {
  color: var(--muted);
  font-style: normal;
  line-height: 1.35;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  padding: 0 9px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.stage-intake {
  color: var(--blue);
}

.stage-evaluation {
  color: var(--amber);
}

.stage-decision {
  color: var(--accent);
}

.stage-reporting {
  color: var(--green);
}

.record-body,
.next-action {
  padding: 16px;
}

.empty-state {
  color: var(--muted);
  line-height: 1.5;
}

.empty-state.error {
  color: #9d2b20;
}

.record-summary p {
  color: var(--muted);
  font-family: Arial, sans-serif;
  line-height: 1.7;
}

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

dl div {
  padding: 12px;
  background: #f8f3e7;
  border-radius: 7px;
}

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

dd {
  margin: 5px 0 0;
  font-weight: 800;
  line-height: 1.25;
}

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

.timeline div,
.next-block {
  display: grid;
  gap: 6px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.timeline span,
.next-block span,
.finance-note span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.timeline em {
  color: var(--muted);
  font-style: normal;
}

.action-stack {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.primary,
.secondary,
.ghost {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 7px;
  font-weight: 800;
  transition: transform 150ms ease, opacity 150ms ease;
}

.primary {
  color: var(--paper);
  background: var(--accent);
  border: 1px solid var(--accent);
}

.secondary {
  color: var(--paper);
  background: var(--blue);
  border: 1px solid var(--blue);
}

.ghost {
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
}

.primary:hover,
.secondary:hover,
.ghost:hover {
  transform: translateY(-1px);
}

.forge-form {
  max-width: 720px;
  display: grid;
  gap: 14px;
  padding: 18px;
  background: rgba(255, 254, 250, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.forge-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.form-copy,
.form-result {
  color: var(--muted);
  font-family: Arial, sans-serif;
  line-height: 1.55;
}

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

.table-pane {
  overflow: hidden;
}

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

.doc-row {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 150px;
  padding: 16px;
  background: var(--white);
}

.finance-bars {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.finance-row {
  display: grid;
  grid-template-columns: 100px minmax(90px, 1fr) 140px;
  align-items: center;
  gap: 12px;
}

.finance-row strong,
.finance-row small {
  text-align: right;
}

.bar {
  height: 12px;
  overflow: hidden;
  background: #eee6d4;
  border-radius: 999px;
}

.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--accent));
}

.finance-note {
  display: grid;
  align-content: center;
  gap: 10px;
  min-height: 220px;
  padding: 24px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.finance-note strong {
  font-size: 26px;
  line-height: 1.18;
}

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

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

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

  .nav {
    display: flex;
    min-width: max-content;
  }

  .rail__note {
    display: none;
  }

  .triad,
  .finance-layout {
    grid-template-columns: 1fr;
  }

  .triad {
    min-height: 0;
  }
}

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

  .rail {
    padding: 14px;
  }

  .brand span {
    font-size: 18px;
  }

  .topbar {
    display: grid;
  }

  .metric {
    min-width: 0;
  }

  .kpis,
  .document-grid,
  .form-row {
    grid-template-columns: 1fr;
  }

  .pane__head {
    display: grid;
  }

  dl,
  .finance-row {
    grid-template-columns: 1fr;
  }

  .finance-row strong,
  .finance-row small {
    text-align: left;
  }
}
