:root {
  --ink: #1a1a2e;
  --paper: #f2e9e4;
  --mauve: #9a8c98;
  --clay: #c9ada7;
  --field: #496b4b;
  --danger: #9d3d35;
  --line: rgba(26, 26, 46, 0.2);
  --soft-line: rgba(26, 26, 46, 0.1);
  --white-paper: #fffaf4;
  --shadow: 0 20px 45px rgba(26, 26, 46, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(26, 26, 46, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(26, 26, 46, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.rail {
  display: flex;
  flex-direction: column;
  gap: 34px;
  min-height: 100vh;
  padding: 24px 18px;
  color: var(--paper);
  background: var(--ink);
  border-right: 3px solid var(--clay);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--paper);
  text-decoration: none;
  font-weight: 800;
  font-size: 20px;
}

.brand img {
  flex: 0 0 auto;
  border: 1px solid rgba(242, 233, 228, 0.22);
}

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

.nav-tab {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: rgba(242, 233, 228, 0.76);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-tab:hover,
.nav-tab.is-active {
  color: var(--ink);
  background: var(--clay);
  transform: translateX(2px);
}

.rail-note {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(242, 233, 228, 0.2);
}

.note-kicker,
.eyebrow {
  display: block;
  margin: 0 0 8px;
  color: var(--mauve);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.rail-note strong {
  display: block;
  color: rgba(242, 233, 228, 0.9);
  font-size: 13px;
  line-height: 1.5;
}

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

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

.topbar h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
}

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

.search {
  display: grid;
  gap: 6px;
  color: var(--mauve);
  font-size: 12px;
  font-weight: 700;
}

.search input,
.canvas-title select {
  min-height: 42px;
  color: var(--ink);
  background: var(--white-paper);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.search input {
  width: 250px;
  padding: 0 12px;
}

.canvas-title select {
  padding: 0 10px;
}

.primary-action,
.secondary-action {
  min-height: 42px;
  padding: 0 14px;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 6px;
  font-weight: 800;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.secondary-action {
  color: var(--ink);
  background: var(--clay);
  border-color: var(--clay);
}

.primary-action:hover,
.secondary-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(26, 26, 46, 0.14);
}

.wide {
  width: 100%;
}

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

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

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

.metric span,
.metric small,
.metric em {
  display: block;
}

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

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 40px;
  line-height: 1;
}

.metric em {
  margin-top: 4px;
  font-style: normal;
  font-weight: 800;
}

.metric small {
  margin-top: 10px;
  color: rgba(26, 26, 46, 0.68);
}

.metric-danger {
  background: #f5ded7;
}

.metric-field {
  background: #e3eadc;
}

.metric-paper {
  background: #fff7df;
}

.screen {
  display: none;
}

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

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

.canvas-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 16px;
}

.canvas-title h2,
.inspector h2,
.settings-block h3 {
  margin: 0;
}

.canvas-title p {
  margin: 6px 0 0;
  color: rgba(26, 26, 46, 0.66);
}

.timeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 244, 0.66);
}

.workflow-step {
  min-width: 0;
  padding: 14px;
  border-right: 1px solid var(--soft-line);
}

.workflow-step:last-child {
  border-right: 0;
}

.step-meta {
  display: grid;
  gap: 4px;
}

.step-meta strong {
  font-size: 14px;
}

.step-meta span {
  color: rgba(26, 26, 46, 0.64);
  font-size: 12px;
}

.progress {
  height: 6px;
  margin-top: 12px;
  overflow: hidden;
  background: rgba(26, 26, 46, 0.1);
}

.progress span {
  display: block;
  height: 100%;
  background: var(--field);
  transition: width 320ms ease;
}

.workflow-step.is-watch .progress span,
.workflow-step.is-active .progress span {
  background: var(--danger);
}

.orders-table {
  overflow: hidden;
  border: 2px solid var(--ink);
  background: var(--white-paper);
}

.table-head,
.order-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.15fr) minmax(150px, 1fr) minmax(112px, 0.7fr) minmax(110px, 0.7fr) minmax(110px, 0.7fr);
  gap: 0;
  align-items: stretch;
}

.table-head {
  color: var(--paper);
  background: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.table-head span,
.order-row > span {
  min-width: 0;
  padding: 12px;
  border-right: 1px solid var(--soft-line);
}

.table-head span:last-child,
.order-row > span:last-child {
  border-right: 0;
}

.order-row {
  width: 100%;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--soft-line);
  transition: background 140ms ease;
}

.order-row:hover,
.order-row.is-selected {
  background: #f3dfd7;
}

.order-row strong,
.order-row small {
  display: block;
}

.order-row small,
.quiet {
  color: rgba(26, 26, 46, 0.62);
  font-size: 12px;
}

.badge {
  align-self: center;
  justify-self: start;
  padding: 5px 8px;
  color: var(--ink);
  background: #e8dedb;
  border: 1px solid rgba(26, 26, 46, 0.18);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge-at_risk,
.badge-watch {
  color: #fff7f1;
  background: var(--danger);
}

.badge-ready,
.badge-done,
.badge-signed,
.badge-shipped,
.badge-active {
  color: #f9fff7;
  background: var(--field);
}

.forge-layout,
.team-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 18px;
}

.paper-preview {
  min-height: 430px;
  padding: 28px;
  background:
    linear-gradient(90deg, transparent 28px, rgba(201, 173, 167, 0.35) 29px, transparent 30px),
    var(--white-paper);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
}

.paper-preview h3 {
  margin: 0 0 18px;
  font-size: 28px;
}

.paper-preview dl,
.inspect-list {
  display: grid;
  gap: 12px;
  margin: 0 0 22px;
}

.paper-preview dl div,
.inspect-list div {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--soft-line);
}

dt {
  color: var(--mauve);
  font-size: 12px;
  font-weight: 800;
}

dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.template-list,
.action-feed,
.settings-block {
  border: 1px solid var(--line);
  background: rgba(255, 250, 244, 0.7);
}

.template-item {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 82px;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--soft-line);
}

.template-item:hover {
  background: #ead8d2;
}

.template-item span,
.person span,
.person small,
.setting-line small {
  color: rgba(26, 26, 46, 0.64);
}

.action-line {
  display: grid;
  grid-template-columns: 150px 110px 100px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--soft-line);
}

.action-line:last-child,
.template-item:last-child {
  border-bottom: 0;
}

.action-line time,
.action-line span {
  color: rgba(26, 26, 46, 0.62);
  font-size: 12px;
}

.action-line p {
  min-width: 0;
  margin: 0;
}

.settings-block {
  padding: 16px;
}

.settings-block h3 {
  margin-bottom: 12px;
}

.setting-line,
.person {
  display: grid;
  gap: 5px;
  padding: 12px 0;
  border-top: 1px solid var(--soft-line);
}

.setting-line:first-of-type,
.person:first-of-type {
  border-top: 0;
}

.inspector {
  min-width: 0;
  min-height: 100vh;
  padding: 24px 20px;
  background: #fff7ef;
}

.inspector-head {
  padding-bottom: 18px;
  border-bottom: 2px solid var(--ink);
}

.inspect-body {
  padding-top: 18px;
}

.empty {
  padding: 22px;
  color: rgba(26, 26, 46, 0.65);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 14px 16px;
  color: var(--paper);
  background: var(--ink);
  border: 2px solid var(--clay);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

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

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

  .inspector {
    grid-column: 1 / -1;
    min-height: auto;
    border-top: 2px solid var(--ink);
  }
}

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

  .rail {
    min-height: auto;
    gap: 18px;
    border-right: 0;
    border-bottom: 3px solid var(--clay);
  }

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

  .nav-tab {
    min-height: 40px;
    padding: 8px;
    text-align: center;
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .canvas-title {
    display: grid;
    align-items: start;
  }

  .topbar-actions,
  .search input,
  .canvas-title select {
    width: 100%;
  }

  .topbar-actions {
    display: grid;
  }

  .metric-strip,
  .timeline,
  .forge-layout,
  .team-grid {
    grid-template-columns: 1fr;
  }

  .metric,
  .workflow-step {
    border-right: 0;
    border-bottom: 1px solid var(--soft-line);
  }

  .metric:last-child,
  .workflow-step:last-child {
    border-bottom: 0;
  }

  .table-head {
    display: none;
  }

  .order-row {
    grid-template-columns: 1fr;
  }

  .order-row > span {
    border-right: 0;
    padding: 8px 12px;
  }

  .action-line {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

@media (max-width: 520px) {
  .nav-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar h1 {
    font-size: 28px;
  }

  .metric strong {
    font-size: 34px;
  }

  .paper-preview dl div,
  .inspect-list div {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

