:root { --sidebar: 240px; }
body { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar { width: var(--sidebar); background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 1.5rem 0; position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; }
.sidebar-logo { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.4rem; color: var(--accent); padding: 0 1.5rem 2rem; }
.sidebar-logo span { color: var(--text); }
.sidebar-nav { flex: 1; }
.nav-item { display: flex; align-items: center; gap: 0.7rem; padding: 0.75rem 1.5rem; color: var(--muted); text-decoration: none; font-size: 0.88rem; font-weight: 500; transition: all 0.15s; border-left: 3px solid transparent; margin-bottom: 2px; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-item.active { color: var(--accent); border-color: var(--accent); background: rgba(0,229,255,0.05); }
.nav-icon { font-size: 1rem; width: 18px; text-align: center; }
.sidebar-footer { padding: 1.5rem; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 0.75rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg,var(--accent3),var(--accent)); display: flex; align-items: center; justify-content: center; font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.85rem; color: #fff; flex-shrink: 0; }
.user-name { font-size: 0.85rem; font-weight: 600; }
.user-role { font-size: 0.75rem; color: var(--muted); }

/* MAIN */
.main { margin-left: var(--sidebar); flex: 1; padding: 2rem 2.5rem; max-width: calc(100vw - var(--sidebar)); position: relative; z-index: 1; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.page-title { font-size: 1.5rem; font-weight: 800; }
.page-sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.1rem; }
.topbar-right { display: flex; gap: 0.75rem; align-items: center; }
.scan-btn { background: var(--accent); color: #000; border: none; padding: 0.6rem 1.2rem; border-radius: 8px; font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.85rem; cursor: pointer; letter-spacing: 0.04em; transition: all 0.2s; }
.scan-btn:hover { opacity: 0.85; }
.notif-btn { background: var(--card); border: 1px solid var(--border); color: var(--text); width: 38px; height: 38px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; position: relative; }
.notif-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; background: var(--high); border-radius: 50%; border: 2px solid var(--card); }

/* STAT CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1.4rem; position: relative; overflow: hidden; }
.stat-card::after { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.stat-card.total::after { background: var(--accent); }
.stat-card.safe::after { background: var(--low); }
.stat-card.warn::after { background: var(--med); }
.stat-card.danger::after { background: var(--high); }
.stat-label { font-size: 0.78rem; color: var(--muted); font-weight: 500; letter-spacing: 0.05em; margin-bottom: 0.5rem; text-transform: uppercase; }
.stat-num { font-family: 'Syne', sans-serif; font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-num.total { color: var(--accent); }
.stat-num.safe { color: var(--low); }
.stat-num.warn { color: var(--med); }
.stat-num.danger { color: var(--high); }
.stat-change { font-size: 0.78rem; color: var(--muted); margin-top: 0.4rem; }
.stat-change.up { color: var(--low); }
.stat-change.down { color: var(--high); }

/* GRID */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.grid-3-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
@media(max-width:900px) { .grid-2, .grid-3-1 { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1.4rem; }
.card-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 1rem; display: flex; align-items: center; justify-content: space-between; }
.card-title span { color: var(--muted); font-size: 0.78rem; font-weight: 400; font-family: 'DM Sans', sans-serif; }

/* BAR CHART */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar { width: 100%; border-radius: 4px 4px 0 0; transition: opacity 0.2s; cursor: pointer; }
.bar:hover { opacity: 0.8; }
.bar-label { font-size: 0.7rem; color: var(--muted); }

/* DONUT */
.donut-wrap { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.donut-legend { display: flex; flex-direction: column; gap: 0.7rem; }
.legend-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* TABLE */
.scan-table { width: 100%; border-collapse: collapse; }
.scan-table th { font-size: 0.75rem; color: var(--muted); font-weight: 500; text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: 0.06em; }
.scan-table td { padding: 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 0.85rem; vertical-align: middle; }
.scan-table tr:last-child td { border-bottom: none; }
.scan-table tr:hover td { background: rgba(255,255,255,0.02); }
.risk-badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 100px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; font-family: 'Syne', sans-serif; }
.badge-low { background: rgba(34,197,94,0.12); color: var(--low); }
.badge-med { background: rgba(245,158,11,0.12); color: var(--med); }
.badge-high { background: rgba(239,68,68,0.12); color: var(--high); }
.email-cell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sender-cell { color: var(--muted); font-size: 0.8rem; }

/* ACTIVITY */
.activity-list { display: flex; flex-direction: column; gap: 0.8rem; }
.activity-item { display: flex; align-items: flex-start; gap: 0.75rem; }
.act-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; flex-shrink: 0; }
.act-icon.high { background: rgba(239,68,68,0.1); }
.act-icon.med { background: rgba(245,158,11,0.1); }
.act-icon.low { background: rgba(34,197,94,0.1); }
.act-text { font-size: 0.83rem; line-height: 1.4; }
.act-time { font-size: 0.75rem; color: var(--muted); }

/* FILTER */
.filter-bar { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-btn { background: var(--bg2); border: 1px solid var(--border); color: var(--muted); padding: 0.35rem 0.9rem; border-radius: 100px; font-size: 0.8rem; cursor: pointer; transition: all 0.15s; font-family: 'DM Sans', sans-serif; }
.filter-btn.active { background: rgba(0,229,255,0.1); border-color: rgba(0,229,255,0.3); color: var(--accent); }
.filter-btn:hover { color: var(--text); }

/* ── MOBILE SIDEBAR ── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 40; backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

.menu-toggle {
  display: none; background: var(--card); border: 1px solid var(--border);
  color: var(--text); width: 38px; height: 38px; border-radius: 8px;
  cursor: pointer; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0; transition: all 0.2s;
}
.menu-toggle:hover { border-color: var(--accent); }

@media(max-width: 768px) {
  .menu-toggle { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 50;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  .sidebar.open { transform: translateX(0); }

  .main {
    margin-left: 0;
    max-width: 100vw;
    padding: 1.5rem 1rem;
  }

  .topbar { padding-top: 0.5rem; }
  .page-title { font-size: 1.2rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3-1 { grid-template-columns: 1fr; }
  .scan-table th:nth-child(2),
  .scan-table td:nth-child(2) { display: none; }
}

@media(max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
}

.signout-btn {
  margin: 0.75rem 1.5rem 0;
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2);
  color: #ef4444; padding: 0.6rem; border-radius: 8px; cursor: pointer;
  font-family: "DM Sans", sans-serif; font-size: 0.85rem;
  width: calc(100% - 3rem); transition: all 0.2s;
}
.signout-btn:hover { background: rgba(239,68,68,0.2); }
