:root {
  --ink: #0d1b2a;
  --paper: #f5ebe0;
  --steel: #778da9;
  --amber: #e0a458;
  --line: rgba(13, 27, 42, 0.18);
  --muted: rgba(13, 27, 42, 0.64);
  --surface: #fffaf4;
  --green: #3f7d58;
  --red: #b44b4b;
  --blue: #335c81;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(13, 27, 42, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 27, 42, 0.045) 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,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.metrics-spine {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 18px;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: inset -1px 0 0 rgba(245, 235, 224, 0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-weight: 900;
  letter-spacing: 0;
}

.brand img {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(245, 235, 224, 0.24);
  border-radius: 10px;
}

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

.nav-button,
.primary-action,
.secondary-action,
.ghost-action,
.segment {
  border: 0;
  border-radius: 7px;
  min-height: 40px;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.nav-button {
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  background: rgba(245, 235, 224, 0.08);
  color: rgba(245, 235, 224, 0.78);
}

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

.spine-gauge {
  display: grid;
  gap: 4px;
  padding: 16px;
  border: 1px solid rgba(245, 235, 224, 0.2);
  background: repeating-linear-gradient(135deg, rgba(245, 235, 224, 0.08), rgba(245, 235, 224, 0.08) 4px, transparent 4px, transparent 10px);
  border-radius: 8px;
}

.spine-gauge strong {
  font-size: clamp(42px, 8vw, 68px);
  line-height: 0.95;
}

.spine-gauge small,
.rail-note {
  color: rgba(245, 235, 224, 0.72);
}

.rail-note {
  margin-top: auto;
  display: grid;
  gap: 8px;
  line-height: 1.35;
}

.mono,
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0;
  font-weight: 800;
  color: var(--steel);
}

.workspace {
  min-width: 0;
  padding: 22px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--ink);
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  letter-spacing: 0;
}

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

.search-box {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  min-height: 40px;
  padding: 0 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(224, 164, 88, 0.22);
}

.primary-action {
  background: var(--amber);
  color: var(--ink);
  font-weight: 900;
  padding: 0 14px;
}

.secondary-action,
.ghost-action {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  font-weight: 800;
  padding: 0 12px;
}

.wide {
  width: 100%;
}

.control-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--paper);
}

.control-strip span {
  background: var(--ink);
  border-radius: 7px;
  padding: 9px 11px;
  min-height: 38px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  display: grid;
  gap: 4px;
  min-width: 0;
}

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

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

.view {
  display: none;
}

.view.is-visible {
  display: block;
  animation: rise 220ms ease both;
}

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

.board-layout,
.details-grid,
.report-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

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

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segment {
  min-height: 31px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

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

.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.lane {
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 244, 0.82);
}

.lane header {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-weight: 900;
}

.tone-a header {
  background: rgba(119, 141, 169, 0.18);
}

.tone-b header {
  background: rgba(224, 164, 88, 0.2);
}

.tone-c header {
  background: rgba(63, 125, 88, 0.18);
}

.tone-d header {
  background: rgba(180, 75, 75, 0.16);
}

.tone-e header {
  background: rgba(13, 27, 42, 0.08);
}

.lane-stack {
  display: grid;
  gap: 8px;
  padding: 8px;
  min-height: 420px;
}

.booking-card {
  width: 100%;
  display: grid;
  gap: 8px;
  text-align: left;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.booking-card:hover,
.booking-card.is-selected {
  border-color: var(--ink);
  transform: translateY(-2px);
}

.booking-card strong,
.booking-card span,
.booking-card small {
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.card-top em,
.status {
  font-style: normal;
  border-radius: 99px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 900;
  background: rgba(119, 141, 169, 0.22);
}

.status.express,
.card-top em {
  background: rgba(224, 164, 88, 0.32);
}

.progress {
  height: 7px;
  border-radius: 99px;
  background: rgba(13, 27, 42, 0.12);
  overflow: hidden;
}

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

.quick-panel,
.inspector,
.route-map,
.calendar-panel,
.report-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.panel-dial {
  display: grid;
  gap: 3px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.quick-form {
  display: grid;
  gap: 10px;
  margin: 12px 0 16px;
}

.quick-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.resource-title {
  display: grid;
  gap: 2px;
}

.resource {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.resource small {
  display: block;
  color: var(--muted);
}

.resource-led {
  width: 11px;
  height: 34px;
  border-radius: 4px;
  background: var(--steel);
}

.resource-led.ready {
  background: var(--green);
}

.resource-led.busy {
  background: var(--amber);
}

.resource-led.maintenance {
  background: var(--red);
}

.details-panel {
  display: grid;
  gap: 12px;
}

.detail-plate {
  min-height: 150px;
  padding: 16px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(245, 235, 224, 0.92), rgba(245, 235, 224, 0.76)),
    repeating-linear-gradient(90deg, transparent, transparent 14px, rgba(13, 27, 42, 0.12) 14px, rgba(13, 27, 42, 0.12) 15px);
  border: 2px solid var(--ink);
}

.detail-plate h3 {
  margin: 14px 0 8px;
  font-size: 32px;
  line-height: 1;
}

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

.detail-list div,
.report-tile {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

dt,
.report-tile span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.timeline {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.timeline-step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.timeline-step span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(13, 27, 42, 0.12);
  font-weight: 900;
}

.timeline-step.is-passed span {
  background: var(--steel);
  color: white;
}

.timeline-step.is-current {
  border-color: var(--amber);
  box-shadow: inset 4px 0 0 var(--amber);
}

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

.day-column {
  min-height: 390px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 244, 0.82);
  padding: 9px;
}

.day-column header {
  font-weight: 900;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.calendar-event {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: left;
  margin-bottom: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

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

.report-tile b {
  display: block;
  margin-top: 4px;
  font-size: 26px;
}

.stage-chart {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

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

.stage-row i {
  display: block;
  height: 16px;
  background: rgba(13, 27, 42, 0.12);
  border-radius: 99px;
  overflow: hidden;
}

.stage-row b {
  display: block;
  height: 100%;
  background: var(--amber);
}

.empty {
  margin: 0;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  padding: 10px 14px;
  transition: opacity 160ms ease, transform 160ms ease;
  max-width: min(420px, calc(100vw - 24px));
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

  .metrics-spine {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .spine-gauge,
  .rail-note {
    display: none;
  }

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

  .board-layout,
  .details-grid,
  .report-layout {
    grid-template-columns: 1fr;
  }
}

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .search-box,
  .topbar-actions select,
  .topbar-actions button {
    width: 100%;
  }

  .spine-nav,
  .metric-row,
  .detail-list,
  .calendar-grid,
  .report-metrics {
    grid-template-columns: 1fr;
  }

  .kanban {
    grid-template-columns: repeat(5, 82vw);
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
  }
}
