/* RepoSignal — Shared Design System */
/* P025: Design system foundation. All tokens from DESIGN.md. */
/* Do not add hardcoded hex values anywhere outside :root */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ═══════════════════════════════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════════════════════════════ */
:root {
  /* Core surfaces */
  --bg:       #0D1117;
  --bg-2:     #161B22;
  --bg-3:     #1C2128;
  --bg-4:     #21262D;
  --border:   #30363D;
  --border-2: #21262D;

  /* Text */
  --fg:   #E6EDF3;
  --fg-2: #8B949E;
  --fg-3: #6E7681;
  --fg-4: #484F58;

  /* Accent — teal from logo */
  --teal:      #2DD4BF;
  --teal-2:    #14B8A6;
  --teal-dim:  rgba(45,212,191,0.10);
  --teal-dim-2:rgba(45,212,191,0.20);
  --blue:      #388BFD;
  --blue-2:    #1F6FEB;
  --blue-dim:  rgba(56,139,253,0.10);

  /* Severity */
  --sev-critical:     #F85149;
  --sev-critical-dim: rgba(248,81,73,0.10);
  --sev-high:         #D29922;
  --sev-high-dim:     rgba(210,153,34,0.10);
  --sev-medium:       #E3B341;
  --sev-medium-dim:   rgba(227,179,65,0.10);
  --sev-low:          #3FB950;
  --sev-low-dim:      rgba(63,185,80,0.10);
  --sev-info:         #388BFD;
  --sev-info-dim:     rgba(56,139,253,0.10);

  /* Signal modes */
  --mode-alert:         #3FB950;
  --mode-alert-dim:     rgba(63,185,80,0.12);
  --mode-prioritize:    #388BFD;
  --mode-prioritize-dim:rgba(56,139,253,0.12);
  --mode-context:       #8B949E;
  --mode-context-dim:   rgba(139,148,158,0.12);
  --mode-uncalibrated:  #D29922;
  --mode-uncalibrated-dim:rgba(210,153,34,0.12);

  /* Governance states */
  --gov-pass:      #3FB950;
  --gov-warn:      #D29922;
  --gov-block:     #F85149;
  --gov-escalate:  #D29922;
  --gov-exception: #8B949E;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  /* Type scale */
  --text-xs:   0.72rem;
  --text-sm:   0.82rem;
  --text-base: 0.9rem;
  --text-md:   1rem;
  --text-lg:   1.1rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  2rem;

  /* Font weights */
  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  /* Line heights */
  --leading-tight:  1.25;
  --leading-normal: 1.5;
  --leading-loose:  1.75;

  /* Spacing (4px base) */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);

  /* Specific use colors */
  --color-on-teal: #0D1117;   /* text on teal background — same as --bg, explicitly tracked */
  --color-white:   #FFFFFF;   /* pure white for contrast on colored backgrounds */

  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Layout */
  --sidebar-width:     240px;
  --sidebar-collapsed: 48px;
  --topbar-height:     56px;
  --content-max-width: 1200px;
  --content-padding:   var(--space-6);
}

/* ═══════════════════════════════════════════════════════════════
   BASE RESET
   ═══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: var(--text-base);
  /* Prevent horizontal scroll on mobile */
  overflow-x: hidden;
  max-width: 100vw;
}

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

code, pre, .mono { font-family: var(--mono); }

img { max-width: 100%; display: block; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font); }

h1, h2, h3, h4, h5, h6 { font-weight: var(--weight-semibold); line-height: var(--leading-tight); }

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font);
  height: 32px;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--teal);
  color: var(--color-on-teal);
  border-color: var(--teal);
}
.btn-primary:hover { background: var(--teal-2); border-color: var(--teal-2); }

.btn-secondary {
  background: var(--bg-3);
  color: var(--fg);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-4); border-color: var(--fg-4); }

.btn-danger {
  background: transparent;
  color: var(--sev-critical);
  border-color: var(--sev-critical);
}
.btn-danger:hover { background: var(--sev-critical-dim); }

.btn-ghost {
  background: transparent;
  color: var(--fg-2);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-4); color: var(--fg); }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); height: 26px; }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: var(--text-md); height: 40px; }
.btn-icon { padding: var(--space-2); width: 32px; height: 32px; justify-content: center; }

/* ═══════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.4;
  white-space: nowrap;
}

/* Signal mode badges */
.badge-alert         { background: var(--mode-alert-dim);         color: var(--mode-alert); }
.badge-prioritize    { background: var(--mode-prioritize-dim);    color: var(--mode-prioritize); }
.badge-context       { background: var(--mode-context-dim);       color: var(--mode-context); }
.badge-uncalibrated  { background: var(--mode-uncalibrated-dim);  color: var(--mode-uncalibrated); }

/* Severity badges */
.badge-critical { background: var(--sev-critical-dim); color: var(--sev-critical); }
.badge-high     { background: var(--sev-high-dim);     color: var(--sev-high); }
.badge-medium   { background: var(--sev-medium-dim);   color: var(--sev-medium); }
.badge-low      { background: var(--sev-low-dim);      color: var(--sev-low); }
.badge-info     { background: var(--sev-info-dim);     color: var(--sev-info); }

/* Governance badges */
.badge-gov-pass      { background: rgba(63,185,80,0.10);  color: var(--gov-pass); }
.badge-gov-warn      { background: rgba(210,153,34,0.10); color: var(--gov-warn); }
.badge-gov-block     { background: rgba(248,81,73,0.10);  color: var(--gov-block); }
.badge-gov-escalate  { background: rgba(210,153,34,0.10); color: var(--gov-escalate); }
.badge-gov-exception { background: var(--bg-3);           color: var(--fg-3); }

/* Plan badges */
.badge-plan-free { background: var(--bg-3);    color: var(--fg-3); }
.badge-plan-pro  { background: var(--blue-dim); color: var(--blue); }
.badge-plan-team { background: var(--teal-dim); color: var(--teal); }

/* ═══════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--fg);
  gap: var(--space-3);
}
.card-header-title { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--fg); }
.card-body  { padding: var(--space-4) var(--space-5); }
.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--bg-3);
  font-size: var(--text-sm);
  color: var(--fg-2);
}

/* ═══════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════ */
input, select, textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg);
  font-size: var(--text-base);
  font-family: var(--font);
  transition: border-color var(--transition-fast);
  outline: none;
  line-height: var(--leading-normal);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-dim);
}
input::placeholder, textarea::placeholder { color: var(--fg-3); }
select { cursor: pointer; appearance: none; }

.field       { margin-bottom: var(--space-5); }
.field-label {
  display: block;
  font-size: var(--text-sm);
  color: var(--fg-2);
  margin-bottom: var(--space-1);
  font-weight: var(--weight-medium);
}
.field-hint  { font-size: var(--text-xs); color: var(--fg-3); margin-top: var(--space-1); }
.field-error { font-size: var(--text-xs); color: var(--sev-critical); margin-top: var(--space-1); }

/* ═══════════════════════════════════════════════════════════════
   STATUS INDICATORS
   ═══════════════════════════════════════════════════════════════ */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.status-healthy  { background: var(--sev-low); }
.status-warning  { background: var(--sev-high); }
.status-critical { background: var(--sev-critical); }
.status-neutral  { background: var(--fg-3); }
.status-syncing  { background: var(--sev-medium); animation: pulse-dot 1.5s ease-in-out infinite; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ═══════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════ */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--fg-2);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-2);
  font-size: var(--text-sm);
  color: var(--fg);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--bg-3); transition: background var(--transition-fast); }
.table-clickable tbody tr { cursor: pointer; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ═══════════════════════════════════════════════════════════════
   SKELETON LOADING
   ═══════════════════════════════════════════════════════════════ */
.skeleton {
  background: var(--bg-3);
  border-radius: var(--radius-md);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
.skeleton-text  { height: 14px; margin-bottom: var(--space-2); border-radius: var(--radius-sm); }
.skeleton-title { height: 20px; width: 40%; margin-bottom: var(--space-3); border-radius: var(--radius-sm); }
.skeleton-block { height: 80px; border-radius: var(--radius-md); }
.skeleton-row   { height: 44px; margin-bottom: 1px; border-radius: 0; }

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATES
   ═══════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--fg-2);
}
.empty-state-icon {
  font-size: 2rem;
  margin-bottom: var(--space-4);
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state-icon svg { width: 48px; height: 48px; }
.empty-state h3 {
  font-size: var(--text-lg);
  color: var(--fg);
  margin-bottom: var(--space-2);
  font-weight: var(--weight-semibold);
}
.empty-state p {
  font-size: var(--text-sm);
  max-width: 400px;
  margin: 0 auto var(--space-5);
  line-height: var(--leading-loose);
}

/* ═══════════════════════════════════════════════════════════════
   ERROR STATES
   ═══════════════════════════════════════════════════════════════ */
.error-state {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: var(--sev-critical);
  background: var(--sev-critical-dim);
  border-radius: var(--radius-md);
  border: 1px solid rgba(248,81,73,0.2);
}

/* ═══════════════════════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════════════════════ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  overflow-x: auto;
}
.tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--fg-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover { color: var(--fg); }
.tab.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
  font-weight: var(--weight-semibold);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ═══════════════════════════════════════════════════════════════
   APP SHELL — LAYOUT
   ═══════════════════════════════════════════════════════════════ */
.app-shell { display: flex; min-height: 100vh; background: var(--bg); }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: width var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-logo {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  gap: var(--space-3);
  flex-shrink: 0;
}
.sidebar-logo img { height: 28px; width: auto; flex-shrink: 0; }
.sidebar-logo-text {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--fg);
  white-space: nowrap;
}
.sidebar.collapsed .sidebar-logo-text { display: none; }

/* Nav */
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-2) 0;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  color: var(--fg-2);
  text-decoration: none;
  font-size: var(--text-sm);
  border-left: 2px solid transparent;
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: var(--bg-4); color: var(--fg); text-decoration: none; }
.nav-item.active {
  background: var(--teal-dim);
  color: var(--teal);
  border-left-color: var(--teal);
  font-weight: var(--weight-semibold);
}
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.nav-label { white-space: nowrap; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: var(--space-3) 0; }
.sidebar.collapsed .nav-item.active { border-left-color: var(--teal); }

.nav-divider { height: 1px; background: var(--border-2); margin: var(--space-2) var(--space-5); }
.nav-item-admin { color: var(--fg-3); }
.nav-item-admin:hover { color: var(--sev-critical); }

/* Sidebar bottom */
.sidebar-bottom {
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.org-selector {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  color: var(--fg-2);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast);
  overflow: hidden;
}
.org-selector:hover { background: var(--bg-4); text-decoration: none; }
.org-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar.collapsed .org-name { display: none; }

.user-area {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  color: var(--fg-2);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast);
  overflow: hidden;
}
.user-area:hover { background: var(--bg-4); text-decoration: none; }
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--teal-dim);
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.sidebar.collapsed .user-name { display: none; }

/* App main */
.app-main {
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-base);
  flex: 1;
}
.sidebar.collapsed ~ .app-main { margin-left: var(--sidebar-collapsed); }

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: var(--space-4);
}
.topbar-left  { display: flex; align-items: center; gap: var(--space-3); flex: 1; min-width: 0; }
.topbar-center { flex: 0 1 320px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--fg-2);
  overflow: hidden;
}
.topbar-breadcrumb a { color: var(--fg-2); text-decoration: none; }
.topbar-breadcrumb a:hover { color: var(--fg); }
.topbar-breadcrumb-sep { color: var(--fg-4); }
.topbar-breadcrumb-current { color: var(--fg); font-weight: var(--weight-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.search-bar { position: relative; width: 100%; }
.search-input {
  width: 100%;
  height: 32px;
  padding: 0 var(--space-3);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg);
  font-size: var(--text-sm);
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition-fast);
}
.search-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-dim); }
.search-hint {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-xs);
  color: var(--fg-4);
  pointer-events: none;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 4px;
  line-height: 1.4;
}

.topbar-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-2);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all var(--transition-fast);
  position: relative;
}
.topbar-icon-btn:hover { background: var(--bg-4); color: var(--fg); }

.sync-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--fg-3);
  white-space: nowrap;
}

.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--sev-critical);
  color: var(--color-white);
  font-size: 10px;
  font-weight: var(--weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* Page content */
.content {
  flex: 1;
  padding: var(--content-padding);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

.page-header {
  margin-bottom: var(--space-6);
}
.page-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--fg);
  margin-bottom: var(--space-1);
}
.page-subtitle {
  font-size: var(--text-sm);
  color: var(--fg-2);
}

/* ═══════════════════════════════════════════════════════════════
   ATTENTION ITEMS (dashboard panels)
   ═══════════════════════════════════════════════════════════════ */
.attention-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-2);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-decoration: none;
}
.attention-item:last-child { border-bottom: none; }
.attention-item:hover { background: var(--bg-3); text-decoration: none; }
.attention-item-center { flex: 1; min-width: 0; }
.attention-item-title { font-size: var(--text-sm); color: var(--fg); font-weight: var(--weight-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attention-item-sub   { font-size: var(--text-xs); color: var(--fg-3); font-family: var(--mono); margin-top: 2px; }
.attention-item-right { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════
   RISK STRIP
   ═══════════════════════════════════════════════════════════════ */
.risk-strip {
  display: flex;
  gap: var(--space-8);
  padding: var(--space-4) var(--space-6);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-wrap: nowrap;
}
.risk-metric { display: flex; flex-direction: column; gap: var(--space-1); min-width: 100px; }
.risk-metric-label { font-size: var(--text-xs); color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
.risk-metric-value { font-size: var(--text-xl); font-weight: var(--weight-bold); color: var(--fg); line-height: 1; }
.risk-metric-sub   { font-size: var(--text-xs); color: var(--fg-3); margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════════
   DROPDOWNS & TOOLTIPS
   ═══════════════════════════════════════════════════════════════ */
.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  z-index: 200;
  overflow: hidden;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--fg-2);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}
.dropdown-item:hover { background: var(--bg-3); color: var(--fg); text-decoration: none; }
.dropdown-item-danger:hover { color: var(--sev-critical); }

/* Tooltip trigger */
.tooltip-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  cursor: help;
  border-bottom: 1px dashed var(--fg-4);
}
.tooltip-trigger .tooltip-content {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  width: 280px;
  font-size: var(--text-xs);
  color: var(--fg-2);
  line-height: var(--leading-loose);
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
  z-index: 300;
  box-shadow: var(--shadow-md);
  border-bottom-width: 1px;
  text-align: left;
  white-space: normal;
}
.tooltip-trigger:hover .tooltip-content { visibility: visible; opacity: 1; }

/* ═══════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-5);
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--fg); }
.modal-body { padding: var(--space-5); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--bg-3);
}

/* ═══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  max-width: 360px;
  box-shadow: var(--shadow-md);
  animation: toast-in 200ms ease;
  pointer-events: auto;
}
.toast-success { background: var(--sev-low-dim); color: var(--sev-low); border: 1px solid rgba(63,185,80,0.3); }
.toast-warning { background: var(--sev-high-dim); color: var(--sev-high); border: 1px solid rgba(210,153,34,0.3); }
.toast-error   { background: var(--sev-critical-dim); color: var(--sev-critical); border: 1px solid rgba(248,81,73,0.3); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════════════════════════════════════════════════════════════
   SEARCH RESULTS DROPDOWN
   ═══════════════════════════════════════════════════════════════ */
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 300;
  overflow: hidden;
  max-height: 480px;
  overflow-y: auto;
}
.search-results-section { padding: var(--space-2) 0; }
.search-results-label {
  padding: var(--space-1) var(--space-4);
  font-size: var(--text-xs);
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--weight-semibold);
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-decoration: none;
}
.search-result-item:hover, .search-result-item.selected { background: var(--bg-3); text-decoration: none; }
.search-result-primary { font-size: var(--text-sm); color: var(--fg); }
.search-result-secondary { font-size: var(--text-xs); color: var(--fg-3); }

/* ═══════════════════════════════════════════════════════════════
   REPO HEADER
   ═══════════════════════════════════════════════════════════════ */
.repo-header {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: var(--space-4) var(--space-6);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.repo-header-left { min-width: 0; }
.repo-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--mono);
}
.repo-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--fg-3);
  flex-wrap: wrap;
}
.repo-header-actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════════════
   FINDING ROWS
   ═══════════════════════════════════════════════════════════════ */
.finding-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-2);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.finding-row:last-child { border-bottom: none; }
.finding-row:hover { background: var(--bg-3); }
.finding-row-center { flex: 1; min-width: 0; }
.finding-title { font-size: var(--text-sm); color: var(--fg); font-weight: var(--weight-medium); }
.finding-path  { font-size: var(--text-xs); color: var(--fg-3); font-family: var(--mono); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finding-row-right { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════
   PR CARDS
   ═══════════════════════════════════════════════════════════════ */
.pr-card {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-2);
  transition: background var(--transition-fast);
}
.pr-card:last-child { border-bottom: none; }
.pr-card:hover { background: var(--bg-3); }
.pr-card-top { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
.pr-card-title { font-size: var(--text-sm); color: var(--fg); font-weight: var(--weight-medium); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-card-meta { font-size: var(--text-xs); color: var(--fg-3); font-family: var(--mono); }
.pr-card-narrative { font-size: var(--text-xs); color: var(--fg-2); font-style: italic; line-height: var(--leading-loose); margin-top: var(--space-2); }
.pr-card-actions { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }

/* ═══════════════════════════════════════════════════════════════
   GOVERNANCE PANEL
   ═══════════════════════════════════════════════════════════════ */
.gov-state-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-weight: var(--weight-semibold);
}
.gov-state-pass     { background: var(--sev-low-dim);      color: var(--sev-low);      border: 1px solid rgba(63,185,80,0.2); }
.gov-state-warn     { background: var(--sev-high-dim);     color: var(--sev-high);     border: 1px solid rgba(210,153,34,0.2); }
.gov-state-block    { background: var(--sev-critical-dim); color: var(--sev-critical); border: 1px solid rgba(248,81,73,0.2); }
.gov-state-escalate { background: var(--sev-high-dim);     color: var(--sev-high);     border: 1px solid rgba(210,153,34,0.2); }
.gov-state-exception{ background: var(--bg-3);             color: var(--fg-2);         border: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════ */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono     { font-family: var(--mono); font-size: var(--text-sm); }
.sr-only  { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.divider  { height: 1px; background: var(--border); margin: var(--space-4) 0; }

.text-xs    { font-size: var(--text-xs); }
.text-sm    { font-size: var(--text-sm); }
.text-base  { font-size: var(--text-base); }
.text-md    { font-size: var(--text-md); }
.text-lg    { font-size: var(--text-lg); }
.text-xl    { font-size: var(--text-xl); }
.text-2xl   { font-size: var(--text-2xl); }

.text-muted    { color: var(--fg-2); }
.text-faint    { color: var(--fg-3); }
.text-teal     { color: var(--teal); }
.text-critical { color: var(--sev-critical); }
.text-high     { color: var(--sev-high); }
.text-low      { color: var(--sev-low); }

.fw-medium   { font-weight: var(--weight-medium); }
.fw-semibold { font-weight: var(--weight-semibold); }
.fw-bold     { font-weight: var(--weight-bold); }

.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2       { gap: var(--space-2); }
.gap-3       { gap: var(--space-3); }
.gap-4       { gap: var(--space-4); }
.gap-6       { gap: var(--space-6); }
.flex-1      { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.p-4  { padding: var(--space-4); }
.p-5  { padding: var(--space-5); }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

/* ═══════════════════════════════════════════════════════════════
   PUBLIC PAGE LAYOUT (auth pages, landing)
   ═══════════════════════════════════════════════════════════════ */
.public-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-content: center;
  margin-bottom: var(--space-8);
  text-decoration: none;
}
.auth-logo img { height: 36px; }
.auth-logo-text { font-size: var(--text-xl); font-weight: var(--weight-bold); color: var(--fg); }
.auth-title { font-size: var(--text-xl); font-weight: var(--weight-bold); color: var(--fg); text-align: center; margin-bottom: var(--space-2); }
.auth-subtitle { font-size: var(--text-sm); color: var(--fg-2); text-align: center; margin-bottom: var(--space-6); }
.auth-links { margin-top: var(--space-5); text-align: center; font-size: var(--text-sm); color: var(--fg-2); }
.auth-links a { color: var(--teal); }

/* ═══════════════════════════════════════════════════════════════
   HAMBURGER (mobile)
   ═══════════════════════════════════════════════════════════════ */
.hamburger-btn { display: none; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar .nav-label,
  .sidebar .sidebar-logo-text,
  .sidebar .org-name,
  .sidebar .user-name { display: none; }
  .sidebar .nav-item { justify-content: center; padding: var(--space-3) 0; }
  .app-main { margin-left: var(--sidebar-collapsed); }
  .topbar-center { flex: 0 0 200px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .risk-strip { gap: var(--space-5); }
}

@media (max-width: 768px) {
  .topbar-center { display: none; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    z-index: 200;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar.mobile-open .nav-label,
  .sidebar.mobile-open .sidebar-logo-text,
  .sidebar.mobile-open .org-name,
  .sidebar.mobile-open .user-name { display: block; }
  .sidebar.mobile-open .nav-item { justify-content: flex-start; padding: var(--space-2) var(--space-5); }
  .app-main { margin-left: 0; }
  .hamburger-btn { display: flex; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .content { padding: var(--space-4); }
  .repo-header { flex-direction: column; }
  .modal { max-width: 100%; margin: var(--space-4); border-radius: var(--radius-lg); }

  /* Prevent any element from forcing horizontal scroll */
  .app-main, .content, .card, .table-wrapper { max-width: 100vw; }

  /* All tables scroll horizontally rather than blowing out the layout */
  .table { min-width: 500px; }
  .table-wrapper, .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: calc(100vw - var(--space-8)); }

  /* Cards stack cleanly */
  .card { overflow: hidden; }

  /* Risk strip wraps on small screens */
  .risk-strip { flex-wrap: wrap; gap: var(--space-3); }
  .risk-metric { min-width: 120px; flex: 1; }

  /* Page headers stack */
  .page-header { flex-direction: column; align-items: flex-start; gap: var(--space-3); }

  /* Flex rows that would overflow wrap instead */
  .flex { flex-wrap: wrap; }

  /* Inputs never cause zoom on iOS (must be 16px+) */
  input, select, textarea { font-size: 16px !important; }

  /* Mobile sidebar overlay */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
    display: none;
  }
  .sidebar-overlay.active { display: block; }
}
