/* ── Reset & Variables ──────────────────────────────────────────────────── */

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

/* Dark theme (default) — do NOT use purple/pink/violet/magenta. See CLAUDE.md. */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2235;
  --bg-card: #151d2e;
  --bg-hover: #1e293b;
  --border: #1e293b;
  --border-light: #2a3548;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #00d4aa;
  --accent-dim: rgba(0, 212, 170, 0.15);
  --accent-hover: #00e6b8;
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-dim: rgba(245, 158, 11, 0.15);
  --success: #22c55e;
  --success-dim: rgba(34, 197, 94, 0.15);
  --info: #3b82f6;
  --info-dim: rgba(59, 130, 246, 0.15);
  --neutral: #94a3b8;
  --neutral-dim: rgba(148, 163, 184, 0.18);
  --logo-grad-a: #0a2540;
  --logo-grad-b: #1a3a5c;
  --auth-grad-mid: #0f1a2e;
  --modal-overlay: rgba(0, 0, 0, 0.6);
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --nav-width: 240px;
  --system-bar-height: 40px;
  --footer-height: 32px;
}

/* Light theme — activated by <html data-theme="light">. */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #0d9488;
  --accent-dim: rgba(13, 148, 136, 0.12);
  --accent-hover: #0f766e;
  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.10);
  --warning: #d97706;
  --warning-dim: rgba(217, 119, 6, 0.12);
  --success: #16a34a;
  --success-dim: rgba(22, 163, 74, 0.10);
  --info: #2563eb;
  --info-dim: rgba(37, 99, 235, 0.10);
  --neutral: #475569;
  --neutral-dim: rgba(71, 85, 105, 0.12);
  --logo-grad-a: #e2e8f0;
  --logo-grad-b: #cbd5e1;
  --auth-grad-mid: #f1f5f9;
  --modal-overlay: rgba(15, 23, 42, 0.35);
  --shadow: 0 1px 2px rgba(15,23,42,0.06), 0 1px 3px rgba(15,23,42,0.08);
  --shadow-lg: 0 4px 16px rgba(15,23,42,0.10);
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── Auth Screen ───────────────────────────────────────────────────────── */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--auth-grad-mid) 50%, var(--bg-primary) 100%);
}

.auth-container {
  width: 400px;
  padding: 40px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--logo-grad-a), var(--logo-grad-b));
  color: var(--accent);
  font-size: 28px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  border: 1px solid var(--border-light);
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.auth-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.auth-form h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
  width: 100%;
}

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

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: transparent;
}

.btn-danger:hover { filter: brightness(1.1); }

.auth-toggle {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-toggle a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

.auth-error {
  background: var(--danger-dim);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

/* ── App Shell ─────────────────────────────────────────────────────────── */

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── System Bar ────────────────────────────────────────────────────────── */

.system-bar {
  height: var(--system-bar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 12px;
}

.system-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.system-bar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.system-bar-logo .logo-sm {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--logo-grad-a), var(--logo-grad-b));
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.system-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.status-dot.green { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.red { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.status-dot.yellow { background: var(--warning); box-shadow: 0 0 6px var(--warning); }

.health-indicators {
  display: flex;
  align-items: center;
  gap: 10px;
}

.health-item {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  cursor: pointer;
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Nav Rail ──────────────────────────────────────────────────────────── */

.nav-rail {
  width: var(--nav-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 8px;
}

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

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
}

.nav-item .tier-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.tier-badge.growth {
  background: var(--info-dim);
  color: var(--info);
}

.tier-badge.enterprise {
  background: var(--neutral-dim);
  color: var(--neutral);
}

/* ── Main Content ──────────────────────────────────────────────────────── */

#main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-primary);
}

/* ── Page Layouts ──────────────────────────────────────────────────────── */

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

.page-header h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.page-header-actions {
  display: flex;
  gap: 8px;
}

/* ── Cards ─────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

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

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── Tool Cards (Home page) ────────────────────────────────────────────── */

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.tool-card.locked {
  opacity: 0.6;
  cursor: default;
}

.tool-card.locked:hover {
  border-color: var(--border);
  transform: none;
  box-shadow: none;
}

.tool-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}

.tool-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.tool-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.tool-card .lock-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */

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

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

tbody tr:hover {
  background: var(--bg-hover);
}

/* ── Badges & Tags ─────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: var(--success-dim); color: var(--success); }
.badge-warning { background: var(--warning-dim); color: var(--warning); }
.badge-danger { background: var(--danger-dim); color: var(--danger); }
.badge-info { background: var(--info-dim); color: var(--info); }
.badge-neutral { background: var(--neutral-dim); color: var(--neutral); }
.badge-muted { background: var(--bg-hover); color: var(--text-muted); }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  margin-right: 4px;
  margin-bottom: 4px;
}

/* ── Stats Row ─────────────────────────────────────────────────────────── */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Compliance Score ──────────────────────────────────────────────────── */

.score-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0 auto 16px;
}

.score-ring .score-value {
  font-size: 32px;
  font-weight: 700;
}

.score-ring .score-unit {
  font-size: 14px;
  color: var(--text-muted);
}

.component-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.component-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

.component-item .comp-name {
  font-size: 13px;
  font-weight: 500;
}

.component-item .comp-rule {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Search & Filters ──────────────────────────────────────────────────── */

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  padding: 9px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
}

.search-input:focus { border-color: var(--accent); }

.filter-pills {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all 0.15s;
}

.filter-pill:hover, .filter-pill.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Modal ─────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ── Lexicon Hits ──────────────────────────────────────────────────────── */

.lexicon-hit {
  background: var(--danger-dim);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.lexicon-hit .hit-match {
  font-weight: 600;
  color: var(--danger);
  font-size: 14px;
}

.lexicon-hit .hit-rule {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Timeline ──────────────────────────────────────────────────────────── */

.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-primary);
}

.timeline-item .tl-date {
  font-size: 11px;
  color: var(--text-muted);
}

.timeline-item .tl-title {
  font-size: 14px;
  font-weight: 500;
  margin-top: 2px;
}

.timeline-item .tl-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Stub Page ─────────────────────────────────────────────────────────── */

.stub-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  text-align: center;
}

.stub-page .stub-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.stub-page h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.stub-page p {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 400px;
}

/* ── Footer ────────────────────────────────────────────────────────────── */

.status-footer {
  height: var(--footer-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Contact Detail Panel ──────────────────────────────────────────────── */

.detail-panel {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
}

.detail-sidebar .avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 24px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.detail-sidebar h3 {
  font-size: 18px;
  font-weight: 600;
}

.detail-sidebar .detail-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.detail-fields {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.detail-field-value {
  font-size: 14px;
}

/* ── Tabs ──────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Loading ───────────────────────────────────────────────────────────── */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 40px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ───────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────── */

/* ── Theme Toggle ──────────────────────────────────────────────────────── */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  transition: all 0.15s;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

/* ── Scrollbar ─────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
