/* ── CSS Custom Properties ──────────────────────────────── */
:root {
  --bg-primary:     #ffffff;
  --bg-secondary:   #f8fafc;
  --bg-card:        #ffffff;
  --bg-sidebar:     #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-input:       #ffffff;

  --text-primary:   #0f172a;
  --text-secondary: #64748b;
  --text-muted:     #94a3b8;
  --text-sidebar:   #94a3b8;
  --text-sidebar-active: #ffffff;

  --border-color:   #e2e8f0;
  --border-input:   #cbd5e1;

  --accent:         #6366f1;
  --accent-light:   #eef2ff;
  --accent-hover:   #4f46e5;

  --success:        #22c55e;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #06b6d4;

  --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);

  --radius:     .75rem;
  --radius-sm:  .5rem;
  --sidebar-w:  260px;
  --topbar-h:   64px;
  --transition: .2s ease;
}

[data-theme="dark"] {
  --bg-primary:     #0f172a;
  --bg-secondary:   #0b1120;
  --bg-card:        #1e293b;
  --bg-sidebar:     #080f1d;
  --bg-sidebar-hover: #1e293b;
  --bg-input:       #1e293b;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-sidebar:   #94a3b8;

  --border-color:   #1e293b;
  --border-input:   #334155;

  --accent-light:   #1e1b4b;
  --shadow-sm:  0 1px 2px rgba(0,0,0,.3);
  --shadow:     0 4px 6px -1px rgba(0,0,0,.4);
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-brand {
  padding: 1.5rem 1.5rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-decoration: none;
}
.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: .5rem;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.1rem; flex-shrink: 0;
}
.sidebar-brand-text {
  color: white;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.2;
}
.sidebar-brand-sub {
  color: var(--text-muted);
  font-size: .7rem;
  font-weight: 400;
}

.sidebar-section { padding: 1.25rem 1rem .5rem; }
.sidebar-label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 0 .5rem;
  margin-bottom: .5rem;
}
.nav-item { list-style: none; }
.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--bg-sidebar-hover); color: #e2e8f0; }
.nav-link.active { background: var(--accent); color: white; }
.nav-link.active .nav-icon { color: white; }
.nav-icon { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: .65rem;
  padding: .15rem .45rem;
  border-radius: 9999px;
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background var(--transition);
}
.sidebar-user:hover { background: var(--bg-sidebar-hover); }
.sidebar-avatar {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: .8rem; font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  color: #e2e8f0;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  color: var(--text-muted);
  font-size: .7rem;
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky; top: 0; z-index: 90;
}
.topbar-left { flex: 1; display: flex; align-items: center; gap: 1rem; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }

.company-switcher select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: .4rem .75rem;
  font-size: .85rem;
  cursor: pointer;
}

.page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Icon Buttons ─────────────────────────────────────────── */
.icon-btn {
  width: 36px; height: 36px;
  border: none; border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  font-size: .9rem;
}
.icon-btn:hover { background: var(--bg-secondary); color: var(--text-primary); }

/* ── Page Body ──────────────────────────────────────────── */
.page-body { padding: 1.75rem; flex: 1; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex; align-items: center; gap: .5rem;
}
.card-body { 
  padding: 1.5rem;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  overflow-x: hidden;
}
.card-body p,
.card-body div {
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}
.card-footer {
  padding: .875rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

/* ── Text Wrapping Utility ──────────────────────────────────── */
.text-wrap {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}
.text-wrap-normal {
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

/* ── Alert Boxes (Gap & Remediation) ─────────────────────────── */
/* Force dark text on light backgrounds even in dark mode */
.alert-danger {
  padding: .75rem;
  background: #fef2f2;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--danger);
  margin-bottom: 1rem;
  color: #0f172a;  /* Always dark text */
}
.alert-danger .alert-title {
  font-size: .75rem;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .025em;
}
.alert-danger p {
  font-size: .875rem;
  color: #0f172a;  /* Always dark text */
  line-height: 1.6;
}

.alert-warning {
  padding: .75rem;
  background: #fffbeb;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--warning);
  color: #0f172a;  /* Always dark text */
}
.alert-warning .alert-title {
  font-size: .75rem;
  font-weight: 700;
  color: var(--warning);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .025em;
}
.alert-warning p {
  font-size: .875rem;
  color: #0f172a;  /* Always dark text */
  line-height: 1.6;
}

/* Dark mode: adjust backgrounds to be slightly darker but still distinct */
[data-theme="dark"] .alert-danger {
  background: #3f1a1a;  /* Darker red */
  color: #fecaca;       /* Light red text */
  border-left-color: #dc2626;
}
[data-theme="dark"] .alert-danger .alert-title {
  color: #fca5a5;
}
[data-theme="dark"] .alert-danger p {
  color: #fecaca;
}

[data-theme="dark"] .alert-warning {
  background: #3f2d0a;  /* Darker yellow */
  color: #fde68a;       /* Light yellow text */
  border-left-color: #f59e0b;
}
[data-theme="dark"] .alert-warning .alert-title {
  color: #fcd34d;
}
[data-theme="dark"] .alert-warning p {
  color: #fde68a;
}


/* ── Stat Cards ──────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex; align-items: flex-start; gap: 1rem;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.stat-icon.indigo  { background: var(--accent-light); color: var(--accent); }
.stat-icon.green   { background: #f0fdf4; color: var(--success); }
.stat-icon.yellow  { background: #fffbeb; color: var(--warning); }
.stat-icon.red     { background: #fef2f2; color: var(--danger); }
.stat-icon.cyan    { background: #ecfeff; color: var(--info); }
[data-theme="dark"] .stat-icon.green  { background: #052e16; }
[data-theme="dark"] .stat-icon.yellow { background: #1c1400; }
[data-theme="dark"] .stat-icon.red    { background: #1e0606; }
[data-theme="dark"] .stat-icon.cyan   { background: #06202a; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-secondary); margin-top: .25rem; }
.stat-delta { font-size: .75rem; margin-top: .25rem; }
.stat-delta.up    { color: var(--success); }
.stat-delta.down  { color: var(--danger); }

/* ── Progress Ring ──────────────────────────────────────── */
.progress-ring { transform: rotate(-90deg); }
.progress-ring-track { fill: none; stroke: var(--border-color); stroke-width: 8; }
.progress-ring-fill  { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }

/* ── Framework Card ─────────────────────────────────────── */
.fw-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color var(--transition);
}
.fw-card:hover { border-color: var(--accent); }
.fw-progress-wrap { position: relative; flex-shrink: 0; }
.fw-progress-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700;
  color: var(--text-primary);
}
.fw-info { flex: 1; min-width: 0; }
.fw-name {
  font-size: .85rem; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fw-sub { font-size: .75rem; color: var(--text-secondary); margin-top: .2rem; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%; border-collapse: collapse;
  font-size: .855rem;
}
.data-table th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.data-table td {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-secondary); }
.data-table tr { transition: background var(--transition); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 9999px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #a16207; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-primary { background: var(--accent-light); color: var(--accent); }
.badge-secondary { background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--border-color); }
.badge-info    { background: #cffafe; color: #0e7490; }
[data-theme="dark"] .badge-success { background: #052e16; color: #4ade80; }
[data-theme="dark"] .badge-warning { background: #1c1400; color: #fbbf24; }
[data-theme="dark"] .badge-danger  { background: #1e0606; color: #f87171; }
[data-theme="dark"] .badge-info    { background: #06202a; color: #22d3ee; }
[data-theme="dark"] .badge-secondary { background: #1e293b; color: #94a3b8; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: white; }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border-color); }
.btn-ghost:hover { background: var(--bg-secondary); color: var(--text-primary); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; color: white; }
.btn-success { background: var(--success); color: white; border-color: var(--success); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: .45rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-control, .form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: .55rem .85rem;
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ── Alerts & Flashes ────────────────────────────────────── */
.alerts-container { margin-bottom: 1rem; }
.alert {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .875rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  border: 1px solid transparent;
  margin-bottom: .5rem;
  animation: slideIn .2s ease;
}
@keyframes slideIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
[data-theme="dark"] .alert-success { background: #052e16; border-color: #14532d; color: #4ade80; }
[data-theme="dark"] .alert-danger  { background: #1e0606; border-color: #7f1d1d; color: #f87171; }
[data-theme="dark"] .alert-info    { background: #172554; border-color: #1e3a8a; color: #93c5fd; }
[data-theme="dark"] .alert-warning { background: #1c1400; border-color: #713f12; color: #fbbf24; }
.alert-close { margin-left: auto; cursor: pointer; opacity: .6; background: none; border: none; color: inherit; font-size: 1.1rem; }
.alert-close:hover { opacity: 1; }

/* ── Status Dots ─────────────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot-implemented { background: var(--success); }
.status-dot-partial     { background: var(--warning); }
.status-dot-gap         { background: var(--danger); }
.status-dot-in_progress { background: var(--accent); }
.status-dot-not_started { background: var(--text-muted); }
.status-dot-not_applicable { background: var(--info); }

/* ── CMM Level Bars ─────────────────────────────────────── */
.cmm-bar { display: flex; gap: 3px; }
.cmm-seg {
  height: 6px; flex: 1;
  border-radius: 2px;
  background: var(--border-color);
  transition: background var(--transition);
}
.cmm-seg.active { background: var(--accent); }

/* ── Login Page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login-hero {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #0f172a 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 3rem; color: white; position: relative; overflow: hidden;
}
.login-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%239C92AC' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-hero-content { position: relative; text-align: center; }
.login-hero-icon {
  width: 72px; height: 72px;
  background: rgba(99,102,241,.3);
  border: 2px solid rgba(99,102,241,.5);
  border-radius: 1rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; margin: 0 auto 1.5rem;
}
.login-hero h1 { font-size: 2rem; font-weight: 800; margin-bottom: .75rem; }
.login-hero p { opacity: .7; max-width: 320px; line-height: 1.6; }
.login-features { margin-top: 2.5rem; display: flex; flex-direction: column; gap: .75rem; }
.login-feature {
  display: flex; align-items: center; gap: .75rem;
  background: rgba(255,255,255,.07);
  padding: .75rem 1rem; border-radius: .5rem;
  font-size: .875rem;
}
.login-form-panel {
  display: flex; align-items: center; justify-content: center;
  padding: 3rem; background: var(--bg-primary);
}
.login-form-box { width: 100%; max-width: 380px; }
.login-form-box h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: .5rem; }
.login-form-box p { color: var(--text-secondary); margin-bottom: 2rem; font-size: .9rem; }

/* ── Tabs ────────────────────────────────────────────────── */
.tab-nav {
  display: flex; border-bottom: 2px solid var(--border-color);
  margin-bottom: 1.5rem; gap: .25rem;
}
.tab-btn {
  padding: .65rem 1rem;
  font-size: .875rem; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer; border: none; background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  display: flex; align-items: center; gap: .4rem;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover { color: var(--text-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Control Detail ──────────────────────────────────────── */
.control-header {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.control-number {
  font-size: .75rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .35rem;
}
.control-name { font-size: 1.25rem; font-weight: 700; margin-bottom: .75rem; }
.control-meta { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ── Framework mapping pills ─────────────────────────────── */
.fw-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .75rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 9999px;
  font-size: .75rem; font-weight: 600;
  white-space: nowrap;
}

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

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .login-hero { display: none; }
  .login-page { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main-content { margin-left: 0; }
}

/* ── Misc Utilities ──────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-accent { color: var(--accent); }
.fw-bold { font-weight: 700; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-full { width: 100%; }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.section-title { font-size: 1rem; font-weight: 700; }
.divider { border: none; border-top: 1px solid var(--border-color); margin: 1.25rem 0; }

/* ── Overlay/Modal ───────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex; justify-content: flex-end; gap: .5rem;
}

/* ── Framework selector ──────────────────────────────────── */
.fw-selector { max-height: 400px; overflow-y: auto; }
.fw-selector-group-title {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted);
  padding: .75rem 0 .35rem;
  position: sticky; top: 0; background: var(--bg-card);
}
.fw-check-item {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .5rem .25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.fw-check-item:hover { background: var(--bg-secondary); }
.fw-check-item input[type=checkbox] { margin-top: 2px; accent-color: var(--accent); }
.fw-check-name { font-size: .85rem; font-weight: 500; }
.fw-check-sub  { font-size: .75rem; color: var(--text-secondary); }
.fw-search {
  position: sticky; top: 0;
  background: var(--bg-card);
  padding-bottom: .5rem;
  z-index: 1;
}

/* Chart containers */
.chart-container { position: relative; }

/* Pagination */
.pagination { display: flex; gap: .25rem; align-items: center; }
.page-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; cursor: pointer;
  text-decoration: none; transition: all var(--transition);
}
.page-btn:hover, .page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.page-btn.disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* ── Notification Bell & Dropdown ─────────────────────────── */
.notification-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--danger);
  color: white;
  font-size: .6rem;
  font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 9999px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  line-height: 1;
  pointer-events: none;
  animation: badgePulse 2s infinite;
}
@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
.notification-dropdown {
  position: absolute;
  top: calc(100% + 8px); right: 0;
  width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}
.notif-dropdown-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-secondary);
}
.notif-dropdown-body {
  max-height: 400px;
  overflow-y: auto;
}
.notif-dropdown-footer {
  padding: .5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}
.notif-item {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex; gap: .75rem; align-items: flex-start;
  cursor: pointer;
  transition: background var(--transition);
}
.notif-item:hover { background: var(--bg-secondary); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--accent-light); }
.notif-item.unread:hover { background: #e0e7ff; }
[data-theme="dark"] .notif-item.unread { background: rgba(99,102,241,.1); }
[data-theme="dark"] .notif-item.unread:hover { background: rgba(99,102,241,.15); }
.notif-item-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 2px; }
.notif-item-content { flex: 1; min-width: 0; }
.notif-item-title { font-size: .82rem; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.notif-item-msg { font-size: .75rem; color: var(--text-secondary); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-item-time { font-size: .65rem; color: var(--text-muted); margin-top: 4px; }

/* Notification list page */
.notif-list-item.notif-unread { background: var(--accent-light); }
[data-theme="dark"] .notif-list-item.notif-unread { background: rgba(99,102,241,.08); }

