/* PagePulse — Midnight theme */

:root {
  --bg: #0d1117;
  --panel: #141a24;
  --panel-edge: #212b3b;
  --text: #e6edf3;
  --muted: #8b949e;
  --teal: #2dd4bf;
  --violet: #a78bfa;
  --red: #f87171;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--text);
  background:
    radial-gradient(1200px 400px at 20% -10%, rgba(45, 212, 191, 0.07), transparent 60%),
    radial-gradient(1000px 400px at 90% -10%, rgba(167, 139, 250, 0.06), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.9em; color: var(--violet); }

/* ---- Top bar ---- */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 28px;
  border-bottom: 1px solid var(--panel-edge);
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 15px;
  white-space: nowrap;
}
.logo-mark { color: var(--teal); text-shadow: 0 0 12px rgba(45, 212, 191, 0.6); }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--teal);
  background: rgba(45, 212, 191, 0.06);
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 8px var(--teal);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.site-name { color: var(--muted); font-family: var(--mono); font-size: 13px; }
.site-switch select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 13px;
}

.preset-switch {
  display: inline-flex;
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  overflow: hidden;
}
.preset-switch a {
  padding: 6px 13px;
  font-size: 13px;
  color: var(--muted);
}
.preset-switch a:hover { text-decoration: none; color: var(--text); }
.preset-switch a.active {
  color: #0d1117;
  background: var(--teal);
  font-weight: 600;
}
.logout { color: var(--muted); font-size: 13px; }

.nav-links { display: inline-flex; gap: 14px; }
.nav-links a { color: var(--muted); font-size: 13.5px; font-weight: 600; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--teal); }

/* ---- Dashboard layout ---- */

.dash {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 28px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 20px;
}
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.stat {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  padding: 18px 22px;
}
.stat h3 {
  margin: 0 0 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  margin: 0 0 4px;
  font-family: var(--mono);
  font-size: 27px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text);
  text-shadow: 0 0 18px rgba(45, 212, 191, 0.35);
}
.delta { font-family: var(--mono); font-size: 12.5px; }
.delta.up { color: var(--teal); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--muted); }

/* ---- Panels ---- */

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  padding: 20px 24px;
}
.panel h2 {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}
.panel-metric, .legend { margin-left: auto; font-size: 11px; letter-spacing: 0.06em; color: var(--muted); text-transform: none; }
.legend { display: inline-flex; gap: 14px; }
.legend-item::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 3px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}
.legend-item.views::before { background: var(--teal); box-shadow: 0 0 6px var(--teal); }
.legend-item.visitors::before { background: var(--violet); }

.panel-grid { display: grid; gap: 20px; }
.panel-grid.two { grid-template-columns: 1fr 1fr; }
.panel-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.panel-grid.split { grid-template-columns: 3fr 2fr; }
@media (max-width: 900px) { .panel-grid.two, .panel-grid.three, .panel-grid.split { grid-template-columns: 1fr; } }

.empty { color: var(--muted); font-size: 13.5px; margin: 4px 0; }

/* ---- Chart ---- */

.chart-panel { padding-bottom: 12px; }
.chart { width: 100%; height: 280px; display: block; }
.chart .grid { stroke: #1c2431; stroke-width: 1; }
.chart .axis { fill: var(--muted); font-family: var(--mono); font-size: 11px; }
.chart .y-axis { text-anchor: end; }
.chart .x-axis { text-anchor: middle; }
.chart .line-views { stroke: var(--teal); stroke-width: 2.5; fill: none; stroke-linecap: round; }
.chart .line-visitors { stroke: var(--violet); stroke-width: 1.5; fill: none; stroke-dasharray: 5 5; opacity: 0.85; }
.chart .pt-hit { fill: transparent; }
.chart .pt-dot { fill: var(--teal); opacity: 0; transition: opacity 0.15s; }
.chart .pt:hover .pt-dot { opacity: 1; }

/* ---- Bar lists ---- */

.bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  counter-reset: rank;
}
.bars li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 8px;
  overflow: hidden;
  font-size: 13.5px;
}
.bar {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, rgba(167, 139, 250, 0.2), rgba(167, 139, 250, 0.07));
  border-radius: 8px;
  z-index: 0;
}
.bar-label {
  position: relative;
  z-index: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.bar-value {
  position: relative;
  z-index: 1;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--teal);
}
.bar-secondary {
  position: relative;
  z-index: 1;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}

/* ---- Heatmap ---- */

.heatmap {
  display: grid;
  grid-template-columns: 36px repeat(24, 1fr);
  gap: 3px;
  align-items: center;
}
.hm-day, .hm-hour {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}
.hm-hour { text-align: left; }
.hm-cell {
  display: block;
  aspect-ratio: 1 / 1;
  min-height: 13px;
  border-radius: 3px;
}
.hm-cell:hover { outline: 1px solid var(--teal); }

/* ---- Donut ---- */

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
}
.donut { width: 158px; height: 158px; flex-shrink: 0; }
.donut-seg {
  fill: none;
  stroke-width: 14;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
}
.donut-seg-0, .donut-swatch-0 { stroke: var(--teal); background: var(--teal); }
.donut-seg-1, .donut-swatch-1 { stroke: var(--violet); background: var(--violet); }
.donut-seg-2, .donut-swatch-2 { stroke: #60a5fa; background: #60a5fa; }
.donut-seg-3, .donut-swatch-3 { stroke: #4b5563; background: #4b5563; }
.donut-total {
  fill: var(--text);
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 600;
  text-anchor: middle;
}
.donut-label {
  fill: var(--muted);
  font-size: 9px;
  text-anchor: middle;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.donut-legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}
.donut-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
}
.donut-name { flex: 1; }
.donut-pct { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ---- Settings ---- */

.settings summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.settings summary:hover { color: var(--text); }
.site-row { border-top: 1px solid var(--panel-edge); margin-top: 16px; padding-top: 16px; }
.site-row h3 { margin: 0 0 8px; font-size: 15px; }
.muted { color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: 13.5px; }

.code-block {
  background: #0a0e14;
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--teal);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---- Forms & buttons ---- */

label { display: block; margin: 12px 0; font-size: 13.5px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; }
input[type="text"], input[type="email"], input[type="password"], select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: #0a0e14;
  border: 1px solid var(--panel-edge);
  border-radius: 9px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
label.check input { width: auto; margin: 0; }
input:focus, select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

button, .button {
  display: inline-block;
  margin-top: 8px;
  padding: 10px 20px;
  background: var(--teal);
  color: #0d1117;
  border: none;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
button:hover, .button:hover { filter: brightness(1.12); text-decoration: none; }
button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--panel-edge);
  font-weight: 500;
}
button.secondary:hover { color: var(--text); border-color: var(--muted); filter: none; }
button.copy { padding: 6px 14px; font-size: 12.5px; }

.inline-form { max-width: 420px; }

/* ---- Heatmaps page ---- */

.hm-pages { width: 100%; border-collapse: collapse; }
.hm-pages td { padding: 9px 10px; border-top: 1px solid var(--panel-edge); font-size: 13.5px; }
.hm-pages tr:first-child td { border-top: none; }
.hm-path { font-family: var(--mono); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-count { color: var(--muted); white-space: nowrap; }
.hm-actions { text-align: right; white-space: nowrap; }
.hm-actions .button, .hm-actions button { margin: 0 0 0 8px; padding: 6px 14px; font-size: 12.5px; }
.hm-frame { width: 100%; height: 720px; border: 1px solid var(--panel-edge); border-radius: 10px; background: #fff; }

/* ---- Auth / setup pages ---- */

body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  padding: 34px 38px 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.auth-card .logo { display: block; font-size: 17px; margin-bottom: 22px; }
.auth-card h2 { margin: 0 0 16px; font-size: 20px; }
.auth-card button { width: 100%; margin-top: 16px; }
.step { font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: 0.04em; }

.error {
  background: rgba(248, 113, 113, 0.09);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 9px;
  padding: 10px 14px;
  color: var(--red);
  font-size: 13.5px;
}
