:root {
  --bg: #0a0b0f;
  --surface: #14161c;
  --surface-hover: #1c1f2a;
  --border: #22263a;
  --text: #e0e4ea;
  --text-muted: #8891a0;
  --text-dim: #555d6e;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.6; min-height: 100vh;
}
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 30% 20%, rgba(100, 120, 180, 0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(140, 100, 160, 0.04) 0%, transparent 60%);
  animation: drift 20s ease-in-out infinite alternate;
}
@keyframes drift { 0% { transform: scale(1) translate(0, 0); } 100% { transform: scale(1.1) translate(-2%, 3%); } }

a { color: var(--accent-hover); text-decoration: none; }

/* Header */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.5rem; border-bottom: 1px solid var(--border);
  background: var(--surface); position: relative; z-index: 1;
}
.header-left { display: flex; align-items: center; gap: 1rem; }
header h1 { font-size: 1.3rem; font-weight: 300; letter-spacing: 0.2em; text-transform: lowercase; }
.status { font-size: 0.8rem; padding: 0.25rem 0.6rem; border-radius: 20px; font-weight: 500; }
.status.offline { color: var(--text-muted); background: var(--surface-hover); }
.status.scanning { color: var(--warning); background: var(--warning-bg); }
.status.done { color: var(--success); background: var(--success-bg); }
.device-badge { font-size: 0.75rem; color: var(--accent-hover); background: rgba(99, 102, 241, 0.1); padding: 0.2rem 0.6rem; border-radius: 10px; font-weight: 500; }

/* Layout */
.app-layout {
  display: grid; grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 52px); position: relative; z-index: 1;
}

/* Radar sidebar */
.whoami-sidebar {
  padding: 1.5rem; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.whoami-container { width: 100%; max-width: 260px; aspect-ratio: 1; position: relative; }
.whoami-container canvas { width: 100%; height: 100%; border-radius: 50%; }
.whoami-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 2rem; opacity: 0.3;
}
.privacy-note { margin-top: auto; }
.privacy-note p { font-size: 0.68rem; color: var(--text-dim); line-height: 1.7; text-align: center; }

/* Buttons */
.btn-primary {
  width: 100%; padding: 0.6rem; background: var(--accent); border: none;
  border-radius: var(--radius-sm); color: white; font-size: 0.9rem;
  font-weight: 500; cursor: pointer; font-family: inherit; transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-scan-module {
  padding: 0.4rem 1rem; background: var(--surface-hover); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 0.8rem;
  cursor: pointer; font-family: inherit; transition: all 0.2s;
}
.btn-scan-module:hover { background: var(--border); }
.btn-scan-module:disabled { opacity: 0.5; cursor: not-allowed; }

/* Results */
.results-container {
  padding: 1.5rem; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem; align-content: start;
}

.empty-state {
  grid-column: 1 / -1; text-align: center; padding: 3rem 2rem;
  color: var(--text-muted); font-size: 0.9rem; line-height: 1.8;
}
.empty-state .small { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.5rem; }

/* Module cards */
.module-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  animation: cardIn 0.3s ease;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.module-header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.module-icon { font-size: 1.1rem; }
.module-label { font-size: 0.85rem; font-weight: 500; flex: 1; }
.module-count { font-size: 0.7rem; color: var(--text-dim); }

/* Risk badges */
.risk-badge {
  font-size: 0.65rem; padding: 0.15rem 0.5rem; border-radius: 10px; font-weight: 500;
}
.risk-badge.high { background: var(--danger-bg); color: var(--danger); }
.risk-badge.medium { background: var(--warning-bg); color: var(--warning); }
.risk-badge.low { background: var(--success-bg); color: var(--success); }
.risk-badge.permission { background: rgba(99, 102, 241, 0.1); color: var(--accent-hover); }

/* Findings list */
.findings-list { padding: 0.5rem 0; }
.finding-row {
  display: flex; align-items: baseline; gap: 0.75rem;
  padding: 0.35rem 1rem; font-size: 0.78rem;
  border-left: 3px solid transparent;
}
.finding-row.high { border-left-color: var(--danger); }
.finding-row.medium { border-left-color: var(--warning); }
.finding-row.low { border-left-color: var(--border); }
.finding-row.good { border-left-color: var(--success); }
.finding-row.info { border-left-color: var(--accent); }
.finding-label { color: var(--text-muted); font-size: 0.7rem; min-width: 100px; flex-shrink: 0; }
.finding-value {
  color: var(--text); font-family: monospace; font-size: 0.75rem;
  word-break: break-all; flex: 1;
}
.finding-row.good .finding-value { color: var(--success); }
.finding-row.info .finding-value { color: var(--text-dim); font-family: inherit; font-style: italic; }

/* Permission prompt */
.permission-prompt {
  padding: 1rem; text-align: center;
}
.permission-prompt p { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 0.75rem; }

/* Detail overlay */
.detail-overlay {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: rgba(10, 11, 15, 0.85); align-items: center; justify-content: center; padding: 1rem;
}
.detail-overlay.visible { display: flex; }
.detail-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; max-width: 420px; width: 100%;
  position: relative;
}
.detail-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  background: none; border: none; color: var(--text-muted); font-size: 1.3rem; cursor: pointer;
}

/* Footer */
footer { position: relative; z-index: 1; border-top: 1px solid var(--border); background: var(--surface); }
.footer-bottom { text-align: center; padding: 0.75rem; }
.footer-bottom a { color: var(--text-dim); font-size: 0.7rem; letter-spacing: 0.1em; }

/* Responsive */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .whoami-sidebar {
    flex-direction: row; flex-wrap: wrap; justify-content: center;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 1rem;
  }
  .whoami-container { max-width: 160px; }
  .privacy-note { display: none; }
  .results-container { grid-template-columns: 1fr; padding: 1rem; }
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
