/* ============================================================
   Apex Radar — Unified Dashboard Shell
   Shared layout for Overview, AI Visibility, Business Intel
   ============================================================ */
:root {
  --page: #f4f4f9;
  --side: #ffffff;
  --ink: #15171c;
  --ink-2: #4a4e58;
  --muted: #7a808a;
  --muted-2: #aab0bb;
  --line: #ececf0;
  --line-2: #e2e3e8;
  --chip: #f3f4f7;
  --accent: #6b5cff;
  --accent-2: #4d3ee5;
  --accent-soft: #ede9ff;
  --green: #16a36b;
  --violet: #7a5cf0;
  --orange: #ff7a3a;
  --red: #d8553b;
  --amber: #f59e0b;
  --area-bg: #fafbfd;
  --content-bg: #f4f4f9;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #eceef3;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
}
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ============ Browser frame ============ */
.browser {
  width: 1100px;
  height: 720px;
  background: #fff;
  border-radius: 14px;
  box-shadow:
    0 1px 0 rgba(17,19,23,.04),
    0 30px 80px -20px rgba(17,19,23,.25),
    0 8px 24px -12px rgba(17,19,23,.15);
  overflow: hidden;
  position: relative;
  display: flex; flex-direction: column;
}
.titlebar {
  height: 38px; background: #ededf1;
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid #dededf;
  flex: 0 0 38px;
}
.titlebar .lights { display: flex; gap: 7px; }
.titlebar .lights span { width: 11px; height: 11px; border-radius: 50%; background: #d6d6da; }
.titlebar .url {
  background: #fff;
  border-radius: 7px;
  padding: 5px 14px;
  font-size: 12px; color: var(--ink-2);
  margin: 0 auto;
  min-width: 320px; text-align: center;
  border: 1px solid #e3e3e7;
}
.titlebar .url b { color: var(--ink); font-weight: 500; }

/* ============ App body ============ */
.app {
  display: grid;
  grid-template-columns: 230px 1fr;
  flex: 1; min-height: 0;
  background: var(--content-bg);
}

/* sidebar */
.side {
  background: var(--side);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.side .scroll {
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 18px;
  flex: 1; overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 7px;
  background: linear-gradient(135deg, #6b5cff 0%, #9d8eff 100%);
  display: flex; align-items: center; justify-content: center;
}
.brand .col { display: flex; flex-direction: column; }
.brand .name { font-weight: 600; font-size: 13px; color: var(--ink); }
.brand .url { font-size: 11px; color: var(--muted); }

.nav-group .label {
  font-size: 10px; font-weight: 600;
  color: var(--muted-2);
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 0 8px 8px;
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 7px;
  font-size: 13px; color: var(--ink-2);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.nav-item .ico {
  width: 16px; height: 16px; flex-shrink: 0;
  color: var(--muted);
}
.nav-item .lbl { flex: 1; }
.nav-item .badge {
  background: #ececf0; color: var(--muted); font-size: 10px;
  padding: 1px 6px; border-radius: 999px; font-family: 'JetBrains Mono', monospace;
}
.nav-item:hover { background: #f3f4f7; color: var(--ink); }
.nav-item:hover .ico { color: var(--ink-2); }
.nav-item.active {
  background: #f3f4f7; color: var(--ink); font-weight: 500;
}
.nav-item.active .ico { color: var(--accent); }
.nav-item.active::before {
  content: ''; position: absolute; right: -12px; top: 8px; bottom: 8px;
  width: 2px; background: var(--accent); border-radius: 2px;
}

.side-foot {
  padding: 12px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}
.upgrade-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.user-pill {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-2);
  padding: 4px 6px;
}
.user-pill .av {
  width: 22px; height: 22px; border-radius: 50%;
  background: #ddd6fe; color: var(--accent-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}

/* content */
.content {
  display: flex; flex-direction: column;
  min-height: 0;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.crumbs .c { color: var(--muted); }
.crumbs .sep { color: var(--muted-2); }
.crumbs .cur { color: var(--ink); font-weight: 500; }
.topbar .right { display: flex; align-items: center; gap: 12px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  border: none; background: transparent;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: #f3f4f7; color: var(--ink-2); }
.run-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.run-btn:hover { background: var(--accent-2); }
.run-btn.pressed {
  transform: scale(.96);
  box-shadow: 0 0 0 6px rgba(107,92,255,.2);
}

/* scrollable canvas */
.canvas {
  flex: 1; overflow-y: auto;
  padding: 22px;
  background: var(--content-bg);
}
.canvas::-webkit-scrollbar { width: 8px; }
.canvas::-webkit-scrollbar-thumb { background: #d6d8df; border-radius: 4px; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
}

/* shared header in pages */
.page-head { padding: 6px 6px 14px; }
.page-eyebrow {
  font-size: 10px; font-weight: 600; color: var(--muted);
  letter-spacing: .14em; text-transform: uppercase;
  margin-bottom: 6px;
}
.page-h1 {
  font-size: 24px; font-weight: 700; letter-spacing: -.02em;
  line-height: 1.2; margin: 0 0 6px;
}
.page-sub {
  font-size: 13px; color: var(--muted);
  line-height: 1.55; max-width: 720px;
  margin: 0 0 12px;
}
.meta-row {
  display: flex; align-items: center; gap: 14px;
  font-size: 12px; color: var(--muted);
  flex-wrap: wrap;
}
.meta-row .scans {
  background: var(--accent-soft); color: var(--accent-2);
  padding: 4px 10px; border-radius: 999px;
  font-weight: 500;
}
.meta-row b { color: var(--ink); font-weight: 500; }

/* ============ Cursor ============ */
.cursor {
  position: absolute;
  width: 22px; height: 22px;
  pointer-events: none;
  z-index: 100;
  transition: left 1.0s cubic-bezier(.4,.05,.2,1), top 1.0s cubic-bezier(.4,.05,.2,1);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.25));
  left: 700px; top: 100px;
}
.cursor.click::after {
  content: ''; position: absolute;
  left: 0; top: 0;
  width: 28px; height: 28px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  transform: translate(-3px,-3px) scale(.5);
  opacity: 0;
  animation: clickRing .55s ease-out;
}
@keyframes clickRing {
  0% { transform: translate(-3px,-3px) scale(.4); opacity: 1; }
  100% { transform: translate(-3px,-3px) scale(1.6); opacity: 0; }
}

/* caption */
.caption {
  position: absolute;
  bottom: 18px; left: 50%;
  background: rgba(21,23,28,.92);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  z-index: 90;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity .35s ease, transform .35s ease;
  max-width: 80%; text-align: center;
  pointer-events: none;
  white-space: nowrap;
}
.caption.show { opacity: 1; transform: translate(-50%, 0); }
.caption b { color: #b9aaff; font-weight: 600; }

/* page transitions */
.view { display: none; flex-direction: column; height: 100%; }
.view.show { display: flex; animation: viewIn .4s ease-out both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* common card pieces */
.kpi-grid { display: grid; gap: 12px; }
.kpi-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}
.kpi .ttl {
  font-size: 10px; color: var(--muted);
  letter-spacing: .08em; text-transform: uppercase;
  font-weight: 600; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.kpi .pill {
  font-size: 9px; color: var(--muted-2);
  background: var(--chip); padding: 2px 6px; border-radius: 4px;
  font-weight: 500; letter-spacing: .04em;
}
.kpi .val {
  font-size: 28px; font-weight: 700; letter-spacing: -.02em;
  line-height: 1;
}
.kpi .val small {
  color: var(--muted-2); font-size: 13px; font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
}
.kpi .delta {
  font-size: 11px; margin-top: 6px; color: var(--muted);
}
.kpi .delta.up { color: var(--green); font-weight: 500; }
.kpi .delta.down { color: var(--red); font-weight: 500; }

.tabs {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.tabs .tab {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tabs .tab.on { background: var(--accent); color: #fff; }

.section-h {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 6px 10px;
}
.section-h h3 {
  font-size: 14px; font-weight: 600; margin: 0;
  letter-spacing: -.005em;
}
.section-h .meta {
  font-size: 11px; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}

/* progress dots */
.progress {
  position: absolute; bottom: 16px; right: 22px;
  display: flex; gap: 6px;
  z-index: 91;
}
.progress span {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,.55);
  transition: background .25s, transform .25s;
}
.progress span.on { background: var(--accent); transform: scale(1.3); }
