:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d2e;
  --bg-card: #1e2235;
  --bg-hover: #252a3d;
  --border: #2d3348;
  --text-primary: #e8eaf0;
  --text-secondary: #8b92a5;
  --accent: #6366f1;
  --accent-hover: #4f52d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}

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

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* Sidebar */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 240px;
  background: var(--bg-secondary); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 100; overflow-y: auto;
}
.sidebar-logo { padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
.sidebar-logo .logo-mark { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.sidebar-logo .logo-icon { width: 32px; height: 32px; background: var(--accent); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.sidebar-logo .logo-text { font-size: 15px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.3px; }
.sidebar-logo .logo-sub { font-size: 10px; color: var(--text-secondary); letter-spacing: 0.5px; text-transform: uppercase; }
.sidebar-nav { padding: 12px 10px; flex: 1; }
.nav-section-label { font-size: 10px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; padding: 8px 10px 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: var(--text-secondary); font-size: 13.5px; font-weight: 500; transition: all 0.15s; margin-bottom: 2px; }
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active { background: rgba(99,102,241,0.15); color: var(--accent); }
.nav-link .icon { width: 18px; text-align: center; font-size: 15px; }

/* Main */
.main-content { margin-left: 240px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 60px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.page-content { padding: 24px; flex: 1; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; position: relative; overflow: hidden; }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.kpi-card.accent::before { background: var(--accent); }
.kpi-card.success::before { background: var(--success); }
.kpi-card.warning::before { background: var(--warning); }
.kpi-card.danger::before { background: var(--danger); }
.kpi-card.info::before { background: var(--info); }
.kpi-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.kpi-value { font-size: 32px; font-weight: 700; letter-spacing: -1px; line-height: 1; }
.kpi-sub { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

/* Tables */
.table-wrapper { overflow-x: auto; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.02); }
td { padding: 10px 16px; border-bottom: 1px solid rgba(45,51,72,0.5); font-size: 13px; color: var(--text-primary); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }

/* Failed URL links */
.failed-url {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  word-break: break-all;
  transition: color 0.15s;
}
.failed-url:hover { color: var(--accent); text-decoration: underline; }

/* Request health stat tiles */
.req-stat {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: 10px; border: 1px solid; min-width: 90px;
  text-align: center;
}
.req-stat-danger  { background: rgba(239,68,68,0.08);  border-color: rgba(239,68,68,0.25); }
.req-stat-warning { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.25); }
.req-stat-info    { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.25); }
.req-stat-num   { font-size: 28px; font-weight: 800; line-height: 1; }
.req-stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 3px; font-weight: 500; }
.req-stat-danger .req-stat-num   { color: var(--danger); }
.req-stat-warning .req-stat-num  { color: var(--warning); }
.req-stat-info .req-stat-num     { color: var(--info); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.badge-success { background: rgba(16,185,129,0.15);  color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15);  color: var(--warning); }
.badge-danger  { background: rgba(239,68,68,0.15);   color: var(--danger); }
.badge-info    { background: rgba(59,130,246,0.15);  color: var(--info); }
.badge-neutral { background: rgba(139,146,165,0.15); color: var(--text-secondary); }
.badge-accent  { background: rgba(99,102,241,0.15);  color: var(--accent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: all 0.15s; white-space: nowrap; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost  { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Screenshot gallery */
.screenshots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.screenshot-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; transition: all 0.2s; }
.screenshot-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.screenshot-card img { width: 100%; height: 160px; object-fit: cover; object-position: top; display: block; }
.screenshot-card .screenshot-meta { padding: 10px 12px; }
.screenshot-card .screenshot-step { font-size: 12px; font-weight: 600; }
.screenshot-card .screenshot-url { font-size: 10px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; text-decoration: none; margin-top: 2px; }
.screenshot-card .screenshot-url:hover { text-decoration: underline; }
.screenshot-step-badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,0.65); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px;
}

/* Lightbox */
.lightbox-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 1000; align-items: center; justify-content: center; gap: 16px; }
.lightbox-overlay.active { display: flex; }
.lightbox-img { max-width: 80vw; max-height: 82vh; border-radius: 8px; object-fit: contain; }
.lightbox-close { position: absolute; top: 20px; right: 24px; font-size: 28px; color: white; cursor: pointer; background: none; border: none; line-height: 1; z-index: 10; }
.lightbox-nav { background: rgba(255,255,255,0.1); border: none; color: white; font-size: 36px; width: 52px; height: 52px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.2s; }
.lightbox-nav:hover { background: rgba(255,255,255,0.2); }

/* Telemetry */
.telemetry-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(45,51,72,0.5); }
.telemetry-item:last-child { border-bottom: none; }
.telemetry-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.dot-error    { background: var(--danger); }
.dot-warning  { background: var(--warning); }
.dot-info     { background: var(--info); }
.dot-critical { background: #ff0055; box-shadow: 0 0 6px #ff005580; }

/* AI report */
.report-section { margin-bottom: 28px; }
.report-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; }
.report-section .content { font-size: 13.5px; line-height: 1.85; color: var(--text-secondary); white-space: pre-wrap; }
.report-section .content strong { color: var(--text-primary); }

/* AI Chat bubbles */
.chat-bubble { padding: 12px 16px; border-radius: 10px; max-width: 90%; font-size: 13.5px; line-height: 1.75; }
.chat-bubble-user { background: rgba(99,102,241,0.15); border: 1px solid rgba(99,102,241,0.25); color: var(--text-primary); align-self: flex-end; margin-left: auto; }
.chat-bubble-ai   { background: var(--bg-hover); border: 1px solid var(--border); color: var(--text-secondary); align-self: flex-start; }
.chat-bubble-ai strong { color: var(--text-primary); }
.chat-bubble-ai p { margin-bottom: 8px; }
.chat-bubble-ai p:last-child { margin-bottom: 0; }
.chat-spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle; margin-right: 6px; }

/* Quick prompts */
.quick-prompt-btn {
  background: var(--bg-primary); border: 1px solid var(--border); border-radius: 20px;
  color: var(--text-secondary); font-size: 11px; padding: 5px 12px; cursor: pointer;
  transition: all 0.15s;
}
.quick-prompt-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Friction timeline */
.friction-timeline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 1100px) { .friction-timeline { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px)  { .friction-timeline { grid-template-columns: 1fr; } }

.friction-step {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: transform 0.15s;
}
.friction-step:hover { transform: translateY(-2px); }

.friction-step-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.friction-step-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1.5px solid;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  flex-shrink: 0;
}

.friction-badge {
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
  flex-shrink: 0;
}

.friction-screenshot {
  position: relative;
  border-radius: 7px;
  overflow: hidden;
  cursor: pointer;
  margin-bottom: 12px;
}
.friction-screenshot img {
  width: 100%; height: 120px;
  object-fit: cover; object-position: top;
  display: block;
  border-radius: 7px;
}
.friction-screenshot-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 12px; font-weight: 600;
  opacity: 0;
  transition: all 0.2s;
  border-radius: 7px;
}
.friction-screenshot:hover .friction-screenshot-overlay {
  background: rgba(0,0,0,0.45);
  opacity: 1;
}

.friction-issues {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 4px;
}
.friction-issues li {
  font-size: 11.5px;
  color: var(--text-secondary);
  padding-left: 14px;
  position: relative;
  line-height: 1.5;
}
.friction-issues li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 10px;
}

/* Plugin heatmap */
.plugin-bar { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.plugin-bar-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; }
.plugin-bar-fill { height: 6px; border-radius: 3px; transition: width 0.5s; }
.impact-critical .plugin-bar-fill { background: var(--danger); }
.impact-high     .plugin-bar-fill { background: var(--warning); }
.impact-medium   .plugin-bar-fill { background: var(--info); }
.impact-low      .plugin-bar-fill { background: var(--success); }

/* Spinner */
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Live */
.live-indicator { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--success); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
}

/* Form */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.form-input { width: 100%; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; color: var(--text-primary); font-size: 14px; outline: none; transition: border-color 0.15s; font-family: inherit; }
.form-input:focus { border-color: var(--accent); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 1200px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px)  { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
