:root {
  --ink: #22223b;
  --paper: #fefae0;
  --olive: #606c38;
  --amber: #dda15e;
  --line: rgba(34, 34, 59, 0.18);
  --muted: rgba(34, 34, 59, 0.68);
  --white: #fffdf0;
  --danger: #9d3c2f;
  --ok: #3f6b44;
  --shadow: 0 18px 44px rgba(34, 34, 59, 0.14);
}

* {
  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(34, 34, 59, 0.07) 1px, transparent 1px),
    linear-gradient(180deg, rgba(34, 34, 59, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

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

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

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

.brand small,
.mono,
.eyebrow,
.search span,
label span,
th {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand small {
  color: rgba(254, 250, 224, 0.7);
  font-size: 11px;
}

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

.nav-tab {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(254, 250, 224, 0.16);
  color: rgba(254, 250, 224, 0.78);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.nav-tab.active,
.nav-tab:hover {
  color: var(--paper);
  border-color: var(--amber);
  background: rgba(221, 161, 94, 0.14);
}

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

.rail-note .mono {
  display: block;
  margin-bottom: 8px;
  color: var(--amber);
  font-size: 11px;
}

.rail-note b {
  font-weight: 600;
  line-height: 1.45;
}

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

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--olive);
  font-size: 12px;
  font-weight: 800;
}

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

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

h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

h3 {
  margin-bottom: 6px;
  font-size: 15px;
  line-height: 1.25;
}

p {
  color: var(--muted);
}

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

.search {
  display: grid;
  gap: 5px;
}

.search span,
label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

input,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 253, 240, 0.86);
}

input:focus,
select:focus {
  outline: 2px solid rgba(221, 161, 94, 0.45);
  border-color: var(--amber);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--ink);
  background: var(--white);
  box-shadow: var(--shadow);
}

.metric-strip > div {
  min-width: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
}

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

.metric-strip .mono {
  display: block;
  color: var(--olive);
  font-size: 11px;
  font-weight: 800;
}

.metric-strip strong {
  display: block;
  margin: 6px 0 4px;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1;
}

.metric-strip small {
  color: var(--muted);
}

.screen {
  display: none;
  min-width: 0;
  margin-top: 22px;
}

.screen.active {
  display: block;
}

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

.primary-action {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  color: var(--paper);
  background: var(--olive);
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.primary-action:hover {
  filter: brightness(1.05);
}

.stage-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(230px, 1fr));
  gap: 12px;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 8px;
}

.stage-column {
  min-height: 390px;
  border: 1px solid var(--ink);
  background: rgba(255, 253, 240, 0.88);
}

.stage-column header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  color: var(--paper);
  background: var(--ink);
}

.stage-column header span,
.stage-column header b {
  overflow-wrap: anywhere;
}

.stage-items {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--amber);
  background: var(--white);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.task-row:hover {
  transform: translateY(-2px);
  border-color: rgba(96, 108, 56, 0.5);
  box-shadow: 0 10px 22px rgba(34, 34, 59, 0.10);
}

.task-main,
.task-ledger {
  min-width: 0;
}

.task-main p,
.task-ledger small {
  margin-bottom: 0;
  font-size: 12px;
}

.task-ledger {
  text-align: right;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.task-ledger span,
.task-ledger b,
.task-ledger small {
  display: block;
}

.task-ledger b {
  margin: 6px 0;
  font-size: 24px;
}

.status {
  display: inline-flex;
  max-width: 100%;
  margin-bottom: 7px;
  padding: 3px 7px;
  border-radius: 4px;
  color: var(--paper);
  background: var(--ink);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.status-approved,
.status-funded,
.status-verified,
.positive {
  color: var(--ok);
}

.status-approved,
.status-funded,
.status-verified {
  color: var(--paper);
  background: var(--olive);
}

.status-missing,
.status-rejected,
.negative {
  color: var(--danger);
}

.status-missing,
.status-rejected {
  color: var(--paper);
  background: var(--danger);
}

.empty,
.error-box {
  padding: 14px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: rgba(254, 250, 224, 0.6);
}

.audit-lane {
  margin-top: 22px;
  border-top: 2px solid var(--ink);
  padding-top: 16px;
}

.audit-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 12px;
  max-width: 100%;
  overflow-x: auto;
}

.audit-list article {
  min-height: 142px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--white);
}

.audit-list .mono {
  display: block;
  margin-bottom: 10px;
  color: var(--olive);
  font-size: 11px;
}

.audit-list b {
  display: block;
  margin-bottom: 8px;
}

.audit-list p {
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.45;
}

.form-panel {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(280px, 1.2fr);
  gap: 24px;
  align-items: start;
  max-width: 980px;
  padding: 22px;
  border: 1px solid var(--ink);
  background: var(--white);
  box-shadow: var(--shadow);
}

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

.grant-form label {
  display: grid;
  gap: 5px;
}

.grant-form button,
.form-status {
  grid-column: 1 / -1;
}

.form-status {
  min-height: 22px;
  margin: 0;
  color: var(--olive);
  font-weight: 700;
}

.overview-status {
  margin-bottom: 12px;
}

.overview-status:empty {
  display: none;
}

.data-table {
  max-width: 100%;
  border: 1px solid var(--ink);
  overflow-x: auto;
  background: var(--white);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--olive);
  background: rgba(96, 108, 56, 0.08);
  font-size: 11px;
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

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

  .rail {
    position: relative;
    min-height: auto;
    padding: 16px;
  }

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

  .nav-tab {
    text-align: center;
    padding: 10px 8px;
  }

  .rail-note {
    display: none;
  }

  .topbar,
  .form-panel {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: stretch;
  }

  .search {
    flex: 1;
  }

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

  .metric-strip > div:nth-child(2) {
    border-right: 0;
  }

  .metric-strip > div:nth-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }
}

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

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

  .brand img {
    width: 42px;
    height: 42px;
  }

  .nav-tabs,
  .grant-form,
  .metric-strip {
    grid-template-columns: 1fr;
  }

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

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

  .canvas-head,
  .toolbar {
    flex-direction: column;
  }

  .primary-action,
  input,
  select {
    width: 100%;
  }

  .stage-board {
    grid-template-columns: minmax(260px, 1fr);
  }
}
