/* ═══════════════════════════════════════════════════════════
   NISTGRC.COM — Shared Design System
   UI/UX Pro Max: AI-Native Dark · GRC SaaS
   Fonts: Inter + JetBrains Mono (Google Fonts)
   ═══════════════════════════════════════════════════════════ */

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

/* ── Token System ── */
:root {
  /* Dark theme (default) */
  --bg:        #0d0f14;
  --surface:   #13161e;
  --surface2:  #1a1d27;
  --surface3:  #21253a;
  --border:    #2a2f45;
  --border2:   #3a4060;
  --text:      #e2e8f8;
  --text2:     #94a3c4;
  --text3:     #5a6585;

  --accent:        #3b82f6;
  --accent-hover:  #60a5fa;
  --accent-dim:    rgba(59,130,246,0.10);
  --accent-glow:   rgba(59,130,246,0.06);

  --green:     #10b981;
  --green-dim: rgba(16,185,129,0.10);
  --yellow:    #f59e0b;
  --yellow-dim:rgba(245,158,11,0.10);
  --orange:    #f97316;
  --orange-dim:rgba(249,115,22,0.10);
  --red:       #ef4444;
  --red-dim:   rgba(239,68,68,0.10);
  --purple:    #8b5cf6;
  --purple-dim:rgba(139,92,246,0.10);
  --blue:      #3b82f6;
  --blue-dim:  rgba(59,130,246,0.10);

  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow:    0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.7);

  --transition: 200ms ease-out;
}

[data-theme='light'] {
  --bg:        #f8faff;
  --surface:   #ffffff;
  --surface2:  #f1f5fb;
  --surface3:  #e4eaf5;
  --border:    #dde3f0;
  --border2:   #c4cde0;
  --text:      #111827;
  --text2:     #374151;
  --text3:     #6b7280;

  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-dim:    rgba(37,99,235,0.08);
  --accent-glow:   rgba(37,99,235,0.04);

  --green:     #059669;
  --green-dim: rgba(5,150,105,0.08);
  --yellow:    #d97706;
  --yellow-dim:rgba(217,119,6,0.08);
  --orange:    #ea580c;
  --orange-dim:rgba(234,88,12,0.08);
  --red:       #dc2626;
  --red-dim:   rgba(220,38,38,0.08);
  --purple:    #7c3aed;
  --purple-dim:rgba(124,58,237,0.08);
  --blue:      #2563eb;
  --blue-dim:  rgba(37,99,235,0.08);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow:    0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.15);
}

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

html { background: var(--bg); scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

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

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ══════════════════════════════════════════════
   TOPBAR / NAV
   ══════════════════════════════════════════════ */
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
  backdrop-filter: blur(12px);
}

.topbar-nav {
  height: 60px;
  background: rgba(13,15,20,0.85);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 8px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

[data-theme='light'] .topbar-nav {
  background: rgba(248,250,255,0.90);
}

/* Logo */
.nistgrc-logo {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
  transition: opacity var(--transition);
  flex-shrink: 0;
}
.nistgrc-logo:hover { opacity: 0.8; }

.logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { color: #fff; width: 18px; height: 18px; }

.nistgrc-text {
  font-size: 17px; font-weight: 700;
  color: var(--text); display: flex; align-items: center;
  letter-spacing: -0.3px;
}
.nistgrc-text .grc { color: inherit; }
.nistgrc-text .dot { color: var(--accent); font-size: 20px; line-height: 0; margin-left: 1px; }

/* Nav links */
.nav-links { display: flex; align-items: center; gap: 2px; margin-left: 12px; }

.nav-link {
  text-decoration: none; color: var(--text3);
  font-size: 13px; font-weight: 500;
  padding: 6px 12px; border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }

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

/* ══════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 16px; height: 36px;
  border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; white-space: nowrap;
  transition: all var(--transition);
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }

.btn-accent {
  background: var(--accent); color: #fff;
  box-shadow: 0 0 0 0 rgba(59,130,246,0);
}
.btn-accent:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 16px rgba(59,130,246,0.3);
}

.btn-ghost {
  background: transparent; color: var(--text2);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }

.btn-surface {
  background: var(--surface2); color: var(--text2);
  border: 1px solid var(--border);
}
.btn-surface:hover { background: var(--surface3); color: var(--text); }

.btn-danger {
  background: var(--red-dim); color: var(--red);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-green {
  background: var(--green-dim); color: var(--green);
  border: 1px solid rgba(16,185,129,0.3);
}
.btn-green:hover { background: rgba(16,185,129,0.2); }

.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 24px; font-size: 15px; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; }
.btn-icon.btn-sm { width: 30px; height: 30px; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ══════════════════════════════════════════════
   CHIPS / BADGES / TAGS
   ══════════════════════════════════════════════ */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-family: var(--mono); font-weight: 600;
  letter-spacing: 0.5px; cursor: pointer;
  border: 1px solid var(--border2); color: var(--text3);
  background: transparent;
  transition: all 0.12s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--text2); color: var(--text2); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-family: var(--mono); font-weight: 600;
  letter-spacing: 0.4px; white-space: nowrap;
}
.tag-green  { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(16,185,129,0.25); }
.tag-blue   { background: var(--blue-dim);   color: var(--blue);   border: 1px solid rgba(59,130,246,0.25); }
.tag-red    { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(239,68,68,0.25); }
.tag-yellow { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(245,158,11,0.25); }
.tag-orange { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(249,115,22,0.25); }
.tag-purple { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(139,92,246,0.25); }
.tag-surface{ background: var(--surface2);   color: var(--text3);  border: 1px solid var(--border); }

/* Status pills */
.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-family: var(--mono); font-weight: 600;
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}

/* Severity badges */
.sev-badge {
  padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-family: var(--mono); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.sev-critical { background: var(--red-dim);    color: var(--red);    }
.sev-high     { background: var(--orange-dim); color: var(--orange); }
.sev-medium   { background: var(--yellow-dim); color: var(--yellow); }
.sev-low      { background: var(--green-dim);  color: var(--green);  }
.sev-none     { background: var(--surface2);   color: var(--text3);  }

/* ══════════════════════════════════════════════
   CARDS / SURFACES
   ══════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: var(--border2); box-shadow: var(--shadow); }

.card-glass {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}
[data-theme='light'] .card-glass { background: rgba(255,255,255,0.7); }

/* Stat card */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.stat-val {
  font-size: 28px; font-weight: 800;
  font-family: var(--mono); line-height: 1;
  margin-bottom: 4px;
}
.stat-lbl {
  font-size: 11px; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.06em;
  font-family: var(--mono);
}

/* ══════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 5px; }

.field-label {
  font-size: 11px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.06em;
  font-family: var(--mono);
}

.field-input, .field-select, .field-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--sans); font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}
.field-input:focus,
.field-select:focus,
.field-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }

.field-input::placeholder,
.field-textarea::placeholder { color: var(--text3); }

.field-select { cursor: pointer; appearance: none; }
.field-textarea { resize: vertical; min-height: 80px; line-height: 1.6; }

.field-error { font-size: 12px; color: var(--red); min-height: 16px; }

/* Password toggle */
.field-wrap { position: relative; }
.field-wrap .field-input { padding-right: 40px; }
.field-eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text3); cursor: pointer; padding: 4px;
  transition: color var(--transition);
}
.field-eye:hover { color: var(--text2); }

/* ══════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%; max-width: 420px; margin: 20px;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.25s ease;
}
.modal-overlay.open .modal-box { transform: translateY(0) scale(1); }

.modal-title { font-size: 20px; font-weight: 800; margin-bottom: 6px; letter-spacing: -0.3px; }
.modal-sub { font-size: 13px; color: var(--text2); margin-bottom: 24px; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; color: var(--text3);
  font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 4px;
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--surface2); }
.modal-form { display: flex; flex-direction: column; gap: 16px; }
.modal-footer { margin-top: 12px; text-align: center; font-size: 12px; color: var(--text3); }
.modal-link {
  color: var(--accent); cursor: pointer; background: none; border: none;
  font-family: var(--sans); font-size: 12px;
}
.modal-link:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════
   SPINNER / LOADING
   ══════════════════════════════════════════════ */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle; flex-shrink: 0;
}
.spinner-sm { width: 14px; height: 14px; }
.spinner-lg { width: 28px; height: 28px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 80px 24px;
  color: var(--text3); font-family: var(--mono); font-size: 13px;
}

/* ══════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════ */
.empty-state {
  text-align: center; padding: 80px 40px;
  background: var(--surface);
  border: 1px dashed var(--border2);
  border-radius: var(--radius-lg);
  max-width: 480px; margin: 0 auto;
}
.empty-icon {
  width: 64px; height: 64px; margin: 0 auto 20px;
  background: var(--surface2); border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
}
.empty-icon svg { color: var(--text3); width: 32px; height: 32px; }
.empty-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.empty-desc { color: var(--text2); font-size: 14px; margin-bottom: 24px; line-height: 1.6; }

/* ══════════════════════════════════════════════
   PAGE LAYOUT
   ══════════════════════════════════════════════ */
.page { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.page-wide { max-width: 1400px; margin: 0 auto; padding: 24px; }

.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 32px;
}
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.page-sub { color: var(--text2); font-size: 13px; margin-top: 4px; }

/* Section */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px; margin-bottom: 20px;
}
.section-title {
  font-size: 16px; font-weight: 700; margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.section-desc { color: var(--text2); font-size: 13px; margin-bottom: 20px; }

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════
   TOPBAR STAT CHIPS
   ══════════════════════════════════════════════ */
.tstat {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px;
  font-size: 11px; font-family: var(--mono); white-space: nowrap;
  color: var(--text2);
}
.tstat-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ══════════════════════════════════════════════
   USER AVATAR
   ══════════════════════════════════════════════ */
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.user-badge { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2); }

/* ══════════════════════════════════════════════
   THEME TOGGLE
   ══════════════════════════════════════════════ */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm); border: 1px solid var(--border2);
  background: var(--surface2); color: var(--text3);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition);
}
.theme-toggle:hover { background: var(--surface3); color: var(--text); }
.theme-toggle svg { width: 16px; height: 16px; }

/* ══════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text3);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-weight: 600;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; vertical-align: middle;
}
.data-table tr:hover td { background: var(--surface2); }
.data-table tr:last-child td { border-bottom: none; }

/* ══════════════════════════════════════════════
   PRINT
   ══════════════════════════════════════════════ */
@media print {
  .no-print { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .topbar, .topbar-nav { display: none !important; }
}

/* ══════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.animate-fade-up { animation: fadeUp 0.22s ease-out; }
.animate-fade-in { animation: fadeIn 0.2s ease-out; }

/* ══════════════════════════════════════════════
   INLINE SVG ICON HELPERS
   ══════════════════════════════════════════════ */
.icon { width: 16px; height: 16px; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }

/* ══════════════════════════════════════════════
   MISC UTILITIES
   ══════════════════════════════════════════════ */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.mono { font-family: var(--mono); }
.text-accent { color: var(--accent); }
.text-muted  { color: var(--text3); }
.text-danger { color: var(--red); }
.text-success{ color: var(--green); }
.text-warn   { color: var(--yellow); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
