/* ── FONTS ───────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=JetBrains+Mono:wght@300;400;500&display=swap');

/* ── TOKENS ──────────────────────────────────────────────────────────────── */
:root {
  --bg:              #000000;
  --purple:          #7c3aed;
  --purple-light:    #a78bfa;
  --orange:          #ea580c;
  --orange-light:    #fb923c;

  --glass-bg:        rgba(255, 255, 255, 0.045);
  --glass-border:    rgba(255, 255, 255, 0.10);
  --glass-hover:     rgba(255, 255, 255, 0.07);
  --glass-strong:    rgba(255, 255, 255, 0.08);

  --text-primary:    rgba(255, 255, 255, 0.92);
  --text-secondary:  rgba(255, 255, 255, 0.50);
  --text-tertiary:   rgba(255, 255, 255, 0.28);

  --radius-sm:  10px;
  --radius-md:  16px;
  --radius-lg:  22px;

  --shadow-glass: 0 8px 32px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.06) inset;
  --shadow-lift:  0 20px 60px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.08) inset;

  --font-display: 'Syne', sans-serif;
  --font-body:    'Syne', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --sidebar-w: 220px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── BACKGROUND GRADIENT ORBS ────────────────────────────────────────────── */
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 600px;
  height: 600px;
  top: -200px;
  left: -200px;
  background: radial-gradient(circle, rgba(124,58,237,0.28) 0%, transparent 70%);
  animation: drift-a 20s ease-in-out infinite alternate;
}

body::after {
  width: 500px;
  height: 500px;
  bottom: -150px;
  right: -150px;
  background: radial-gradient(circle, rgba(234,88,12,0.22) 0%, transparent 70%);
  animation: drift-b 25s ease-in-out infinite alternate;
}

@keyframes drift-a {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 30px) scale(1.08); }
}
@keyframes drift-b {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-30px, -20px) scale(1.06); }
}

/* ── LAYOUT ──────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── SIDEBAR ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  padding: 28px 16px;
  gap: 8px;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.logo {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  padding: 0 8px 24px;
  background: linear-gradient(135deg, #fff 30%, var(--purple-light) 70%, var(--orange-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

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

.nav-item.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.20), rgba(234,88,12,0.12));
  color: var(--text-primary);
  border-color: rgba(124,58,237,0.30);
  font-weight: 600;
}

/* ── HEALTH BAR ──────────────────────────────────────────────────────────── */
.health-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

.health-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: background 0.4s ease;
  flex-shrink: 0;
}

.health-dot.dot-ok  { background: #34d399; box-shadow: 0 0 6px #34d39966; }
.health-dot.dot-err { background: #f87171; box-shadow: 0 0 6px #f8717166; }

.health-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── MAIN PANEL ──────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.main::-webkit-scrollbar       { width: 5px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* ── PANELS ──────────────────────────────────────────────────────────────── */
.panel { display: none; flex-direction: column; gap: 20px; }
.panel.active { display: flex; }

/* ── GLASS CARD ──────────────────────────────────────────────────────────── */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-glass);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.glass-card:hover {
  border-color: rgba(255,255,255,0.14);
  box-shadow: var(--shadow-lift);
}

/* ── CARD TITLE ROW ──────────────────────────────────────────────────────── */
.card-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 18px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
}

/* ── UPLOAD CARD ─────────────────────────────────────────────────────────── */
.upload-card { display: flex; flex-direction: column; gap: 16px; }

.input-toggle {
  display: flex;
  gap: 6px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 4px;
  width: fit-content;
}

.toggle-btn {
  padding: 7px 16px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: none;
}

.toggle-btn.active {
  background: rgba(255,255,255,0.10);
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.toggle-btn:hover { transform: none; box-shadow: none; }

.upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

input[type="file"] {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-secondary);
}

input[type="file"]::file-selector-button {
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

input[type="file"]::file-selector-button:hover {
  background: rgba(255,255,255,0.12);
}

/* Global textarea style — covers ALL textareas including heatmap */
textarea {
  width: 100%;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  padding: 14px 16px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

textarea:focus        { border-color: rgba(124,58,237,0.5); }
textarea::placeholder { color: var(--text-tertiary); }

.mode-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

select {
  background: rgba(0,0,0,0.45);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

select:focus { border-color: rgba(124,58,237,0.5); }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
button {
  background: linear-gradient(135deg, var(--purple) 0%, #5b21b6 50%, var(--orange) 100%);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 22px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(124,58,237,0.3);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(124,58,237,0.45);
}

button:active { transform: translateY(0); }

/* ── STATS CARD ──────────────────────────────────────────────────────────── */
.stats-card pre {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
  letter-spacing: 0.02em;
}

/* ── MODE TAG ────────────────────────────────────────────────────────────── */
.mode-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

.mode-reviewer {
  background: rgba(124,58,237,0.15);
  color: var(--purple-light);
  border: 1px solid rgba(124,58,237,0.25);
}

.mode-junior {
  background: rgba(234,88,12,0.15);
  color: var(--orange-light);
  border: 1px solid rgba(234,88,12,0.25);
}

/* ── REPORT CARD ─────────────────────────────────────────────────────────── */
.report-card pre#diffReport {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 520px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

/* ── LOADING ─────────────────────────────────────────────────────────────── */
.loading-state {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 8px 0;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(124,58,237,0.2);
  border-top-color: var(--purple-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.loading-text  { color: var(--text-tertiary); font-size: 13px; text-align: center; padding: 20px 0; }
.error-text    { color: #f87171; }

.error-card {
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  color: #f87171;
  font-size: 13px;
}

/* ── SANITISATION WARNING ────────────────────────────────────────────────── */
.sanitise-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(251,146,60,0.08);
  border: 1px solid rgba(251,146,60,0.25);
  border-left: 3px solid #fb923c;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 12.5px;
  color: #fb923c;
  line-height: 1.6;
  margin-bottom: 16px;
}

/* ── CHANGE INTELLIGENCE ─────────────────────────────────────────────────── */
.intel-card { display: flex; flex-direction: column; min-height: 400px; }

#intelligencePanel {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.intel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  color: var(--text-tertiary);
  padding: 48px 20px;
  font-size: 13px;
  line-height: 1.6;
}

.intel-summary-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}

.intel-type-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.intel-summary-text { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

.intel-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin-top: 4px;
  margin-bottom: 2px;
}

.intel-layers { display: flex; flex-wrap: wrap; gap: 8px; }

.intel-layer-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  transition: border-color 0.2s;
}

.intel-layer-chip:hover { border-color: rgba(124,58,237,0.3); }
.intel-chip-count { font-size: 11px; color: var(--text-tertiary); }

.intel-risk-list { display: flex; flex-direction: column; gap: 6px; }

.intel-risk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid;
  flex-wrap: wrap;
}

.intel-risk-path  { font-size: 12px; font-family: var(--font-mono); flex: 1; word-break: break-all; color: var(--text-primary); }
.intel-risk-badge { font-size: 11px; font-weight: 700; white-space: nowrap; }
.intel-risk-churn { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; }

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

.intel-file-card {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s;
}

.intel-file-card:hover { border-color: rgba(255,255,255,0.16); }

.intel-file-header  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.intel-file-type-badge { font-size: 9px; font-weight: 800; letter-spacing: 0.08em; min-width: 68px; }
.intel-file-path    { font-size: 12px; font-family: var(--font-mono); flex: 1; color: var(--text-primary); word-break: break-all; }
.intel-file-layer   { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; }
.intel-file-meta    { display: flex; gap: 14px; font-size: 12px; align-items: center; }
.intel-added        { color: #34d399; font-family: var(--font-mono); }
.intel-removed      { color: #f87171; font-family: var(--font-mono); }
.intel-conflict     { font-size: 11px; font-weight: 600; margin-left: auto; }

.intel-churn-bar-bg {
  height: 2px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}

.intel-churn-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--orange-light));
  border-radius: 2px;
  transition: width 0.5s ease;
}

.intel-ext-row { display: flex; flex-wrap: wrap; gap: 8px; }

.intel-ext-chip {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.intel-ext-chip strong { color: var(--purple-light); margin-left: 4px; }

/* ── ASSISTANT ───────────────────────────────────────────────────────────── */
.assistant-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

input[type="text"],
input:not([type="file"]):not([type="checkbox"]) {
  flex: 1;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 9px 14px;
  outline: none;
  transition: border-color 0.2s ease;
  min-width: 160px;
}

input:focus        { border-color: rgba(124,58,237,0.5); }
input::placeholder { color: var(--text-tertiary); }

#detectedTopic {
  font-size: 11px;
  color: var(--text-tertiary);
  display: block;
  margin-top: 8px;
}

pre#assistantAnswer {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── GITHUB REPOS ────────────────────────────────────────────────────────── */
.repo-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-glass);
  transition: all 0.25s ease;
}

.repo-card:hover {
  border-color: rgba(124,58,237,0.30);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(124,58,237,0.15);
  transform: translateY(-2px);
}

.repo-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.repo-rank   { font-size: 11px; font-weight: 700; color: var(--text-tertiary); font-family: var(--font-mono); min-width: 28px; }
.repo-header strong { font-size: 15px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.2px; }

.repo-lang {
  font-size: 11px;
  font-weight: 600;
  color: var(--purple-light);
  background: rgba(124,58,237,0.12);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: 20px;
  padding: 2px 10px;
  margin-left: auto;
}

.repo-card p    { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 12px; }
.repo-meta      { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-tertiary); font-family: var(--font-mono); margin-bottom: 14px; }
.repo-card a    { font-size: 12px; font-weight: 600; color: var(--orange-light); text-decoration: none; letter-spacing: 0.02em; transition: color 0.2s; }
.repo-card a:hover { color: #fdba74; }

/* ── CHURN HEATMAP — ADD SECTION ─────────────────────────────────────────── */

.hm-session-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  min-height: 0;
}

.hm-session-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(124,58,237,0.12);
  border: 1px solid rgba(124,58,237,0.25);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
}

.hm-chip-label { color: var(--purple-light); font-weight: 600; }
.hm-chip-lines { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 11px; }

.hm-chip-remove {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 11px;
  padding: 0;
  cursor: pointer;
  box-shadow: none;
  line-height: 1;
}

.hm-chip-remove:hover { color: #f87171; transform: none; box-shadow: none; }

.hm-add-row {
  display: grid;
  grid-template-columns: 200px 1fr auto;
  gap: 12px;
  align-items: start;
}

.hm-add-row input {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s ease;
  flex: none;
  min-width: unset;
  width: 100%;
}

.hm-add-row input:focus        { border-color: rgba(124,58,237,0.5); }
.hm-add-row input::placeholder { color: var(--text-tertiary); }

.hm-add-row textarea {
  min-height: 90px;
  font-size: 12px;
  padding: 12px 14px;
}

.hm-add-row button { align-self: start; }

.hm-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.hm-ghost-btn {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  box-shadow: none;
}

.hm-ghost-btn:hover { background: var(--glass-hover); transform: none; box-shadow: none; }

@media (max-width: 700px) {
  .hm-add-row { grid-template-columns: 1fr; }
}

/* ── CHURN HEATMAP — RESULTS ─────────────────────────────────────────────── */

.hm-summary-text  { font-size: 14px; color: var(--text-secondary); line-height: 1.7; }
.hm-summary-stat  { font-family: var(--font-mono); font-weight: 700; color: var(--text-primary); font-size: 15px; }
.hm-summary-hotfile { font-family: var(--font-mono); color: var(--orange-light); font-size: 13px; }

.hm-hotspot-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--glass-border);
}

.hm-hotspot-row:last-child { border-bottom: none; }

.hm-hotspot-rank  { font-size: 22px; flex-shrink: 0; width: 32px; text-align: center; padding-top: 2px; }

.hm-hotspot-info  { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.hm-hotspot-name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.hm-hotspot-icon { font-size: 16px; flex-shrink: 0; }

.hm-hotspot-names { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }

.hm-hotspot-filename {
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.hm-hotspot-filepath {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hm-layer-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--purple-light);
  background: rgba(124,58,237,0.12);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: 20px;
  padding: 2px 9px;
  white-space: nowrap;
  flex-shrink: 0;
}

.hm-hotspot-bar-bg {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: hidden;
}

.hm-hotspot-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--orange-light));
  border-radius: 4px;
  transition: width 0.7s cubic-bezier(0.16,1,0.3,1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 28px;
}

.hm-bar-pct {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  padding-right: 5px;
  white-space: nowrap;
}

.hm-hotspot-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
  min-width: 90px;
}

.hm-stat-total   { font-size: 18px; font-weight: 800; font-family: var(--font-mono); color: var(--text-primary); letter-spacing: -0.5px; }
.hm-stat-label   { font-size: 10px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; }
.hm-stat-touches { font-size: 11px; color: var(--orange-light); font-family: var(--font-mono); }

/* ── HEATMAP TABLE ───────────────────────────────────────────────────────── */

.hm-grid-card { overflow: hidden; }

.hm-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.hm-table { border-collapse: collapse; width: 100%; min-width: 400px; }

.hm-th-layer { width: 32px; padding: 10px 4px; }

.hm-th-file {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 14px 10px 4px;
  min-width: 180px;
  white-space: nowrap;
}

.hm-th-col {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 10px 12px;
  text-align: center;
  white-space: nowrap;
  border-left: 1px solid var(--glass-border);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hm-th-total,
.hm-th-touches {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 12px;
  text-align: center;
  border-left: 1px solid rgba(255,255,255,0.06);
  white-space: nowrap;
}

.hm-td-layer { text-align: center; font-size: 16px; padding: 10px 4px; width: 32px; }

.hm-td-file {
  font-family: var(--font-mono);
  padding: 8px 14px 8px 4px;
  max-width: 200px;
  min-width: 140px;
}

.hm-file-name {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hm-file-path {
  display: block;
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.hm-td-cell {
  text-align: center;
  padding: 6px 10px;
  border-left: 1px solid var(--glass-border);
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: outline 0.1s ease;
  position: relative;
  min-width: 60px;
  cursor: default;
}

.hm-td-cell:hover { outline: 1px solid rgba(255,255,255,0.25); z-index: 2; }

.hm-td-empty { opacity: 0.4; }

.hm-cell-dash { font-size: 12px; color: var(--text-tertiary); opacity: 0.4; }

.hm-cell-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.95);
  display: block;
  line-height: 1.3;
}

.hm-cell-dot {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin: 2px auto 0;
  opacity: 0.9;
}

.hm-td-total {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--purple-light);
  text-align: center;
  padding: 8px 12px;
  border-left: 1px solid rgba(255,255,255,0.06);
  white-space: nowrap;
}

.hm-td-touches { text-align: center; padding: 8px 12px; min-width: 80px; }

.hm-touch-fraction {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.hm-touch-bar-bg {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}

.hm-touch-bar-fill {
  height: 100%;
  background: var(--purple-light);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ── HEATMAP LEGEND ──────────────────────────────────────────────────────── */

.hm-legend {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
  flex-wrap: wrap;
}

.hm-legend-scale { display: flex; align-items: center; gap: 8px; }

.hm-legend-types { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.hm-legend-type { display: flex; align-items: center; gap: 5px; }

.hm-legend-bar {
  width: 100px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg,
    rgba(124,58,237,0.3),
    rgba(179,73,124,0.6),
    rgba(234,88,12,0.9)
  );
}

.hm-legend-label { font-size: 11px; color: var(--text-tertiary); }

.hm-dot-legend {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}