:root {
  --ink: #22223b;
  --paper: #fefae0;
  --olive: #606c38;
  --amber: #dda15e;
  --line: rgba(34, 34, 59, 0.16);
  --muted: rgba(34, 34, 59, 0.62);
  --white: #fffdf0;
  --danger: #a74437;
  --ok: #2f6f4e;
  --shadow: 0 18px 45px rgba(34, 34, 59, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(96, 108, 56, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(34, 34, 59, 0.08) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

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

button {
  cursor: pointer;
}

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

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

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

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.brand small,
.rail-ledger small {
  display: block;
  color: rgba(254, 250, 224, 0.68);
  margin-top: 4px;
}

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

.view-tab {
  min-height: 44px;
  border: 1px solid rgba(254, 250, 224, 0.18);
  background: transparent;
  color: var(--paper);
  text-align: left;
  padding: 10px 12px;
  border-radius: 6px;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.view-tab:hover,
.view-tab.is-active {
  background: rgba(254, 250, 224, 0.12);
  border-color: rgba(254, 250, 224, 0.42);
  transform: translateX(3px);
}

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

.source-ok {
  color: #b7d991;
}

.source-warn {
  color: var(--amber);
}

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

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.mono {
  margin: 0;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--muted);
}

.rail .mono {
  color: rgba(254, 250, 224, 0.58);
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 56px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 20px;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.search-box {
  display: grid;
  gap: 3px;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(96, 108, 56, 0.16);
}

.icon-button,
.primary-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: var(--paper);
  background: var(--ink);
  padding: 10px 14px;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 19px;
}

.primary-button {
  background: var(--olive);
  font-weight: 700;
}

.icon-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

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

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

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

.metric-ledger strong {
  display: block;
  margin: 6px 0;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
}

.metric-ledger small,
.task-row small,
.finance-row small,
.doc-row small,
.lane small {
  color: var(--muted);
}

.metric-ledger .delta {
  background: var(--amber);
}

.screen {
  display: none;
}

.screen.is-visible {
  display: block;
  animation: screenIn 220ms ease both;
}

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

.canvas-head,
.section-head,
.panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.canvas-head p {
  margin-bottom: 0;
  color: var(--muted);
  max-width: 680px;
}

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

.warehouse-map {
  min-height: 338px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(154px, 1fr);
  gap: 1px;
  border: 1px solid var(--ink);
  background: var(--ink);
}

.zone-cell {
  min-width: 0;
  border: 0;
  background: var(--white);
  text-align: left;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  animation: zoneIn 260ms ease both;
  animation-delay: var(--delay);
  transition: background 160ms ease, transform 160ms ease;
}

.zone-cell:hover {
  background: #fff7cf;
  transform: translateY(-2px);
}

.zone-cell strong {
  font-size: clamp(20px, 3vw, 34px);
  line-height: 1;
}

.zone-watch {
  box-shadow: inset 0 -7px 0 var(--amber);
}

@keyframes zoneIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.audit-panel,
.task-table-zone,
.task-form,
.checklist-preview,
.doc-list,
.finance-list,
.finance-totals {
  background: rgba(255, 253, 240, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.audit-panel {
  padding: 16px;
  min-width: 0;
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-event {
  border-left: 3px solid var(--olive);
  padding: 0 0 0 12px;
}

.audit-event strong {
  display: block;
  margin: 3px 0;
}

.audit-event p {
  margin-bottom: 5px;
  color: var(--ink);
}

.workflow-lanes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.lane {
  min-width: 0;
  border-top: 4px solid var(--ink);
  background: rgba(255, 253, 240, 0.82);
  padding: 13px;
}

.lane strong {
  display: block;
  margin: 10px 0;
  font-size: 30px;
  line-height: 1;
}

.lane-bar {
  height: 7px;
  background: rgba(34, 34, 59, 0.12);
  overflow: hidden;
}

.lane-bar span {
  display: block;
  width: var(--rate);
  height: 100%;
  background: var(--olive);
  transition: width 260ms ease;
}

.task-table-zone {
  padding: 16px;
}

.task-table {
  display: grid;
  gap: 8px;
}

.task-row {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(120px, 0.8fr) minmax(110px, 0.7fr) minmax(90px, 0.55fr) minmax(86px, 0.55fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: rgba(255, 253, 240, 0.8);
  color: var(--ink);
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.task-row:hover,
.task-row.is-selected {
  background: #fff7cf;
  border-color: rgba(34, 34, 59, 0.45);
  transform: translateX(2px);
}

.task-row span {
  min-width: 0;
}

.task-row strong,
.task-row small {
  display: block;
  overflow-wrap: anywhere;
}

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

.bad {
  color: var(--danger);
}

.empty {
  margin: 0;
  color: var(--muted);
}

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

.task-form,
.checklist-preview {
  padding: 18px;
}

.task-form {
  display: grid;
  gap: 14px;
}

.task-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

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

.form-status {
  margin-bottom: 0;
  color: var(--muted);
}

.checklist-preview {
  border-color: rgba(96, 108, 56, 0.35);
}

.checklist-preview ol {
  margin: 18px 0 0;
  padding-left: 22px;
  display: grid;
  gap: 12px;
}

.doc-list,
.finance-list {
  overflow: hidden;
}

.doc-row,
.finance-row {
  display: grid;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.doc-row {
  grid-template-columns: minmax(240px, 1.4fr) minmax(150px, 0.8fr) 96px 120px;
}

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

.finance-totals {
  padding: 18px;
  min-height: 160px;
  background: var(--ink);
  color: var(--paper);
}

.finance-totals .mono,
.finance-totals small {
  color: rgba(254, 250, 224, 0.68);
}

.finance-totals strong {
  display: block;
  margin: 14px 0;
  font-size: 34px;
  overflow-wrap: anywhere;
}

.finance-row {
  grid-template-columns: minmax(260px, 1fr) 120px 84px 120px;
}

.status-pill {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(96, 108, 56, 0.14);
  color: var(--olive);
  font-weight: 700;
}

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

  .rail {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 5px solid var(--amber);
  }

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

  .view-tab {
    text-align: center;
  }

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

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

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

  .topbar,
  .canvas-head,
  .section-head,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .search-box,
  .toolbar select,
  .toolbar button {
    width: 100%;
  }

  .views,
  .metric-ledger,
  .warehouse-map,
  .workflow-lanes,
  .split-fields,
  .task-row,
  .doc-row,
  .finance-row {
    grid-template-columns: 1fr;
  }

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

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

  .warehouse-map {
    grid-auto-rows: 120px;
  }
}
