:root {
  color-scheme: dark;
  --bg: #0d1014;
  --panel: #151a20;
  --panel-2: #11161d;
  --line: #27303a;
  --text: #edf3f7;
  --muted: #8f9da9;
  --blue: #5aa7ff;
  --green: #55d68b;
  --amber: #f5b84b;
  --rose: #f06f7e;
  --violet: #9d8cff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 16%, rgba(90, 167, 255, 0.12), transparent 28rem),
    radial-gradient(circle at 86% 8%, rgba(85, 214, 139, 0.1), transparent 24rem),
    linear-gradient(145deg, #0d1014 0%, #111419 58%, #0b0d10 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
select,
input {
  font: inherit;
}

button {
  border: 0;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(13, 16, 20, 0.82);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: #071014;
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: 0;
}

.brand strong,
.brand span,
.operator strong,
.operator span {
  display: block;
}

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

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

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: #1c242c;
  color: var(--text);
}

.nav-item svg,
.icon-button svg,
.primary-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.operator {
  margin-top: auto;
  border: 1px solid var(--line);
  background: #121820;
  border-radius: 8px;
  padding: 14px;
}

.label,
.eyebrow {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.workspace {
  padding: 26px;
  display: grid;
  gap: 18px;
  min-width: 0;
}

.topbar,
.panel-heading,
.top-actions,
.status-pill,
.segmented,
.map-legend {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.04;
}

h2 {
  font-size: 18px;
}

.top-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill,
.primary-button,
.icon-button,
.segmented {
  border: 1px solid var(--line);
  background: #151b22;
  color: var(--text);
  border-radius: 8px;
}

.status-pill {
  gap: 9px;
  height: 40px;
  padding: 0 12px;
  color: #d9e4ec;
}

.pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(85, 214, 139, 0.7);
  animation: pulse 1.8s infinite;
}

.primary-button,
.icon-button {
  height: 40px;
  cursor: pointer;
}

.primary-button {
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #e8f7ff, #a7f4c5);
  color: #081014;
  font-weight: 800;
}

.icon-button {
  width: 40px;
  display: grid;
  place-items: center;
}

.icon-button.small {
  width: 34px;
  height: 34px;
}

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

.metric,
.panel {
  border: 1px solid var(--line);
  background: rgba(21, 26, 32, 0.92);
  box-shadow: var(--shadow);
}

.metric {
  border-radius: 8px;
  padding: 16px;
  min-height: 116px;
  display: grid;
  align-content: space-between;
  overflow: hidden;
  position: relative;
}

.metric::after {
  content: "";
  position: absolute;
  inset: auto 12px 12px auto;
  width: 72px;
  height: 34px;
  border: 1px solid currentColor;
  border-top: 0;
  opacity: 0.18;
  transform: skewX(-18deg);
}

.metric span,
.metric small {
  color: var(--muted);
}

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

.accent-blue {
  color: var(--blue);
}

.accent-green {
  color: var(--green);
}

.accent-amber {
  color: var(--amber);
}

.accent-rose {
  color: var(--rose);
}

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

.lower-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr 0.9fr;
  gap: 18px;
}

.panel {
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
}

.panel-heading {
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading.compact {
  padding-bottom: 12px;
}

.segmented {
  padding: 3px;
  gap: 2px;
}

.segmented button {
  min-width: 54px;
  height: 30px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.segmented button.selected {
  color: #091014;
  background: var(--text);
  font-weight: 800;
}

.map-panel {
  min-height: 470px;
}

#missionMap {
  display: block;
  width: 100%;
  height: min(46vh, 430px);
  min-height: 320px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #0f151c;
  background-size: 36px 36px;
}

.map-legend {
  padding: 12px 16px 16px;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 50%;
  margin-right: 6px;
}

.crm {
  background: var(--blue);
}

.ads {
  background: var(--amber);
}

.telegram {
  background: var(--green);
}

.docs {
  background: var(--rose);
}

.run-list,
.agent-grid,
.timeline,
.run-form {
  padding: 16px;
}

.run-list,
.agent-grid,
.timeline,
.run-form {
  display: grid;
  gap: 12px;
}

.run-card,
.agent-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11171e;
}

.run-card {
  padding: 13px;
  display: grid;
  gap: 10px;
  cursor: pointer;
}

.run-card.active {
  border-color: rgba(90, 167, 255, 0.75);
  background: #132032;
}

.run-head,
.run-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.run-title {
  font-weight: 800;
}

.badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  color: #091014;
  background: var(--green);
  font-weight: 800;
}

.badge.waiting {
  background: var(--amber);
}

.badge.review {
  background: var(--rose);
}

.run-meta {
  color: var(--muted);
  font-size: 12px;
}

.progress {
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: #25303a;
}

.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.agent-card {
  padding: 13px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.agent-card strong,
.agent-card span {
  display: block;
}

.agent-card span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.agent-card meter {
  grid-column: 1 / -1;
  width: 100%;
  height: 7px;
}

.agent-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #091014;
}

.agent-icon.blue {
  background: var(--blue);
}

.agent-icon.green {
  background: var(--green);
}

.agent-icon.amber {
  background: var(--amber);
}

.agent-icon.rose {
  background: var(--rose);
}

.timeline {
  list-style: none;
  margin: 0;
}

.timeline li {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.timeline li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.time {
  color: var(--muted);
  font-size: 12px;
}

.event strong,
.event span {
  display: block;
}

.event span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.run-form label {
  display: grid;
  gap: 7px;
}

.run-form label > span {
  color: var(--muted);
  font-size: 13px;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #10161d;
  color: var(--text);
  padding: 0 10px;
}

input[type="range"] {
  accent-color: var(--green);
}

.toggle {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px !important;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.toggle span {
  color: var(--text) !important;
}

.full {
  width: 100%;
  justify-content: center;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 12px rgba(85, 214, 139, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(85, 214, 139, 0);
  }
}

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

  .brand div:not(.brand-mark),
  .nav-item span,
  .operator {
    display: none;
  }

  .sidebar {
    align-items: center;
  }

  .nav-item {
    width: 48px;
    justify-content: center;
    padding: 0;
  }

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

  .mission-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    justify-content: space-between;
  }

  .brand div:not(.brand-mark) {
    display: block;
  }

  .nav {
    display: flex;
    gap: 4px;
  }

  .nav-item {
    width: 38px;
    height: 38px;
  }

  .workspace {
    padding: 14px;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    justify-content: flex-start;
  }

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

  .metric {
    min-height: 96px;
  }

  #missionMap {
    min-height: 260px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .timeline li {
    grid-template-columns: 58px minmax(0, 1fr);
  }
}
