* { box-sizing: border-box; }

:root {
  --bg: #0a0a0a;
  --bg-elevated: #111111;
  --bg-hover: #1e1e1e;
  --border: #222222;
  --border-light: rgba(255,255,255,0.07);
  --text: #e5e5e5;
  --text-muted: #a3a3a3;
  --text-dim: #555555;
  --accent: #a855f7;
  --accent-hover: #9333ea;
  --danger: rgba(220,38,38,0.9);
  --radius: 8px;
  --radius-lg: 10px;
  --sidebar-w: 72px;
}

html, body {
  margin: 0; padding: 0;
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; line-height: 1.5;
}

body.auth-required { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login-screen { text-align: center; padding: 40px 24px; max-width: 400px; width: 100%; }

.login-logo {
  width: 52px; height: 52px; margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
}
.login-logo img { width: 52px; height: 52px; object-fit: contain; }

.login-screen h1 { font-size: 1.6em; font-weight: 700; margin: 0 0 6px; color: #fff; }

.login-screen .tagline {
  font-family: 'Geist Mono', monospace; font-size: 0.85em; font-weight: 500;
  color: var(--text-dim); margin: 0 0 24px; text-transform: uppercase; letter-spacing: 0.06em;
}
.login-screen .tagline-accent { color: #fff; }

.login-screen .login-hint {
  font-size: 0.82em; color: var(--text-dim); margin: 0 0 20px;
  padding: 10px 14px; background: var(--bg-elevated);
  border-radius: var(--radius); border: 1px solid var(--border);
}

.login-screen p { color: var(--text-muted); margin: 0 0 20px; font-size: 0.9em; }

.btn-google {
  width: 100%; padding: 12px 20px; border: none; border-radius: var(--radius);
  background: var(--accent); color: #fff;
  font-family: 'Geist', sans-serif; font-size: 0.95em; font-weight: 500;
  cursor: pointer; transition: background 0.2s;
}
.btn-google:hover { background: var(--accent-hover); }

.btn-google-redirect {
  background: none; border: none; color: var(--text-dim);
  font-family: 'Geist', sans-serif; font-size: 0.82em;
  cursor: pointer; text-decoration: underline; padding: 0;
}
.btn-google-redirect:hover { color: var(--accent); }
.btn-google-redirect:disabled { cursor: default; opacity: 0.6; }

/* ── App shell ──────────────────────────────────────────────────────────────── */
.app-shell { display: none; min-height: 100vh; }
.app-shell.visible { display: flex; }

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-elevated); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  height: 100vh; position: sticky; top: 0; overflow: hidden;
}

.sidebar-brand {
  display: flex; align-items: center; justify-content: center;
  padding: 14px 0; border-bottom: 1px solid var(--border-light); flex-shrink: 0;
}

.sidebar-logo-img { width: 36px; height: 36px; object-fit: contain; flex-shrink: 0; }

.sidebar-nav { list-style: none; margin: 0; padding: 8px 0; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav li { margin: 0; }

.sidebar-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 9px 4px; gap: 5px; color: var(--text-dim); text-decoration: none;
  border-radius: 8px; margin: 1px 6px; border-left: none;
  transition: color 0.15s, background 0.15s;
}
.sidebar-nav a svg { width: 19px; height: 19px; flex-shrink: 0; }

.nav-label {
  font-size: 0.6em; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.04em; text-align: center; line-height: 1.2;
}

.sidebar-nav a:hover { background: var(--bg-hover); color: var(--text-muted); }
.sidebar-nav a.active { background: rgba(168,85,247,0.14); color: var(--accent); }

.sidebar-user {
  padding: 12px 6px 8px; border-top: 1px solid var(--border-light);
  display: flex; flex-direction: column; align-items: center; flex-shrink: 0;
}

.sidebar-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg-hover); border: 1px solid var(--border); color: var(--text-muted);
  font-size: 0.78em; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; user-select: none;
}

.sidebar-footer {
  padding: 4px 6px 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.btn-signout-icon {
  background: none; border: none; padding: 5px; cursor: pointer; color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: color 0.2s, background 0.2s;
}
.btn-signout-icon:hover { color: var(--text-muted); background: var(--bg-hover); }
.btn-signout-icon svg { width: 15px; height: 15px; }

/* ── Main ───────────────────────────────────────────────────────────────────── */
.main { flex: 1; padding: 28px 36px; overflow-y: auto; height: 100vh; }

/* ── Page header ────────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--border-light); }
.page-header h2 { font-size: 1.35em; font-weight: 600; margin: 0 0 5px; color: #fff; letter-spacing: -0.02em; }
.page-header .subtitle { font-size: 0.85em; color: var(--text-muted); margin: 0; }

/* ── Pages ──────────────────────────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px; margin-bottom: 20px;
}
.card-title {
  font-family: 'Geist Mono', monospace; font-size: 0.75em; font-weight: 500;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 10px;
}
.card-subtitle { font-size: 0.85em; color: var(--text-muted); margin: -6px 0 16px; line-height: 1.5; }
.card-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-title-row .card-title { margin-bottom: 0; }
.badge--pro { background: rgba(168,85,247,0.15); color: var(--accent); border: 1px solid rgba(168,85,247,0.4); font-size: 0.7em; font-weight: 700; padding: 2px 8px; border-radius: 10px; letter-spacing: 0.05em; }
.card--locked { opacity: 0.45; filter: grayscale(0.5); pointer-events: none; position: relative; }
.card--locked::after { content: ''; position: absolute; inset: 0; border-radius: var(--radius-lg); background: rgba(15,23,36,0.25); }

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

.metric-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px; transition: border-color 0.2s;
}
.metric-card:hover { border-color: rgba(255,255,255,0.12); }
.metric-value { font-size: 1.7em; font-weight: 700; color: #fff; margin: 0 0 4px; letter-spacing: -0.02em; }
.metric-label {
  font-family: 'Geist Mono', monospace; font-size: 0.7em; font-weight: 500;
  color: var(--text-muted); margin: 0; text-transform: uppercase; letter-spacing: 0.04em;
}
.metric-change { font-size: 0.78em; margin-top: 8px; color: var(--text-dim); }
.metric-change.positive { color: #22c55e; }

/* ── Charts ─────────────────────────────────────────────────────────────────── */
.charts-section { margin-bottom: 20px; }

.chart-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px; margin-bottom: 18px;
}
.chart-row--split { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.chart-row--split .chart-container { flex: 2; min-width: 300px; }
.chart-row--split .chart-container--narrow { flex: 1; min-width: 220px; }

.chart-container {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; min-height: 280px;
}
.chart-container.full-width { grid-column: 1 / -1; }
.chart-container--gauge { min-height: auto !important; max-width: 260px; }

.chart-title { font-size: 0.9em; font-weight: 600; color: var(--text); margin: 0 0 14px; }

/* ── Policy gauge ───────────────────────────────────────────────────────────── */
.gauge-wrapper { position: relative; max-width: 220px; margin: 0 auto; }
.gauge-label {
  text-align: center; font-size: 0.82em; color: var(--text-muted);
  margin: 6px 0 0; line-height: 1.4;
}

/* ── Table section ──────────────────────────────────────────────────────────── */
.table-section {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 24px; margin-bottom: 20px;
}

.table-section-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.table-section-header .section-title { margin: 0; }

.section-title { font-size: 1em; font-weight: 600; color: var(--text); margin: 0 0 16px; }

.search-bar {
  width: 100%; padding: 11px 16px; margin-bottom: 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  font-family: 'Geist', sans-serif; font-size: 0.88em; transition: border-color 0.2s;
}
.search-bar:focus { outline: none; border-color: var(--accent); }
.search-bar::placeholder { color: var(--text-dim); }
.search-bar--inline { width: 280px; margin-bottom: 0; flex-shrink: 0; }

.explorer-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.explorer-toolbar .search-bar { flex: 1; margin-bottom: 0; }
.btn-export { padding: 10px 18px; font-size: 0.85em; white-space: nowrap; flex-shrink: 0; }

/* ── Filter chips ───────────────────────────────────────────────────────────── */
.filter-chips { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }

.chip {
  padding: 5px 14px; border: 1px solid var(--border); border-radius: 20px;
  background: none; color: var(--text-dim);
  font-family: 'Geist', sans-serif; font-size: 0.8em; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--text-muted); }
.chip.active { background: rgba(168,85,247,0.15); border-color: var(--accent); color: var(--accent); }

/* ── Date range ─────────────────────────────────────────────────────────────── */
.date-range {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  font-size: 0.84em; color: var(--text-muted);
}
.date-range input[type="date"] {
  padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  font-family: 'Geist', sans-serif; font-size: 0.88em; color-scheme: dark;
  text-transform: uppercase;
}
.date-range input[type="date"]:focus { outline: none; border-color: var(--accent); }

/* ── Events table ───────────────────────────────────────────────────────────── */
.events-table { width: 100%; border-collapse: collapse; font-size: 0.84em; }

.events-table thead th {
  text-align: left; padding: 11px 12px;
  border-bottom: 2px solid var(--border); color: var(--text-muted); font-weight: 600; font-size: 0.88em;
}
.events-table tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border-light); color: var(--text); }
.events-table tbody tr:hover { background: var(--bg-hover); }
.events-table tbody tr:last-child td { border-bottom: none; }

.table-url {
  max-width: 240px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; color: var(--accent); display: inline-block;
}
.table-email { color: var(--text-muted); font-size: 0.9em; }

.site-category-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 0.76em; font-weight: 600; border: 1px solid; white-space: nowrap;
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 4px;
  font-size: 0.73em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge.action-redacted  { background: rgba(34,197,94,0.15);  color: #22c55e; }
.badge.action-blocked   { background: rgba(168,85,247,0.15); color: #60a5fa; }
.badge.action-ignored   { background: rgba(251,191,36,0.15); color: #fbbf24; }
.badge.action-cancelled { background: rgba(168,85,247,0.15); color: #a855f7; }
.badge.action-detected  { background: rgba(107,114,128,0.15);color: #9ca3af; }

/* ── Recent findings feed ───────────────────────────────────────────────────── */
.recent-finding-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--border-light); font-size: 0.85em;
}
.recent-finding-item:last-child { border-bottom: none; padding-bottom: 0; }
.rf-type { font-weight: 500; color: var(--text); flex: 1; min-width: 0; }
.rf-url {
  color: var(--accent); font-size: 0.9em; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rf-time { color: var(--text-dim); font-size: 0.85em; flex-shrink: 0; white-space: nowrap; }

/* ── Heatmap ────────────────────────────────────────────────────────────────── */
.heatmap { overflow-x: auto; padding-bottom: 4px; }

.heatmap-row { display: flex; gap: 3px; margin-bottom: 3px; align-items: center; }

.heatmap-day-label {
  width: 28px; flex-shrink: 0;
  font-size: 0.68em; color: var(--text-dim); text-align: right; padding-right: 5px;
}

.heatmap-hour-label {
  flex: 1; min-width: 16px; font-size: 0.58em;
  color: var(--text-dim); text-align: center;
}

.heatmap-cell {
  flex: 1; min-width: 16px; height: 18px; border-radius: 2px;
  background: rgba(168,85,247,0.05); cursor: default;
  transition: opacity 0.1s;
}
.heatmap-cell:hover { opacity: 0.75; }

/* ── User risk table (inline risk % coloring done in JS) ────────────────────── */

/* ── Compliance score card ──────────────────────────────────────────────────── */
.compliance-score-card { margin-bottom: 20px; }

.compliance-score-value {
  font-size: 3.2em; font-weight: 700; letter-spacing: -0.03em; line-height: 1;
}
.compliance-score-meta { font-size: 0.88em; color: var(--text-muted); margin-top: 4px; }
.compliance-score-row { display: flex; align-items: center; gap: 24px; padding: 4px 0; }
.compliance-score-label { font-size: 1.1em; font-weight: 600; margin: 0 0 4px; }

/* ── Toggles ────────────────────────────────────────────────────────────────── */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--border-light);
}
.toggle-row:last-of-type { border-bottom: none; }
.toggle-row label { font-size: 0.9em; color: var(--text); margin: 0; cursor: pointer; }
.toggle-hint { font-size: 0.78em; color: var(--text-dim); margin: 3px 0 0; line-height: 1.4; }

.toggle {
  position: relative; width: 42px; height: 23px;
  background: var(--border); border-radius: 12px; cursor: pointer;
  flex-shrink: 0; transition: background 0.2s;
}
.toggle.on { background: var(--accent); }
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 19px; height: 19px; background: #fff; border-radius: 50%; transition: transform 0.2s;
}
.toggle.on::after { transform: translateX(19px); }
.toggle--locked { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ── Detection Rules card ───────────────────────────────────────────────────── */
.detection-rules-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.detection-rules-plan-badge { align-self: center; flex-shrink: 0; }
.detection-rules-locked { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 32px; }
.detection-rules-group { margin-bottom: 20px; }
.detection-rules-group-label { font-size: 0.72em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); margin: 0 0 8px; }
.detection-rule-row { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border-light); }
.detection-rule-row:last-child { border-bottom: none; }
.detection-rule-row span { font-size: 0.85em; color: var(--text-muted); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn-primary {
  padding: 9px 18px; border: none; border-radius: var(--radius);
  background: var(--accent); color: #fff;
  font-family: 'Geist', sans-serif; font-size: 0.88em; font-weight: 500;
  cursor: pointer; transition: background 0.2s; margin-top: 16px;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-signout {
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 6px;
  background: transparent; color: var(--text-muted);
  font-family: 'Geist', sans-serif; font-size: 0.84em;
  cursor: pointer; transition: background 0.2s, color 0.2s;
}
.btn-signout:hover { background: var(--bg-hover); color: var(--text); }

/* ── Settings ───────────────────────────────────────────────────────────────── */
.settings-user-row { display: flex; align-items: center; gap: 16px; padding: 4px 0; }
.settings-avatar-lg { width: 44px !important; height: 44px !important; font-size: 1.1em !important; border-radius: 50% !important; }
.settings-user-info { display: flex; flex-direction: column; gap: 8px; }
.settings-email-text { font-size: 0.9em; color: var(--text-muted); margin: 0; word-break: break-all; }

/* ── Premium card ───────────────────────────────────────────────────────────── */
.premium-card {
  background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(168,85,247,0.07) 100%);
  border: 1px solid rgba(168,85,247,0.22); border-radius: var(--radius-lg);
  padding: 28px; margin-bottom: 24px;
}
.premium-card h3 { font-size: 1.1em; font-weight: 600; margin: 0 0 8px; color: #fff; }
.premium-card .badge.free { background: var(--bg-hover); color: var(--text-muted); border: 1px solid var(--border); margin-bottom: 12px; }
.premium-card .badge.premium { background: rgba(168,85,247,0.18); color: var(--accent); border: 1px solid rgba(168,85,247,0.4); margin-bottom: 12px; }
.premium-card p { color: var(--text-muted); font-size: 0.9em; margin: 0 0 20px; }

.premium-features { list-style: none; padding: 0; margin: 0 0 24px; }
.premium-features li { padding: 7px 0; font-size: 0.88em; color: var(--text-muted); display: flex; align-items: center; gap: 10px; }
.premium-features li::before { content: '✓'; color: var(--accent); font-weight: 700; }

.btn-upgrade {
  padding: 11px 22px; border: none; border-radius: var(--radius);
  background: var(--accent); color: #fff;
  font-family: 'Geist', sans-serif; font-size: 0.92em; font-weight: 500;
  cursor: pointer; transition: background 0.2s;
}
.btn-upgrade:hover { background: var(--accent-hover); }

.premium-card--disabled {
  opacity: 0.45;
  filter: grayscale(0.6);
  pointer-events: none;
  position: relative;
}
.premium-card--disabled::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: var(--radius-lg);
  background: rgba(15,23,36,0.35);
}
.coming-soon-note {
  margin: 10px 0 0;
  font-size: 0.78em;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.policy-stat-card { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.policy-stat-number { font-size: 3em; font-weight: 700; color: var(--accent); margin: 0 0 6px; line-height: 1; }
.policy-stat-label { font-size: 0.95em; font-weight: 600; color: var(--text); margin: 0 0 6px; }
.policy-stat-sub { font-size: 0.78em; color: var(--text-dim); margin: 0; }

.custom-rules-placeholder { margin-top: 4px; }
.custom-rule-row { display: flex; gap: 8px; align-items: center; }
.custom-rule-input {
  flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text-muted); font-family: 'Geist', sans-serif;
  font-size: 0.85em;
}

/* ── Misc ───────────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 36px 24px; color: var(--text-dim); font-size: 0.88em; }

.save-status { font-size: 0.84em; margin-top: 12px; padding: 8px 12px; border-radius: var(--radius); display: none; }
.save-status.visible { display: block; }
.save-status.success { background: rgba(34,197,94,0.12); color: #22c55e; }
.save-status.error   { background: rgba(220,38,38,0.12); color: #ef4444; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.9em; font-weight: 500; color: var(--text); margin-bottom: 8px; }
.form-group input[type="text"], .form-group input[type="password"], .form-group input[type="url"] {
  width: 100%; max-width: 400px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  font-family: 'Geist', sans-serif; font-size: 0.9em;
}
.form-group input:focus { outline: none; border-color: var(--accent); }
