/* BCM Ops Risk — Modern UI */
:root {
  --bg: #0d1117;
  --bg-elevated: #161b22;
  --bg-card: #21262d;
  --border: #30363d;
  --text: #f0f6fc;
  --text-secondary: #8b949e;
  --accent: #58a6ff;
  --accent-soft: rgba(88, 166, 255, 0.15);
  --high: #f85149;
  --high-soft: rgba(248, 81, 73, 0.12);
  --medium: #d29922;
  --medium-soft: rgba(210, 153, 34, 0.12);
  --low: #3fb950;
  --low-soft: rgba(63, 185, 80, 0.12);
  --critical: #da3633;
  --monitor: #d29922;
  --clean: #3fb950;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.app { min-height: 100vh; }
.container { max-width: 720px; margin: 0 auto; padding: 0 20px 40px; }

/* Top bar */
.topbar {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(1.2);
}
.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, #a371f7 100%);
  opacity: 0.95;
}
.brand-title { font-size: 1.35rem; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.brand-desc { font-size: 0.85rem; color: var(--text-secondary); margin: 4px 0 0 0; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-link { color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.topbar-link:hover { text-decoration: underline; }
.updated { font-size: 0.8rem; color: var(--text-secondary); }

.auth-box { max-width: 380px; margin: 60px auto; padding: 32px; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); }
.auth-box h1 { margin: 0 0 8px; font-size: 1.5rem; }
.auth-box .auth-desc { color: var(--text-secondary); margin-bottom: 20px; }
.auth-box label { display: block; margin-top: 12px; font-size: 0.9rem; }
.auth-box input[type=email],
.auth-box input[type=password] { width: 100%; padding: 10px; margin-top: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); }
.auth-box .auth-checkbox { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.auth-box button { margin-top: 20px; }
.auth-error { color: var(--high); font-size: 0.9rem; margin-bottom: 12px; }
.auth-footer { margin-top: 20px; font-size: 0.9rem; color: var(--text-secondary); }
.auth-footer a { color: var(--accent); }
.btn-refresh {
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn-refresh:hover { background: var(--border); border-color: var(--text-secondary); }

/* Status banner */
.status-banner {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 24px 0 20px;
  box-shadow: var(--shadow);
}
.status-pill,
.hero-status {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.hero-status.critical { color: var(--critical); }
.hero-status.monitor { color: var(--monitor); }
.hero-status.clean { color: var(--clean); }
.status-desc,
.hero-why { margin: 0; font-size: 0.9rem; color: var(--text-secondary); }

/* Alerts */
.alerts-block { margin-bottom: 24px; }
.section-title { font-size: 0.95rem; font-weight: 600; color: var(--text-secondary); margin: 0 0 12px 0; }
.alerts-list { display: flex; flex-direction: column; gap: 10px; }
.alert-item {
  background: var(--high-soft);
  border: 1px solid rgba(248, 81, 73, 0.35);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  transition: transform 0.15s;
}
.alert-item:hover { transform: translateY(-1px); }
.alert-item .alert-title { font-weight: 600; font-size: 0.95rem; margin: 0 0 4px 0; }
.alert-item .alert-title a { color: var(--text); text-decoration: none; }
.alert-item .alert-title a:hover { color: var(--accent); text-decoration: underline; }
.alert-item .alert-meta { font-size: 0.8rem; color: var(--text-secondary); }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  transition: border-color 0.2s, transform 0.15s;
}
.stat:hover { border-color: var(--text-secondary); transform: translateY(-2px); }
.stat-num {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.stat-name { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.stat.high .stat-num { color: var(--high); }
.stat.medium .stat-num { color: var(--medium); }
.stat.low .stat-num { color: var(--low); }
.stat.total .stat-num { color: var(--text); }

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.tabs { display: flex; gap: 6px; }
.tab {
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.tab:hover { color: var(--text); background: var(--bg-card); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; }
.filters select,
.filters input {
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  min-width: 140px;
}
.filters input::placeholder { color: var(--text-secondary); }

/* Feed / cards */
.feed { margin-bottom: 32px; }
.findings { display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.card:hover {
  border-color: var(--text-secondary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.card.source-x { border-left: 4px solid var(--accent); }
.card .title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 8px 0;
  line-height: 1.4;
}
.card .title a { color: var(--text); text-decoration: none; }
.card .title a:hover { color: var(--accent); text-decoration: underline; }
.card .summary { font-size: 0.9rem; color: var(--text-secondary); margin: 0 0 12px 0; line-height: 1.5; }
.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.high { background: var(--high-soft); color: var(--high); }
.badge.medium { background: var(--medium-soft); color: var(--medium); }
.badge.low { background: var(--low-soft); color: var(--low); }
.badge.source { background: var(--accent-soft); color: var(--accent); }
.card .actions-toggle {
  font-size: 0.82rem;
  color: var(--accent);
  cursor: pointer;
  margin-top: 10px;
  font-weight: 500;
}
.card .actions-toggle:hover { text-decoration: underline; }
.card .actions-list {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 8px;
  padding-left: 18px;
  display: none;
}
.card .actions-list.open { display: block; }
.card .related { font-size: 0.8rem; color: var(--text-secondary); margin-top: 8px; }
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.grok-report-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 24px; }
.grok-report-title { font-weight: 600; font-size: 1rem; margin-bottom: 12px; color: var(--accent); }
.grok-report-body { font-size: 0.9rem; line-height: 1.65; white-space: pre-wrap; word-wrap: break-word; }

/* Footer */
.footer {
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.footer code {
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
  padding: 2px 6px;
  background: var(--bg-card);
  border-radius: 4px;
}

@media (max-width: 640px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .toolbar { flex-direction: column; align-items: stretch; }
  .tabs { justify-content: center; }
  .topbar-inner { flex-direction: column; align-items: flex-start; }
}
