@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  color-scheme: light;
  --bg: #f8fafc;
  --paper: #ffffff;
  --paper-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  
  /* Brand/Accent Colors */
  --accent: #4f46e5;
  --accent-light: #e0e7ff;
  --accent-glow: rgba(79, 70, 229, 0.08);
  
  /* Role Colors */
  --guard: #3b82f6;
  --guard-bg: #eff6ff;
  --guard-line: #bfdbfe;
  
  --middle: #0ea5e9;
  --middle-bg: #f0f9ff;
  --middle-line: #bae6fd;
  
  --exit: #f43f5e;
  --exit-bg: #fff1f2;
  --exit-line: #fecdd3;
  
  /* Utility Colors */
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  
  /* Shadows & Radius */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.04), 0 2px 8px -1px rgba(15, 23, 42, 0.02);
  --shadow-md: 0 10px 30px -10px rgba(15, 23, 42, 0.06), 0 4px 12px -5px rgba(15, 23, 42, 0.02);
  --shadow-lg: 0 20px 40px -15px rgba(15, 23, 42, 0.08), 0 8px 20px -10px rgba(15, 23, 42, 0.04);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  justify-content: space-between;
  padding: 16px clamp(18px, 4vw, 56px);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: all 0.3s ease;
}

.eyebrow {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin: 0 0 2px;
  text-transform: uppercase;
}

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

h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  background: linear-gradient(135deg, var(--text) 40%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 10px;
  font-weight: 600;
  font-size: 13px;
  background: var(--paper-2);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

#status-dot {
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
  display: inline-block;
  height: 8px;
  width: 8px;
  position: relative;
}

#status-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  border: 2px solid #10b981;
  animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
  opacity: 0;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.6);
    opacity: 0.8;
  }
  50%, 100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

main {
  display: grid;
  gap: 20px;
  margin: 0 auto;
  max-width: 1400px;
  padding: 24px clamp(14px, 3vw, 32px) 56px;
}

/* Hero Section */
.hero {
  align-items: center;
  display: grid;
  gap: 32px;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 260px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.04) 0%, rgba(14, 165, 233, 0.02) 100%);
  border: 1px solid rgba(79, 70, 229, 0.08);
  border-radius: var(--radius-lg);
  padding: 36px 48px;
  box-shadow: var(--shadow-sm);
}

.hero-copy h2 {
  font-size: clamp(26px, 3.6vw, 42px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.hero-copy p {
  color: var(--muted);
  font-size: 15px;
  margin-top: 12px;
  max-width: 640px;
  line-height: 1.6;
}

/* Orbital Radar Widget */
.orbital {
  aspect-ratio: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 260px;
  height: 260px;
  margin: 0 auto;
}

.ring {
  border-radius: 50%;
  position: absolute;
  transform-origin: center;
}

.ring-one {
  inset: 10%;
  border: 1px dashed rgba(79, 70, 229, 0.15);
  animation: spin 45s linear infinite;
}

.ring-two {
  inset: 28%;
  border: 1px solid rgba(14, 165, 233, 0.18);
  animation: spin-reverse 30s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes spin-reverse {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

.node {
  background: currentColor;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 10px currentColor;
  height: 14px;
  position: absolute;
  width: 14px;
  animation: float 4s ease-in-out infinite alternate;
}

.node-a {
  color: var(--accent);
  left: 20%;
  top: 18%;
  animation-delay: 0s;
}

.node-b {
  color: var(--middle);
  right: 18%;
  top: 28%;
  animation-delay: 0.8s;
}

.node-c {
  color: var(--amber);
  bottom: 24%;
  left: 32%;
  animation-delay: 1.6s;
}

.node-d {
  color: var(--exit);
  bottom: 30%;
  right: 30%;
  animation-delay: 2.4s;
}

@keyframes float {
  0% { transform: translateY(0px) scale(1); }
  100% { transform: translateY(-6px) scale(1.05); }
}

/* Control Strip Filter */
.control-strip {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, 1fr);
  padding: 16px 20px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 11px;
  font-weight: 700;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

select, input {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  min-height: 42px;
  padding: 0 14px;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  box-shadow: var(--shadow-sm);
}

select:focus, input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

/* Metrics Dashboard Cards */
.metrics {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.metric, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 104px;
  padding: 20px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.metric:nth-child(1)::before { background: var(--accent); }
.metric:nth-child(2)::before { background: var(--exit); }
.metric:nth-child(3)::before { background: var(--guard); }
.metric:nth-child(4)::before { background: var(--purple); }
.metric:nth-child(5)::before { background: var(--amber); }
.metric:nth-child(6)::before { background: var(--middle); }

.metric:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(79, 70, 229, 0.15);
}

.metric:hover::before {
  opacity: 1;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric strong {
  display: block;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* Two-column layout */
.grid-two {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
}

.panel {
  min-width: 0;
  padding: 22px;
  transition: box-shadow 0.2s ease;
}

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

.panel-head h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  background: var(--paper-2);
  padding: 4px 10px;
  border-radius: 6px;
}

/* Map widget */
#map {
  height: 420px;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* Snapshot Composition Panel */
canvas {
  display: block;
  width: 100%;
}

.insights {
  display: grid;
  gap: 12px;
}

.insights.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.insight {
  background: var(--bg);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.insight:hover {
  transform: translateX(4px);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.insight span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 4px;
}

.insight strong {
  display: block;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 2px;
}

.insight p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* Progress bars widget */
.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.bar-row:hover {
  background: var(--bg);
}

.bar-row span {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

.bar-row span code {
  color: var(--text);
  font-weight: 600;
  background: var(--paper-2);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  font-size: 11px;
}

.bar-line {
  background: var(--line);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.bar-fill {
  background: linear-gradient(90deg, var(--accent), var(--middle));
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-row:hover .bar-fill {
  filter: brightness(1.05);
  box-shadow: 0 0 8px rgba(79, 70, 229, 0.3);
}

/* Explorer Section */
.explorer-head {
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.controls {
  display: flex;
  gap: 10px;
}

input[type="search"] {
  min-width: 380px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 16px;
  padding-left: 36px;
}

.table-wrap {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  max-height: 560px;
  overflow: auto;
  box-shadow: var(--shadow-sm);
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

th, td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

td {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  transition: background-color 0.15s ease;
}

tr:hover td {
  background: #f8fafc;
}

tr:last-child td {
  border-bottom: none;
}

td strong {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}

td code {
  color: var(--muted);
  font-size: 11px;
  background: var(--paper-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

td span {
  color: var(--muted);
  font-size: 12.5px;
}

/* Badge pills */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.pill.exit {
  background: var(--exit-bg);
  color: var(--exit);
  border-color: var(--exit-line);
}

.pill.guard {
  background: var(--guard-bg);
  color: var(--guard);
  border-color: var(--guard-line);
}

.pill.middle {
  background: var(--middle-bg);
  color: var(--middle);
  border-color: var(--middle-line);
}

/* Media Queries */
@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
    padding: 32px;
  }

  .orbital {
    display: none;
  }

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

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

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

  input[type="search"] {
    min-width: 0;
    width: 100%;
  }

  .controls {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 16px 24px;
  }

  .control-strip {
    grid-template-columns: 1fr;
  }

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

  .insights.compact {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .metrics {
    grid-template-columns: 1fr;
  }
}
