:root {
  --ink: #0b1d2c;
  --muted: #4a5b6f;
  --navy: #0b4f8a;
  --sky: #1ea7c6;
  --bg: #eef2f7;
  --surface: #ffffff;
  --border: #d6dde6;
  --pill: #e6f3f8;
  --shadow: 0 18px 40px rgba(11, 31, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Manrope', 'Sora', 'Segoe UI', sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, rgba(0, 161, 199, 0.08), transparent 35%),
    radial-gradient(circle at 80% 10%, rgba(11, 79, 138, 0.08), transparent 40%), var(--bg);
  overflow: hidden;
}

.page {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(120deg, #002a52 0%, #00498c 60%, #00a1c7 100%);
  color: #ffffff;
  box-shadow: var(--shadow);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 22px;
  flex-wrap: wrap;
}

.color-switch {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-start;
  font-size: 0.8rem;
}

.dim-option {
  position: relative;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  cursor: pointer;
}

.dim-option.active {
  color: #ffffff;
}

.dim-option::after {
  content: '';
  position: absolute;
  top: 8px;
  left: 100%;
  width: 16px;
  height: 1px;
  background: rgba(255, 255, 255, 0.35);
}

.dim-option:last-child::after {
  display: none;
}

.dim-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.2);
}

.dim-dot.active {
  background: #ffffff;
  border-color: #ffffff;
}

.dim-label {
  text-align: center;
  max-width: 80px;
  line-height: 1.2;
  white-space: normal;
}

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

.brand-logo {
  height: 46px;
  width: auto;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.brand-subtitle {
  color: rgba(255, 255, 255, 0.75);
  margin: 0;
  font-size: 0.9rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.82);
}

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

.pill {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 0.9rem;
}

.pill .stat-fixed {
  display: inline-block;
  min-width: 78px;
  text-align: right;
}

.pill.alt {
  background: rgba(0, 0, 0, 0.2);
}

.insights-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
  grid-column: 3;
  grid-row: 1 / span 2;
}

.panel::-webkit-scrollbar,
.insights-panel::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.stacked-charts {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.chart-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.chart-toggle-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.mini-toggle-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.mini-toggle-btn.active {
  background: #0b4f8a;
  color: #fff;
  box-shadow: 0 2px 6px rgba(11, 79, 138, 0.22);
}

.mini-toggle-btn:focus-visible {
  outline: 2px solid #0b4f8a;
  outline-offset: 1px;
}

.chart-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.chart-legend.compact {
  gap: 4px 6px;
}

.chart-legend.compact .legend-chip {
  padding: 2px 3px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 6px;
  background: transparent;
  border: none;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.stacked-svg {
  width: 100%;
  height: auto;
}

.time-marker {
  stroke: #0b4f8a;
  stroke-width: 1.4;
  stroke-dasharray: 2 3;
}

.app {
  display: grid;
  grid-template-columns: 360px 1fr 380px;
  grid-template-rows: 1fr 220px;
  flex: 1;
  min-height: 0;
  height: calc(100vh - 96px);
  overflow: hidden;
}

.panel {
  background: var(--surface);
  padding: 11px;
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  height: 100%;
  scrollbar-width: none;
  grid-row: 1 / span 2;
}

.panel-section {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 7px;
  box-shadow: 0 14px 28px rgba(11, 31, 52, 0.08);
}

.panel-section.subtle {
  background: transparent;
  box-shadow: none;
  border-color: transparent;
}

.panel-title {
  margin: 4px 0 10px;
  font-size: 1.05rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

label span {
  font-weight: 600;
  color: var(--ink);
}

select {
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-family: inherit;
  font-size: 0.95rem;
}

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

.inline-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.field.compact select {
  min-width: 120px;
}

.field.toggle {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--ink);
}

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

.badge {
  background: var(--pill);
  color: var(--navy);
  border-radius: 12px;
  padding: 4px 10px;
  font-weight: 800;
}

button {
  font-family: inherit;
}

.cta {
  border: none;
  background: var(--navy);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(11, 79, 138, 0.25);
}

.ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--navy);
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

.ghost:hover {
  border-color: var(--navy);
}

.stat-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.stat-card {
  background: #f4f7fc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  flex: 1;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--ink);
}

.filter-footer {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 5;
}

.follow-info {
  position: absolute;
  top: 62px;
  right: 12px;
  width: min(240px, calc(100% - 24px));
  max-width: 240px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  padding: 8px 10px;
  color: #0f1724;
  font-size: 0.72rem;
  line-height: 1.35;
  z-index: 6;
}

.follow-info.hidden {
  display: none;
}

.follow-info-title {
  font-weight: 700;
  margin-bottom: 3px;
  font-size: 0.75rem;
}

.follow-info-content {
  display: grid;
  gap: 2px;
}

.follow-info-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.follow-info-label {
  color: #47566b;
}

.follow-info-value {
  text-align: right;
  font-weight: 600;
}

.follow-tilt-row {
  align-items: center;
  margin-top: 2px;
  padding-top: 3px;
  border-top: 1px solid rgba(0,0,0,0.08);
}
.follow-tilt-toggle {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 17px;
  cursor: pointer;
}
.follow-tilt-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.follow-tilt-slider {
  position: absolute;
  inset: 0;
  background: #c4cdd8;
  border-radius: 9px;
  transition: background 0.2s;
}
.follow-tilt-slider::before {
  content: '';
  position: absolute;
  width: 13px;
  height: 13px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.follow-tilt-toggle input:checked + .follow-tilt-slider {
  background: #0b4f8a;
}
.follow-tilt-toggle input:checked + .follow-tilt-slider::before {
  transform: translateX(15px);
}

.icon-button {
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 1rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.icon-button:hover {
  background: #f1f4f9;
}

.view {
  position: relative;
  background: radial-gradient(circle at 35% 10%, rgba(0, 161, 199, 0.08), transparent 35%),
    radial-gradient(circle at 70% 20%, rgba(11, 79, 138, 0.08), transparent 40%), var(--bg);
  height: 100%;
  min-height: 0;
  grid-column: 2;
  grid-row: 1;
}

.impression-panel {
  grid-column: 2;
  grid-row: 2;
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 6px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.impression-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.page.map-expanded .panel,
.page.map-expanded .insights-panel,
.page.map-expanded .impression-panel {
  display: none;
}

.page.map-expanded .app {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.page.map-expanded .view {
  grid-column: 1;
  grid-row: 1;
  height: calc(100vh - 74px);
}

.speedometer {
  position: absolute;
  bottom: 12px;
  right: 110px;
  width: 120px;
  height: 120px;
  z-index: 6;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.speedometer.hidden {
  opacity: 0;
  pointer-events: none;
}
.speedo-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.32));
}

#analog-clock {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  z-index: 6;
}

.analog-clock .hand {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: 50% 100%;
  transform: translate(-50%, -100%) rotate(0deg);
  border-radius: 4px;
}

.analog-clock .hand.hour {
  width: 6px;
  height: 26px;
  background: #0b4f8a;
}

.analog-clock .hand.minute {
  width: 4px;
  height: 34px;
  background: #1aa7c6;
}

.analog-clock .hand.second {
  width: 2px;
  height: 38px;
  background: #e4572e;
}

.analog-clock .center-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #0b4f8a;
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.analog-clock .ticks {
  position: absolute;
  inset: 4px;
}

.analog-clock .tick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 8px;
  background: rgba(0, 0, 0, 0.45);
}

.analog-clock .tick:nth-child(1) {
  transform: translate(-50%, -50%) rotate(0deg) translateY(-36px);
}
.analog-clock .tick:nth-child(2) {
  transform: translate(-50%, -50%) rotate(30deg) translateY(-36px);
}
.analog-clock .tick:nth-child(3) {
  transform: translate(-50%, -50%) rotate(60deg) translateY(-36px);
}
.analog-clock .tick:nth-child(4) {
  transform: translate(-50%, -50%) rotate(90deg) translateY(-36px);
}
.analog-clock .tick:nth-child(5) {
  transform: translate(-50%, -50%) rotate(120deg) translateY(-36px);
}
.analog-clock .tick:nth-child(6) {
  transform: translate(-50%, -50%) rotate(150deg) translateY(-36px);
}
.analog-clock .tick:nth-child(7) {
  transform: translate(-50%, -50%) rotate(180deg) translateY(-36px);
}
.analog-clock .tick:nth-child(8) {
  transform: translate(-50%, -50%) rotate(210deg) translateY(-36px);
}
.analog-clock .tick:nth-child(9) {
  transform: translate(-50%, -50%) rotate(240deg) translateY(-36px);
}
.analog-clock .tick:nth-child(10) {
  transform: translate(-50%, -50%) rotate(270deg) translateY(-36px);
}
.analog-clock .tick:nth-child(11) {
  transform: translate(-50%, -50%) rotate(300deg) translateY(-36px);
}
.analog-clock .tick:nth-child(12) {
  transform: translate(-50%, -50%) rotate(330deg) translateY(-36px);
}
#deck-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.loading {
  position: absolute;
  inset: 0;
  background: rgba(238, 242, 247, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  color: var(--navy);
  z-index: 10;
}

.hidden {
  display: none !important;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(11, 79, 138, 0.2);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

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

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

  .panel {
    position: relative;
    z-index: 2;
  }
}

@media (max-width: 720px) {
  .topbar-row {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .inline-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
