:root {
  --ink: #263238;
  --paper: #f0f4f8;
  --surface: #ffffff;
  --green: #00a676;
  --yellow: #ffcf56;
  --muted: #6b7b83;
  --line: rgba(38, 50, 56, .14);
  --danger: #e65d4f;
  --shadow: 0 18px 55px rgba(38, 50, 56, .14);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.rail {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: var(--ink);
  color: var(--paper);
}

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

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

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

.brand small,
.mono,
.eyebrow {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0;
}

.brand small,
.mono,
.eyebrow,
.rail-note {
  color: rgba(240, 244, 248, .72);
  font-size: 12px;
}

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

.tab {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(240, 244, 248, .18);
  border-radius: 8px;
  background: transparent;
  color: var(--paper);
  text-align: left;
  padding: 10px 12px;
  transition: background .18s ease, transform .18s ease, border-color .18s ease;
}

.tab:hover,
.tab.is-active {
  background: rgba(0, 166, 118, .18);
  border-color: rgba(0, 166, 118, .7);
  transform: translateX(3px);
}

.rail-note {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(240, 244, 248, .18);
  line-height: 1.5;
}

.rail-note b {
  display: block;
  margin-top: 8px;
  color: var(--paper);
  font-weight: 650;
}

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

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 58px);
  line-height: .96;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.04;
  letter-spacing: 0;
}

.search {
  display: grid;
  gap: 6px;
  min-width: min(320px, 100%);
  color: var(--muted);
  font-size: 12px;
}

.search input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(255, 255, 255, .86);
  color: var(--ink);
  outline: none;
}

.search input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 166, 118, .16);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 96px;
  padding: 18px;
  background: rgba(255, 255, 255, .92);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: 0;
}

.metric.alert strong {
  color: var(--danger);
}

.board {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr) minmax(250px, 330px);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.path-panel,
.stage,
.inspector {
  min-width: 0;
}

.panel-head,
.notebook-head,
.inspector-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 14px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.panel-head .mono {
  color: var(--muted);
}

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

.record {
  display: grid;
  gap: 7px;
  width: 100%;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, .78);
  color: var(--ink);
  text-align: left;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.record:hover,
.record.is-selected {
  transform: translateY(-2px);
  border-color: rgba(0, 166, 118, .65);
  background: #fff;
}

.record strong,
.assignment strong,
.calendar-slot strong {
  overflow-wrap: anywhere;
}

.record small,
.record-foot {
  color: var(--muted);
  font-size: 12px;
}

.record-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.version,
.conflict-dot,
.phase-mark {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 24px;
  border-radius: 6px;
  padding: 3px 7px;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0;
  background: var(--ink);
  color: var(--paper);
}

.conflict-dot {
  background: var(--yellow);
  color: var(--ink);
}

.stage,
.inspector {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .86);
  padding: 18px;
  box-shadow: var(--shadow);
}

.notebook-head p,
.inspector-head p {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0;
}

.notebook-head .mono {
  color: var(--green);
}

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

.lane {
  min-height: 360px;
  border-left: 4px solid var(--line);
  padding-left: 12px;
}

.phase-0 {
  border-color: var(--green);
}

.phase-1 {
  border-color: var(--yellow);
}

.phase-2 {
  border-color: #5aa6d6;
}

.phase-3 {
  border-color: #263238;
}

.lane-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  margin-bottom: 10px;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.lane-title b {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
}

.assignment {
  display: grid;
  gap: 9px;
  min-height: 136px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.assignment.blocked {
  border-color: rgba(230, 93, 79, .7);
}

.assignment.done {
  opacity: .76;
}

.assignment .mono {
  color: var(--muted);
}

.assignment-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(38, 50, 56, .12);
}

.bar i {
  display: block;
  height: 100%;
  background: var(--green);
}

.detail-stack {
  display: grid;
  gap: 10px;
}

.detail-row {
  display: grid;
  grid-template-columns: 98px minmax(160px, 1fr) minmax(110px, .5fr) 92px;
  gap: 12px;
  align-items: center;
  min-height: 62px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.detail-row button,
.inspector-actions button {
  min-height: 38px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  padding: 8px 10px;
}

.detail-row button:disabled,
.inspector-actions button:disabled {
  cursor: not-allowed;
  opacity: .42;
}

.calendar-grid {
  display: grid;
  gap: 12px;
}

.calendar-lane {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  min-height: 96px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.calendar-lane h3 {
  margin: 0;
  font-size: 15px;
}

.calendar-slot {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 1px solid rgba(0, 166, 118, .38);
  border-radius: 8px;
  background: rgba(0, 166, 118, .08);
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.calendar-slot.has-conflict {
  border-color: var(--yellow);
  background: rgba(255, 207, 86, .18);
}

.calendar-slot span,
.calendar-slot em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.report-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

td span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.specs {
  display: grid;
  gap: 1px;
  margin: 0;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.specs div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 11px;
  background: #fff;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.inspector-actions {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.inspector-actions button:first-child {
  background: var(--green);
  border-color: var(--green);
  color: #061f18;
  font-weight: 750;
}

.empty-state,
.loading {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
}

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

  .rail {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    padding: 14px;
  }

  .tabs {
    display: flex;
    overflow-x: auto;
  }

  .tab {
    width: auto;
    min-width: 112px;
    text-align: center;
  }

  .rail-note {
    display: none;
  }

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

  .inspector {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .topbar {
    display: grid;
    align-items: start;
  }

  .metrics,
  .board,
  .workflow-lanes {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 82px;
  }

  .lane {
    min-height: auto;
  }

  .detail-row,
  .calendar-lane {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
