:root {
  --bg-0: #0b1020;
  --bg-1: #0f172a;
  --bg-2: #111827;
  --bg-3: #141c2f;
  --panel: rgba(17, 24, 39, 0.88);
  --panel-soft: rgba(20, 28, 47, 0.78);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: rgba(255, 255, 255, 0.92);
  --text-soft: rgba(255, 255, 255, 0.68);
  --text-muted: rgba(255, 255, 255, 0.48);
  --blue: #4f8cff;
  --indigo: #5b6cff;
  --purple: #9b6dff;
  --orange: #ffb454;
  --green: #59d38c;
  --red: #ff6b7a;
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.28);
  --shadow-sm: 0 8px 18px rgba(0, 0, 0, 0.22);
  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 20% 10%, rgba(91, 108, 255, 0.16), transparent 24%),
    radial-gradient(circle at 80% 0%, rgba(79, 140, 255, 0.12), transparent 18%),
    radial-gradient(circle at 50% 30%, rgba(155, 109, 255, 0.10), transparent 30%),
    linear-gradient(180deg, #0b1020 0%, #0f172a 42%, #0b1020 100%);
  color: var(--text);
  font-family: "Inter", "Manrope", system-ui, sans-serif;
}

body {
  overflow-x: hidden;
}

button, input, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  position: relative;
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 18%, rgba(79, 140, 255, 0.06), transparent 24%),
    radial-gradient(circle at 75% 12%, rgba(155, 109, 255, 0.06), transparent 24%),
    radial-gradient(circle at 70% 72%, rgba(89, 211, 140, 0.05), transparent 26%);
  filter: blur(1px);
}

.topbar {
  height: 78px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0 1.8rem;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 16, 32, 0.76);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 3px;
}

.brand-dot {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.08);
}

.dot-a { background: var(--blue); }
.dot-b { background: var(--orange); }
.dot-c { background: var(--green); }

.brand-title {
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -0.03em;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.topnav {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.nav-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  padding: 0.7rem 0.95rem;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: 0.18s ease;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-link.is-active {
  color: #dbe6ff;
  background: rgba(79, 140, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(79, 140, 255, 0.24), 0 0 24px rgba(79, 140, 255, 0.08);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.85rem;
  font-weight: 700;
}

.status-pill--success {
  color: #cdf7dd;
  border-color: rgba(89, 211, 140, 0.28);
  background: rgba(89, 211, 140, 0.12);
}

.status-pill--danger {
  color: #ffd0d7;
  border-color: rgba(255, 107, 122, 0.28);
  background: rgba(255, 107, 122, 0.12);
}

.avatar-button {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 0.45rem 0.7rem 0.45rem 0.45rem;
}

.avatar-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.06));
  color: #e6ecff;
  font-size: 0.78rem;
  font-weight: 800;
}

.avatar-name {
  font-weight: 700;
  color: var(--text-soft);
}

.chevron {
  color: var(--text-muted);
  font-size: 0.9rem;
  transform: translateY(-1px);
}

.mobile-menu-button {
  display: none;
}

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

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.kpi-card,
.panel,
.chart-card,
.summary-card,
.filter-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
}

.kpi-card {
  padding: 1.1rem 1.2rem;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-value {
  font-family: "Manrope", "Inter", sans-serif;
  font-size: 2rem;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--text);
}

.info-strip {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.35rem;
}

.info-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.info-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.info-value {
  font-weight: 700;
  color: #e6ecff;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
  animation: fade-in 0.24s ease;
}

@keyframes fade-in {
  from { opacity: 0.45; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.8rem 0 1.25rem;
}

.section-heading h1 {
  margin: 0;
  font-size: clamp(2rem, 2.5vw, 2.6rem);
  letter-spacing: -0.05em;
  font-family: "Manrope", "Inter", sans-serif;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
}

.dashboard-grid {
  display: grid;
  gap: 1rem;
}

.dashboard-grid--control {
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.95fr);
  margin-bottom: 1rem;
}

.dashboard-grid--double {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.dashboard-source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.dashboard-cost-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.dashboard-source-card,
.dashboard-cost-card {
  padding: 1rem 1.05rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.dashboard-source-card strong,
.dashboard-cost-card strong {
  display: block;
  margin-bottom: 0.85rem;
  font-size: 1rem;
}

.dashboard-metric-list {
  display: grid;
  gap: 0.6rem;
}

.panel {
  padding: 1.3rem;
}

.panel--span-8 {
  grid-column: span 8;
}

.panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel__head h2,
.panel__head h3 {
  margin: 0;
  font-family: "Manrope", "Inter", sans-serif;
  letter-spacing: -0.04em;
}

.panel__head p {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.panel__head--compact {
  margin-bottom: 0.75rem;
}

.hero-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 280px;
  gap: 1rem;
  align-items: start;
}

.dataforseo-stack {
  display: grid;
  gap: 1rem;
}

.hero-layout--dataforseo {
  grid-template-columns: minmax(0, 1.65fr) minmax(290px, 340px);
  align-items: stretch;
}

.filter-card,
.summary-card,
.chart-card {
  padding: 1.25rem;
}

.filter-card {
  position: sticky;
  top: 96px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.field--full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(8, 12, 25, 0.72);
  color: var(--text);
  padding: 0.92rem 0.95rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.field textarea {
  resize: vertical;
  min-height: 120px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: rgba(255, 255, 255, 0.32);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(79, 140, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.14);
}

.field select[multiple] {
  min-height: 144px;
}

.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.92rem 1.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  transition: 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--indigo), var(--blue));
  box-shadow: 0 14px 30px rgba(79, 140, 255, 0.24), inset 0 1px 0 rgba(255,255,255,0.16);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #6a7cff, #5a98ff);
}

.btn-secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.btn-block {
  width: 100%;
}

.helper-note {
  margin-top: 0.8rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.chart-card {
  min-height: 520px;
}

.hero-layout--dataforseo .chart-card {
  min-height: 560px;
}

.chart-card__head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.chart-card__head h3 {
  margin: 0;
  font-size: 1.45rem;
}

.chart-card__head p {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
}

.chart-legend-hint {
  align-self: start;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(79, 140, 255, 0.12);
  border: 1px solid rgba(79, 140, 255, 0.18);
  color: #dbe6ff;
  font-size: 0.78rem;
  font-weight: 700;
}

.chart-wrap {
  position: relative;
  height: 460px;
}

.keyword-wow-panel {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.keyword-wow-standalone .keyword-wow-grid {
  margin-top: 0.2rem;
}

.keyword-wow-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.keyword-wow-head h4 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.03em;
}

.keyword-wow-head p {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.keyword-wow-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.chart-card--wide {
  min-height: 520px;
}

.data-source-card {
  padding: 0.95rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.data-source-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.geo-rank-list,
.demography-bars {
  display: grid;
  gap: 0.55rem;
}

.geo-rank-row,
.demography-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1.35fr auto;
  gap: 0.65rem;
  align-items: center;
  color: var(--text);
}

.geo-rank-row span,
.demography-row span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.geo-rank-row strong,
.demography-row strong {
  justify-self: end;
}

.demography-block + .demography-block {
  margin-top: 0.95rem;
  padding-top: 0.95rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.demography-title {
  margin-bottom: 0.55rem;
  color: #dfe8ff;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.demography-track {
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.demography-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(79, 140, 255, 0.95), rgba(91, 108, 255, 0.95));
  box-shadow: 0 0 18px rgba(79, 140, 255, 0.22);
}

.raw-batch {
  padding: 0.85rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.raw-batch + .raw-batch {
  margin-top: 0.8rem;
}

.raw-batch summary {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.raw-batch summary::-webkit-details-marker {
  display: none;
}

.raw-batch pre {
  margin: 0.8rem 0 0;
  padding: 0.9rem;
  border-radius: 14px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.32);
  color: #dbe6ff;
  font-size: 0.76rem;
  line-height: 1.55;
}

.keyword-wow-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
  padding: 0.85rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.keyword-wow-label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.keyword-wow-label strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.keyword-wow-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.18);
}

.keyword-wow-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  justify-content: space-between;
  flex-wrap: wrap;
}

.keyword-wow-latest {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.keyword-wow-submeta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.summary-card {
  display: flex;
  flex-direction: column;
}

.summary-list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.93rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.summary-row:last-child {
  border-bottom: 0;
}

.summary-row span {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.summary-row strong {
  color: var(--text);
  font-size: 1rem;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.stack-list {
  display: grid;
  gap: 0.8rem;
}

.list-card {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.list-card strong {
  display: block;
  margin-bottom: 0.2rem;
}

.list-card small,
.list-meta {
  color: var(--text-muted);
}

.list-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.mini-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.mini-stat span {
  color: var(--text-muted);
}

.mini-stat strong {
  font-family: "Manrope", "Inter", sans-serif;
  font-size: 1.35rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.77rem;
  font-weight: 800;
}

.status-chip--accent {
  color: #dbe6ff;
  background: rgba(79, 140, 255, 0.11);
  border-color: rgba(79, 140, 255, 0.18);
}

.table-panel {
  margin-top: 1rem;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: rgba(10, 15, 29, 0.96);
  color: #a9c0ff;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 1rem !important;
}

.trends-inline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.field--action {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.settings-grid {
  margin-bottom: 1rem;
}

@media (max-width: 1220px) {
  .hero-layout {
    grid-template-columns: 1fr;
  }

  .hero-layout--dataforseo {
    grid-template-columns: 1fr;
  }

  .dashboard-grid--control,
  .dashboard-grid--double,
  .dashboard-source-grid,
  .dashboard-cost-grid {
    grid-template-columns: 1fr;
  }

  .filter-card {
    position: static;
  }

  .chart-card {
    min-height: 460px;
  }
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: auto auto 1fr;
  }

  .topnav {
    display: none;
  }

  .mobile-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 0.55rem 0.85rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .trends-inline {
    grid-template-columns: 1fr;
  }

  .dashboard-cost-grid {
    grid-template-columns: 1fr;
  }

  .keyword-wow-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 720px) {
  .page {
    padding: 1rem 0.85rem 2rem;
  }

  .topbar {
    padding: 0 0.9rem;
    grid-template-columns: auto 1fr auto;
  }

  .avatar-name {
    display: none;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .chart-card,
  .summary-card,
  .filter-card {
    padding: 1rem;
  }

  .chart-wrap {
    height: 320px;
  }

  .data-source-card__head,
  .geo-rank-row,
  .demography-row,
  .raw-batch summary {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: flex-start;
  }

  .raw-batch summary .status-chip {
    align-self: flex-start;
  }
}
