:root {
  --ink: #17202a;
  --paper: #f7f3e8;
  --teal: #2f8f83;
  --amber: #f2b544;
  --clay: #c85f4b;
  --mist: #e5ded0;
  --line: rgba(23, 32, 42, .16);
  --shadow: 0 22px 70px rgba(23, 32, 42, .14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(23, 32, 42, .055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 32, 42, .05) 1px, transparent 1px),
    var(--paper);
  background-size: 64px 64px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: var(--ink);
  color: var(--paper);
}

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

.brand img {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

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

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

.brand small {
  color: rgba(247, 243, 232, .68);
  margin-top: 4px;
}

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

.tab {
  border: 1px solid rgba(247, 243, 232, .14);
  background: rgba(247, 243, 232, .06);
  color: var(--paper);
  min-height: 44px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border-radius: 8px;
  transition: background .18s ease, transform .18s ease, border-color .18s ease;
}

.tab:hover,
.tab.is-active {
  background: rgba(47, 143, 131, .3);
  border-color: rgba(47, 143, 131, .8);
  transform: translateX(2px);
}

.tab-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
}

.rail-note {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(247, 243, 232, .72);
  font-size: 13px;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 0 rgba(242, 181, 68, .7);
  animation: pulse 1.8s infinite;
}

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

.topbar,
.section-head,
.metrics,
.planner-grid,
.analytics-layout {
  animation: rise .42s ease both;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .09em;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 54px);
  line-height: .98;
  max-width: 780px;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.1;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search {
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(23, 32, 42, .72);
}

.search input {
  width: min(280px, 58vw);
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .48);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.search input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 143, 131, .16);
}

.icon-button,
.primary-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.icon-button {
  width: 42px;
  background: var(--ink);
  color: var(--paper);
}

.primary-button {
  padding: 0 16px;
  background: var(--teal);
  color: white;
}

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

.metrics div {
  min-width: 0;
  padding: 14px 16px 14px 0;
}

.metrics span {
  display: block;
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
}

.metrics small {
  color: rgba(23, 32, 42, .62);
  font-weight: 700;
}

.screen {
  display: none;
}

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

.planner-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.calendar-panel,
.inspector,
.chart-surface,
.import-panel,
.public-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(247, 243, 232, .74);
  box-shadow: var(--shadow);
}

.calendar-panel,
.chart-surface,
.import-panel,
.public-status {
  padding: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.section-head.compact {
  margin-top: 22px;
}

.sync-time,
.status-line {
  color: rgba(23, 32, 42, .62);
  font-size: 13px;
  font-weight: 700;
}

.time-ruler {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 0 10px 8px 188px;
  color: rgba(23, 32, 42, .5);
  font-size: 12px;
  font-weight: 800;
}

.lane-board {
  display: grid;
  gap: 10px;
}

.lane {
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  min-height: 96px;
  border-top: 1px solid var(--line);
}

.lane-person {
  padding: 12px 14px 10px 0;
  border-right: 1px solid var(--line);
}

.lane-person strong,
.lane-person span {
  display: block;
}

.lane-person strong {
  color: var(--lane-color);
  font-size: 15px;
}

.lane-person span {
  margin: 3px 0 10px;
  color: rgba(23, 32, 42, .64);
  font-size: 12px;
}

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

.lane-track {
  position: relative;
  min-height: 96px;
  background:
    linear-gradient(90deg, rgba(23, 32, 42, .08) 1px, transparent 1px);
  background-size: 20% 100%;
}

.session-block {
  position: absolute;
  top: 14px;
  width: min(220px, 34%);
  min-height: 62px;
  border: 2px solid var(--teal);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink);
  text-align: left;
  padding: 10px;
  box-shadow: 0 10px 24px rgba(23, 32, 42, .12);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.session-block:hover,
.session-block.is-selected {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(23, 32, 42, .18);
}

.session-block strong,
.session-block span {
  display: block;
  overflow-wrap: anywhere;
}

.session-block strong {
  font-size: 13px;
}

.session-block span {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(23, 32, 42, .62);
}

.state-done {
  background: rgba(47, 143, 131, .12);
}

.state-blocked {
  background: rgba(200, 95, 75, .14);
}

.state-active {
  background: rgba(242, 181, 68, .18);
}

.inspector {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.inspector-inner {
  padding: 18px;
}

.inspector-title h2 {
  margin: 10px 0 6px;
  font-size: 26px;
}

.inspector-title p {
  color: rgba(23, 32, 42, .64);
}

.big-progress {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 16px 0;
}

.big-progress span,
.bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(23, 32, 42, .1);
  overflow: hidden;
}

.big-progress span {
  display: block;
  background: var(--teal);
}

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

.stop-list {
  display: grid;
  gap: 12px;
}

.stop-row {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.stop-row strong,
.stop-row span {
  display: block;
}

.stop-row span {
  margin-top: 3px;
  color: rgba(23, 32, 42, .62);
  font-size: 12px;
}

.proof-list,
.state-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.proof-badge,
.route-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}

.proof-accepted,
.status-done {
  background: rgba(47, 143, 131, .15);
  color: #1e655d;
}

.proof-review,
.status-active,
.status-planned {
  background: rgba(242, 181, 68, .22);
  color: #7a5310;
}

.proof-pending,
.status-risk,
.status-blocked {
  background: rgba(200, 95, 75, .16);
  color: #8c3f31;
}

.state-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

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

.portfolio {
  margin-top: 0;
}

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

.route-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, .86);
  color: var(--ink);
  text-align: left;
  padding: 14px;
  display: grid;
  gap: 9px;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.route-card:hover,
.route-card.is-selected {
  transform: translateY(-2px);
  border-color: var(--teal);
  background: white;
}

.route-card strong,
.route-card small {
  overflow-wrap: anywhere;
}

.route-card strong {
  font-size: 17px;
  line-height: 1.08;
}

.route-card small,
.route-meta {
  color: rgba(23, 32, 42, .64);
}

.route-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.route-meta em {
  font-style: normal;
}

.analytics-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 18px;
}

.progress-bars {
  display: grid;
  gap: 14px;
}

.progress-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 2fr 52px;
  gap: 12px;
  align-items: center;
}

.progress-row span {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.progress-row div {
  height: 18px;
  background: rgba(23, 32, 42, .1);
  border-radius: 999px;
  overflow: hidden;
}

.progress-row i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

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

.proof-cell {
  min-height: 140px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  border-radius: 8px;
}

.proof-cell strong {
  font-size: 42px;
  line-height: 1;
}

.mapping-grid,
.public-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.mapping-grid div,
.public-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 250, 240, .74);
}

.mapping-grid strong,
.mapping-grid span {
  display: block;
}

.mapping-grid span {
  margin-top: 8px;
  color: rgba(23, 32, 42, .62);
  overflow-wrap: anywhere;
}

.status-line {
  margin: 16px 0 0;
}

.public-item h3 {
  margin: 12px 0 8px;
}

.public-item p {
  margin-bottom: 8px;
}

.public-item small {
  color: rgba(23, 32, 42, .64);
}

.empty-state {
  padding: 18px;
  color: rgba(23, 32, 42, .62);
  font-weight: 700;
}

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

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

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 12px rgba(242, 181, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(242, 181, 68, 0);
  }
}

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

@media (max-width: 1120px) {
  .planner-grid,
  .analytics-layout {
    grid-template-columns: 1fr;
  }

  .inspector {
    position: static;
    max-height: none;
  }

  .route-grid,
  .mapping-grid,
  .public-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .rail {
    position: static;
    height: auto;
    padding: 14px;
    gap: 14px;
  }

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

  .tab {
    justify-content: center;
  }

  .tab span:last-child {
    display: none;
  }

  .workspace {
    padding: 16px;
  }

  .topbar {
    display: grid;
  }

  .toolbar {
    justify-content: stretch;
  }

  .search {
    flex: 1 1 auto;
  }

  .search input {
    width: 100%;
  }

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

  .time-ruler {
    display: none;
  }

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

  .lane-person {
    border-right: 0;
  }

  .lane-track {
    min-height: 168px;
    background-size: 25% 100%;
  }

  .session-block {
    width: 74%;
    left: 12px !important;
  }

  .route-grid,
  .mapping-grid,
  .public-board,
  .proof-matrix {
    grid-template-columns: 1fr;
  }

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