:root {
  --ink: #14213d;
  --paper: #ffffff;
  --line: #d7dce6;
  --muted: #69758a;
  --action: #fca311;
  --trust: #2a9d8f;
  --wash: #f5f6f8;
  --danger: #b23b3b;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(20, 33, 61, 0.055) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(0deg, rgba(20, 33, 61, 0.045) 1px, transparent 1px) 0 0 / 36px 36px,
    var(--paper);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

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

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.brand strong {
  display: block;
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--wash);
}

.tab {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

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

.workspace {
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr) 300px;
  gap: 18px;
  padding: 18px;
}

.rail,
.inspector,
.main-panel {
  min-width: 0;
}

.rail {
  padding-top: 4px;
}

.rail-title,
.kicker {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stage-filter {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 42px;
  margin-bottom: 7px;
  padding: 0 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.stage-filter span {
  width: 8px;
  height: 8px;
  border: 2px solid var(--ink);
  border-radius: 50%;
}

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

.stage-filter.is-active span {
  background: var(--action);
  border-color: var(--action);
}

.panel,
.inspector {
  border: 1px solid var(--ink);
  background: rgba(255, 255, 255, 0.92);
}

.main-panel {
  min-height: calc(100vh - 102px);
}

.screen {
  display: none;
  padding: 22px;
  animation: screenIn 180ms ease-out both;
}

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

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

.board-head,
.split-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

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

h1,
h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(32px, 5vw, 68px);
  line-height: 0.95;
}

h2 {
  font-size: clamp(25px, 3vw, 42px);
  line-height: 1;
}

h3 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search {
  display: grid;
  gap: 5px;
  width: min(320px, 100%);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.search input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0 12px;
  color: var(--ink);
  background: var(--paper);
  outline: none;
}

.search input:focus {
  box-shadow: 0 0 0 3px rgba(252, 163, 17, 0.24);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  margin-bottom: 18px;
}

.metric {
  padding: 14px;
  border-right: 1px solid var(--line);
}

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

.metric b {
  display: block;
  font-size: clamp(26px, 3vw, 40px);
  font-family: var(--serif);
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.workflow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.workflow-step {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--wash);
  position: relative;
  overflow: hidden;
}

.workflow-step::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: var(--fill, 20%);
  height: 4px;
  background: var(--action);
  transition: width 220ms ease;
}

.workflow-step strong {
  display: block;
  font-size: 15px;
}

.workflow-step span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.item-list {
  display: grid;
  gap: 8px;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.3fr) 110px 120px 120px 94px;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.item-row:hover,
.item-row.is-selected {
  border-color: var(--ink);
  transform: translateX(3px);
}

.item-title {
  min-width: 0;
}

.item-title strong {
  display: block;
  font-size: 16px;
}

.item-title small,
.cell-note {
  color: var(--muted);
  font-size: 12px;
}

.stage-pill {
  display: inline-flex;
  justify-content: center;
  min-width: 92px;
  padding: 6px 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
}

.stage-pill.archive {
  background: var(--trust);
}

.stage-pill.deal {
  background: var(--action);
  color: var(--ink);
}

.progress-line {
  height: 7px;
  background: var(--line);
}

.progress-line span {
  display: block;
  width: var(--value);
  height: 100%;
  background: var(--trust);
}

.row-action,
.accent-action,
.ghost-action {
  min-height: 38px;
  border: 1px solid var(--ink);
  padding: 0 12px;
}

.row-action,
.accent-action {
  background: var(--action);
  color: var(--ink);
  font-weight: 800;
}

.ghost-action {
  width: 100%;
  margin-top: 12px;
  background: var(--paper);
  color: var(--ink);
}

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

.detail-block,
.report-block {
  border-top: 2px solid var(--ink);
  padding-top: 14px;
  min-width: 0;
}

dl {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 0;
  font-weight: 700;
}

.stack-list {
  display: grid;
  gap: 8px;
}

.stack-item {
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--wash);
}

.stack-item strong {
  display: block;
}

.stack-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.event {
  min-height: 150px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.event time {
  display: inline-block;
  margin-bottom: 16px;
  padding: 5px 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
}

.event .status {
  display: inline-block;
  margin-top: 12px;
  color: var(--trust);
  font-weight: 800;
  font-size: 12px;
}

.bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 10px;
}

.bar-track {
  height: 12px;
  background: var(--line);
}

.bar-track span {
  display: block;
  width: var(--value);
  height: 100%;
  background: var(--action);
}

.inspector {
  min-height: calc(100vh - 102px);
  padding: 18px;
  position: sticky;
  top: 86px;
  align-self: start;
}

.inspector h2 {
  margin-bottom: 16px;
  font-size: 31px;
}

.inspector p:last-child {
  color: var(--muted);
  line-height: 1.5;
}

.mini-map {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.mini-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.mini-step.is-current {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.mini-step.is-done {
  border-color: var(--trust);
  color: var(--ink);
}

.empty,
.error {
  padding: 18px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--wash);
}

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

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 148px minmax(0, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
    min-height: auto;
    position: static;
  }

  .item-row {
    grid-template-columns: minmax(160px, 1fr) 105px 105px 94px;
  }

  .item-row .cell-note:nth-of-type(2) {
    display: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    flex: 1 0 auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .rail {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0;
  }

  .rail-title {
    display: none;
  }

  .stage-filter {
    flex: 0 0 auto;
    width: auto;
    min-height: 38px;
    margin: 0;
  }

  .screen {
    padding: 16px;
  }

  .board-head,
  .split-head {
    flex-direction: column;
  }

  .metrics,
  .workflow,
  .detail-grid,
  .report-grid,
  .calendar-grid {
    grid-template-columns: 1fr;
  }

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

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

  .item-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .stage-pill,
  .row-action {
    justify-self: start;
  }

  dl {
    grid-template-columns: 96px minmax(0, 1fr);
  }
}
