:root {
  --ink: #252422;
  --paper: #fffcf2;
  --paper-2: #f3efe4;
  --accent: #eb5e28;
  --blue: #4f6d7a;
  --mint: #7aa095;
  --line: rgba(37, 36, 34, 0.15);
  --muted: rgba(37, 36, 34, 0.65);
  --shadow: 0 18px 50px rgba(37, 36, 34, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

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

.brand img {
  flex: 0 0 auto;
}

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

.nav-item,
.stage-tab,
.plain-button,
.accent-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 13px;
}

.nav-item {
  background: transparent;
  color: rgba(255, 252, 242, 0.74);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 13px;
}

.nav-item.is-active,
.nav-item:hover {
  color: var(--paper);
  background: rgba(255, 252, 242, 0.1);
  border-color: rgba(255, 252, 242, 0.16);
}

.rail-signal {
  margin-top: auto;
  border-top: 1px solid rgba(255, 252, 242, 0.18);
  padding-top: 18px;
  line-height: 1.55;
}

.label,
.eyebrow {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 800;
}

.left-rail .label {
  color: rgba(255, 252, 242, 0.52);
}

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

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

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 0.95;
}

.eyebrow {
  margin: 0;
  color: var(--blue);
}

.top-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.search-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.search-box input,
.case-form input,
.case-form textarea,
.note-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 242, 0.82);
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

.search-box input {
  min-width: 270px;
}

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

.accent-button {
  background: var(--accent);
  color: #fff;
  border-color: rgba(37, 36, 34, 0.08);
  font-weight: 800;
}

.plain-button {
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink);
  font-weight: 800;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr)) minmax(260px, 1.2fr);
  gap: 10px;
  margin-bottom: 16px;
}

.metric,
.workflow-line,
.queue-column,
.record-column,
.action-column,
.form-panel,
.preview-panel,
.document-wall,
.finance-wall {
  background: rgba(255, 252, 242, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 14px;
}

.metric span,
.metric em {
  display: block;
  color: var(--muted);
  font-style: normal;
}

.metric strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 28px;
  line-height: 1;
}

.workflow-line {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
}

.workflow-line span {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 14px;
  border-left: 1px solid var(--line);
  color: var(--muted);
}

.workflow-line b {
  color: var(--ink);
}

.screen {
  display: none;
}

.screen.is-visible {
  display: block;
  animation: reveal 180ms ease-out;
}

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

.three-column-board {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(360px, 1.35fr) minmax(280px, 0.95fr);
  gap: 12px;
  align-items: start;
}

.queue-column,
.record-column,
.action-column {
  min-width: 0;
  padding: 14px;
  box-shadow: var(--shadow);
}

.record-column {
  min-height: 620px;
}

.column-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.column-head h2 {
  margin: 2px 0 0;
  font-size: 21px;
}

.counter {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
}

.stage-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.stage-tab {
  min-height: 34px;
  padding: 7px 8px;
  background: var(--paper-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

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

.case-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 242, 0.6);
  padding: 12px;
  text-align: left;
  color: var(--ink);
}

.case-row.is-selected {
  border-color: var(--accent);
  background: #fff7ed;
}

.case-row-main {
  min-width: 0;
}

.case-row-main strong,
.case-row-main em {
  display: block;
}

.case-row-main strong {
  overflow-wrap: anywhere;
}

.case-row-main em {
  margin-top: 4px;
  color: var(--muted);
  font-style: normal;
  line-height: 1.4;
}

.progress-mini {
  grid-column: 1 / -1;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(79, 109, 122, 0.14);
}

.progress-mini i,
.progress-large div {
  display: block;
  height: 100%;
  background: var(--blue);
}

.chip {
  align-self: start;
  border-radius: 999px;
  padding: 6px 9px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 900;
  background: var(--paper-2);
  color: var(--ink);
}

.chip-attention,
.chip-doc-missing,
.chip-money-hold {
  background: #ffe1d5;
  color: #8d2d0c;
}

.chip-active,
.chip-doc-review,
.chip-money-invoice {
  background: #dce8ec;
  color: #284d5b;
}

.chip-won,
.chip-doc-ready,
.chip-money-paid {
  background: #dcece4;
  color: #23513f;
}

.chip-paused,
.chip-money-planned {
  background: #ece7d8;
  color: #665b3c;
}

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

.record-title h3 {
  margin: 3px 0 0;
  font-size: 30px;
  line-height: 1.05;
}

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

.record-grid div,
.record-block,
.next-card,
.note-form,
.finance-total {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(243, 239, 228, 0.55);
}

dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 900;
}

dd {
  margin: 4px 0 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.record-block {
  margin-top: 10px;
}

.record-block span,
.note-form label {
  color: var(--blue);
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
}

.record-block p,
.next-card p,
.preview-panel p,
.finance-total p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.progress-large {
  position: relative;
  height: 34px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(79, 109, 122, 0.14);
  margin-top: 12px;
}

.progress-large span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: var(--ink);
}

.note-stack {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.note-stack p {
  margin: 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
  line-height: 1.5;
  color: var(--muted);
}

.note-stack b {
  margin-right: 8px;
  color: var(--ink);
}

.action-panel {
  display: grid;
  gap: 12px;
}

.next-card h3 {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 1.12;
}

.next-card .accent-button,
.note-form .plain-button {
  width: 100%;
  margin-top: 12px;
}

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

.note-form textarea,
.case-form textarea {
  min-height: 104px;
  resize: vertical;
}

.form-workspace {
  display: grid;
  grid-template-columns: minmax(300px, 560px) minmax(260px, 1fr);
  gap: 12px;
}

.form-panel,
.preview-panel,
.document-wall,
.finance-wall {
  padding: 18px;
  box-shadow: var(--shadow);
}

.form-panel h2,
.preview-panel h2,
.document-wall h2,
.finance-wall h2 {
  margin: 4px 0 16px;
  font-size: 30px;
}

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

.case-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.document-list,
.finance-list {
  display: grid;
  gap: 10px;
}

.doc-row,
.finance-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

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

.doc-row div > span,
.finance-row div > span {
  margin-top: 4px;
  color: var(--muted);
}

.finance-total {
  margin-bottom: 6px;
}

.finance-total strong {
  display: block;
  font-size: 42px;
  line-height: 1;
  margin-top: 8px;
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

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

  .three-column-board,
  .metric-strip {
    grid-template-columns: 1fr 1fr;
  }

  .action-column,
  .workflow-line {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

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

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

  .nav-item {
    min-height: 38px;
    text-align: center;
    padding: 9px 6px;
    font-size: 12px;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .top-actions {
    display: grid;
    align-items: stretch;
  }

  .search-box input {
    min-width: 0;
  }

  .metric-strip,
  .three-column-board,
  .form-workspace,
  .record-grid,
  .workflow-line {
    grid-template-columns: 1fr;
  }

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

  .record-column {
    min-height: 0;
  }

  .doc-row,
  .finance-row,
  .record-title {
    grid-template-columns: 1fr;
    display: grid;
  }
}
