:root {
  --ink: #252422;
  --paper: #fffcf2;
  --line: #ded8c8;
  --muted: #6f6b63;
  --orange: #eb5e28;
  --blue: #4f6d7a;
  --mint: #d6ece2;
  --rose: #f4d8ce;
  --white: #fffefa;
  --shadow: 0 20px 50px 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", "Segoe UI", Arial, sans-serif;
}

body {
  min-height: 100%;
  margin: 0;
  font-size: 16px;
  line-height: 1.65;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(79, 109, 122, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(235, 94, 40, 0.08) 1px, transparent 1px),
    var(--paper);
  background-size: 44px 44px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(170px, 0.5fr);
  gap: 18px;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 242, 0.94);
  backdrop-filter: blur(14px);
}

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

.brand img {
  flex: 0 0 auto;
  filter: drop-shadow(0 7px 14px rgba(37, 36, 34, 0.12));
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

.brand strong {
  font-size: 20px;
  line-height: 1.05;
  letter-spacing: 0;
}

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

.mode-tabs {
  display: inline-flex;
  min-width: 0;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--white);
}

.tab {
  min-height: 36px;
  padding: 7px 12px;
  border: 0;
  border-radius: 2px;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
  transition: color 160ms ease, background 160ms ease;
}

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

.reaction {
  justify-self: end;
  text-align: right;
}

.reaction span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.reaction strong {
  color: var(--orange);
  font-size: 26px;
  line-height: 1.1;
}

main {
  padding: 22px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.workspace {
  height: calc(100vh - 96px);
  min-height: 650px;
  display: none;
  grid-template-columns: minmax(280px, 360px) minmax(360px, 1fr) minmax(280px, 330px);
  gap: 16px;
}

.workspace.is-active {
  display: grid;
}

.queue-pane,
.record-pane,
.action-pane,
.form-screen,
.data-screen {
  min-width: 0;
  border: 1px solid var(--line);
  background: rgba(255, 254, 250, 0.9);
  box-shadow: var(--shadow);
}

.queue-pane,
.record-pane,
.action-pane {
  overflow: hidden;
}

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

.pane-head h1,
.pane-head h2,
.section-head h2,
.form-copy h2 {
  margin: 0;
  max-width: 680px;
  font-size: 22px;
  line-height: 1.18;
  letter-spacing: 0;
}

.pane-head.slim h2 {
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  font-weight: 700;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper);
  font-size: 21px;
  line-height: 1;
}

.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: var(--white);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  padding: 10px 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 109, 122, 0.16);
}

.stage-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.stage-cell {
  padding: 10px 8px;
  border-right: 1px solid var(--line);
  text-align: center;
}

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

.stage-cell b {
  display: block;
  color: var(--blue);
  font-size: 20px;
  line-height: 1.1;
}

.stage-cell span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.case-list,
.action-list {
  height: calc(100% - 211px);
  overflow: auto;
}

.case-card {
  width: 100%;
  display: block;
  padding: 15px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  background: transparent;
  text-align: left;
  transition: background 160ms ease, transform 160ms ease;
}

.case-card:hover,
.case-card.is-selected {
  background: rgba(79, 109, 122, 0.1);
}

.case-card:hover {
  transform: translateX(3px);
}

.case-card strong,
.case-card span {
  display: block;
  min-width: 0;
}

.case-card strong {
  font-size: 17px;
  line-height: 1.25;
}

.case-card .meta {
  color: var(--muted);
  font-size: 13px;
}

.card-row,
.record-meta,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chip {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  line-height: 1.2;
  color: var(--ink);
  background: var(--mint);
}

.chip.status-risk,
.chip.severity-critical,
.chip.status-missing {
  background: var(--rose);
  color: #762f1b;
}

.chip.status-review,
.chip.severity-high,
.chip.status-draft {
  background: #fde0c8;
  color: #7a3518;
}

.chip.status-ready,
.chip.status-approved,
.chip.status-signed {
  background: var(--mint);
  color: #1c5545;
}

.chip.status-active,
.chip.severity-normal {
  background: #dbe5ef;
  color: #264b60;
}

.record-pane {
  overflow: auto;
}

.record-header {
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(79, 109, 122, 0.12), rgba(235, 94, 40, 0.08));
}

.record-header h2 {
  margin: 9px 0;
  max-width: 820px;
  font-size: 36px;
  line-height: 1.08;
  letter-spacing: 0;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.metric {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.1;
}

.record-section {
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
}

.record-section h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.timeline,
.doc-list,
.deadline-list {
  display: grid;
  gap: 10px;
}

.timeline-item,
.doc-item,
.deadline-item,
.action-item,
.finance-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: var(--white);
}

.timeline-item p,
.doc-item p,
.deadline-item p,
.action-item p,
.finance-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.action-item {
  margin: 0;
  border-width: 0 0 1px 0;
  border-radius: 0;
  background: transparent;
}

.action-item button {
  margin-top: 10px;
  min-height: 34px;
  border: 1px solid var(--blue);
  border-radius: 4px;
  color: var(--blue);
  background: transparent;
}

.empty-state {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.form-screen {
  max-width: 940px;
  margin: 0 auto;
  padding: 28px;
}

.form-copy p:last-child {
  max-width: 620px;
  color: var(--muted);
}

.intake-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

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

.intake-form label:nth-child(5),
.intake-form label:nth-child(6),
.primary-action,
.form-status {
  grid-column: 1 / -1;
}

.primary-action {
  min-height: 46px;
  border: 0;
  border-radius: 4px;
  color: var(--paper);
  background: var(--orange);
  font-weight: 700;
}

.form-status {
  min-height: 24px;
  margin: 0;
  color: var(--blue);
}

.data-screen {
  max-width: 1120px;
  margin: 0 auto;
  min-height: 620px;
}

.document-board,
.finance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
}

.document-column,
.finance-item {
  min-width: 0;
}

.document-column h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.doc-item {
  margin-bottom: 10px;
}

.finance-item strong {
  display: block;
  font-size: 28px;
  line-height: 1.15;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--paper);
  background: var(--ink);
  box-shadow: var(--shadow);
  animation: rise 180ms ease both;
}

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

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

  .reaction {
    justify-self: start;
    text-align: left;
  }

  .workspace {
    height: auto;
    min-height: 0;
    grid-template-columns: 330px minmax(0, 1fr);
  }

  .action-pane {
    grid-column: 1 / -1;
  }

  .case-list,
  .action-list {
    height: auto;
    max-height: 470px;
  }
}

@media (max-width: 760px) {
  main {
    padding: 12px;
  }

  .topbar {
    padding: 12px;
  }

  .mode-tabs {
    overflow-x: auto;
    width: 100%;
  }

  .tab {
    flex: 1 0 auto;
    padding-inline: 10px;
  }

  .workspace {
    display: none;
    grid-template-columns: 1fr;
  }

  .workspace.is-active {
    display: grid;
  }

  .record-header h2 {
    font-size: 28px;
  }

  .record-grid,
  .intake-form,
  .document-board,
  .finance-grid {
    grid-template-columns: 1fr;
  }

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

  .metric:last-child {
    border-bottom: 0;
  }
}

