:root {
  --ink: #252422;
  --paper: #fffcf2;
  --paper-2: #f3efe3;
  --line: #ddd5c5;
  --accent: #eb5e28;
  --steel: #4f6d7a;
  --green: #2f7d59;
  --red: #b6412e;
  --muted: #736c61;
  --shadow: 0 24px 70px rgba(37, 36, 34, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(79, 109, 122, 0.07) 1px, transparent 1px),
    linear-gradient(180deg, rgba(37, 36, 34, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 42px 42px;
  font-family: "Arial Narrow", "Roboto Condensed", "Segoe UI", Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

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

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

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

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

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

.nav-button {
  width: 100%;
  border: 1px solid rgba(255, 252, 242, 0.16);
  border-radius: 8px;
  color: var(--paper);
  background: transparent;
  padding: 12px 11px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.nav-button:hover,
.nav-button.is-active {
  background: rgba(255, 252, 242, 0.12);
  border-color: rgba(255, 252, 242, 0.44);
  transform: translateX(2px);
}

.workflow-mark {
  margin-top: auto;
  border-top: 1px solid rgba(255, 252, 242, 0.18);
  padding-top: 18px;
  display: grid;
  gap: 8px;
}

.workflow-mark span,
.kicker,
.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.workflow-mark span {
  color: rgba(255, 252, 242, 0.58);
}

.workflow-mark strong {
  font-size: 14px;
  line-height: 1.55;
}

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

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

.eyebrow {
  margin: 0 0 7px;
  color: var(--steel);
}

h1,
h2,
h3,
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;
}

h3 {
  margin-bottom: 8px;
  font-size: 19px;
  line-height: 1.2;
}

.topbar-tools {
  display: flex;
  align-items: end;
  gap: 10px;
}

.search {
  display: grid;
  gap: 6px;
  min-width: 260px;
}

.search span,
.create-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 252, 242, 0.86);
  padding: 11px 12px;
  outline: none;
}

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

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

.icon-button,
.primary-action,
.secondary-action,
.tiny-action {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 11px 14px;
  font-weight: 800;
}

.icon-button {
  width: 42px;
  color: var(--paper);
  background: var(--steel);
  font-size: 22px;
  line-height: 1;
}

.primary-action {
  color: var(--paper);
  background: var(--accent);
}

.secondary-action,
.tiny-action {
  color: var(--ink);
  background: #e6dfd0;
}

.tiny-action {
  min-height: 34px;
  padding: 8px 10px;
}

.full {
  width: 100%;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 252, 242, 0.92);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.metric {
  min-height: 86px;
  padding: 14px;
  display: grid;
  align-content: center;
  gap: 8px;
  border-right: 1px solid var(--line);
}

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

.metric span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
}

.metric strong {
  font-size: 28px;
  line-height: 1;
}

.metric.accent strong {
  color: var(--accent);
}

.metric.danger strong {
  color: var(--red);
}

.metric small {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--steel);
  font-size: 12px;
}

.view {
  display: none;
  animation: lift 220ms ease both;
}

.view.is-visible {
  display: block;
}

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

.inbox-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(360px, 1.55fr) minmax(260px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.queue-panel,
.record-panel,
.action-panel,
.full-panel,
.create-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 242, 0.94);
  box-shadow: var(--shadow);
}

.queue-panel,
.record-panel,
.action-panel,
.full-panel {
  min-width: 0;
}

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

.panel-head select {
  max-width: 134px;
}

.case-list {
  display: grid;
  gap: 8px;
  padding: 10px;
  max-height: calc(100vh - 250px);
  overflow: auto;
}

.case-row {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 12px;
  text-align: left;
  display: grid;
  gap: 10px;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.case-row:hover,
.case-row.is-active {
  background: #f0eadc;
  border-color: #d1c7b6;
  transform: translateY(-1px);
}

.row-top,
.row-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.row-top strong {
  line-height: 1.18;
}

.row-meta,
.row-foot {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.chip,
.status-chip,
.doc-state {
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  text-transform: uppercase;
}

.chip.stable,
.status-chip.stable,
.doc-state.signed {
  color: #123b28;
  background: rgba(47, 125, 89, 0.14);
}

.chip.attention,
.status-chip.attention,
.doc-state.review {
  color: #6e351a;
  background: rgba(235, 94, 40, 0.16);
}

.chip.risk,
.status-chip.risk,
.doc-state.missing {
  color: #6d1f16;
  background: rgba(182, 65, 46, 0.15);
}

.progress-line {
  height: 7px;
  border-radius: 999px;
  background: #dfd8ca;
  overflow: hidden;
}

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

.record-body {
  padding: 16px;
  display: grid;
  gap: 14px;
}

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

.record-grid div,
.record-section,
.split-section,
.notes-section,
.action-callout,
.finance-mini {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
  padding: 13px;
}

.record-grid span,
.finance-mini span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.record-grid strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.record-section p,
.action-callout p,
.create-form p {
  margin-bottom: 0;
  color: #514b43;
  line-height: 1.6;
}

.split-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

ul {
  list-style: none;
  margin: 9px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #4f493f;
  line-height: 1.35;
}

time {
  color: var(--steel);
  white-space: nowrap;
}

blockquote {
  margin: 10px 0 0;
  border-left: 3px solid var(--steel);
  padding-left: 10px;
}

blockquote p {
  margin: 3px 0 0;
  color: #514b43;
  line-height: 1.55;
}

.action-body {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.note-form {
  display: grid;
  gap: 9px;
}

.note-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.finance-mini {
  display: grid;
  gap: 7px;
}

.finance-mini em {
  color: var(--accent);
  font-style: normal;
  font-weight: 900;
}

.create-form {
  max-width: 760px;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.form-copy {
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

.create-form label {
  display: grid;
  gap: 6px;
}

.full-panel {
  overflow: hidden;
}

.document-table,
.finance-board {
  display: grid;
}

.document-row,
.finance-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.6fr) 110px 120px 120px;
  gap: 14px;
  align-items: center;
  min-height: 64px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.finance-row {
  grid-template-columns: minmax(240px, 1.5fr) 130px 88px 110px 150px;
}

.document-row:last-child,
.finance-row:last-child {
  border-bottom: 0;
}

.document-row strong,
.finance-row strong {
  display: block;
  margin-bottom: 4px;
}

.document-row span,
.finance-row span,
.muted {
  color: var(--muted);
  line-height: 1.35;
}

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

.finance-row em {
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.finance-row.overdue em {
  color: var(--red);
}

.finance-row.planned em {
  color: var(--steel);
}

.finance-row.paid em {
  color: var(--green);
}

.empty {
  padding: 16px;
  color: var(--muted);
  line-height: 1.5;
}

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

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

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

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

  .nav-stack {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    flex: 1 1 420px;
  }

  .workflow-mark {
    margin-top: 0;
    border-top: 0;
    border-left: 1px solid rgba(255, 252, 242, 0.18);
    padding: 0 0 0 16px;
  }

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

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

  .inbox-grid {
    grid-template-columns: 1fr;
  }

  .case-list {
    max-height: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .topbar,
  .topbar-tools,
  .row-top,
  .row-foot,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    min-width: 0;
  }

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

  .workflow-mark {
    width: 100%;
    border-left: 0;
    padding-left: 0;
  }

  .metric-strip,
  .record-grid,
  .split-section,
  .case-list {
    grid-template-columns: 1fr;
  }

  .document-row,
  .finance-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  h1 {
    font-size: 36px;
  }
}
