:root {
  --page: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f1f4f8;
  --text: #20252c;
  --muted: #6f7782;
  --subtle: #9aa4af;
  --line: #dfe4ea;
  --line-strong: #cad2db;
  --teal: #00a7a2;
  --teal-soft: #dff8f6;
  --blue: #4f7df5;
  --blue-soft: #e5ebff;
  --green: #26b978;
  --amber: #d89418;
  --red: #e45858;
  --shadow: 0 20px 50px rgba(31, 43, 59, .13);
  --soft-shadow: 0 8px 24px rgba(31, 43, 59, .09);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(300px, 520px) minmax(250px, 1fr);
  gap: 18px;
  align-items: center;
  min-height: 66px;
  padding: 10px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #121820;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

.brand b,
.brand small {
  display: block;
}

.brand b {
  font-size: 14px;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--surface-soft);
}

.search svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: #657180;
  stroke-width: 2;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.search:focus-within {
  border-color: var(--line-strong);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 125, 245, .09);
}

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

.top-actions a,
.fullscreen-btn,
.login-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  padding: 9px 14px;
  box-shadow: 0 2px 8px rgba(30, 41, 59, .05);
}

.top-actions a:hover,
.fullscreen-btn:hover,
.login-form button:hover {
  border-color: #aeb9c5;
  background: #f8fafc;
}

main {
  width: 100%;
}

.live-stage {
  position: relative;
  min-height: 706px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #f8f8fa;
}

#earthCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage-meta {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 30px 36px 0;
  pointer-events: none;
}

.stage-meta h1 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1;
}

.stage-meta span,
.legend span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.legend {
  display: inline-flex;
  gap: 20px;
  align-items: center;
  margin-top: 42px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(0, 167, 162, .12);
}

.dot.visitor {
  background: var(--teal);
}

.dot.order {
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(79, 125, 245, .13);
}

.fullscreen-btn {
  position: absolute;
  z-index: 3;
  top: 28px;
  right: 34px;
  gap: 8px;
}

.fullscreen-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.zoom-control {
  position: absolute;
  right: 34px;
  bottom: 310px;
  z-index: 3;
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #ffffff;
  box-shadow: var(--soft-shadow);
}

.zoom-control button {
  width: 42px;
  height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: #59636f;
  font-size: 24px;
  line-height: 1;
}

.zoom-control button:last-child {
  border-right: 0;
}

.metric-deck {
  position: absolute;
  z-index: 4;
  left: 36px;
  right: 36px;
  bottom: 26px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.hero-card,
.panel,
.insight-strip article,
.login-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .95);
  box-shadow: var(--shadow);
}

.hero-card {
  min-height: 144px;
  padding: 20px 22px;
}

.hero-card span,
.insight-strip span,
.panel p {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.hero-card strong {
  display: block;
  color: var(--text);
  font-size: 46px;
  line-height: 1;
}

.hero-card small {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  margin-top: 14px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: #087b79;
  font-size: 12px;
  font-weight: 900;
  padding: 4px 9px;
}

.hero-card-live {
  border-left: 5px solid var(--teal);
}

.hero-card-wide {
  position: relative;
  overflow: hidden;
  border-bottom: 7px solid transparent;
}

.activity-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 6px;
  height: 10px;
}

.activity-strip i {
  display: block;
  background: var(--teal);
}

.activity-strip i:nth-child(3n) {
  background: #8bd8d2;
}

.activity-strip i:nth-child(5n) {
  background: #d7ecea;
}

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

.card-row small {
  margin: 0;
  background: #e9eef3;
  color: #68727f;
}

.mini-bars {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  align-items: end;
  gap: 10px;
  height: 92px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0 0;
}

.mini-bars i {
  display: block;
  min-height: 8px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #8f9aa5, #cbd3da);
}

.mini-bars i:last-child {
  background: #4f575f;
}

.behavior-flow {
  display: grid;
  grid-template-columns: 1fr 32px 1fr 32px 1fr;
  align-items: center;
  gap: 2px;
  min-height: 104px;
  margin-top: 12px;
}

.bubble {
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #cfd9df);
  box-shadow: inset -10px -14px 22px rgba(82, 96, 109, .16), inset 8px 8px 22px rgba(255, 255, 255, .8);
  text-align: center;
}

.bubble.accent {
  background: radial-gradient(circle at 35% 30%, #ffffff, #7ddbd7);
}

.bubble b {
  align-self: end;
  font-size: 22px;
  line-height: 1;
}

.bubble span {
  align-self: start;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.connector {
  height: 1px;
  background: linear-gradient(90deg, #aab6c1, var(--teal));
}

.insight-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  padding: 22px 36px 0;
}

.insight-strip article {
  padding: 17px 18px;
  box-shadow: var(--soft-shadow);
}

.insight-strip strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 21px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-grid,
.chart-grid {
  display: grid;
  gap: 18px;
  padding: 18px 36px 0;
}

.analysis-grid {
  grid-template-columns: minmax(0, 1.7fr) minmax(310px, .7fr);
}

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

.panel {
  min-width: 0;
  padding: 20px;
  box-shadow: var(--soft-shadow);
}

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

h2 {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.1;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  color: #303842;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.tag {
  display: inline-flex;
  align-items: center;
  max-width: 230px;
  margin: 2px 4px 2px 0;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: #38414c;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag.good {
  border-color: #bdebe8;
  background: var(--teal-soft);
  color: #087b79;
}

.tag.warn {
  border-color: #d6defd;
  background: var(--blue-soft);
  color: #345fd4;
}

.muted {
  color: var(--muted);
}

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

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 10px;
  align-items: center;
}

.bar-label {
  color: #303842;
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-value {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

.bar-track {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f5;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--page);
}

.login-shell {
  width: min(100%, 460px);
}

.login-card {
  padding: 30px;
}

.login-card h1 {
  margin: 0 0 10px;
  font-size: 31px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.login-copy {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: #303842;
  font-size: 13px;
  font-weight: 800;
}

.login-form input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 16px;
  padding: 13px 14px;
  outline: none;
}

.login-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 125, 245, .12);
}

.login-form button {
  cursor: pointer;
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
  font-size: 15px;
}

.login-error {
  display: none;
  margin: 16px 0 0;
  color: var(--red);
  font-size: 14px;
  font-weight: 800;
}

body.stage-fullscreen .live-stage {
  position: fixed;
  inset: 0;
  z-index: 100;
  min-height: 100vh;
}

body.stage-fullscreen .topbar,
body.stage-fullscreen .insight-strip,
body.stage-fullscreen .analysis-grid,
body.stage-fullscreen .chart-grid,
body.stage-fullscreen main > .panel {
  display: none;
}

@media (max-width: 1180px) {
  .metric-deck,
  .chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .live-stage {
    min-height: 880px;
  }

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

@media (max-width: 860px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr;
  }

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

  .stage-meta {
    flex-direction: column;
    padding: 24px 18px 0;
  }

  .legend {
    margin-top: 0;
  }

  .fullscreen-btn {
    top: 24px;
    right: 18px;
  }

  .zoom-control {
    display: none;
  }

  .metric-deck,
  .insight-strip,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .live-stage {
    min-height: 1180px;
  }

  .metric-deck {
    left: 18px;
    right: 18px;
  }

  .insight-strip,
  .analysis-grid,
  .chart-grid {
    padding-left: 18px;
    padding-right: 18px;
  }
}
