:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #141b2d;
  --panel-2: #1b2440;
  --line: #2a3554;
  --text: #f4f7ff;
  --muted: #8f9bb8;
  --accent: #6ee7b7;
  --accent-2: #60a5fa;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 80% 0, #172554 0, transparent 28%), var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button {
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  color: #07111f;
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
}
button:hover { filter: brightness(1.08); }
button.ghost { color: var(--text); background: var(--panel-2); }
button.compact { margin: 8px 5px 0 0; padding: 5px 8px; font-size: 11px; }
input, select {
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  background: #0e1528;
}
header {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 32, .85);
}
h1, h2, h3, p { margin: 0; }
header h1 { font-size: 20px; letter-spacing: .02em; }
header p, #project-app-id { color: var(--muted); font-size: 12px; }
.auth { display: flex; gap: 8px; }
main { min-height: calc(100vh - 76px); display: grid; grid-template-columns: 230px 1fr; }
aside { border-right: 1px solid var(--line); padding: 22px 14px; }
.aside-title, .toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.aside-title { margin: 0 8px 14px; }
.projects { display: grid; gap: 6px; }
.project {
  padding: 11px 12px;
  border-radius: 9px;
  color: var(--text);
  cursor: pointer;
}
.project:hover, .project.active { background: var(--panel-2); }
.project small { display: block; color: var(--muted); }
#content { padding: 28px; min-width: 0; }
.hidden { display: none !important; }
.empty { color: var(--muted); padding: 18px; text-align: center; }
.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(20, 27, 45, .92);
}
#create-project { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
#new-key { padding: 14px; margin-top: 14px; overflow: auto; color: var(--accent); background: #08101e; }
.range { display: flex; align-items: center; gap: 8px; }
.auto-refresh { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.auto-refresh input { min-width: 0; width: 15px; height: 15px; margin: 0; }
#last-refresh { min-width: 70px; color: var(--muted); font-size: 10px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 14px; margin: 22px 0 14px; }
.metrics.key-metrics { grid-template-columns: repeat(3, minmax(170px, 1fr)); }
.metrics article {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(145deg, var(--panel), #10172a);
}
.metrics span { display: block; color: var(--muted); }
.metrics strong { display: block; margin-top: 6px; font-size: 28px; }
.metrics small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.metric-modules {
  display: grid;
  grid-template-columns: repeat(6, minmax(125px, 1fr));
  gap: 10px;
  margin: 22px 0 10px;
}
.metric-module {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--panel);
  text-align: left;
}
.metric-module:hover, .metric-module.active { border-color: var(--accent); background: var(--panel-2); }
.metric-module span, .metric-module small { display: block; color: var(--muted); font-weight: 500; }
.metric-module strong { display: block; margin: 5px 0 2px; color: var(--text); font-size: 23px; }
.metric-module small { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.metric-detail { margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 10px; }
.detail-item { padding: 12px 14px; border-radius: 9px; background: #0e1528; }
.detail-item span, .detail-item small { display: block; color: var(--muted); }
.detail-item strong { display: block; margin: 4px 0; font-size: 22px; }
.detail-item small { font-size: 10px; }
.funnel-panel { margin-bottom: 14px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-heading h3 { margin-bottom: 2px; }
.panel-heading p { color: var(--muted); font-size: 12px; }
.funnel { display: grid; gap: 10px; padding: 0; text-align: left; }
.funnel-row { display: grid; grid-template-columns: minmax(110px, 180px) minmax(180px, 1fr) 170px; align-items: center; gap: 14px; }
.funnel-label strong, .event-name strong { display: block; }
.funnel-label small, .event-name small { display: block; color: var(--muted); font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.funnel-track { height: 34px; border-radius: 7px; overflow: hidden; background: #0e1528; }
.funnel-fill {
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  border-radius: 7px;
  color: #07111f;
  background: var(--accent);
  font-weight: 800;
  transition: width .25s ease;
}
.funnel-fill.zero { width: 0 !important; padding: 0; }
.funnel-rate { color: var(--muted); font-size: 12px; }
.funnel-rate strong { margin-right: 5px; color: var(--text); font-size: 16px; }
.grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .8fr); gap: 14px; margin-bottom: 14px; }
.grid.single-right { grid-template-columns: 1fr; }
.panel h3 { margin-bottom: 16px; }
.chart-heading { display: flex; align-items: center; justify-content: space-between; }
.chart-legend { display: flex; gap: 12px; color: var(--muted); font-size: 11px; }
.chart-legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 2px; }
.chart-legend .active-dot::before { background: var(--accent-2); }
.chart-legend .new-dot::before { background: var(--accent); }
.chart { min-height: 230px; display: flex; align-items: end; gap: 9px; padding-top: 20px; overflow-x: auto; }
.bar-column { min-width: 38px; flex: 1; height: 205px; display: flex; flex-direction: column; justify-content: end; align-items: stretch; }
.bar-pair { height: 180px; display: flex; align-items: end; justify-content: center; gap: 3px; }
.bar { width: 42%; min-height: 2px; border-radius: 5px 5px 2px 2px; }
.active-bar { background: var(--accent-2); }
.new-bar { background: var(--accent); }
.bar-column span { margin-top: 7px; color: var(--muted); font-size: 10px; text-align: center; white-space: nowrap; }
.event-list { max-height: 250px; overflow: auto; padding: 0; text-align: left; }
.event {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
}
.event { cursor: pointer; }
.event:hover { background: var(--panel-2); }
.event-name strong { color: var(--accent); }
.event small { color: var(--muted); }
.dimension-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 0; text-align: left; }
.dimension-grid h4 { margin: 0 0 8px; color: var(--muted); }
.dimension-grid ol { margin: 0; padding-left: 22px; }
.dimension-grid li { margin: 5px 0; }
.property-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.property-buttons button { padding: 5px 8px; color: var(--text); background: var(--panel-2); font-size: 11px; }
.breakdown-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.table-wrap { overflow: auto; }
.event-explorer-heading { flex-wrap: wrap; }
.event-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.event-filters input, .event-filters select { min-width: 170px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
td code { color: var(--accent); }
td pre { max-width: 580px; margin: 0; white-space: pre-wrap; color: #b8c3df; }
.anonymous-id { max-width: 150px; overflow: hidden; color: var(--muted); font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; color: var(--muted); }
.pagination button:disabled { cursor: default; opacity: .4; }
#toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 430px;
  padding: 12px 16px;
  border-radius: 9px;
  background: #26334f;
  opacity: 0;
  transform: translateY(8px);
  transition: .2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 850px) {
  main { grid-template-columns: 1fr; }
  aside { border-right: 0; border-bottom: 1px solid var(--line); }
  .projects { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .grid, .metrics { grid-template-columns: 1fr 1fr; }
  .metric-modules { grid-template-columns: repeat(3, 1fr); }
  .funnel-row { grid-template-columns: 130px minmax(140px, 1fr) 140px; }
  header { height: auto; padding: 16px; gap: 12px; flex-wrap: wrap; }
}
@media (max-width: 560px) {
  #content { padding: 16px; }
  .grid, .metrics { grid-template-columns: 1fr; }
  .metric-modules { grid-template-columns: repeat(2, 1fr); }
  .toolbar, .range { align-items: stretch; flex-direction: column; }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .funnel-row { grid-template-columns: 1fr; gap: 5px; }
}
