@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --bg: #f6f7f9;
  --bg-elevated: #ffffff;
  --ink: #14151a;
  --ink-soft: #5c6370;
  --line: #e6e8ee;
  --accent: #ef443b;
  --accent-deep: #d1322a;
  --accent-soft: #ffe8e6;
  --ok: #0f9f6e;
  --warn: #c47d00;
  --shadow: 0 18px 50px rgba(20, 21, 26, 0.08);
  --radius: 18px;
  --font-display: 'Outfit', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100dvh;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
img { max-width: 100%; display: block; }

.container {
  width: min(1120px, calc(100% - 2.5rem));
  margin-inline: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1.15rem;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(239, 68, 59, 0.35);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.35rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 28px rgba(239, 68, 59, 0.28);
}
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: #fff; }
/* Logout on dark sidebar: never flip to white-on-white */
.app-side .btn-ghost {
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.28) !important;
  background: transparent !important;
}
.app-side .btn-ghost:hover,
.app-side .btn-ghost:focus-visible {
  background: rgba(255, 255, 255, 0.14) !important;
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.45) !important;
}
.btn-dark {
  background: var(--ink);
  color: #fff;
}
.btn-dark:hover { background: #000; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.55rem 0.95rem; font-size: 0.92rem; }

.field { display: grid; gap: 0.4rem; margin-bottom: 0.9rem; }
.field label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.field input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus {
  border-color: #f3a39e;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.pill-ok { background: #e6f7f0; color: #0b7a55; }
.pill-warn { background: #fff4df; color: #8a5a00; }
.pill-muted { background: #eef0f4; color: #5c6370; }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.alert {
  border-radius: 12px;
  padding: 0.8rem 1rem;
  font-size: 0.92rem;
  margin-bottom: 1rem;
}
.alert-error { background: #ffe8e6; color: #9b1c1c; }
.alert-ok { background: #e6f7f0; color: #0b7a55; }
.alert-info { background: #eef2ff; color: #3730a3; }

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: center;
  color: var(--ink-soft);
  font-size: 0.82rem;
  margin: 1.1rem 0;
}
.divider::before, .divider::after {
  content: '';
  height: 1px;
  background: var(--line);
}

.fade-up {
  animation: fadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.fade-up-delay { animation-delay: 0.12s; }
.fade-up-delay-2 { animation-delay: 0.24s; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
  background: rgba(246, 247, 249, 0.82);
  border-bottom: 1px solid transparent;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  gap: 1rem;
}
.nav-links {
  display: flex;
  gap: 1.25rem;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.95rem;
}
.nav-links a:hover { color: var(--ink); }
.nav-actions { display: flex; gap: 0.55rem; align-items: center; }

.hero {
  padding: 3.5rem 0 4rem;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 2.5rem;
  align-items: center;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
  margin: 0.7rem 0 1rem;
}
.hero p.lead {
  font-size: 1.12rem;
  color: var(--ink-soft);
  max-width: 34rem;
  margin: 0 0 1.5rem;
}
.hero-cta { display: flex; flex-wrap: wrap; gap: 0.7rem; }

.hero-visual {
  position: relative;
  min-height: 420px;
}
.hero-stage {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  background:
    radial-gradient(circle at 20% 20%, rgba(239, 68, 59, 0.18), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(20, 21, 26, 0.08), transparent 45%),
    linear-gradient(160deg, #1a1b22 0%, #2a2c36 100%);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.desk-window {
  position: absolute;
  inset: 12% 10% 10% 10%;
  background: #0e0f13;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
  transform: perspective(900px) rotateY(-8deg) rotateX(4deg);
  animation: floatWin 5.5s ease-in-out infinite;
}
@keyframes floatWin {
  0%, 100% { transform: perspective(900px) rotateY(-8deg) rotateX(4deg) translateY(0); }
  50% { transform: perspective(900px) rotateY(-6deg) rotateX(3deg) translateY(-10px); }
}
.desk-topbar {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  background: #17181f;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.desk-topbar i {
  width: 9px; height: 9px; border-radius: 50%;
  background: #3a3d48;
}
.desk-topbar i:nth-child(1) { background: #ef443b; }
.desk-topbar i:nth-child(2) { background: #f5b942; }
.desk-topbar i:nth-child(3) { background: #3dcf8e; }
.desk-body {
  display: grid;
  grid-template-columns: 140px 1fr;
  height: calc(100% - 36px);
}
.desk-side {
  background: #14151b;
  padding: 14px;
  color: rgba(255,255,255,0.7);
  font-size: 0.72rem;
}
.desk-side .id-chip {
  margin-top: 10px;
  background: rgba(239, 68, 59, 0.15);
  color: #ff8e88;
  border-radius: 8px;
  padding: 8px;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.04em;
}
.desk-screen {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent),
    repeating-linear-gradient(0deg, transparent, transparent 22px, rgba(255,255,255,0.02) 23px),
    #1c1e27;
  position: relative;
}
.desk-cursor {
  position: absolute;
  width: 14px; height: 14px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
  top: 38%; left: 46%;
  animation: cursorMove 4s ease-in-out infinite;
}
@keyframes cursorMove {
  0%, 100% { top: 38%; left: 46%; }
  50% { top: 55%; left: 62%; }
}

.section { padding: 4rem 0; }
.section h2 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.5rem;
}
.section .sub {
  color: var(--ink-soft);
  max-width: 36rem;
  margin-bottom: 2rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.feature {
  padding: 1.35rem;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
}
.feature h3 {
  font-family: var(--font-display);
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
}
.feature p { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.price-card {
  padding: 1.5rem;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.price-card.featured {
  border-color: var(--accent);
  box-shadow: 0 16px 40px rgba(239, 68, 59, 0.12);
  transform: translateY(-4px);
}
.price-card h3 {
  font-family: var(--font-display);
  margin: 0;
}
.price-card .amount {
  font-family: var(--font-display);
  font-size: 2.2rem;
  letter-spacing: -0.03em;
}
.price-card .amount span { font-size: 0.95rem; color: var(--ink-soft); font-weight: 500; }
.price-card ul {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}
.price-card li { padding: 0.28rem 0; }
.price-card li::before { content: '✓ '; color: var(--ok); font-weight: 700; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 2rem 0 calc(2rem + var(--sab));
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* Auth shell */
.auth-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}
.auth-art {
  background:
    radial-gradient(circle at 30% 20%, rgba(239, 68, 59, 0.35), transparent 40%),
    linear-gradient(165deg, #14151a 0%, #242632 100%);
  color: #fff;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-art::after {
  content: '';
  position: absolute;
  inset: auto -20% -30% 20%;
  height: 70%;
  background: radial-gradient(circle, rgba(239,68,59,0.25), transparent 60%);
  pointer-events: none;
}
.auth-art h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 3vw, 2.8rem);
  letter-spacing: -0.04em;
  line-height: 1.1;
  max-width: 16ch;
  margin: 1.5rem 0 0.8rem;
  position: relative;
  z-index: 1;
}
.auth-art p {
  color: rgba(255,255,255,0.72);
  max-width: 28ch;
  position: relative;
  z-index: 1;
}
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: var(--bg);
}
.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.auth-card h1 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  margin: 0.3rem 0 0.35rem;
}
.auth-card .muted { color: var(--ink-soft); margin: 0 0 1.2rem; font-size: 0.95rem; }
.auth-switch { text-align: center; margin-top: 1rem; color: var(--ink-soft); font-size: 0.92rem; }
.auth-switch a { color: var(--accent); font-weight: 600; }

.btn-google {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.85rem 1rem;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-google.is-on { display: inline-flex; }
.btn-google:hover { background: #fafafa; }
.btn-google svg { width: 18px; height: 18px; }
.auth-google-split { display: none; }
.auth-google-split.is-on { display: grid; }

/* App shell */
.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 240px 1fr;
}
.app-side {
  background: #14151a;
  color: #fff;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.app-side .brand { color: #fff; }
.app-nav a {
  display: block;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  color: rgba(255,255,255,0.7);
  font-weight: 500;
  margin-bottom: 0.25rem;
}
.app-nav a.active, .app-nav a:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.lang-switch {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.app-side .lang-switch {
  width: 100%;
  border-color: rgba(255,255,255,.25);
  background: rgba(255,255,255,.06);
  color: #fff;
  margin-bottom: 0.5rem;
}
.app-main { padding: 1.5rem; }
.app-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 1rem;
}
.app-top h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: -0.03em;
  margin: 0;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
.stat {
  padding: 1.1rem 1.2rem;
}
.stat .label { color: var(--ink-soft); font-size: 0.85rem; }
.stat .value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  margin-top: 0.2rem;
}
.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
}
table.data th {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.copyable { cursor: pointer; }
.copyable:hover { color: var(--accent); }

.alert-ok {
  background: #e8f8f1;
  color: #0b6b45;
  border: 1px solid #b6e5d0;
}

/* Analytics dashboard */
.analytics-hero {
  background:
    radial-gradient(1200px 280px at 10% -20%, rgba(239,68,59,0.18), transparent 55%),
    radial-gradient(900px 240px at 90% 0%, rgba(20,21,26,0.08), transparent 50%),
    #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.35rem 1.4rem 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.analytics-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.analytics-hero h2 {
  font-family: var(--font-display);
  margin: 0;
  letter-spacing: -0.03em;
  font-size: 1.45rem;
}
.analytics-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
}
.analytics-filters .field { margin: 0; min-width: 140px; }
.analytics-filters label { font-size: 0.75rem; }
.analytics-filters input,
.analytics-filters select {
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.7rem;
}
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.kpi {
  background: rgba(255,255,255,0.82);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem 0.9rem;
}
.kpi .k { color: var(--ink-soft); font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi .v {
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  margin-top: 0.15rem;
  line-height: 1.1;
}
.kpi .s { color: var(--ink-soft); font-size: 0.8rem; margin-top: 0.2rem; }
.kpi.warn .v { color: var(--warn); }
.kpi.ok .v { color: var(--ok); }
.kpi.accent .v { color: var(--accent); }

.analytics-panels {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 1rem;
  margin-top: 1rem;
}
@media (max-width: 960px) {
  .analytics-panels { grid-template-columns: 1fr; }
}
.chart-card, .list-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
}
.chart-card h3, .list-card h3 {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: 1rem;
}
.bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(28px, 1fr));
  gap: 0.35rem;
  align-items: end;
  height: 160px;
  padding-top: 0.5rem;
}
.bar-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  gap: 0.25rem;
}
.bar-stack {
  width: 100%;
  max-width: 36px;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 8px 8px 4px 4px;
  overflow: hidden;
  min-height: 4px;
  background: #f1f2f5;
}
.bar-seg { width: 100%; }
.bar-seg.opened { background: var(--ok); }
.bar-seg.attempts { background: #3b82f6; }
.bar-seg.denied { background: var(--accent); }
.bar-label {
  font-size: 0.62rem;
  color: var(--ink-soft);
  writing-mode: horizontal-tb;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.legend {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 0.35rem;
}
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.rank-list li:last-child { border-bottom: 0; }
.pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.75rem;
  font-weight: 600;
}
.pill.ok { background: #e8f8f1; color: #0b6b45; }
.pill.bad { background: #ffe8e6; color: #b42318; }
.analytics-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  margin: 0.4rem 0 0.8rem;
}
.db-note {
  font-size: 0.82rem;
  color: var(--ink-soft);
  background: #f6f7f9;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}

@media (max-width: 960px) {
  .hero, .auth-shell, .app-shell, .feature-grid, .pricing-grid, .stat-grid {
    grid-template-columns: 1fr;
  }
  .auth-art { min-height: 220px; padding: 1.5rem; }
  .nav-links { display: none; }
  .hero-visual { min-height: 300px; }
  .desk-window { transform: none; inset: 8%; animation: none; }
  .app-side { display: none; }
  .price-card.featured { transform: none; }
}
