/* ═══════════════════════════════════════════════════════════
   CogniWatch v3 — Design System
   "A look from the future" — Premium Cyber Observatory
   ═══════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-base:       #05080f;
  --bg-surface:    #0a1020;
  --bg-card:       #0d1528;
  --bg-card-hover: #111d35;
  --bg-input:      #080e1c;
  --bg-nav:        rgba(5,8,15,.92);
  --border:        rgba(255,255,255,.06);
  --border-hover:  rgba(0,200,255,.18);
  --text-primary:  #e8ecf4;
  --text-secondary:#8899b4;
  --text-muted:    #4a5d7a;
  --accent:        #00c8ff;
  --accent-dim:    rgba(0,200,255,.12);
  --green:         #00e584;
  --green-dim:     rgba(0,229,132,.12);
  --red:           #ff4d6a;
  --red-dim:       rgba(255,77,106,.12);
  --orange:        #ff9f1c;
  --orange-dim:    rgba(255,159,28,.12);
  --purple:        #a78bfa;
  --purple-dim:    rgba(167,139,250,.12);
  --yellow:        #fbbf24;
  --font:          'Inter', system-ui, -apple-system, sans-serif;
  --mono:          'JetBrains Mono', 'Fira Code', monospace;
  --radius:        10px;
  --radius-sm:     6px;
  --radius-lg:     14px;
  --shadow:        0 1px 3px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  --shadow-lg:     0 4px 12px rgba(0,0,0,.4), 0 24px 48px rgba(0,0,0,.3);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font); background: var(--bg-base); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; transition: opacity .15s; }
a:hover { opacity: .8; }
button { font-family: var(--font); cursor: pointer; }
img { display: block; max-width: 100%; }
img.fw-real-icon { display: inline-block; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,200,255,.15); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,200,255,.3); }

/* ── Layout ── */
#app { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; }

/* ── Sidebar / Topnav ── */
.topnav {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-nav);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 1.25rem; height: 52px; gap: 1rem;
}
.topnav-brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; cursor: pointer; }
.topnav-brand img { width: 32px; height: 32px; border-radius: 50%; }
.topnav-brand .name { font-size: .95rem; font-weight: 700; letter-spacing: -.02em; }
.topnav-brand .name span { color: var(--accent); }
.topnav-brand .tagline { font-size: .6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .1em; margin-top: -2px; }

.topnav-tabs { display: flex; align-items: center; gap: 2px; margin-left: 1rem; }
.tab-btn {
  position: relative;
  padding: .45rem .9rem; border-radius: var(--radius-sm); font-size: .8rem;
  font-weight: 500; color: var(--text-muted); background: transparent;
  border: none; transition: all .15s; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.tab-btn:hover { color: var(--text-secondary); background: rgba(255,255,255,.04); }
.tab-btn.active { color: var(--accent); background: var(--accent-dim); }
.tab-btn.active::after { content:''; position: absolute; bottom: -9px; left: 20%; right: 20%; height: 2px; background: var(--accent); border-radius: 2px; }
.tab-icon { font-size: .85rem; line-height: 1; }
.tab-badge { min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; font-size: .6rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; background: var(--red); color: #fff; margin-left: 2px; }
.tab-external { font-size: .6rem; opacity: .4; }

.topnav-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.scanner-pill {
  display: flex; align-items: center; gap: 5px; padding: .3rem .7rem;
  border: 1px solid var(--border); border-radius: 99px;
  font-size: .7rem; font-family: var(--mono); color: var(--text-muted);
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.pill-dot.live  { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse 2s infinite; }
.pill-dot.idle  { background: #555; }
.btn-icon { background: none; border: none; color: var(--text-muted); padding: 6px; border-radius: var(--radius-sm); transition: all .15s; }
.btn-icon:hover { color: var(--text-primary); background: rgba(255,255,255,.06); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--purple)); display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; color: #000; cursor: pointer; }

/* ── Page Container ── */
.page { display: none; overflow-y: auto; }
.page.active { display: block; }
.page-inner { padding: 1.25rem; max-width: 1560px; margin: 0 auto; }

/* ── Stat Cards ── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
@media (max-width: 900px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .stats-row { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1rem 1.15rem; position: relative; overflow: hidden;
  transition: border-color .25s, transform .2s; cursor: default;
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-1px); }
.stat-card::before {
  content:''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0; transition: opacity .25s;
}
.stat-card:hover::before { opacity: .5; }
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .65rem; }
.stat-label { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.stat-icon-wrap { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: .95rem; }
.stat-value { font-size: 1.85rem; font-weight: 800; font-family: var(--mono); line-height: 1; margin-bottom: .35rem; color: var(--text-primary); }
.stat-value.loading { color: var(--text-muted); opacity: .3; }
.stat-sub { font-size: .7rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }

/* ── Cards ── */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; transition: border-color .2s; box-shadow: var(--shadow);
}
.card:hover { border-color: rgba(255,255,255,.09); }
.card-head { padding: .85rem 1.15rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.card-title { font-size: .82rem; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 7px; }
.card-body { padding: 1rem 1.15rem; }
.card-body-flush { padding: 0; }

/* ── Grids ── */
.grid-2col { display: grid; grid-template-columns: 1fr 380px; gap: .75rem; }
@media (max-width: 1100px) { .grid-2col { grid-template-columns: 1fr; } }
.grid-half { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 700px) { .grid-half { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.grid-activity { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 900px) { .grid-activity { grid-template-columns: 1fr; } }

/* ── Table ── */
.tbl-scroll { overflow: auto; max-height: 480px; }
table { width: 100%; border-collapse: collapse; font-size: .8rem; }
thead th {
  padding: .55rem 1rem; text-align: left; font-size: .65rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted);
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--bg-card); z-index: 2; white-space: nowrap;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text-secondary); }
tbody tr { border-bottom: 1px solid rgba(255,255,255,.025); transition: background .1s; }
tbody tr:hover { background: rgba(0,200,255,.03); }
tbody td { padding: .55rem 1rem; vertical-align: middle; white-space: nowrap; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-muted); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 99px; font-size: .62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; border: 1px solid;
}
.badge-critical { background: rgba(255,77,106,.12); color: var(--red); border-color: rgba(255,77,106,.2); }
.badge-high     { background: var(--orange-dim);     color: var(--orange); border-color: rgba(255,159,28,.2); }
.badge-medium   { background: rgba(251,191,36,.1);   color: var(--yellow); border-color: rgba(251,191,36,.2); }
.badge-low      { background: var(--green-dim);      color: var(--green); border-color: rgba(0,229,132,.2); }
.badge-info     { background: var(--accent-dim);     color: var(--accent); border-color: rgba(0,200,255,.2); }
.badge-live     { background: var(--green-dim);      color: var(--green); border-color: rgba(0,229,132,.2); font-size: .6rem; }

/* ── Confidence Bar ── */
.conf-wrap { display: flex; align-items: center; gap: 7px; min-width: 90px; }
.conf-track { flex: 1; height: 4px; background: rgba(255,255,255,.05); border-radius: 99px; overflow: hidden; }
.conf-fill { height: 100%; border-radius: 99px; transition: width .4s cubic-bezier(.4,0,.2,1); }
.conf-val { font-family: var(--mono); font-size: .72rem; width: 30px; text-align: right; }

/* ── Framework Chips ── */
.fw-chip { display: inline-flex; align-items: center; gap: 4px; }
.fw-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ── Alert Items ── */
.alert-list { overflow-y: auto; max-height: 440px; }
.alert-item { padding: .75rem 1rem; border-bottom: 1px solid rgba(255,255,255,.03); border-left: 3px solid; cursor: default; transition: background .1s; }
.alert-item:hover { background: rgba(255,255,255,.02); }
.alert-item:last-child { border-bottom: none; }
.alert-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; margin-bottom: 3px; }
.alert-title { font-size: .78rem; font-weight: 600; color: var(--text-primary); }
.alert-desc { font-size: .72rem; color: var(--text-muted); line-height: 1.35; margin-bottom: 4px; }
.alert-meta { display: flex; gap: 10px; font-size: .65rem; color: var(--text-muted); flex-wrap: wrap; }

/* ── Risk Bars ── */
.risk-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .25rem; }
.risk-row:last-child { margin-bottom: 0; }
.risk-label { font-size: .7rem; width: 48px; color: var(--text-secondary); flex-shrink: 0; }
.risk-track { flex: 1; height: 6px; background: rgba(255,255,255,.04); border-radius: 99px; overflow: hidden; }
.risk-fill { height: 100%; border-radius: 99px; transition: width .6s cubic-bezier(.4,0,.2,1); }
.risk-count { font-size: .7rem; font-family: var(--mono); color: var(--text-muted); width: 30px; text-align: right; }

/* ── Timeline ── */
.timeline { padding: .5rem .75rem; max-height: 360px; overflow-y: auto; }
.tl-item { display: flex; gap: .75rem; padding: .5rem 0; position: relative; }
.tl-item::before { content:''; position: absolute; left: 12px; top: 26px; bottom: -6px; width: 1px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .6rem; flex-shrink: 0; }
.tl-body { flex: 1; min-width: 0; }
.tl-title { font-size: .76rem; font-weight: 600; color: var(--text-primary); margin-bottom: 1px; }
.tl-desc { font-size: .7rem; color: var(--text-muted); line-height: 1.3; }
.tl-time { font-size: .64rem; font-family: var(--mono); color: var(--text-muted); margin-top: 2px; }

/* ── Topology / Force Graph placeholder ── */
.topo-canvas { width: 100%; height: 400px; background: var(--bg-base); border-radius: var(--radius); position: relative; overflow: hidden; }

/* ── Filter Bar ── */
.filter-bar { display: flex; align-items: center; gap: .5rem; padding: .65rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search-input {
  flex: 1; min-width: 140px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .4rem .75rem; color: var(--text-primary);
  font-size: .8rem; font-family: var(--font); outline: none; transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(0,200,255,.08); }
.filter-select {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .4rem .65rem; color: var(--text-secondary); font-size: .76rem; outline: none; cursor: pointer;
}
.filter-select:focus { border-color: var(--accent); }
.result-label { font-size: .7rem; color: var(--text-muted); margin-left: auto; white-space: nowrap; font-family: var(--mono); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: .42rem .85rem; border-radius: var(--radius-sm); font-size: .78rem; font-weight: 600; border: none; transition: all .15s; cursor: pointer; }
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { opacity: .3; cursor: not-allowed; }
.btn-ghost { background: rgba(255,255,255,.04); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: rgba(255,255,255,.08); color: var(--text-primary); }
.btn-sm { padding: .32rem .65rem; font-size: .72rem; }

/* ── Sentinel Cards ── */
.sentinel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
@media (max-width: 900px) { .sentinel-grid { grid-template-columns: 1fr; } }
.sentinel-card { padding: 1rem; }
.sentinel-score { font-size: 2.5rem; font-weight: 800; font-family: var(--mono); line-height: 1; }
.sentinel-ring { position: relative; width: 100px; height: 100px; margin: 0 auto; }

/* ── Empty State ── */
.empty { text-align: center; padding: 2rem; color: var(--text-muted); font-size: .85rem; }
.empty-icon { font-size: 1.8rem; margin-bottom: .5rem; opacity: .35; }

/* ── Skeleton ── */
@keyframes shimmer { 0%{background-position:-200% 0} 100%{background-position:200% 0} }
.skeleton { background: linear-gradient(90deg, rgba(255,255,255,.03) 25%, rgba(255,255,255,.06) 50%, rgba(255,255,255,.03) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; display: block; }

/* ── Loader ── */
.loader-screen {
  position: fixed; inset: 0; z-index: 9999; background: var(--bg-base);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem;
  transition: opacity .35s ease;
}
.loader-screen img { width: 56px; height: 56px; border-radius: 50%; animation: breathe 2s ease-in-out infinite; }
.loader-text { font-size: .78rem; color: var(--text-muted); font-family: var(--mono); }

/* ── Animations ── */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }
@keyframes breathe { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.06);opacity:.7} }
@keyframes fadeUp { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
.fade-up { animation: fadeUp .3s ease forwards; }

/* ── CVE Panel ── */
.cve-row {
  padding: .55rem .75rem;
  border-left: 3px solid var(--orange);
  background: rgba(255,159,28,.04);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: .45rem;
  transition: background .15s;
}
.cve-row:hover { background: rgba(255,159,28,.08); }
.cve-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .25rem;
}
.cve-id { font-size: .78rem; font-weight: 600; letter-spacing: .02em; }
.cve-cvss { font-size: .72rem; font-weight: 600; }
.cve-cvss::before { content: 'CVSS '; font-size: .6rem; opacity: .6; }
.cve-framework { margin-left: auto; }
.cve-desc { font-size: .72rem; color: var(--text-secondary); line-height: 1.45; margin-bottom: .2rem; }
.cve-mitigation { font-size: .68rem; color: var(--green); background: var(--green-dim); padding: 3px 8px; border-radius: 4px; display: inline-block; }
.cve-fix-label { font-weight: 600; opacity: .7; }


/* ── Responsive ── */
@media (max-width: 768px) {
  .topnav { padding: 0 .75rem; gap: .5rem; }
  .topnav-brand .tagline { display: none; }
  .page-inner { padding: .75rem; }
  .tab-btn span:not(.tab-icon):not(.tab-badge) { display: none; }
  .grid-2col { grid-template-columns: 1fr; }
}

/* ── Light Theme ── */
[data-theme="light"] {
  --bg: #f5f7fa; --card-bg: #fff; --border: #e2e8f0;
  --text-primary: #1a202c; --text-secondary: #718096;
  --accent: #0077cc; --green: #059669; --red: #dc2626;
  --orange: #d97706; --yellow: #ca8a04; --purple: #7c3aed;
}
[data-theme="light"] .topnav { background: rgba(255,255,255,.95); border-bottom: 1px solid #e2e8f0; }
[data-theme="light"] .card { background: #fff; border: 1px solid #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
[data-theme="light"] .stat-card { background: #fff; border: 1px solid #e2e8f0; }
[data-theme="light"] .tab-btn { color: #4a5568; }
[data-theme="light"] .tab-btn:hover, [data-theme="light"] .tab-btn.active { color: #0077cc; }
[data-theme="light"] input, [data-theme="light"] select { background: #f7fafc; border-color: #e2e8f0; color: #1a202c; }
[data-theme="light"] table { color: #1a202c; }
[data-theme="light"] th { color: #718096; border-color: #e2e8f0; }
[data-theme="light"] td { border-color: #edf2f7; }
[data-theme="light"] .page-header { border-color: rgba(0,119,204,.15) !important; background: linear-gradient(135deg,rgba(0,119,204,.04) 0%,rgba(124,58,237,.03) 100%) !important; }
[data-theme="light"] .skeleton { background: #e2e8f0; }
[data-theme="light"] .risk-track { background: #e2e8f0; }

/* Hide hamburger on desktop */
.hamburger { display: none; }
@media (max-width: 768px) {
  .hamburger { display: flex; }
}
