/* AI Visibility dashboard shell. Brand tokens (--accent, --bg, etc.) come from
   the runtime-generated /static/brand.css (Part IV). Semantic colors live here. */

:root {
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --border: #e6e6ea;
  --muted: #6b7280;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 16, 24, 0.04), 0 4px 12px rgba(16, 16, 24, 0.04);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}

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

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 0 0 8px 0; z-index: 100;
}
.skip-link:focus { left: 0; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-logo { display: block; object-fit: contain; }
.brand-logo.brand-sm { width: 26px; height: 26px; }
.brand-emoji.brand-sm { font-size: 22px; }
.name-text { font-size: 16px; letter-spacing: -0.01em; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-toggle {
  display: none; margin-left: auto;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px; color: var(--ink); cursor: pointer;
}

/* Layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 60px - 48px); }
.sidebar {
  border-right: 1px solid var(--border);
  padding: 18px 12px; background: var(--surface);
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: block; padding: 8px 12px; border-radius: 8px;
  color: var(--ink); font-size: 14px; font-weight: 500;
}
.sidebar nav a:hover { background: var(--accent-soft); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.section-label {
  margin: 16px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}

.main { padding: 28px 32px; max-width: 1180px; }

/* Footer */
.site-footer {
  height: 48px; display: flex; align-items: center; padding: 0 20px;
  border-top: 1px solid var(--border); background: var(--surface);
  font-size: 12.5px; color: var(--muted);
}
.site-footer span { font-weight: 600; color: var(--ink); }

/* Page header */
.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.02em; }
.page-head p { margin: 0; color: var(--muted); }

/* Metric cards */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.metric-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.metric-card .label { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.metric-card .value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; }
.metric-card .delta { font-size: 13px; font-weight: 600; margin-top: 2px; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--err); }
.delta.flat { color: var(--muted); }
.metric-card .hint { font-size: 11.5px; color: var(--muted); cursor: help; }

/* Cards + sections */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; letter-spacing: -0.01em; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

/* Charts */
.chart-wrap { position: relative; height: 300px; }
.chart-wrap.tall { height: 360px; }

/* Tables */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.data th {
  font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
  cursor: default; user-select: none;
}
table.data th[data-sort] { cursor: pointer; }
table.data th[aria-sort="ascending"]::after { content: " \2191"; }
table.data th[aria-sort="descending"]::after { content: " \2193"; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.tenant-row { background: var(--accent-soft); }
table.data tr.tenant-row td { font-weight: 650; }

/* Badges + pills */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650;
}
.badge.core { background: var(--accent-soft); color: var(--accent); }
.badge.extended { background: #f1f1f4; color: var(--muted); }
.badge.critical { background: #fde8e8; color: var(--err); }
.badge.notable { background: #fef3e2; color: var(--warn); }
.badge.info { background: #f1f1f4; color: var(--muted); }

.pos { font-variant-numeric: tabular-nums; font-weight: 650; }
.pos.p1 { color: var(--ok); }
.pos.none { color: var(--muted); font-weight: 400; }

/* Insights + actions */
.insight { border-left: 3px solid var(--border); padding: 12px 16px; margin-bottom: 12px; }
.insight.action_required { border-left-color: var(--err); }
.insight.notable { border-left-color: var(--warn); }
.insight.info { border-left-color: var(--muted); }
.insight h3 { margin: 0 0 4px; font-size: 15px; }
.insight p { margin: 0; color: var(--muted); font-size: 14px; }

.action-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.action-row .prio {
  flex: none; width: 44px; height: 44px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px;
}
.action-row .body { flex: 1; }
.action-row h3 { margin: 0 0 2px; font-size: 15px; }
.action-row .meta { font-size: 12.5px; color: var(--muted); }

/* Detail / expand panels */
.expand-panel {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; margin: 4px 0 10px; font-size: 13.5px; white-space: pre-wrap;
}

.empty {
  text-align: center; color: var(--muted); padding: 48px 20px;
}
.empty svg { opacity: 0.4; margin-bottom: 12px; }

select.run-select {
  font: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink);
}

.provenance { font-size: 12px; color: var(--muted); margin-top: 6px; }
.provenance a { color: var(--muted); text-decoration: underline; }

/* Responsive */
@media (max-width: 860px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .app { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; inset: 60px 0 auto 0; z-index: 30;
    transform: translateY(-120%); transition: transform 0.2s ease;
    border-bottom: 1px solid var(--border); max-height: calc(100vh - 60px); overflow-y: auto;
  }
  .sidebar.open { transform: translateY(0); }
  .main { padding: 20px 16px; }
}
@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
