:root {
  --bg: #0f1117;
  --bg-raised: #181a24;
  --bg-card: #1e2030;
  --bg-input: #252839;
  --border: #2d3044;
  --border-hover: #3d4060;
  --ink: #e2e4ed;
  --ink-muted: #8b8fa7;
  --ink-faint: #5c5f77;
  --accent: #10b981;
  --accent-hover: #34d399;
  --accent-dim: rgba(16, 185, 129, 0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.12);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.35);
  --transition: 150ms ease;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

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

/* ── Layout ── */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-brand h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--ink);
}

.sidebar-brand span {
  font-size: .75rem;
  color: var(--ink-muted);
  font-weight: 500;
}

.sidebar nav { flex: 1; }

.nav-section {
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-faint);
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-weight: 500;
  font-size: .875rem;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--bg-card); color: var(--ink); }

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.nav-item .icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--bg-input);
  color: var(--ink-muted);
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  min-width: 22px;
  text-align: center;
}

.nav-item.active .badge {
  background: var(--accent-dim);
  color: var(--accent);
}

.sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

.status-dot.ok { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.status-dot.warn { background: var(--amber); }
.status-dot.err { background: var(--red); }

.sidebar-status {
  font-size: .8rem;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
}

/* ── Main ── */
.main {
  padding: 28px 32px 48px;
  overflow-y: auto;
  max-width: 1100px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--ink-muted);
  font-size: .9rem;
}

/* ── Metrics ── */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color var(--transition);
}

.metric-card:hover { border-color: var(--border-hover); }

.metric-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric-label .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1;
}

/* ── Sections / Tabs ── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: border-color var(--transition);
}

.card:hover { border-color: var(--border-hover); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Forms ── */
label.field {
  display: block;
  margin-bottom: 14px;
}

label.field .field-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 5px;
}

input, textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--ink);
  transition: border-color var(--transition);
  resize: vertical;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input::placeholder, textarea::placeholder {
  color: var(--ink-faint);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: .84rem;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-input);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--border-hover);
  color: var(--ink);
}

.btn-sm {
  padding: 5px 10px;
  font-size: .78rem;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: none;
  padding: 5px 10px;
  font-size: .78rem;
}
.btn-ghost:hover { background: var(--accent-dim); }

.btn:disabled {
  opacity: .5;
  cursor: wait;
}

/* ── Tags / Badges ── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
}

.tag-accent { background: var(--accent-dim); color: var(--accent); }
.tag-blue { background: var(--blue-dim); color: var(--blue); }
.tag-amber { background: var(--amber-dim); color: var(--amber); }
.tag-purple { background: var(--purple-dim); color: var(--purple); }
.tag-red { background: var(--red-dim); color: var(--red); }
.tag-muted { background: var(--bg-input); color: var(--ink-muted); }

/* ── Data rows ── */
.data-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.data-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}

.data-row:hover { border-color: var(--border-hover); }

.data-row-body { flex: 1; min-width: 0; }

.data-row-title {
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: 3px;
  word-break: break-word;
}

.data-row-meta {
  color: var(--ink-muted);
  font-size: .8rem;
}

.data-row-actions {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--ink-faint);
  font-size: .88rem;
}

.empty-state .empty-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: .5;
}

/* ── Site card ── */
.site-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0 8px;
}

.site-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
}

.site-info h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.site-info a { font-size: .85rem; }

.site-info p {
  color: var(--ink-muted);
  font-size: .82rem;
  margin-top: 2px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

/* ── Score bar ── */
.score-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-track {
  flex: 1;
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width .3s ease;
}

.score-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--ink-muted);
  min-width: 28px;
  text-align: right;
}

/* ── GEO mention chips ── */
.mention-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
}

/* ── Response preview ── */
.response-preview {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  color: var(--ink-muted);
  line-height: 1.5;
  max-height: 120px;
  overflow: hidden;
  position: relative;
}

.response-preview::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--bg));
}

.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: -260px;
    z-index: 100;
    width: 240px;
    transition: left var(--transition);
    height: 100vh;
  }
  .sidebar.open { left: 0; }
  .main { padding: 20px 16px 48px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .card-grid { grid-template-columns: 1fr; }
}
