:root {
  --ink: #1b1b3a;
  --paper: #fbfefb;
  --coral: #ff6b6b;
  --teal: #4ecdc4;
  --charcoal: #232635;
  --mist: #edf4ef;
  --line: rgba(27, 27, 58, 0.16);
  --line-strong: rgba(27, 27, 58, 0.34);
  --muted: rgba(27, 27, 58, 0.66);
  --shadow: 0 20px 55px rgba(27, 27, 58, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 360px;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(27, 27, 58, 0.055) 1px, transparent 1px),
    linear-gradient(0deg, rgba(27, 27, 58, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}

.left-rail,
.inspect-drawer {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 0;
  overflow: auto;
  background: rgba(251, 254, 251, 0.92);
}

.left-rail {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px;
  border-right: 2px solid var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 20px;
  font-weight: 850;
  line-height: 1;
}

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

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

.nav-button {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 9px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.nav-button span {
  width: 12px;
  height: 12px;
  border: 2px solid var(--teal);
}

.nav-button:hover span,
.nav-button.is-active span {
  background: var(--coral);
  border-color: var(--ink);
}

.rail-status {
  margin-top: auto;
  padding-top: 18px;
  border-top: 2px solid var(--ink);
}

.rail-status span,
.drawer-kicker,
.eyebrow,
.request-form span,
.tile-top,
.tile-bottom,
.inspect-title span,
.mini-section > span,
.activity-list span,
.table-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.rail-status strong {
  display: block;
  margin-top: 8px;
  color: var(--charcoal);
  font-size: 13px;
  line-height: 1.45;
}

.workspace {
  min-width: 0;
  padding: 26px clamp(16px, 3vw, 38px) 42px;
}

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

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

.eyebrow {
  margin-bottom: 7px;
  color: var(--teal);
}

h1 {
  max-width: 850px;
  margin-bottom: 0;
  font-size: clamp(34px, 5vw, 72px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.sync-state {
  flex: 0 0 auto;
  max-width: 190px;
  padding: 9px 11px;
  border: 2px solid var(--ink);
  background: var(--paper);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.sync-state[data-mode="busy"] {
  background: var(--teal);
}

.sync-state[data-mode="ok"] {
  background: var(--paper);
}

.sync-state[data-mode="error"] {
  background: var(--coral);
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 22px 0;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.metrics-strip article {
  min-width: 0;
  padding: 16px;
  border-right: 1px solid var(--line-strong);
}

.metrics-strip article:last-child {
  border-right: 0;
}

.metrics-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metrics-strip strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.filters-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 24px;
  padding: 12px 0;
  background: rgba(251, 254, 251, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.filters-bar label {
  display: grid;
  gap: 6px;
  min-width: min(340px, 100%);
}

.filters-bar label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.filters-bar input,
.request-form input {
  width: 100%;
  min-height: 42px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  padding: 9px 11px;
  color: var(--ink);
  outline: 0;
}

.filters-bar input:focus,
.request-form input:focus {
  box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.36);
}

.segment-control {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.segment-control button,
.drawer-actions button,
.request-form button {
  min-height: 38px;
  border: 2px solid var(--ink);
  background: var(--paper);
  padding: 8px 11px;
  cursor: pointer;
  font-weight: 800;
}

.segment-control button:hover,
.segment-control button.is-active,
.drawer-actions button:hover,
.request-form button {
  background: var(--ink);
  color: var(--paper);
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
  animation: panelIn 180ms ease-out;
}

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

.section-head p {
  max-width: 660px;
  margin-bottom: 0;
}

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

.route-tile {
  display: grid;
  gap: 12px;
  min-height: 214px;
  padding: 16px;
  border: 2px solid var(--ink);
  background: rgba(251, 254, 251, 0.86);
  cursor: pointer;
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.route-tile:hover,
.route-tile.is-selected {
  transform: translateY(-2px);
  background: #ffffff;
  box-shadow: 8px 8px 0 var(--teal);
}

.route-tile.is-selected {
  box-shadow: 8px 8px 0 var(--coral);
}

.tile-top,
.tile-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tile-top i {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid var(--ink);
  color: var(--ink);
  font-style: normal;
}

.tone-red {
  background: var(--coral);
}

.tone-teal {
  background: var(--teal);
}

.tone-quiet {
  background: var(--mist);
}

.route-tile > strong {
  font-size: clamp(21px, 2.4vw, 31px);
  line-height: 1.02;
}

.guest-line,
.route-line {
  color: var(--charcoal);
  overflow-wrap: anywhere;
}

.progress-line {
  display: block;
  width: 100%;
  height: 12px;
  border: 2px solid var(--ink);
  background: var(--paper);
}

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

.request-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
  padding: 18px;
  border: 2px solid var(--ink);
  background: rgba(251, 254, 251, 0.86);
  box-shadow: var(--shadow);
}

.request-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.request-form button {
  align-self: end;
}

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

.activity-list article,
.table-row,
.table-head {
  display: grid;
  grid-template-columns: 136px minmax(0, 1.2fr) minmax(90px, 0.5fr) minmax(92px, 0.5fr);
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 254, 251, 0.72);
}

.activity-list article {
  grid-template-columns: 142px 120px minmax(0, 1fr);
}

.activity-list p {
  margin-bottom: 0;
}

.data-table {
  border: 2px solid var(--ink);
  background: rgba(251, 254, 251, 0.88);
  overflow: auto;
}

.table-head {
  background: var(--ink);
  color: var(--paper);
}

.table-row strong,
.table-row span,
.activity-list strong,
.activity-list span,
.activity-list p {
  min-width: 0;
  overflow-wrap: anywhere;
}

.inspect-drawer {
  padding: 22px;
  border-left: 2px solid var(--ink);
}

.drawer-kicker {
  margin-bottom: 14px;
}

.inspector-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 2px dashed var(--line-strong);
  color: var(--muted);
  text-align: center;
}

.inspector-content {
  display: grid;
  gap: 18px;
}

.inspect-title {
  display: grid;
  gap: 7px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--ink);
}

.inspect-title strong {
  font-size: 28px;
  line-height: 1;
}

.inspect-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.inspect-facts div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
}

.inspect-facts dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.inspect-facts dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
}

.mini-section {
  display: grid;
  gap: 9px;
}

.mini-section ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mini-section li {
  display: grid;
  gap: 3px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.mini-section li span {
  width: max-content;
  max-width: 100%;
  padding: 2px 6px;
  background: var(--mist);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-section li small {
  color: var(--muted);
}

.drawer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.drawer-actions button:last-child {
  background: var(--coral);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 28px;
  border: 2px dashed var(--line-strong);
  background: rgba(251, 254, 251, 0.82);
  color: var(--muted);
}

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

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

  .inspect-drawer {
    position: relative;
    grid-column: 1 / -1;
    height: auto;
    border-left: 0;
    border-top: 2px solid var(--ink);
  }
}

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

  .left-rail,
  .inspect-drawer {
    position: relative;
    height: auto;
  }

  .left-rail {
    border-right: 0;
    border-bottom: 2px solid var(--ink);
  }

  .rail-nav,
  .metrics-strip,
  .portfolio-grid,
  .request-form,
  .inspect-facts {
    grid-template-columns: 1fr;
  }

  .topline,
  .filters-bar,
  .section-head {
    display: grid;
  }

  .filters-bar {
    top: 0;
  }

  .segment-control {
    justify-content: start;
  }

  .metrics-strip article {
    border-right: 0;
    border-bottom: 1px solid var(--line-strong);
  }

  .metrics-strip article:last-child {
    border-bottom: 0;
  }

  .activity-list article,
  .table-row,
  .table-head {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .drawer-actions {
    grid-template-columns: 1fr;
  }
}
