:root {
  --bg: #0b0f19;
  --panel: #111827;
  --border: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, .12);
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --orange: #f59e0b;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, sans-serif; }
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--border); padding: 24px 16px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 26px; font-weight: 800; }
.brand span { color: var(--accent); }
.tagline { color: var(--muted); font-size: 11px; margin-bottom: 18px; }
.nav { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  color: var(--muted); font-size: 14px; transition: all .15s;
}
.nav-item:hover { background: var(--accent-soft); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.lockdown-btn {
  margin-top: auto; background: rgba(239, 68, 68, .12); color: var(--red);
  border: 1px solid var(--red); border-radius: 10px; padding: 12px;
  font-weight: 700; cursor: pointer; font-size: 13px;
}
.lockdown-btn:hover { background: rgba(239, 68, 68, .22); }
.warranty-note {
  margin-top: 12px; font-size: 11px; color: var(--muted);
  background: var(--accent-soft); border-radius: 8px; padding: 10px; line-height: 1.5;
}

/* ── Main ── */
.main { flex: 1; padding: 28px 32px; max-width: 1200px; }
.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 22px; flex-wrap: wrap; gap: 8px; }
.view-header h1 { font-size: 24px; }
.date, .subtitle { color: var(--muted); font-size: 13px; }
.live-dot { color: var(--green); font-size: 12px; font-weight: 700; animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { opacity: .4; } }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 20px; }
.card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 16px; }

/* Score ring */
.score-card { text-align: center; }
.big-ring { width: 160px; margin: 0 auto; position: relative; }
.big-ring svg { width: 160px; height: 160px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 12; }
.ring-fill {
  fill: none; stroke: var(--accent); stroke-width: 12; stroke-linecap: round;
  stroke-dasharray: 439.8; stroke-dashoffset: 439.8;
  transition: stroke-dashoffset 1.2s cubic-bezier(.22,1,.36,1), stroke .5s;
}
.big-ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.big-ring-label span { font-size: 42px; font-weight: 800; }
.big-ring-label small { color: var(--muted); }
.score-trend { margin-top: 10px; color: var(--green); font-size: 13px; }

/* Metrics */
.metric-list { display: flex; flex-direction: column; gap: 12px; }
.metric { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.metric strong { color: var(--text); font-size: 16px; }

/* Keywords */
.keyword-rank { list-style: none; }
.keyword-rank li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.keyword-rank li:last-child { border: none; }
.kw-pos { width: 22px; height: 22px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.kw-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.kw-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #8b5cf6); border-radius: 3px; }
.kw-count { color: var(--muted); font-size: 12px; width: 40px; text-align: right; }

/* Feed */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--border); font-size: 13.5px; align-items: baseline; }
.feed-item:last-child { border: none; }
.feed-time { color: var(--muted); font-family: ui-monospace, monospace; font-size: 12px; flex-shrink: 0; width: 70px; }
.feed-item.warn { color: #fcd34d; }
.feed-item.ok { color: #86efac; }
.feed-item.info { color: var(--text); }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border: none; }
.pill { padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.pill.active { background: rgba(34,197,94,.15); color: var(--green); }
.pill.revoked { background: rgba(148,163,184,.15); color: var(--muted); }
.pill.warn { background: rgba(239,68,68,.15); color: var(--red); }
.pill.clean { background: rgba(34,197,94,.15); color: var(--green); }
.link-url { color: var(--accent); font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }
.btn-sm {
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent);
  border-radius: 8px; padding: 7px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.btn-sm:hover { background: rgba(59,130,246,.25); }
.btn-revoke { background: transparent; color: var(--red); border: 1px solid var(--red); border-radius: 6px; padding: 4px 10px; font-size: 11px; cursor: pointer; }

/* Extension audit */
.audit-donut { display: flex; flex-direction: column; gap: 14px; }
.donut-stat { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.donut-stat strong { color: var(--text); margin-left: auto; font-size: 18px; }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.green { background: var(--green); } .dot.yellow { background: var(--yellow); } .dot.red { background: var(--red); }
.flagged-item { border-left: 3px solid var(--yellow); background: var(--bg); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.flagged-item.high { border-left-color: var(--red); }
.flagged-item .fi-name { font-weight: 700; display: flex; justify-content: space-between; }
.flagged-item .fi-reason { color: var(--muted); font-size: 12.5px; margin-top: 4px; line-height: 1.5; }
.flagged-item .fi-perms { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.perm-chip { background: var(--border); border-radius: 5px; padding: 2px 8px; font-size: 10.5px; color: var(--muted); font-family: ui-monospace, monospace; }

/* Shadow map */
.shadow-platform { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 20px; margin-bottom: 14px; display: flex; gap: 24px; align-items: flex-start; }
.shadow-platform .sp-icon { font-size: 34px; }
.sp-body { flex: 1; }
.sp-name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.risk-pill { padding: 3px 12px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.risk-pill.high { background: rgba(239,68,68,.15); color: var(--red); }
.risk-pill.medium { background: rgba(234,179,8,.15); color: var(--yellow); }
.risk-pill.low { background: rgba(34,197,94,.15); color: var(--green); }
.sp-stats { display: flex; gap: 24px; margin-top: 12px; flex-wrap: wrap; }
.sp-stat { font-size: 13px; color: var(--muted); }
.sp-stat strong { display: block; color: var(--text); font-size: 20px; }
.correlation-card { border-color: var(--orange); }
.correlation-card p { color: var(--muted); line-height: 1.7; font-size: 14px; }
.correlation-card strong { color: var(--orange); }

/* Reports */
.report-tabs { display: flex; gap: 8px; }
.tab { background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 8px; padding: 8px 16px; cursor: pointer; font-size: 13px; }
.tab.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.report-card { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13.5px; line-height: 1.8; white-space: pre-wrap; color: #cbd5e1; }
.report-card .rpt-highlight { color: var(--accent); font-weight: 700; }

/* Trust badge */
.badge-preview-card { display: flex; flex-direction: column; }
.trust-badge {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  border: 1px solid var(--accent); border-radius: 14px; padding: 20px;
  display: flex; gap: 16px; align-items: center;
}
.badge-shield {
  width: 52px; height: 52px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 26px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; flex-shrink: 0;
}
.trust-badge strong { color: var(--accent); font-size: 13px; letter-spacing: .04em; }
.trust-badge p { color: var(--muted); font-size: 12px; margin: 4px 0; }
.trust-badge small { color: var(--muted); font-size: 11px; }
.embed-code { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; font-size: 11.5px; color: var(--muted); overflow-x: auto; margin-bottom: 10px; }
.verify-link { color: var(--accent); font-size: 13px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(4px); }
.modal.hidden { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--red); border-radius: 18px; padding: 32px; max-width: 440px; }
.modal-box h2 { margin-bottom: 14px; }
.modal-box p { color: var(--muted); margin-bottom: 10px; }
.modal-box ul { margin: 0 0 22px 20px; color: var(--muted); line-height: 1.9; }
.modal-box ul strong { color: var(--text); }
.modal-actions { display: flex; gap: 10px; }
.btn-danger-solid { flex: 1; background: var(--red); color: #fff; border: none; border-radius: 10px; padding: 12px; font-weight: 700; cursor: pointer; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 10px; padding: 12px 20px; cursor: pointer; }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ── Referrals + Team Admin views ── */
.dim { color: var(--muted); font-size: 13.5px; }
.ref-link-row { display: flex; gap: 10px; align-items: center; margin: 12px 0 16px; }
.ref-link-row .verify-link { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-share-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-ghost-sm { display: inline-block; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); color: var(--text); font-size: 13px; text-decoration: none; background: transparent; cursor: pointer; }
.btn-ghost-sm:hover { border-color: var(--accent); color: var(--accent); }
.progress-bar { height: 8px; background: var(--border); border-radius: 999px; margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); border-radius: 999px; transition: width .4s; }
.how-list { list-style: none; padding: 0; }
.how-list li { padding: 8px 0; color: var(--muted); font-size: 14px; }
.how-list strong { color: var(--text); }
.team-create-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.input { flex: 1; min-width: 180px; padding: 10px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 14px; }
.input:focus { outline: none; border-color: var(--accent); }
select.input { flex: 0 1 auto; }
.pill-green { background: rgba(34,197,94,.15); color: var(--green); }
.pill-yellow { background: rgba(234,179,8,.15); color: var(--yellow); }
.hidden { display: none !important; }

/* ── Launch Promo card ── */
.promo-card { border-color: var(--accent); background: linear-gradient(135deg, var(--panel), rgba(59,130,246,.07)); margin-bottom: 24px; }
.promo-progress-row { display: flex; align-items: center; gap: 16px; margin: 16px 0; }
.pill-red { background: rgba(239,68,68,.15); color: var(--red); }

/* ── Posture Scan ── */
.scan-score-row { display: flex; align-items: center; gap: 20px; }
.scan-grade { width: 72px; height: 72px; border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 800; background: var(--accent-soft); color: var(--accent); border: 2px solid var(--accent); }
.scan-grade.grade-A { color: var(--green); border-color: var(--green); background: rgba(34,197,94,.1); }
.scan-grade.grade-B { color: var(--accent); }
.scan-grade.grade-C { color: var(--yellow); border-color: var(--yellow); background: rgba(234,179,8,.1); }
.scan-grade.grade-D, .scan-grade.grade-F { color: var(--red); border-color: var(--red); background: rgba(239,68,68,.1); }
.finding { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-top: 12px; }
.finding-head { display: flex; align-items: center; gap: 10px; }
.finding-title { font-weight: 600; font-size: 14px; }
.finding-detail { color: var(--muted); font-size: 13px; margin-top: 6px; }
.finding-fix { font-size: 13px; margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: rgba(34,197,94,.08); border-left: 3px solid var(--green); }
.finding-fix b { color: var(--green); }
.pill-critical { background: rgba(239,68,68,.2); color: var(--red); }
.pill-high { background: rgba(239,68,68,.15); color: var(--red); }
.pill-medium { background: rgba(234,179,8,.15); color: var(--yellow); }
.pill-low { background: rgba(59,130,246,.15); color: var(--accent); }
