*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  font-size: 14px;
}

/* ── Login ─────────────────────────────────────── */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 48px 40px;
  text-align: center;
  width: 340px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.login-logo { font-size: 40px; margin-bottom: 12px; }

.login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }

.login-subtitle { color: #64748b; margin-bottom: 28px; }

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #dc2626;
  padding: 8px 12px;
  margin-bottom: 16px;
  font-size: 13px;
}

.btn-google {
  display: inline-flex; align-items: center; gap: 10px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  color: #374151;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}
.btn-google:hover { background: #f9fafb; border-color: #9ca3af; }

/* ── Top bar ─────────────────────────────────────── */
.topbar {
  background: #1e293b;
  color: #f8fafc;
  position: sticky; top: 0; z-index: 100;
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-title { font-weight: 700; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user  { color: #94a3b8; font-size: 13px; }

.btn-export, .btn-logout {
  font-size: 13px; color: #cbd5e1; text-decoration: none;
  padding: 4px 10px; border-radius: 6px;
  border: 1px solid #334155;
  transition: background 0.15s;
}
.btn-export:hover, .btn-logout:hover { background: #334155; }
.btn-export { color: #93c5fd; border-color: #1d4ed8; }

/* ── Main layout ─────────────────────────────────── */
.main {
  max-width: 1280px; margin: 0 auto; padding: 24px;
}

/* ── Tabs ─────────────────────────────────────────── */
.tabs {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px;
}

.tab-btn {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #475569;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 16px;
  transition: all 0.15s;
}
.tab-btn:hover  { border-color: #93c5fd; color: #1e40af; }
.tab-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }

/* ── Days selector ───────────────────────────────── */
.days-selector {
  margin-bottom: 20px;
  color: #64748b;
}
.days-selector select {
  border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 4px 8px; font-size: 13px;
  background: #fff; color: #1e293b;
  margin-left: 6px;
}

/* ── Keyword section ─────────────────────────────── */
.kw-section {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 20px;
  overflow: hidden;
}

.kw-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
}

.kw-title {
  font-size: 15px; font-weight: 600; color: #1e293b;
}

.kw-meta {
  display: flex; align-items: center; gap: 10px;
}

.rank-badge {
  border-radius: 20px; color: #fff;
  font-size: 13px; font-weight: 700;
  padding: 3px 10px;
}

.kw-updated { font-size: 12px; color: #94a3b8; }

.kw-empty {
  padding: 24px 20px;
  color: #94a3b8; font-style: italic;
}

/* ── Charts row ──────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
}

@media (max-width: 768px) {
  .charts-row { grid-template-columns: 1fr; }
}

.chart-wrap { padding: 0 8px; }
.chart-wrap:first-child { border-right: 1px solid #f1f5f9; padding-right: 20px; }
@media (max-width: 768px) {
  .chart-wrap:first-child { border-right: none; border-bottom: 1px solid #f1f5f9; padding-bottom: 16px; margin-bottom: 16px; }
}

.chart-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: #94a3b8;
  margin-bottom: 8px;
}

/* ── Competitor table ────────────────────────────── */
.comp-table-wrap { padding: 0 20px 16px; overflow-x: auto; }

.comp-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.comp-table th {
  text-align: left; padding: 8px 10px;
  color: #64748b; font-weight: 600;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.comp-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f1f5f9;
}
.comp-table tr:last-child td { border-bottom: none; }
.comp-above td { background: #fef2f2; }
.comp-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── States ──────────────────────────────────────── */
.loading, .empty-state, .error-state {
  padding: 40px 24px; text-align: center; color: #94a3b8;
}
.error-state { color: #ef4444; }
