/* ═══════════════════════════════════════════════════════════════════════
   Droidwatch — Premium Design System
   Dark-first, workstation layout, glassmorphism, micro-interactions
   Tokens: /css/tokens.css (imported via <link> before this file)
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Skip link (a11y) ───────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 8px;
  z-index: 9999;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.875rem;
  border-radius: 0 0 var(--radius) var(--radius);
  text-decoration: none;
  transition: top var(--t-fast);
}
.skip-link:focus { top: 0; }

/* ── Reset & Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Ensure the HTML hidden attribute always wins over any display rule */
[hidden] { display: none !important; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  /* Subtle noise texture */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

/* ── Scrollbars ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Focus ──────────────────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ── App Shell ──────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  transition: grid-template-columns var(--t-slow);
}

/* The drawer is rendered as a fixed overlay (see .drawer below) so opening it
 * does NOT reflow the main column. The .drawer-open class is kept on the shell
 * because the drawer's slide-in transform is scoped to that selector. */

.app-shell.sidebar-collapsed {
  grid-template-columns: 60px 1fr;
}

/* ── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  z-index: 100;
  transition: width var(--t-slow);
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
  white-space: nowrap;
}

.sidebar__logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.sidebar__nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--t-fast);
  white-space: nowrap;
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar__item:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.sidebar__item.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.sidebar__item.active .icon { stroke: var(--accent); }

.sidebar__item--small { font-size: 12px; padding: 7px 10px; }

.sidebar__badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar__footer {
  padding: 8px;
  border-top: 1px solid var(--border);
}

.sidebar__auth-user {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: 6px 12px;
  font-size: .78rem;
  color: var(--text-muted);
}
.sidebar__role-badge {
  font-size: .65rem;
  background: #1f6feb;
  color: #fff;
  padding: .1rem .35rem;
  border-radius: 20px;
  flex-shrink: 0;
}
.sidebar__version {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 10px;
  text-align: center;
}

.icon { width: 18px; height: 18px; flex-shrink: 0; transition: stroke var(--t-fast); }

/* Collapsed sidebar */
.app-shell.sidebar-collapsed .sidebar__logo-text,
.app-shell.sidebar-collapsed .sidebar__item > span:not(.sidebar__badge),
.app-shell.sidebar-collapsed .sidebar__version {
  display: none;
}
.app-shell.sidebar-collapsed .sidebar__logo {
  justify-content: center;
  padding: 16px 8px 12px;
}
.app-shell.sidebar-collapsed .sidebar__item {
  justify-content: center;
  padding: 10px;
}
.app-shell.sidebar-collapsed .sidebar__badge {
  position: absolute;
  top: 4px;
  right: 4px;
  margin-left: 0;
}

/* ── Main Column ────────────────────────────────────────────────────── */
.main-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Topbar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 90;
}

.topbar__menu-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
  transition: all var(--t-fast);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.topbar__menu-btn:hover { background: var(--surface-2); color: var(--text-primary); }

.topbar__search-wrap {
  flex: 1;
  position: relative;
  max-width: 480px;
}

.topbar__search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  pointer-events: none;
}

.topbar__search {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px 7px 34px;
  color: var(--text-primary);
  font-size: 13px;
  transition: all var(--t-fast);
}

.topbar__search::placeholder { color: var(--text-muted); }
.topbar__search:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ── Inputs / Selects / Textareas ───────────────────────────────────── */
.input,
input.input,
select.input,
textarea.input {
  background: var(--surface-2, #1e1e2e);
  border: 1px solid var(--border, #2a2a3a);
  border-radius: var(--radius, 8px);
  color: var(--text-primary, #e2e8f0);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.input::placeholder {
  color: var(--text-muted, #6b7280);
}
.input:focus {
  border-color: var(--accent, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  border: 1px solid var(--border, #2a2a3a);
  white-space: nowrap;
  text-decoration: none;
  background: var(--surface-2, #1e1e2e);
  color: var(--text-primary, #e2e8f0);
}
.btn:hover:not(:disabled) {
  background: var(--surface-3, #252535);
  border-color: var(--border-hover, #3a3a4a);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 4px 12px var(--accent-glow);
  transform: translateY(-1px);
}
.btn--primary:active { transform: translateY(0); }
.btn--primary:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: rgba(255,255,255,.1);
}
.btn--ghost:hover {
  background: rgba(255,255,255,.05);
  color: var(--text);
  border-color: rgba(255,255,255,.18);
}

.btn--secondary {
  background: var(--surface-2);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn--secondary:hover {
  background: var(--surface-3);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn--danger {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  border-color: rgba(239,68,68,0.2);
}
.btn--danger:hover { background: var(--danger); color: #fff; }

.btn--icon {
  padding: 7px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn--icon:hover { background: var(--surface-3); color: var(--text-primary); }

.btn--sm { padding: 4px 10px; font-size: 12px; }

/* ── Main Content ───────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  padding-bottom: 48px;
}

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.card:hover { border-color: var(--border-hover); }

.card--glass {
  background: rgba(17,19,24,0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.card--gradient {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
}

[data-theme="light"] .card--glass {
  background: rgba(255,255,255,0.8);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card__subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── KPI Cards ──────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all var(--t-fast);
}
.kpi-card:hover { border-color: var(--border-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.kpi-card__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.kpi-card__value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}

.kpi-card__sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Score Ring ─────────────────────────────────────────────────────── */
.score-ring-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
}

.score-ring {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}
.score-ring svg { transform: rotate(-90deg); }
.score-ring__bg { stroke: var(--surface-2); }
.score-ring__fill { transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1); }
.score-ring__text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}
.score-ring__sub { font-size: 10px; color: var(--text-muted); }

/* ── Verdict Badge ──────────────────────────────────────────────────── */
.verdict-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.verdict-badge--benign    { background: rgba(16,185,129,0.15); color: var(--verd-benign); }
.verdict-badge--suspicious { background: rgba(245,158,11,0.15); color: var(--verd-suspicious); }
.verdict-badge--high-risk { background: rgba(239,68,68,0.15);  color: var(--verd-highrisk); }
.verdict-badge--malicious { background: rgba(220,38,38,0.2);   color: var(--verd-malicious); border: 1px solid rgba(220,38,38,0.3); }

/* ── Severity Badge ─────────────────────────────────────────────────── */
.sev-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sev-badge--critical { background: rgba(220,38,38,0.2);   color: var(--sev-critical); }
.sev-badge--high     { background: rgba(239,68,68,0.15);  color: var(--sev-high); }
.sev-badge--medium   { background: rgba(245,158,11,0.15); color: var(--sev-medium); }
.sev-badge--low      { background: rgba(59,130,246,0.15); color: var(--sev-low); }
.sev-badge--info     { background: rgba(107,114,128,0.15);color: var(--sev-info); }

/* ── Tables ─────────────────────────────────────────────────────────── */
.data-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 9px 12px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
[data-theme="light"] .data-table tr:nth-child(even) td { background: rgba(0,0,0,0.02); }

.data-table tr:hover td { background: var(--accent-subtle); cursor: pointer; }

.data-table .mono { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: 11px; }

/* ── Findings Table ─────────────────────────────────────────────────── */
.findings-row { cursor: pointer; }
.findings-row:hover td { background: var(--accent-subtle) !important; }

/* ── Tag Chips ──────────────────────────────────────────────────────── */
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid var(--accent-glow);
}

/* ── Right Drawer ───────────────────────────────────────────────────── */
/* Fixed overlay so opening it never resizes/reflows the main column.
 * Sits below the topbar (--topbar-h) and slides in via transform. */
.drawer {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: var(--drawer-w);
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
  transform: translateX(100%);
  transition: transform var(--t-slow);
  z-index: 200;
  min-width: 0;
}

.app-shell.drawer-open .drawer {
  transform: translateX(0);
}

.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: var(--topbar-h);
}

.drawer__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}

/* Close (X) button — sized for an obvious click target with a red hover. */
.drawer__close {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.drawer__close:hover {
  background: var(--surface-3);
  color: var(--danger);
  border-color: var(--border);
}
.drawer__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.drawer__close .icon { width: 20px; height: 20px; }

/* Triage bar at the top of the Summary tab — three color-coded actions. */
.triage-bar {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 4px 0 16px;
}
.triage-bar__label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.triage-bar__status {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: none;
}
.triage-bar__status.is-visible { display: block; }
.triage-bar__actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.triage-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t-fast);
}
.triage-btn:hover { color: var(--text-primary); border-color: var(--border-hover); }
.triage-btn.is-active { color: #fff; border-color: transparent; }
.triage-btn--fp:hover,
.triage-btn--fp.is-active { background: rgba(239,68,68,.18); color: #fca5a5; border-color: rgba(239,68,68,.4); }
.triage-btn--fp.is-active { background: var(--danger); color: #fff; }
.triage-btn--ok:hover,
.triage-btn--ok.is-active { background: rgba(34,197,94,.18); color: #86efac; border-color: rgba(34,197,94,.4); }
.triage-btn--ok.is-active { background: #16a34a; color: #fff; }
.triage-btn--rev:hover,
.triage-btn--rev.is-active { background: rgba(245,158,11,.18); color: #fcd34d; border-color: rgba(245,158,11,.4); }
.triage-btn--rev.is-active { background: #d97706; color: #fff; }

/* Notes & history — card-style list with a composer textarea. */
.notes-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.notes-block__title {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.notes-block__count {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
  min-width: 22px;
  text-align: center;
}

.notes-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; max-height: 240px; overflow-y: auto; }
.notes-empty {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}
.notes-empty__icon { font-size: 20px; line-height: 1; opacity: .8; }
.notes-empty__title { font-weight: 600; color: var(--text-secondary); margin-bottom: 1px; }

.notes-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}
.notes-item--false_positive { border-left-color: var(--danger); }
.notes-item--confirmed      { border-left-color: #16a34a; }
.notes-item--needs_review   { border-left-color: #d97706; }
.notes-item--note           { border-left-color: var(--accent); }
.notes-item__head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.notes-item__type { font-weight: 700; color: var(--text-primary); }
.notes-item__time { color: var(--text-muted); }
.notes-item__del {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.notes-item:hover .notes-item__del,
.notes-item:focus-within .notes-item__del { opacity: 1; }
.notes-item__del:hover { color: var(--danger); background: rgba(239,68,68,.12); }
.notes-item__text {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.notes-composer { display: flex; flex-direction: column; gap: 6px; }
.notes-composer__input {
  width: 100%;
  resize: vertical;
  min-height: 64px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.notes-composer__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.notes-composer__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.notes-composer__hint { font-size: 11px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 5px; }
.notes-composer__hint kbd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-secondary);
}
.notes-composer__send {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
.notes-composer__send:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.notes-composer__send:disabled { opacity: .45; cursor: not-allowed; }
.notes-composer__send svg { width: 13px; height: 13px; }

.drawer__tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  flex-shrink: 0;
  overflow-x: auto;
}

.drawer__tab {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--t-fast);
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.drawer__tab:hover { color: var(--text-secondary); }
.drawer__tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ── Evidence Viewer ────────────────────────────────────────────────── */
.evidence-block {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  font-size: 12px;
}

.evidence-block__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.evidence-block__meta-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}

.evidence-block__snippet {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
  padding: 8px;
  background: var(--surface);
  border-radius: 4px;
  border: 1px solid var(--border);
  position: relative;
}

.evidence-block__copy {
  position: absolute;
  top: 6px;
  right: 6px;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.evidence-block__snippet:hover .evidence-block__copy { opacity: 1; }

.evidence-block__confidence {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Score Breakdown Bar ────────────────────────────────────────────── */
.breakdown-bar {
  display: grid;
  grid-template-columns: 160px 1fr 50px;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.breakdown-bar:last-child { border-bottom: none; }
.breakdown-bar__label { font-size: 12px; color: var(--text-secondary); line-height: 1.3; }
.breakdown-bar__track { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.breakdown-bar__fill { height: 100%; border-radius: 3px; transition: width 0.8s cubic-bezier(0.4,0,0.2,1); }
.breakdown-bar__val { font-size: 12px; color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ── Tabs (inline) ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast);
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Module Sections ────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-count {
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

/* ── Dropzone ───────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-mid);
  position: relative;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.dropzone__icon {
  color: var(--text-muted);
  margin-bottom: 16px;
  display: block;
  margin-left: auto;
  margin-right: auto;
  transition: color var(--t-mid);
}

.dropzone:hover .dropzone__icon { color: var(--accent); }

.dropzone__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.dropzone__sub {
  font-size: 13px;
  color: var(--text-muted);
}

.link { color: var(--accent); cursor: pointer; text-decoration: underline; }

/* ── Upload Queue ───────────────────────────────────────────────────── */
.upload-queue {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upload-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.upload-item__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.upload-item__name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-item__status {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.progress-bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 0.4s ease;
}

.progress-bar__fill--success { background: var(--success); }
.progress-bar__fill--error   { background: var(--danger); }

/* ── Drop Overlay (global drag) ─────────────────────────────────────── */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(91,106,240,0.15);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast);
  border: 3px dashed var(--accent);
}

.drop-overlay.visible { opacity: 1; pointer-events: auto; }

.drop-overlay__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
}

/* ── Modal ──────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn var(--t-fast) ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 540px;
  max-width: calc(100vw - 32px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp var(--t-mid) ease;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal__title { font-size: 15px; font-weight: 700; }

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
.modal__close:hover {
  background: var(--surface-2, rgba(255,255,255,0.06));
  color: var(--text-primary);
}

.modal__body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Toast ──────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  animation: slideInRight 0.2s ease;
  max-width: 340px;
}

.toast--success { border-left: 3px solid var(--success); }
.toast--error   { border-left: 3px solid var(--danger); }
.toast--info    { border-left: 3px solid var(--info); }

/* ── Home View (VirusTotal style) ────────────────────────────────── */

/* Hero */
.vt-hero {
  max-width: 780px;
  margin: 0 auto 2.5rem;
  padding: 2.5rem 1rem 0;
  text-align: center;
}
.vt-hero__brand {
  display: inline-flex;
  align-items: center;
  gap: .9rem;
  margin-bottom: 1.25rem;
  text-align: left;
}
.vt-hero__name {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -.04em;
  line-height: 1;
}
.vt-hero__tagline {
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: .15rem;
}
.vt-hero__desc {
  font-size: .9rem;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 580px;
  margin: 0 auto 1.75rem;
}

/* Drop zone */
.vt-dropzone {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 2.5rem 1.5rem;
  cursor: pointer;
  transition: border-color .2s, background .2s, box-shadow .2s;
  position: relative;
  outline: none;
  margin-bottom: 1rem;
}
.vt-dropzone:hover,
.vt-dropzone:focus {
  border-color: var(--accent);
  background: var(--surface-2);
}
.vt-dropzone--active {
  border-color: #58a6ff;
  background: rgba(31, 111, 235, .08);
  box-shadow: 0 0 0 4px rgba(31, 111, 235, .15);
}
.vt-dropzone--pulse {
  border-color: #58a6ff;
}
.vt-dropzone__idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
}
.vt-dropzone__icon-wrap {
  color: var(--text-muted);
  opacity: .55;
  margin-bottom: .25rem;
}
.vt-dropzone__text {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  justify-content: center;
  font-size: .95rem;
}
.vt-dropzone__cta {
  font-weight: 600;
  color: var(--text-primary);
}
.vt-dropzone__or {
  color: var(--text-muted);
}
.vt-dropzone__browse {
  background: none;
  border: none;
  color: var(--accent);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.vt-dropzone__browse:hover { color: var(--accent-hover, #79c0ff); }
.vt-dropzone__formats {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .15rem;
}
.vt-dropzone__formats code {
  background: var(--surface-3, var(--surface-2));
  padding: .05rem .3rem;
  border-radius: 4px;
  font-size: .72rem;
}
/* ── Upload consent checkbox ─────────────────────────────────────────────── */
.upload-consent {
  max-width: 520px;
  margin: .9rem auto 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
}
.upload-consent__label {
  display: flex;
  align-items: center;
  gap: .55rem;
  cursor: pointer;
  user-select: none;
}
.upload-consent__label:hover .upload-consent__checkmark {
  border-color: rgba(88,166,255,.45);
}
.upload-consent__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.upload-consent__checkmark {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 1.5px solid rgba(255,255,255,.18);
  border-radius: 4px;
  background: rgba(255,255,255,.03);
  position: relative;
  transition: border-color .15s, background .15s;
}
.upload-consent__checkmark::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 1px;
  width: 8px;
  height: 5px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg);
  opacity: 0;
  transition: opacity .12s;
}
.upload-consent__input:checked + .upload-consent__checkmark {
  background: var(--accent, #58a6ff);
  border-color: var(--accent, #58a6ff);
}
.upload-consent__input:checked + .upload-consent__checkmark::after {
  opacity: 1;
}
.upload-consent__text {
  font-size: .8rem;
  color: var(--text-muted, #8b949e);
  line-height: 1.45;
}
.upload-consent__text a {
  color: var(--accent, #58a6ff);
  text-decoration: none;
  opacity: .9;
}
.upload-consent__text a:hover {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.upload-consent__note {
  font-size: .69rem;
  color: rgba(139,148,158,.4);
  margin: 0;
  text-align: center;
  letter-spacing: .01em;
}

/* ── Upload disclaimer ───────────────────────────────────────────────────── */
.upload-disclaimer {
  max-width: 620px;
  margin: .75rem auto 1.75rem;
  padding: .6rem .85rem;
  font-size: .72rem;
  line-height: 1.55;
  color: var(--text-muted);
  text-align: center;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 8px;
}
.upload-disclaimer--modal {
  max-width: 100%;
  margin: .75rem 0 0;
  text-align: left;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border, rgba(255,255,255,.08));
  border-radius: 0;
  padding: .6rem 0 0;
}
.upload-disclaimer__link {
  color: var(--accent, #58a6ff);
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: .85;
}
.upload-disclaimer__link:hover {
  opacity: 1;
}

.vt-dropzone__drag-over {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
}

/* Search row */
.vt-search-row {
  margin-top: .25rem;
  margin-bottom: 1.5rem;
}
.vt-search-wrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 .75rem;
  transition: border-color .2s;
}
.vt-search-wrap:focus-within { border-color: var(--accent); }
.vt-search-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.vt-search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  padding: .65rem .5rem;
  font-size: .88rem;
  color: var(--text-primary);
}
.vt-search-input::placeholder { color: var(--text-muted); }
.vt-search-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: .38rem .85rem;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .15s;
}
.vt-search-btn:hover { opacity: .88; }

/* Stats row */
.vt-stats-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex-wrap: wrap;
  margin-bottom: .5rem;
  padding: .75rem 0 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: .5rem;
}
.vt-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1.75rem;
}
.vt-stat__n {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -.02em;
  line-height: 1;
}
.vt-stat__l {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .3rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.vt-stat-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
}

/* Section headers */
.section-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .85rem;
}
.section-subtitle {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin: 0;
}

/* Recent runs grid (VT-style) */
.vt-recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.vt-skeleton-card {
  height: 120px;
  border-radius: 12px;
}
.vt-run-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.vt-run-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.vt-run-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
}
.vt-run-card__info { flex: 1; min-width: 0; }
.vt-run-card__app {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vt-run-card__pkg {
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: .15rem;
}
.vt-run-card__score-wrap {
  flex-shrink: 0;
}
.vt-run-card__badges {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.vt-run-card__footer {
  display: flex;
  justify-content: space-between;
  font-size: .72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: .4rem;
  margin-top: .1rem;
}

/* Active job cards */
.active-jobs-list {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.active-job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: .75rem;
}
.active-job-card__name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-primary);
  grid-row: 1;
  grid-column: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.active-job-card__stage {
  font-size: .75rem;
  color: var(--text-muted);
  grid-row: 2;
  grid-column: 1;
}
.active-job-card__bar {
  grid-column: 1 / -2;
  grid-row: 3;
  background: var(--surface-2);
  border-radius: 4px;
  height: 4px;
  overflow: hidden;
}
.active-job-card__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width .5s ease;
}
.active-job-card__pct {
  font-size: .72rem;
  color: var(--accent);
  font-weight: 700;
  grid-column: 3;
  grid-row: 1 / 4;
  align-self: center;
}

/* Keep old run-card for backward compat on /runs page */
.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.run-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
  color: inherit;
  display: block;
}
.run-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.run-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.run-card__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.run-card__score {
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}

.run-card__package {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'SF Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 10px;
}

.run-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Runs List ──────────────────────────────────────────────────────── */
.runs-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--t-fast);
}
.filter-chip:hover { border-color: var(--border-hover); color: var(--text-primary); }
.filter-chip.active { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent-glow); }

/* ── Pagination ─────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 4px;
}
.pagination__info {
  font-size: 13px;
  color: var(--text-muted);
}
.pagination__controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pagination__btn,
.pagination__page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--t-fast);
}
.pagination__btn:hover:not(:disabled),
.pagination__page:hover:not(.active) {
  background: var(--surface-3);
  color: var(--text-primary);
  border-color: var(--border-hover);
}
.pagination__btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.pagination__page.active {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent-glow);
  font-weight: 700;
}
.pagination__ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  color: var(--text-muted);
  font-size: 13px;
  user-select: none;
}

/* ── Package Version History Timeline ────────────────────────────────── */
.ph-timeline { display: flex; flex-direction: column; gap: 0; }

.ph-version { display: flex; gap: 14px; }

.ph-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 20px;
  padding-top: 18px;
}
.ph-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--surface-1);
  box-shadow: 0 0 0 2px currentColor;
}
.ph-line {
  width: 2px;
  flex: 1;
  background: var(--border);
  margin: 4px 0;
  min-height: 20px;
}

.ph-card {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: border-color var(--t-fast);
}
.ph-card:hover { border-color: var(--border-hover); }

.ph-version--escalated .ph-card { border-color: var(--sev-critical); background: rgba(239,68,68,.04); }
.ph-version--worsened  .ph-card { border-color: var(--sev-high);     background: rgba(249,115,22,.04); }
.ph-version--improved  .ph-card { border-color: var(--success);      background: rgba(34,197,94,.04); }

.ph-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.ph-version-label { font-weight: 700; font-size: 15px; margin-right: 8px; }
.ph-date { font-size: 12px; }

.ph-diff {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  font-size: 13px;
}
.ph-transition { font-weight: 600; }
.ph-transition--escalated { color: var(--sev-critical); }
.ph-transition--worsened  { color: var(--sev-high); }
.ph-transition--improved  { color: var(--success); }
.ph-transition--stable    { color: var(--text-muted); }

.ph-delta { font-weight: 700; font-size: 14px; }

.ph-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Version Diff View ───────────────────────────────────────────────── */
.diff-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.diff-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.diff-card__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.diff-card__value { line-height: 1; margin-bottom: 4px; }

.diff-section { margin-bottom: 28px; }
.diff-section__title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tag--warn { background: rgba(249,115,22,.15); color: var(--sev-high); border-color: rgba(249,115,22,.3); }

/* ── Threat Intel Feed ──────────────────────────────────────────────── */
.feed-lookup-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.feed-lookup-card__title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}
.feed-lookup-card__desc { font-size: 13px; color: var(--text-muted); }

.feed-stats-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.feed-stat { font-size: 13px; color: var(--text-secondary); }
.feed-stat--critical strong { color: var(--sev-critical); }
.feed-stat--high     strong { color: var(--sev-high); }
.feed-stat--medium   strong { color: var(--sev-medium); }

/* ── App Explorer ───────────────────────────────────────────────────── */
.explore-search-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.explore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.explore-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.explore-card:hover {
  border-color: var(--accent-glow);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
}
.explore-card:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.explore-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.explore-card__avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}
.explore-card__name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
}
.explore-card__pkg {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 100%;
}
.explore-card__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.explore-card__score {
  font-weight: 800;
  font-size: 16px;
}
.explore-card__date {
  font-size: 11px;
}

/* Skeleton shimmer */
.explore-card--skeleton { cursor: default; pointer-events: none; }
.skeleton-box {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Empty State ────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  opacity: 0.4;
}

.empty-state__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state__sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 300px;
  margin: 0 auto 20px;
}

/* ── IOC Panel ──────────────────────────────────────────────────────── */
.ioc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  font-size: 12px;
  transition: all var(--t-fast);
}
.ioc-item:hover { border-color: var(--border-hover); background: var(--surface-2); }
.ioc-item__url {
  flex: 1;
  font-family: 'SF Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.ioc-item__risk { flex-shrink: 0; }
.ioc-item--high { border-left: 2px solid var(--sev-high); }
.ioc-item--medium { border-left: 2px solid var(--sev-medium); }
.ioc-item--low { border-left: 2px solid var(--sev-low); }

/* ── Compare View ───────────────────────────────────────────────────── */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.diff-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.diff-badge--new      { background: rgba(16,185,129,0.15); color: var(--success); }
.diff-badge--resolved { background: rgba(59,130,246,0.15); color: var(--info); }
.diff-badge--changed  { background: rgba(245,158,11,0.15); color: var(--warning); }
.diff-badge--unchanged{ background: var(--surface-3); color: var(--text-muted); }

/* ── Animations ─────────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin { to { transform: rotate(360deg); } }

.animate-pulse { animation: pulse 1.5s ease-in-out infinite; }
.animate-spin  { animation: spin 1s linear infinite; }

/* ── Loading Spinner ────────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner--sm { width: 14px; height: 14px; }
.spinner--lg { width: 32px; height: 32px; border-width: 3px; }

/* ── Skeleton Loader ────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Confidence Bar ─────────────────────────────────────────────────── */
.confidence-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.confidence-bar__track { flex: 1; height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.confidence-bar__fill  { height: 100%; border-radius: 2px; background: var(--accent); }
.confidence-bar__label { color: var(--text-muted); min-width: 32px; text-align: right; }

/* ── Status Dot ─────────────────────────────────────────────────────── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot--running { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.status-dot--done    { background: var(--success); }
.status-dot--failed  { background: var(--danger); }
.status-dot--queued  { background: var(--text-muted); }

/* ── Theme toggle icons ─────────────────────────────────────────────── */
[data-theme="dark"]  .icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: none; }

/* ── Chart containers ───────────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  width: 100%;
}

.chart-tooltip {
  position: fixed;
  background: var(--surface-2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 5000;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  transform: translate(-50%, -110%);
  transition: opacity var(--t-fast);
}

/* ── Run Detail Layout ──────────────────────────────────────────────── */
.run-detail-header {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.run-detail-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-glow) 0%, transparent 60%);
  pointer-events: none;
}

/* ── Run Detail: two-column body (sidebar + content) ────────────────── */
.run-detail-body {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 20px;
  align-items: start;
}
/* Grid items default to min-width:auto, so one wide descendant (a long
 * undecoded string, a many-column table) stretches the 1fr track past the
 * viewport and drags every sibling section with it. */
.run-detail-body > * { min-width: 0; }

/* ── Module Sidebar ─────────────────────────────────────────────────── */
#module-nav {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  max-height: calc(100vh - var(--topbar-h) - 40px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.msb-group { margin-bottom: 2px; }
.msb-group__label {
  padding: 10px 14px 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  user-select: none;
}

.msb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-secondary);
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
  line-height: 1.4;
}
.msb-item:hover { background: var(--surface-2); color: var(--text-primary); }
.msb-item.active { background: var(--accent-subtle); color: var(--accent); font-weight: 600; }
.msb-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.msb-item--alert:not(.active) { color: var(--sev-high); }
.msb-item--alert.active { background: rgba(239,68,68,0.08); color: var(--sev-high); }
.msb-item--alert.active::before { background: var(--sev-high); }

.msb-item__label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msb-item__count {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-weight: 700;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.msb-item--alert .msb-item__count { background: rgba(239,68,68,0.15); color: var(--sev-high); }
.msb-divider { height: 1px; background: var(--border); margin: 4px 10px; }

/* ── Severity bars (overview) ───────────────────────────────────────── */
.sev-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sev-bar:last-child { margin-bottom: 0; }
.sev-bar__label { width: 58px; font-size: 11px; color: var(--text-secondary); text-align: right; font-weight: 600; text-transform: capitalize; }
.sev-bar__track { flex: 1; height: 9px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.sev-bar__fill { height: 100%; border-radius: 5px; transition: width 0.7s cubic-bezier(0.4,0,0.2,1); }
.sev-bar__val { width: 28px; font-size: 12px; font-weight: 700; color: var(--text-primary); text-align: right; }

/* ── OWASP coverage grid ────────────────────────────────────────────── */
.owasp-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.owasp-cell {
  padding: 10px 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  text-align: center;
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  background: var(--surface-2);
}
.owasp-cell:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.owasp-cell__id { font-size: 9.5px; font-weight: 800; letter-spacing: 0.04em; margin-bottom: 4px; color: var(--text-muted); }
.owasp-cell__count { font-size: 20px; font-weight: 800; line-height: 1; margin-bottom: 3px; color: var(--text-muted); }
.owasp-cell__name { font-size: 9px; color: var(--text-muted); line-height: 1.3; }
.owasp-cell--clean { background: rgba(16,185,129,0.06); border-color: rgba(16,185,129,0.25); }
.owasp-cell--clean .owasp-cell__id, .owasp-cell--clean .owasp-cell__count { color: var(--success); }
.owasp-cell--medium { background: rgba(245,158,11,0.06); border-color: rgba(245,158,11,0.25); }
.owasp-cell--medium .owasp-cell__id, .owasp-cell--medium .owasp-cell__count { color: var(--warning); }
.owasp-cell--high { background: rgba(239,68,68,0.07); border-color: rgba(239,68,68,0.25); }
.owasp-cell--high .owasp-cell__id, .owasp-cell--high .owasp-cell__count { color: var(--sev-high); }
.owasp-cell--critical { background: rgba(220,38,38,0.09); border-color: rgba(220,38,38,0.3); }
.owasp-cell--critical .owasp-cell__id, .owasp-cell--critical .owasp-cell__count { color: var(--sev-critical); }

/* ── Intelligence Snapshot grid ─────────────────────────────────────── */
.intel-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.intel-metric {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 14px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
  position: relative;
  overflow: hidden;
}
.intel-metric:hover { border-color: var(--border-hover); background: var(--surface-3); transform: translateY(-1px); }
.intel-metric__icon { font-size: 16px; line-height: 1; margin-bottom: 2px; }
.intel-metric__val {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}
.intel-metric__label { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.intel-metric__sub { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.intel-metric--alert { border-color: rgba(239,68,68,0.3); }
.intel-metric--alert .intel-metric__val { color: var(--sev-high); }
.intel-metric--warn { border-color: rgba(245,158,11,0.3); }
.intel-metric--warn .intel-metric__val { color: var(--warning); }
.intel-metric--ok { border-color: rgba(16,185,129,0.2); }
.intel-metric--ok .intel-metric__val { color: var(--success); }

/* ── Behavioral checklist ───────────────────────────────────────────── */
.behavior-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.behavior-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
}
.behavior-item__icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.behavior-item--ok .behavior-item__icon { background: rgba(16,185,129,0.15); }
.behavior-item--warn .behavior-item__icon { background: rgba(245,158,11,0.12); }
.behavior-item--bad .behavior-item__icon { background: rgba(239,68,68,0.12); }
.behavior-item--info .behavior-item__icon { background: rgba(91,106,240,0.12); }
.behavior-item__label { flex: 1; color: var(--text-secondary); line-height: 1.3; }
.behavior-item__label strong { display: block; color: var(--text-primary); font-weight: 600; margin-bottom: 1px; }

/* ── All Findings filter bar ────────────────────────────────────────── */
.af-filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.af-filter-bar input, .af-filter-bar select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}
.af-filter-bar input:focus, .af-filter-bar select:focus { border-color: var(--accent); }
.af-filter-bar input { width: 200px; }

/* Backward-compat: old module-btn kept for any code still referencing it */
.module-nav { display: none; }
.module-btn { display: none; }

/* ── Utility ────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-4   { margin-top: 16px; }
.mt-6   { margin-top: 24px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 12px; }
.font-mono { font-family: 'SF Mono','Fira Code','Consolas',monospace; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 60px 1fr; }
  /* Above this breakpoint the drawer is overlay too; here we just lift the
   * z-index above the sidebar so it stays usable on narrow viewports. */
  .drawer { z-index: 500; }
  .sidebar__logo-text, .sidebar__item > span:not(.sidebar__badge), .sidebar__version { display: none; }
  .sidebar__logo { justify-content: center; padding: 16px 8px 12px; }
  .sidebar__item { justify-content: center; padding: 10px; }
  .compare-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .intel-grid { grid-template-columns: repeat(2, 1fr); }
  .behavior-grid { grid-template-columns: repeat(2, 1fr); }
  /* Collapse module sidebar to horizontal scroll on small screens. The strip
   * below only scrolls inside itself because .run-detail-body > * sets
   * min-width:0 — without it a nowrap row of tabs widens the whole column. */
  .run-detail-body { grid-template-columns: 1fr; }
  #module-nav {
    position: static;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    border-radius: var(--radius);
    padding: 4px;
  }
  .msb-group { display: flex; flex-direction: row; align-items: center; flex-shrink: 0; }
  .msb-group__label { display: none; }
  .msb-divider { display: none; }
  /* width:auto undoes the base rule's width:100% — as full-width flex items the
   * tabs made the strip ~9500px long, i.e. two dozen swipes to the last one. */
  .msb-item { white-space: nowrap; flex-shrink: 0; border-radius: 20px; padding: 5px 12px; width: auto; }
  .msb-item__label { flex: 0 1 auto; }
  .msb-item.active::before { display: none; }
  .msb-item.active { background: var(--accent-subtle); border-radius: 20px; }
  .owasp-grid { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 600px) {
  .main-content { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .run-detail-header { padding: 16px; }
  .topbar__search-wrap { display: none; }
}

/* ── Spinner animation ──────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Stats Dashboard v2 ─────────────────────────────────────────────── */
.stats-kpi8 {
  grid-template-columns: repeat(8, 1fr);
}
.stats-hero-row {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}
.stats-score-card {
  padding: 28px 32px;
  min-width: 210px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.stats-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.stats-sev-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.stats-dist-row { /* handled inline */ }

/* Legacy kpi row kept for compatibility */
.stats-kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stats-kpi        { padding: 1.2rem 1rem; text-align: center; }
.stats-kpi__value { font-size: 2rem; font-weight: 800; line-height: 1; margin-bottom: .4rem; }
.stats-kpi__label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

@media (max-width: 1100px) {
  .stats-kpi8 { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 900px) {
  .stats-kpi8        { grid-template-columns: repeat(3, 1fr); }
  .stats-kpi-row     { grid-template-columns: repeat(3, 1fr); }
  .stats-hero-row    { grid-template-columns: 1fr 1fr !important; }
  .stats-score-card  { grid-column: 1 / -1; min-width: unset; }
  .stats-sev-grid    { grid-template-columns: repeat(3, 1fr); }
  .stats-rank-row    { grid-template-columns: 1fr !important; }
  .stats-dist-row    { grid-template-columns: 1fr !important; }
}
@media (max-width: 600px) {
  .stats-kpi8        { grid-template-columns: repeat(2, 1fr); }
  .stats-kpi-row     { grid-template-columns: repeat(2, 1fr); }
  .stats-hero-row    { grid-template-columns: 1fr !important; }
  .stats-sev-grid    { grid-template-columns: repeat(2, 1fr); }
}

/* ── Batch upload progress ──────────────────────────────────────────── */
.batch-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  border-radius: 6px;
  background: var(--bg);
  margin-bottom: .4rem;
  font-size: .85rem;
}
.batch-item__name   { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-item__status { font-size: .75rem; font-weight: 600; min-width: 5rem; text-align: right; }
.batch-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: .2rem;
}
.batch-progress-bar__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .4s ease;
}

/* Backdrop is hidden by default; only the mobile media query makes it visible */
.mobile-sidebar-backdrop { display: none; }

/* ── Mobile overlay sidebar (≤ 480 px) ──────────────────────────────── */
@media (max-width: 480px) {
  /* sidebar becomes a full overlay — hidden by default */
  :root { --sidebar-w: 240px; }

  /* Sidebar becomes position:fixed below (out of grid flow), leaving .main-col
   * as the only in-flow grid item. A single 1fr track guarantees it auto-places
   * into a full-width column — with "0px 1fr" it landed in the 0px track and
   * collapsed to 0 width (blank screen on iOS Safari / any ≤480px viewport). */
  .app-shell {
    grid-template-columns: 1fr;
    position: relative;
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform var(--t-slow);
    z-index: 600;
    /* restore text that was hidden at 900px */
  }
  .sidebar__logo-text,
  .sidebar__item > span:not(.sidebar__badge),
  .sidebar__version { display: revert; }
  .sidebar__logo { justify-content: flex-start; padding: 16px; }
  .sidebar__item { justify-content: flex-start; padding: 10px 16px; }

  /* .mobile-sidebar-open class toggled by JS */
  .app-shell.mobile-sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* semi-transparent backdrop */
  .mobile-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 599;
  }
  .app-shell.mobile-sidebar-open .mobile-sidebar-backdrop {
    display: block;
  }

  /* make topbar hamburger visible and bigger */
  .topbar__menu-btn {
    display: flex !important;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
  }

  /* upload dropzone full width */
  .upload-zone { padding: 24px 16px; }
  .upload-zone__icon { width: 48px; height: 48px; }

  /* touch-friendly run list rows */
  .run-row { min-height: 64px; }
  .run-row__actions { gap: 8px; }
  .run-row__actions .btn { padding: 8px 12px; font-size: 12px; }

  /* KPI grid 2 columns on very small screens */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-kpi8 { grid-template-columns: repeat(2, 1fr); }
  .stats-hero-row { grid-template-columns: 1fr; }
  .stats-sev-grid { grid-template-columns: repeat(2, 1fr); }
  /* .owasp-grid is set to 2 columns by the run-detail mobile block below. */

  /* hide topbar search on very small screens */
  .topbar__search-wrap { display: none; }

  /* full-width modals */
  .modal__box { width: 95vw; max-width: 95vw; margin: 0 auto; }
}

/* ── Run detail on phones (responsive level 2) ──────────────────────── */

/* Escape hatch for wide report tables. run-detail.js wraps every table that
 * isn't already inside a .data-table-wrap, so the table scrolls on its own
 * instead of pushing the page sideways. Not scoped to a breakpoint — a narrow
 * desktop window has the same problem. */
.rd-scroll-x {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 600px) {
  /* Hero: stack the three columns. The desktop layout pins the action column
   * right with margin-left:auto and right-aligns the hash — inline styles, so
   * these overrides need !important. */
  .rd-hero { gap: 16px !important; }
  .rd-hero__id { flex-basis: 100%; min-width: 0 !important; }
  .rd-hero__actions {
    width: 100%;
    margin-left: 0 !important;
    align-items: stretch !important;
  }
  .rd-hero__btns { justify-content: flex-start !important; }
  .rd-hero__btns .btn {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 38px;   /* touch target */
  }
  .rd-hero__meta { text-align: left !important; }
  .rd-hero__sha {
    justify-content: flex-start !important;
    white-space: normal !important;
    flex-wrap: wrap;
  }

  /* Section switcher stays reachable while scrolling a long report, instead of
   * scrolling away at the top (it is position:static from the 900px block).
   * top:0, not --topbar-h: the scrollport is .main-content, which already
   * starts below the topbar — offsetting again would leave a 56px dead gap. */
  #module-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    /* First shadow paints a solid band over .main-content's 16px top padding —
     * overflow clips at the padding edge, so without it the report scrolls
     * visibly through the gap above the pinned strip. Box-shadows aren't
     * clipped by this element's own overflow-x:auto, unlike a ::before. */
    box-shadow: 0 -16px 0 var(--bg), var(--shadow-sm);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  #module-nav::-webkit-scrollbar { display: none; }
  .msb-item { min-height: 36px; align-items: center; }

  /* Overview grids: 5- and 4-up don't survive a phone. */
  .owasp-grid    { grid-template-columns: repeat(2, 1fr); }
  .intel-grid    { grid-template-columns: repeat(2, 1fr); }
  .behavior-grid { grid-template-columns: 1fr; }
  .kpi-grid      { grid-template-columns: repeat(2, 1fr); }

  /* Finding drawer: min(760px, 55vw) is a ~200px sliver on a phone. */
  :root { --drawer-w: 100vw; }
  .drawer { border-left: none; }
  .drawer__close { width: 40px; height: 40px; }

  /* Denser tables fit more columns before horizontal scrolling kicks in. */
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 10px; }

  /* Two-up card grids are declared inline as `1fr 1fr`; grid items default to
   * min-width:auto, so on a phone the tracks blow past the card instead of
   * shrinking. Collapsing to one column is the only thing that fits. */
  .rd-grid2 { grid-template-columns: 1fr !important; }
  .rd-grid6 { grid-template-columns: repeat(2, 1fr) !important; }
  /* Same min-width:auto trap one level down: a nowrap chip inside a cell keeps
   * the track from shrinking to the column it was just collapsed into. */
  .rd-grid2 > *, .rd-grid6 > * { min-width: 0; }

  /* Dynamic-analysis CTA: the runner <select> sizes to its longest option
   * ("Mock (canned output, no device required)"), and its <label> wrapper is
   * shrink-to-fit, so max-width:100% resolves against an already-too-wide box.
   * Stacking the row is what actually contains it. */
  #dyn-cta > div { flex-direction: column; align-items: stretch !important; }
  #dyn-cta label { max-width: 100%; min-width: 0; }
  #dyn-cta select, #dyn-cta input { max-width: 100%; min-width: 0; width: 100%; }
  #dyn-status { margin-left: 0 !important; }
}

/* ── Print / PDF Export ─────────────────────────────────────────────── */
@media print {
  /* Hide interactive chrome */
  .sidebar, .topbar, .module-nav, .right-drawer,
  .btn, button, [id="btn-reanalyze"],
  #module-nav, .run-detail-body #module-nav,
  .finding-row .finding-row__actions { display: none !important; }
  .run-detail-body { grid-template-columns: 1fr !important; }

  /* Expand layout to full page */
  body, .app-shell { background: #fff !important; color: #111 !important; }
  .app-shell { grid-template-columns: 1fr !important; grid-template-rows: 1fr !important; }
  .main-content { padding: 24px !important; max-width: 100% !important; }

  /* Cards become print blocks */
  .card {
    border: 1px solid #ddd !important;
    background: #fff !important;
    break-inside: avoid;
    margin-bottom: 16px !important;
  }

  /* Force color scheme for readability */
  :root {
    --text-primary: #111 !important;
    --text-secondary: #333 !important;
    --text-muted: #666 !important;
    --border: #ddd !important;
    --surface: #fff !important;
    --surface-2: #f5f5f5 !important;
    --bg: #fff !important;
  }

  /* Finding rows */
  .finding-row { break-inside: avoid; border-bottom: 1px solid #eee !important; }

  /* Tables */
  table { break-inside: auto; }
  tr { break-inside: avoid; break-after: auto; }

  /* Page setup */
  @page { margin: 20mm; size: A4; }

  /* Show all module content (not just active) */
  #module-content { display: block !important; }

  /* Print links as-is */
  a[href]:after { content: " (" attr(href) ")"; font-size: 10px; color: #666; }
  a[href^="#"]:after, a[href^="javascript:"]:after { content: ""; }
}

/* ── My Analyses — selected rows ── */
.data-table tbody tr.selected { background: rgba(59,130,246,.08); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.clickable:hover { background: var(--hover, rgba(255,255,255,.04)); }
