@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #030712;
  --bg-elevated: #0a1020;
  --glass: rgba(14, 22, 42, 0.72);
  --glass-2: rgba(20, 30, 56, 0.9);
  --border: rgba(148, 163, 184, 0.12);
  --border-glow: rgba(99, 102, 241, 0.35);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --indigo: #6366f1;
  --cyan: #22d3ee;
  --pink: #f472b6;
  --emerald: #34d399;
  --amber: #fbbf24;
  --violet: #a78bfa;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 520px;
  height: 520px;
  top: -120px;
  left: -80px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.35), transparent 70%);
}

body::after {
  width: 480px;
  height: 480px;
  top: 20%;
  right: -100px;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.18), transparent 70%);
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px 22px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(8, 12, 24, 0.95), rgba(8, 12, 24, 0.78));
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.brand-home {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 16px;
  transition: background 0.15s, transform 0.15s;
}

.brand-home:hover {
  background: rgba(99, 102, 241, 0.08);
  transform: translateY(-1px);
}

.brand-home .brand-icon {
  font-size: 1.35rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(34, 211, 238, 0.25));
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.nav-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
}

.nav-chip:hover {
  border-color: var(--border-glow);
  background: rgba(99, 102, 241, 0.1);
}

.home-chip {
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.35);
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--indigo), var(--cyan));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.4);
}

.brand h1 {
  margin: 0;
  font-size: 1.08rem;
  background: linear-gradient(90deg, #fff, #c7d2fe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.nav-title {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 12px 6px;
  font-weight: 700;
}

.field { margin-bottom: 16px; }

label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

input, select, button { font: inherit; }

input, select {
  width: 100%;
  background: var(--glass-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--border-glow);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

button {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s, filter 0.15s;
}

button:hover { transform: translateY(-1px); filter: brightness(1.06); }

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--indigo), #4f46e5);
  color: white;
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.35);
}

.btn-secondary {
  width: 100%;
  margin-top: 10px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.hint-box {
  margin-top: 28px;
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(34, 211, 238, 0.06));
  border: 1px solid rgba(99, 102, 241, 0.2);
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.6;
}

.main { padding: 32px 36px 48px; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 28px;
}

.page-header h2 {
  margin: 0 0 8px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.1);
  color: #6ee7b7;
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 12px var(--emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  padding: 18px 18px 16px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.stat-card.clickable {
  cursor: pointer;
}

.stat-card.clickable:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
  box-shadow: 0 20px 40px rgba(99, 102, 241, 0.15);
}

.stat-card.clickable:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}

.stat-hint {
  margin-top: 10px;
  font-size: 0.72rem;
  color: #818cf8;
  font-weight: 600;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--indigo), var(--cyan));
  opacity: 0.8;
}

.stat-card.emerald::before { background: linear-gradient(90deg, var(--emerald), var(--cyan)); }
.stat-card.pink::before { background: linear-gradient(90deg, var(--pink), var(--violet)); }
.stat-card.violet::before { background: linear-gradient(90deg, var(--violet), #6366f1); }
.stat-card.amber::before { background: linear-gradient(90deg, var(--amber), var(--pink)); }

.stat-icon {
  font-size: 1.2rem;
  margin-bottom: 8px;
  opacity: 0.9;
}

.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  margin-top: 6px;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.panel {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.panel-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.panel-hint {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.panel-body { padding: 8px 22px 22px; }

.tag {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
  font-size: 0.75rem;
  font-weight: 700;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.charts-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.chart-box { height: 300px; padding: 12px 18px 18px; }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

tbody tr { transition: background 0.15s; }
tbody tr:hover td { background: rgba(99, 102, 241, 0.06); }

.site-link {
  color: #a5b4fc;
  text-decoration: none;
  font-weight: 700;
}

.site-link:hover { color: var(--cyan); }

.domain-tag {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  font-size: 0.7rem;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 18px 22px 0;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
}

.tab.active {
  color: white;
  background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(34,211,238,0.12));
  border-color: rgba(99, 102, 241, 0.5);
}

.tab-panel { display: none; padding: 22px; }
.tab-panel.active { display: block; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
}

.section-title {
  margin: 0 0 14px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rank-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(80px, 1.4fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 11px;
}

.rank-list {
  min-width: 0;
}

.grid-2 > div,
.grid-3 > div {
  min-width: 0;
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.site-cell {
  min-width: 200px;
}

.site-cell .site-name {
  font-weight: 700;
  word-break: break-word;
}

.row-idle td {
  opacity: 0.55;
}

.row-active td:first-child {
  box-shadow: inset 3px 0 0 var(--emerald);
}

.table-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 16px !important;
}

.metric-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 22px !important;
  border-bottom: 1px solid var(--border);
}

.metric-toolbar input,
.metric-toolbar select {
  width: auto;
  min-width: 220px;
  flex: 1;
}

.btn-inline {
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.35);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 22px 22px;
}

.page-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-info {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.rank-bar .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
  font-weight: 600;
  color: #e2e8f0;
}

.rank-bar .bar-wrap {
  height: 9px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.rank-bar .bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--indigo), var(--cyan));
}

.rank-bar .count {
  min-width: 44px;
  text-align: right;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.hidden { display: none !important; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 36px 16px;
  font-size: 0.9rem;
}

.back-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text);
  margin-bottom: 16px;
  padding: 10px 18px;
}

.metrics-note {
  margin-top: 8px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(34, 211, 238, 0.06);
  border: 1px solid rgba(34, 211, 238, 0.15);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 32px 28px;
  border-radius: 24px;
  background: var(--glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-brand {
  margin-bottom: 28px;
  padding-bottom: 0;
  border-bottom: none;
  justify-content: center;
}

.login-form .btn-primary {
  margin-top: 8px;
}

.last-updated {
  opacity: 0.85;
  font-weight: 600;
}

.login-error {
  color: #fb7185;
  font-size: 0.88rem;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(251, 113, 133, 0.08);
  border: 1px solid rgba(251, 113, 133, 0.2);
}

@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .charts-grid, .charts-grid-3, .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
