:root {
  --ink: #22223b;
  --paper: #fefae0;
  --olive: #606c38;
  --copper: #dda15e;
  --line: rgba(34, 34, 59, 0.16);
  --muted: rgba(34, 34, 59, 0.68);
  --white: #fffdf0;
  --danger: #9f3a28;
  --good: #486b4f;
  --shadow: 0 24px 70px rgba(34, 34, 59, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(34, 34, 59, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(34, 34, 59, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  color: var(--ink);
  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: 270px minmax(0, 1fr);
  min-height: 100vh;
}

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

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

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

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

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

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

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

.tab,
.filter,
.icon-button,
.advance,
.primary-action {
  border: 0;
  cursor: pointer;
}

.tab {
  text-align: left;
  padding: 12px 13px;
  color: rgba(254, 250, 224, 0.78);
  background: transparent;
  border-left: 3px solid transparent;
  border-radius: 0 6px 6px 0;
}

.tab.is-active,
.tab:hover {
  color: var(--paper);
  background: rgba(254, 250, 224, 0.08);
  border-color: var(--copper);
}

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

.rail-note p {
  margin: 8px 0 0;
  color: rgba(254, 250, 224, 0.72);
  line-height: 1.45;
}

.workspace {
  min-width: 0;
  padding: 24px clamp(16px, 3vw, 34px) 42px;
}

.topbar,
.section-head,
.map-head,
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.topbar {
  align-items: center;
  margin-bottom: 22px;
}

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

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 48px);
}

h2 {
  font-size: clamp(23px, 3vw, 34px);
}

h3 {
  font-size: 17px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.db-badge {
  background: var(--olive);
  color: var(--paper);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.db-badge.is-offline {
  background: var(--copper);
  color: var(--ink);
}

.screen {
  display: none;
  animation: surfaceIn 260ms ease both;
}

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

.ledger {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: rgba(255, 253, 240, 0.74);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

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

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

.label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 12px;
}

.metric strong {
  display: block;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1;
}

.metric small {
  display: block;
  margin-top: 10px;
  color: var(--olive);
  font-weight: 700;
}

.ops-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
}

.map-canvas,
.audit-panel,
.request-form,
.document-list,
.finance-table {
  background: rgba(255, 253, 240, 0.78);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.map-canvas {
  position: relative;
  overflow: hidden;
  min-height: 620px;
  padding: 20px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.filter {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
}

.filter.is-active,
.filter:hover {
  background: var(--ink);
  color: var(--paper);
}

.route-loop {
  position: absolute;
  inset: 88px 26px auto auto;
  width: min(42vw, 440px);
  height: 280px;
  opacity: 0.26;
  pointer-events: none;
}

.loop-line {
  position: absolute;
  inset: 18px;
  border: 2px dashed var(--olive);
  border-radius: 50%;
  transform: rotate(-18deg);
}

.node {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--copper);
  border: 3px solid var(--ink);
  z-index: 2;
}

.node-a { left: 30px; top: 62px; }
.node-b { right: 84px; top: 12px; }
.node-c { right: 28px; bottom: 74px; }
.node-d { left: 122px; bottom: 20px; }

.task-board {
  position: relative;
  display: grid;
  gap: 12px;
  margin-top: 30px;
  z-index: 1;
}

.task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px 120px;
  grid-template-areas:
    "main numbers action"
    "progress progress action";
  gap: 12px 16px;
  align-items: center;
  padding: 16px;
  background: rgba(254, 250, 224, 0.88);
  border-left: 5px solid var(--olive);
  box-shadow: inset 0 0 0 1px rgba(34, 34, 59, 0.08);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.task-row:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 1px rgba(34, 34, 59, 0.13), 0 16px 36px rgba(34, 34, 59, 0.11);
}

.task-row[data-priority="high"] {
  border-left-color: var(--danger);
}

.task-main {
  grid-area: main;
  min-width: 0;
}

.task-main p {
  margin: 8px 0 0;
  color: var(--muted);
}

.status,
.doc-type {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--olive);
  font: 700 11px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  text-transform: uppercase;
}

.task-numbers {
  grid-area: numbers;
  text-align: right;
  min-width: 0;
}

.task-numbers strong,
.task-numbers small {
  display: block;
}

.task-numbers small {
  color: var(--muted);
  margin-top: 6px;
}

.delta {
  display: inline-block;
  margin-bottom: 8px;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-weight: 700;
}

.is-hot {
  color: var(--danger);
}

.is-good {
  color: var(--good);
}

.gate-progress {
  grid-area: progress;
  height: 8px;
  background: rgba(34, 34, 59, 0.11);
  overflow: hidden;
}

.gate-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--olive), var(--copper));
  transition: width 280ms ease;
}

.advance {
  grid-area: action;
  align-self: stretch;
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
  padding: 10px;
  min-width: 0;
}

.audit-panel {
  padding: 18px;
  min-height: 620px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
}

.event-list {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.event {
  border-left: 2px solid var(--copper);
  padding-left: 13px;
}

.event span,
.event p {
  color: var(--muted);
}

.event span {
  display: block;
  font: 12px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  margin-bottom: 6px;
}

.event p {
  margin: 7px 0 0;
  line-height: 1.45;
}

.form-layout {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 24px;
  align-items: start;
}

.form-copy {
  padding-top: 20px;
  max-width: 480px;
}

.form-copy p:last-child {
  color: var(--muted);
  line-height: 1.55;
}

.request-form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

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

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

.check-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.check-line input {
  width: 18px;
  height: 18px;
}

.primary-action {
  background: var(--olive);
  color: var(--paper);
  border-radius: 6px;
  padding: 14px 16px;
  font-weight: 800;
}

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

.section-head {
  align-items: end;
  margin-bottom: 18px;
}

.search {
  max-width: 330px;
}

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

.document-row,
.finance-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 150px;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

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

.document-row p {
  margin: 7px 0 0;
  color: var(--muted);
}

.document-row strong,
.document-row time,
.finance-row em,
.finance-row small {
  color: var(--muted);
  font-style: normal;
}

.finance-total {
  text-align: right;
}

.finance-total span,
.finance-total strong {
  display: block;
}

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

.finance-total strong {
  font-size: 24px;
}

.finance-row {
  grid-template-columns: 160px minmax(0, 1fr) 120px 150px 110px;
}

.finance-row b {
  text-align: right;
}

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

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

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

  .rail {
    position: static;
    height: auto;
    padding: 16px;
  }

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

  .tab {
    text-align: center;
    border-left: 0;
    border-bottom: 3px solid transparent;
    border-radius: 6px 6px 0 0;
  }

  .rail-note {
    display: none;
  }

  .ops-grid,
  .form-layout {
    grid-template-columns: 1fr;
  }

  .audit-panel {
    min-height: auto;
  }
}

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

  .topbar,
  .section-head,
  .map-head {
    display: grid;
  }

  .status-strip,
  .filters {
    justify-content: flex-start;
    flex-wrap: wrap;
    white-space: normal;
  }

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

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

  .metric:nth-child(2n) {
    border-right: 0;
  }

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

  .map-canvas {
    min-height: auto;
    padding: 14px;
  }

  .route-loop {
    display: none;
  }

  .task-row {
    grid-template-columns: 1fr;
    grid-template-areas:
      "main"
      "numbers"
      "progress"
      "action";
  }

  .task-numbers {
    text-align: left;
  }

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

  .document-row,
  .finance-row {
    align-items: start;
  }

  .finance-row b {
    text-align: left;
  }

  .search {
    max-width: none;
  }
}

