:root {
  --ink: #1a1a2e;
  --paper: #f2e9e4;
  --muted: #9a8c98;
  --clay: #c9ada7;
  --canvas: #fffaf4;
  --line: #2a2635;
  --green: #52796f;
  --amber: #b7791f;
  --red: #a33b2f;
  --shadow: 0 18px 60px rgba(26, 26, 46, 0.12);
}

* {
  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.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(26, 26, 46, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 42px 42px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

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

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

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

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

.brand small {
  color: var(--clay);
  font-size: 12px;
  margin-top: 2px;
}

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

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

.nav-button:hover,
.nav-button.is-active {
  color: var(--ink);
  background: var(--paper);
  transform: translateX(3px);
}

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

.rail-note span,
.rail-note b {
  display: block;
}

.rail-note span {
  color: var(--clay);
  font-size: 12px;
  text-transform: uppercase;
}

.rail-note b {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.45;
}

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

.work-header {
  min-height: 136px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 20px;
  align-items: stretch;
  border-bottom: 3px solid var(--line);
  padding-bottom: 22px;
  animation: rise 360ms ease both;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 0.94;
  letter-spacing: 0;
}

.work-header p {
  max-width: 760px;
  margin: 14px 0 0;
  color: #4b4150;
  line-height: 1.5;
}

.header-mark {
  padding: 14px;
  background: var(--canvas);
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.header-mark span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.header-mark strong {
  font-size: 56px;
  line-height: 1;
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 2px solid var(--line);
  border-top: 0;
  background: var(--canvas);
  animation: rise 420ms ease both;
}

.metric-cell {
  min-height: 104px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-right: 2px solid var(--line);
}

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

.metric-cell strong {
  font-size: clamp(28px, 4vw, 52px);
  line-height: 0.98;
}

.metric-cell span {
  margin-top: 6px;
  color: #615564;
  font-size: 13px;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
  margin-top: 22px;
}

.canvas-panel,
.inspector,
.history-panel,
.settings-grid,
.team-grid,
.loading-panel,
.error-panel {
  background: var(--canvas);
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
}

.canvas-panel {
  min-width: 0;
}

.tool-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 2px solid var(--line);
}

.stage-filters {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stage-chip {
  min-height: 34px;
  padding: 7px 10px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 0;
}

.stage-chip.is-active {
  color: var(--paper);
  background: var(--ink);
}

.search-box {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.search-box span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.search-box input {
  min-width: 0;
  height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0;
}

.calendar-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(126px, 1fr));
  border-bottom: 2px solid var(--line);
  overflow-x: auto;
}

.calendar-slot {
  min-height: 118px;
  padding: 13px;
  border-right: 2px solid var(--line);
  background: rgba(242, 233, 228, 0.58);
  display: grid;
  align-content: space-between;
  transition: background 180ms ease;
}

.calendar-slot:hover {
  background: #fff;
}

.calendar-slot span,
.calendar-slot small {
  color: #625866;
  font-size: 12px;
}

.calendar-slot strong {
  font-size: 26px;
}

.conflict-high {
  box-shadow: inset 0 -6px 0 var(--red);
}

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

.conflict-none {
  box-shadow: inset 0 -6px 0 var(--green);
}

.order-list {
  display: grid;
}

.order-row {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 14px;
  align-items: center;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(26, 26, 46, 0.22);
}

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

.row-title,
.row-meta,
.row-copy {
  min-width: 0;
  overflow-wrap: anywhere;
}

.row-title {
  display: block;
  font-weight: 800;
}

.row-meta {
  display: block;
  margin-top: 5px;
  color: #625866;
  font-size: 13px;
}

.row-risk {
  min-width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  font-weight: 900;
}

.risk-high {
  color: var(--red);
}

.risk-watch {
  color: var(--amber);
}

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

.inspector {
  position: sticky;
  top: 24px;
  overflow: hidden;
}

.inspector-top {
  padding: 18px;
  color: var(--paper);
  background: var(--ink);
}

.status-tag {
  display: inline-block;
  margin-bottom: 16px;
  padding: 4px 7px;
  color: var(--ink);
  background: var(--clay);
  font-size: 12px;
  font-weight: 800;
}

.inspector-top strong {
  display: block;
  font-size: 24px;
  overflow-wrap: anywhere;
}

.inspector-top p {
  margin: 8px 0 0;
  color: var(--clay);
  line-height: 1.45;
}

.inspect-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
  border-bottom: 2px solid var(--line);
}

.inspect-grid div {
  min-width: 0;
  padding: 13px;
  border-right: 1px solid rgba(26, 26, 46, 0.22);
  border-bottom: 1px solid rgba(26, 26, 46, 0.22);
}

dt {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

dd {
  margin: 5px 0 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.paper-note {
  padding: 16px;
  line-height: 1.5;
  border-bottom: 2px solid var(--line);
}

.action-stack {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.action-stack button,
.primary-action,
.error-panel button {
  min-height: 40px;
  padding: 9px 12px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 0;
}

.action-stack button:hover,
.primary-action,
.error-panel button {
  color: var(--paper);
  background: var(--ink);
}

.history-panel,
.settings-grid,
.team-grid {
  margin-top: 22px;
}

.history-row,
.setting-row,
.team-row {
  min-width: 0;
  display: grid;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid rgba(26, 26, 46, 0.24);
}

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

.history-row time,
.history-row span,
.setting-row span,
.team-row span,
.team-row small {
  color: #625866;
  font-size: 12px;
}

.history-row p {
  margin: 5px 0 0;
  line-height: 1.45;
}

.history-row span {
  justify-self: end;
  padding: 5px 8px;
  border: 1px solid var(--line);
}

.setting-row {
  grid-template-columns: minmax(0, 1.2fr) 90px minmax(0, 1fr) 58px;
}

.setting-row strong,
.team-row strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.toggle input {
  position: absolute;
  opacity: 0;
}

.toggle i {
  width: 48px;
  height: 28px;
  display: block;
  background: var(--muted);
  border: 2px solid var(--line);
}

.toggle i::after {
  content: "";
  width: 18px;
  height: 18px;
  margin: 3px;
  display: block;
  background: var(--paper);
  transition: transform 160ms ease;
}

.toggle input:checked + i {
  background: var(--green);
}

.toggle input:checked + i::after {
  transform: translateX(20px);
}

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

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

.loading-panel,
.error-panel,
.empty-state {
  min-height: 170px;
  padding: 26px;
  display: grid;
  place-items: center;
  text-align: center;
}

.loading-panel span {
  width: 42px;
  height: 42px;
  border: 3px solid var(--clay);
  border-top-color: var(--ink);
  animation: spin 900ms linear infinite;
}

.error-panel {
  gap: 12px;
  align-content: center;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

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

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

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

  .nav-button {
    text-align: center;
  }

  .rail-note {
    margin-top: 0;
  }

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

  .inspector {
    position: static;
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 14px;
  }

  .work-header {
    grid-template-columns: 1fr;
  }

  .header-mark {
    min-height: 106px;
  }

  .metrics-strip {
    grid-template-columns: 1fr 1fr;
  }

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

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

  .rail-nav {
    grid-template-columns: 1fr 1fr;
  }

  .history-row span {
    justify-self: start;
  }

  .calendar-board {
    grid-template-columns: repeat(2, minmax(136px, 1fr));
  }
}
