:root {
  --ink: #2b2d42;
  --paper: #edf2f4;
  --accent: #ef233c;
  --muted: #8d99ae;
  --line: rgba(43, 45, 66, 0.16);
  --surface: #f8fafb;
  --ok: #2f9e73;
  --warn: #d08a16;
  --shadow: 0 20px 60px rgba(43, 45, 66, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--paper);
  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: 104px minmax(0, 1fr);
  min-height: 100svh;
}

.side-rail {
  position: sticky;
  top: 0;
  height: 100svh;
  padding: 18px 14px;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 30px;
  z-index: 4;
}

.brand {
  color: inherit;
  text-decoration: none;
  display: grid;
  justify-items: center;
  gap: 8px;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0;
}

.brand img {
  width: 48px;
  height: 48px;
}

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

.rail-button {
  width: 76px;
  min-height: 70px;
  border: 1px solid rgba(237, 242, 244, 0.18);
  background: transparent;
  color: rgba(237, 242, 244, 0.72);
  display: grid;
  place-items: center;
  gap: 4px;
  border-radius: 6px;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.rail-button:hover,
.rail-button.active {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
  transform: translateX(2px);
}

.rail-button span:last-child {
  font-size: 11px;
  line-height: 1.1;
}

.rail-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(239, 35, 60, 0.12);
  color: var(--accent);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
}

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

.top-strip {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  min-height: 82px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

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

h1 {
  font-size: clamp(30px, 4vw, 58px);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: 0;
}

h3 {
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: 0;
}

.mono-label,
.task-topline,
.quick-metrics,
.map-caption,
.timeline-event time,
.priority {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0;
}

.mono-label {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.quick-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 640px;
  font-size: 12px;
}

.quick-metrics span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.52);
  border-radius: 6px;
}

.quick-metrics b {
  margin-right: 5px;
  color: var(--accent);
}

.alert-strip {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  border-left: 6px solid var(--accent);
  box-shadow: var(--shadow);
}

.alert-strip strong,
.alert-strip span {
  overflow-wrap: anywhere;
}

.alert-strip button {
  margin-left: auto;
  border: 1px solid rgba(237, 242, 244, 0.4);
  background: transparent;
  color: var(--paper);
  border-radius: 5px;
  padding: 8px 11px;
}

.alert-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 7px rgba(239, 35, 60, 0.18);
}

.alert-dot.muted {
  background: var(--ok);
  box-shadow: 0 0 0 7px rgba(47, 158, 115, 0.15);
}

.screen {
  display: none;
  animation: rise 240ms ease both;
}

.screen.active {
  display: block;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 210px) minmax(150px, 210px);
  gap: 10px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  text-transform: uppercase;
}

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239, 35, 60, 0.12);
}

.operations-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.45fr) minmax(330px, 0.9fr) minmax(260px, 0.56fr);
  gap: 14px;
  align-items: stretch;
}

.map-canvas,
.task-panel,
.timeline-panel,
.import-console,
.public-status,
.public-share,
.analytics-layout > section {
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.map-canvas {
  min-height: 640px;
  overflow: hidden;
  display: grid;
  grid-template-rows: 1fr auto;
}

.plan-layer {
  position: relative;
  min-height: 560px;
  background:
    linear-gradient(90deg, rgba(43, 45, 66, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(43, 45, 66, 0.08) 1px, transparent 1px),
    linear-gradient(135deg, #fdfefe, #dfe7eb);
  background-size: 52px 52px, 52px 52px, auto;
  isolation: isolate;
}

.plan-layer::before {
  content: "";
  position: absolute;
  inset: 9% 10%;
  border: 2px solid rgba(43, 45, 66, 0.22);
  transform: skew(-8deg);
}

.plan-zone {
  position: absolute;
  min-width: 128px;
  min-height: 92px;
  padding: 12px;
  border: 2px solid rgba(43, 45, 66, 0.28);
  background: rgba(237, 242, 244, 0.86);
  color: var(--ink);
  display: grid;
  align-content: space-between;
  border-radius: 4px;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.plan-zone span {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.plan-zone strong {
  justify-self: start;
  padding: 4px 7px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 4px;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
}

.plan-zone.selected {
  border-color: var(--accent);
  transform: translateY(-3px);
}

.plan-zone.critical {
  background: #fff4f5;
  box-shadow: inset 0 0 0 2px rgba(239, 35, 60, 0.22);
}

.zone-a {
  left: 11%;
  top: 13%;
}

.zone-b {
  left: 43%;
  top: 18%;
  min-width: 170px;
  min-height: 128px;
}

.zone-c {
  right: 10%;
  top: 48%;
  min-width: 150px;
  min-height: 116px;
}

.zone-d {
  left: 18%;
  bottom: 16%;
  min-width: 172px;
}

.route {
  position: absolute;
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--muted) 0 12px, transparent 12px 20px);
  opacity: 0.9;
  transform-origin: left center;
}

.route-one {
  left: 23%;
  top: 34%;
  width: 38%;
  transform: rotate(12deg);
}

.route-two {
  left: 36%;
  top: 62%;
  width: 44%;
  transform: rotate(-17deg);
}

.pin {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 5px solid var(--accent);
  border-radius: 50% 50% 50% 0;
  background: var(--paper);
  transform: rotate(-45deg);
  animation: pulsePin 1800ms ease-in-out infinite;
}

.pin-one {
  left: 40%;
  top: 44%;
}

.pin-two {
  right: 26%;
  top: 41%;
  animation-delay: 420ms;
}

.map-caption {
  min-height: 78px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--line);
}

.task-panel,
.timeline-panel {
  min-height: 640px;
  padding: 14px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.small-action,
.task-actions button,
.import-console button,
.public-share button {
  min-height: 36px;
  border: 0;
  border-radius: 5px;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--paper);
}

.task-list,
.timeline {
  display: grid;
  gap: 10px;
  align-content: start;
  overflow: auto;
  padding-right: 2px;
}

.task-item {
  border: 1px solid var(--line);
  border-left: 5px solid var(--muted);
  border-radius: 6px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 9px;
}

.task-item.status-blocked {
  border-left-color: var(--accent);
}

.task-item.status-review {
  border-left-color: var(--warn);
}

.task-item.status-done {
  border-left-color: var(--ok);
}

.task-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.task-topline span {
  padding: 3px 6px;
  background: var(--paper);
  border-radius: 4px;
}

.priority.critical {
  color: var(--accent);
}

.task-item p,
.import-console p {
  color: #596171;
  font-size: 14px;
  line-height: 1.45;
}

.progress-row {
  height: 8px;
  border-radius: 999px;
  background: #dce4e8;
  overflow: hidden;
}

.progress-row span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--ink));
  border-radius: inherit;
  transition: width 260ms ease;
}

.progress-row.large {
  height: 12px;
}

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

.task-actions button {
  min-width: 0;
  padding: 8px 6px;
  font-size: 12px;
  background: #f1f4f6;
  color: var(--ink);
}

.task-actions button:hover,
.small-action:hover,
.import-console button:hover,
.public-share button:hover {
  background: var(--accent);
  color: #fff;
}

.timeline-event {
  border-left: 4px solid var(--muted);
  padding: 9px 10px;
  background: #fff;
  display: grid;
  gap: 5px;
}

.timeline-event.critical {
  border-left-color: var(--accent);
}

.timeline-event.warning {
  border-left-color: var(--warn);
}

.timeline-event time {
  color: var(--muted);
  font-size: 11px;
}

.timeline-event p {
  color: #596171;
  font-size: 13px;
  line-height: 1.4;
}

.analytics-layout,
.import-layout,
.public-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr 0.8fr;
  gap: 14px;
}

.analytics-layout > section,
.import-console,
.public-status,
.public-share {
  padding: 18px;
  min-height: 260px;
}

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

.metric-cell,
.status-grid div {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

.metric-cell strong {
  font-size: 30px;
  line-height: 1;
  color: var(--accent);
}

.bar-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 32px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-row div {
  height: 12px;
  background: #dce4e8;
  border-radius: 999px;
  overflow: hidden;
}

.bar-row i {
  display: block;
  height: 100%;
  background: var(--ink);
  border-radius: inherit;
}

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

.status-grid strong {
  font-size: 26px;
  color: var(--ink);
}

.import-layout {
  grid-template-columns: minmax(320px, 0.8fr) minmax(360px, 1.2fr);
}

.import-console {
  display: grid;
  align-content: start;
  gap: 14px;
}

.import-console button,
.public-share button {
  justify-self: start;
  background: var(--accent);
}

pre {
  margin: 0;
  min-height: 150px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
  padding: 14px;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.template-stack {
  display: grid;
  gap: 12px;
}

.template-stack div {
  min-height: 126px;
  padding: 18px;
  display: grid;
  grid-template-columns: 56px 1fr;
  align-content: center;
  column-gap: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.template-stack span {
  grid-row: span 2;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.template-stack small,
.public-event span {
  color: var(--muted);
}

.public-layout {
  grid-template-columns: minmax(320px, 1fr) minmax(280px, 0.7fr);
}

.public-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 16px 0;
}

.status-pill {
  justify-self: start;
  background: #fff4f5;
  color: var(--accent);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.public-event {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.public-share {
  display: grid;
  gap: 12px;
  align-content: start;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  background: var(--ink);
  color: var(--paper);
  border-left: 5px solid var(--accent);
  border-radius: 6px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 20;
}

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

.empty-state {
  padding: 20px;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

@keyframes pulsePin {
  0%,
  100% {
    transform: rotate(-45deg) scale(1);
  }
  50% {
    transform: rotate(-45deg) scale(1.12);
  }
}

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

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

  .map-canvas {
    grid-column: 1 / -1;
    min-height: 500px;
  }

  .plan-layer {
    min-height: 420px;
  }

  .timeline-panel {
    min-height: 420px;
  }
}

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

  .side-rail {
    position: static;
    height: auto;
    padding: 10px;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .brand {
    grid-template-columns: 38px auto;
    justify-items: start;
    min-width: 128px;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

  .rail-nav {
    display: flex;
  }

  .rail-button {
    width: 72px;
    min-height: 56px;
  }

  .workspace {
    padding: 14px;
  }

  .top-strip {
    align-items: start;
    flex-direction: column;
  }

  .quick-metrics {
    justify-content: flex-start;
  }

  .alert-strip {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .alert-strip button {
    margin-left: 0;
  }

  .filters,
  .operations-grid,
  .analytics-layout,
  .import-layout,
  .public-layout {
    grid-template-columns: 1fr;
  }

  .map-canvas,
  .task-panel,
  .timeline-panel {
    min-height: auto;
  }

  .plan-layer {
    min-height: 420px;
  }

  .plan-zone {
    min-width: 112px;
    min-height: 82px;
    padding: 10px;
  }

  .zone-b {
    left: 38%;
    min-width: 132px;
  }

  .zone-c {
    right: 5%;
    min-width: 124px;
  }

  .map-caption,
  .public-event {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 460px) {
  .workspace {
    padding: 10px;
  }

  h1 {
    font-size: 34px;
  }

  .quick-metrics span {
    width: 100%;
  }

  .task-actions,
  .metric-board,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr 32px;
  }

  .bar-row span {
    grid-column: 1 / -1;
  }

  .plan-layer {
    min-height: 520px;
  }

  .zone-a {
    left: 7%;
    top: 8%;
  }

  .zone-b {
    left: 31%;
    top: 28%;
  }

  .zone-c {
    right: 7%;
    top: 55%;
  }

  .zone-d {
    left: 8%;
    bottom: 7%;
    min-width: 142px;
  }
}
