@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght@300;400;500;600;700&family=Fira+Code:wght@400;500;600&display=swap');

:root {
  --bg: #07090d;
  --bg-elev: #0b0e14;
  --panel: #0f131b;
  --panel-2: #141a24;
  --border: #1e2631;
  --border-strong: #2a3442;
  --text: #e9edf4;
  --muted: #8b96a8;
  --accent: #3b82f6;
  --accent-bright: #60a5fa;
  --accent-2: #f5a524;
  --green: #34d399;
  --red: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Fira Sans', system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1100px 560px at 15% -12%, rgba(59, 130, 246, 0.09), transparent 60%),
    radial-gradient(900px 500px at 105% -8%, rgba(245, 165, 36, 0.05), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.num {
  font-family: 'Fira Code', ui-monospace, SFMono-Regular, monospace;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

.icon { width: 18px; height: 18px; flex-shrink: 0; }

:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: rgba(59, 130, 246, 0.35); }

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 9, 13, 0.78);
  backdrop-filter: blur(12px);
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  color: var(--text);
}
.topbar-brand:hover { color: var(--accent-bright); text-decoration: none; }
.topbar-brand .brand-mark { height: 28px; width: auto; }

.topbar nav { display: flex; gap: 0.35rem; align-items: center; }

.nav-link, .nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.92rem;
  font-family: inherit;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav-link:hover, .nav-btn:hover {
  color: var(--text);
  background: var(--panel);
  text-decoration: none;
}
.nav-link:active, .nav-btn:active { transform: scale(0.97); }
.nav-link .icon, .nav-btn .icon { width: 17px; height: 17px; }

.inline-form { display: inline; margin: 0; }

/* ---------- Layout ---------- */

.container { max-width: 1000px; margin: 0 auto; padding: 1.5rem 1.5rem 3rem; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.5rem 0 1.5rem;
}
.page-head-titles { display: flex; flex-direction: column; gap: 0.1rem; }
.page-head h1 { margin: 0; font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; }
.page-head .muted { font-size: 0.95rem; }

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

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.25);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: #4c8dff; text-decoration: none; box-shadow: 0 4px 18px rgba(59, 130, 246, 0.4); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn .icon { width: 18px; height: 18px; }

.btn-block { width: 100%; justify-content: center; padding: 0.65rem 1rem; font-size: 1rem; }

/* ---------- Snippet ---------- */

.snippet {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}
.snippet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1rem;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.snippet-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.snippet-title .icon { width: 15px; height: 15px; color: var(--accent-bright); }
.snippet pre {
  margin: 0;
  padding: 1rem 1.1rem;
  background: var(--bg-elev);
  overflow-x: auto;
  font-family: 'Fira Code', ui-monospace, monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #a8d0ff;
}
.snippet code { font-family: inherit; }

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.copy-btn:hover { color: var(--text); border-color: var(--accent); background: rgba(59, 130, 246, 0.08); }
.copy-btn:active { transform: scale(0.96); }
.copy-btn .icon { width: 15px; height: 15px; }

/* ---------- API keys ---------- */

.api-note {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: rgba(245, 165, 36, 0.07);
  border: 1px solid rgba(245, 165, 36, 0.28);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  margin-bottom: 1.5rem;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--muted);
}
.api-note .icon { width: 15px; height: 15px; color: var(--accent-2); flex: none; margin-top: 2px; }
.api-note code {
  font-family: 'Fira Code', ui-monospace, monospace;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--panel-2);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.api-example { color: var(--text); }

/* ---------- Stat cards ---------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.stat-card:hover { border-color: var(--border-strong); }
.stat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}
.stat-card-top .icon { width: 20px; height: 20px; color: var(--accent-bright); filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.35)); }
.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-value { font-size: 1.7rem; font-weight: 600; letter-spacing: -0.02em; }

.meter {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 0.6rem;
}
.meter-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-2), var(--red));
  transition: width 0.4s ease;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}
.panel-title {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.panel-title .icon { color: var(--accent-bright); }
.panel-count { color: var(--muted); font-size: 0.82rem; }

.chart-panel { padding-top: 1.15rem; }

.chart { width: 100%; height: auto; display: block; }
.chart .gridline { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-family: 'Fira Code', monospace; font-size: 11px; }
.chart .chart-line { fill: none; stroke: var(--accent-bright); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .chart-dot {
  fill: var(--accent-2);
  stroke: var(--bg);
  stroke-width: 2;
  filter: drop-shadow(0 0 6px rgba(245, 165, 36, 0.7));
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-2 .panel { margin-bottom: 0; }

/* ---------- Tables ---------- */

.breakdown { width: 100%; border-collapse: collapse; }
.breakdown tr { transition: background 0.12s ease; }
.breakdown tr:hover { background: rgba(59, 130, 246, 0.06); }
.breakdown td { padding: 0.55rem 0.25rem; border-bottom: 1px solid var(--border); }
.breakdown tr:last-child td { border-bottom: none; }
.breakdown td.label {
  max-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.93rem;
}
.breakdown td.value {
  text-align: right;
  color: var(--muted);
  font-family: 'Fira Code', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
}

/* ---------- Scroll depth ---------- */

.depth-row { display: flex; align-items: center; gap: 0.9rem; padding: 0.42rem 0; }
.depth-label {
  width: 3.2rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-family: 'Fira Code', monospace;
}
.depth-bar-wrap {
  flex: 1;
  height: 0.8rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.depth-bar {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #1e40af, var(--accent-bright));
  transition: width 0.4s ease;
}
.depth-count {
  width: 8.5rem;
  text-align: right;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: 'Fira Code', monospace;
  font-variant-numeric: tabular-nums;
}

/* ---------- Empty states ---------- */

.empty {
  color: var(--muted);
  text-align: center;
  padding: 2.25rem 1rem;
  font-size: 0.95rem;
}
.empty .icon {
  width: 34px;
  height: 34px;
  margin: 0 auto 0.7rem;
  display: block;
  color: var(--border-strong);
}
.empty p { margin: 0; }
.empty a { font-weight: 500; }

/* ---------- Sites ---------- */

.site-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.9rem;
}
.site-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.site-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.site-card-info { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.site-card strong { font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-card .muted { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-card .arrow {
  color: var(--muted);
  transition: color 0.15s ease, transform 0.15s ease;
}
.site-card .arrow .icon { width: 20px; height: 20px; }
.site-card:hover .arrow { color: var(--accent-bright); transform: translateX(3px); }

/* ---------- Forms ---------- */

.card-form {
  max-width: 440px;
  display: grid;
  gap: 1.1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.card-form label, .auth-card label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
}

input, select {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:hover, select:hover { border-color: #35404f; }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.back-link { margin: 0.25rem 0 0; font-size: 0.92rem; }
.back-link a { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); }
.back-link a:hover { color: var(--text); text-decoration: none; }
.back-link .icon { width: 16px; height: 16px; }

/* ---------- Auth ---------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.25rem;
  box-shadow: var(--shadow);
}
.auth-logo {
  display: flex;
  justify-content: center;
  margin: 0 0 1.75rem;
}
.auth-logo .brand-mark { height: 110px; width: auto; filter: drop-shadow(0 0 18px rgba(59, 130, 246, 0.35)); }
.auth-card form { display: grid; gap: 1.1rem; }
.auth-alt { text-align: center; font-size: 0.9rem; color: var(--muted); margin: 0.1rem 0 0; }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .kpis { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .container { padding: 1rem 1rem 2.5rem; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .topbar { padding: 0.6rem 1rem; }
  .nav-link span, .nav-btn span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .site-card:hover { transform: none; }
  .nav-link:active, .nav-btn:active, .btn:active, .copy-btn:active { transform: none; }
}
