:root {
  --ink: #1a1a2e;
  --paper: #f2e9e4;
  --mauve: #9a8c98;
  --clay: #c9ada7;
  --linen: #fffaf3;
  --line: rgba(26, 26, 46, 0.18);
  --danger: #b43f32;
  --warn: #8f6a12;
  --calm: #31705d;
}

* {
  box-sizing: border-box;
}

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

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

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

button {
  cursor: pointer;
}

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

.left-rail,
.inspection {
  background: var(--ink);
  color: var(--paper);
}

.left-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  border-right: 3px solid var(--clay);
}

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

.brand img {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(242, 233, 228, 0.2);
}

.nav-tabs {
  display: grid;
  gap: 6px;
  margin-top: 34px;
}

.nav-tab {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  color: rgba(242, 233, 228, 0.78);
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
}

.nav-tab.is-active {
  color: var(--paper);
  background: rgba(242, 233, 228, 0.08);
  border-left-color: var(--clay);
}

.tab-mark {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--clay);
}

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

.rail-note span {
  display: block;
  color: rgba(242, 233, 228, 0.62);
  font-size: 12px;
  text-transform: uppercase;
}

.rail-note strong {
  display: block;
  margin-top: 8px;
  line-height: 1.35;
}

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

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

.eyebrow {
  margin: 0 0 7px;
  color: var(--mauve);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

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

.toolbar {
  display: flex;
  gap: 8px;
  min-width: min(100%, 520px);
}

.toolbar input,
.toolbar select,
.action-form textarea {
  width: 100%;
  color: var(--ink);
  background: var(--linen);
  border: 2px solid var(--ink);
  border-radius: 0;
  outline: none;
}

.toolbar input,
.toolbar select {
  min-height: 44px;
  padding: 0 12px;
}

.toolbar select {
  max-width: 160px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 18px;
  border: 2px solid var(--ink);
  background: var(--linen);
}

.metric {
  min-width: 0;
  padding: 16px;
  border-right: 2px solid var(--ink);
}

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

.metric span {
  display: block;
  min-height: 32px;
  color: var(--mauve);
  font-size: 13px;
}

.metric strong {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: clamp(32px, 4.5vw, 62px);
  line-height: 0.9;
}

.metric small {
  font-size: 18px;
}

.blueprint {
  margin-top: 18px;
  background: var(--clay);
  border: 2px solid var(--ink);
}

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

.stage {
  position: relative;
  min-height: 54px;
  padding: 10px 16px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-right: 2px solid var(--ink);
  text-align: left;
  font-weight: 800;
}

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

.stage span {
  display: block;
  color: rgba(26, 26, 46, 0.62);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.canvas-panel {
  margin-top: 18px;
}

.lanes {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  border: 2px solid var(--ink);
  background: var(--linen);
  overflow-x: auto;
}

.lane {
  min-height: 440px;
  border-right: 2px solid var(--ink);
}

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

.lane header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 12px;
  background: rgba(154, 140, 152, 0.16);
  border-bottom: 2px solid var(--ink);
  font-weight: 800;
}

.order-tile {
  display: block;
  width: calc(100% - 18px);
  margin: 9px;
  padding: 12px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 0;
  text-align: left;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.order-tile:hover,
.order-tile.is-selected {
  transform: translate(-2px, -2px);
  background: #fffdf8;
  box-shadow: 4px 4px 0 var(--ink);
}

.tile-top,
.tile-meta,
.tile-note {
  display: block;
}

.tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.tile-top em {
  font-style: normal;
  font-weight: 900;
}

.order-tile strong {
  display: block;
  margin-top: 10px;
  line-height: 1.18;
}

.tile-meta {
  margin-top: 10px;
  color: var(--mauve);
  font-size: 12px;
}

.tile-note {
  margin-top: 10px;
  color: rgba(26, 26, 46, 0.72);
  font-size: 12px;
  line-height: 1.35;
}

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

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

.calm {
  color: var(--calm);
}

.inspection {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  overflow-y: auto;
  border-left: 3px solid var(--clay);
}

.drawer-head h2 {
  margin-bottom: 22px;
  font-size: 28px;
  line-height: 1.05;
}

.muted {
  color: rgba(242, 233, 228, 0.68);
}

.inspection-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
  border: 1px solid rgba(242, 233, 228, 0.25);
}

.inspection-grid div {
  padding: 12px;
  border-right: 1px solid rgba(242, 233, 228, 0.25);
  border-bottom: 1px solid rgba(242, 233, 228, 0.25);
}

.inspection-grid dt {
  color: rgba(242, 233, 228, 0.58);
  font-size: 12px;
}

.inspection-grid dd {
  margin: 5px 0 0;
  font-size: 18px;
  font-weight: 900;
}

.inspect-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(242, 233, 228, 0.25);
}

.inspect-section h3,
.action-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--clay);
  font-size: 13px;
  text-transform: uppercase;
}

.inspect-section p {
  margin-bottom: 0;
  color: rgba(242, 233, 228, 0.86);
  line-height: 1.45;
}

.action-form {
  margin-top: 24px;
}

.action-form textarea {
  min-height: 108px;
  padding: 12px;
  resize: vertical;
}

.action-form button {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  color: var(--ink);
  background: var(--clay);
  border: 2px solid var(--paper);
  font-weight: 900;
}

.history-list,
.settings-grid,
.team-list,
.loading,
.empty-state,
.error-state {
  border: 2px solid var(--ink);
  background: var(--linen);
}

.history-row,
.setting-row,
.team-row {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-bottom: 2px solid var(--ink);
}

.history-row {
  grid-template-columns: 160px minmax(0, 1fr) 100px;
}

.history-row:last-child,
.setting-row:last-child,
.team-row:last-child {
  border-bottom: 0;
}

.history-row time,
.history-row span,
.setting-row span,
.team-row span {
  color: var(--mauve);
  font-size: 12px;
}

.history-row p,
.setting-row p {
  margin: 5px 0 0;
  line-height: 1.4;
}

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

.setting-row {
  border-right: 2px solid var(--ink);
}

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

.setting-row strong {
  font-size: 30px;
}

.team-row {
  grid-template-columns: minmax(0, 1fr) 160px 48px;
  align-items: center;
}

meter {
  width: 100%;
  height: 16px;
}

.loading,
.empty-state,
.error-state {
  padding: 28px;
  min-height: 180px;
}

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

  .inspection {
    position: static;
    grid-column: 1 / -1;
    height: auto;
    border-left: 0;
    border-top: 3px solid var(--clay);
  }
}

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

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

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

  .workspace {
    padding: 18px;
  }

  .topbar,
  .toolbar {
    display: grid;
  }

  .toolbar {
    min-width: 0;
  }

  .toolbar select {
    max-width: none;
  }

  .metric-strip,
  .blueprint-line,
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .metric {
    border-bottom: 2px solid var(--ink);
  }

  .lanes {
    grid-template-columns: minmax(220px, 1fr);
  }

  .lane {
    min-height: auto;
    border-right: 0;
    border-bottom: 2px solid var(--ink);
  }

  .history-row,
  .team-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .nav-tabs,
  .metric-strip,
  .blueprint-line,
  .settings-grid,
  .inspection-grid {
    grid-template-columns: 1fr;
  }

  .metric,
  .stage,
  .setting-row {
    border-right: 0;
  }
}

