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

:root {
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --nav-h: 60px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.10);
}

.dark {
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #162032;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.4);
}

html {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

body { min-height: 100vh; }

/* ── NAV ── */
.nav {
  position: sticky; top: 0; z-index: 200;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--nav-h);
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  transition: background 0.3s, border-color 0.3s;
}
.nav-left { display: flex; align-items: center; gap: 32px; }
.nav-logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 1.3rem; }
.logo-text { font-weight: 700; font-size: 1rem; letter-spacing: -0.02em; color: var(--text); }
.logo-sub { color: var(--accent); }
.nav-tabs { display: flex; gap: 2px; }
.nav-tab {
  padding: 7px 14px; border-radius: 7px;
  font-size: 0.875rem; font-weight: 500;
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; transition: all 0.15s;
}
.nav-tab:hover { background: var(--surface-alt); color: var(--text); }
.nav-tab.active { background: var(--accent); color: #fff; }

.nav-right { display: flex; align-items: center; gap: 12px; }

.notif-btn {
  position: relative; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; cursor: pointer;
  color: var(--text-muted); transition: background 0.15s;
}
.notif-btn:hover { background: var(--surface-alt); }
.notif-badge {
  position: absolute; top: 4px; right: 4px;
  width: 16px; height: 16px; border-radius: 99px;
  background: #ef4444; color: #fff;
  font-size: 0.65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.theme-toggle {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-alt);
  color: var(--text-muted); cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { background: var(--surface); color: var(--text); }

.avatar {
  width: 34px; height: 34px; border-radius: 99px;
  background: var(--accent); color: #fff;
  font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ── NOTIF PANEL ── */
.notif-overlay {
  display: none; position: fixed; inset: 0; z-index: 299;
}
.notif-overlay.open { display: block; }
.notif-panel {
  position: fixed; top: calc(var(--nav-h) + 8px); right: 16px;
  width: 300px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 300;
  transform: translateY(-8px) scale(0.97); opacity: 0;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(.34,1.56,.64,1);
}
.notif-panel.open {
  transform: translateY(0) scale(1); opacity: 1;
  pointer-events: auto;
}
.notif-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.875rem;
}
.notif-clear {
  font-size: 0.8rem; color: var(--accent);
  background: none; border: none; cursor: pointer;
}
.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: rgba(99,102,241,.05); }
.notif-dot {
  width: 8px; height: 8px; border-radius: 99px; margin-top: 4px; flex-shrink: 0;
}
.notif-dot.success { background: #10b981; }
.notif-dot.warning { background: #f59e0b; }
.notif-dot.error   { background: #ef4444; }
.notif-title { font-size: 0.85rem; font-weight: 500; color: var(--text); }
.notif-time  { font-size: 0.75rem; color: var(--text-subtle); margin-top: 2px; }

/* ── MAIN ── */
.main { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px;
}
.page-title { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em; }
.page-sub { color: var(--text-muted); font-size: 0.875rem; margin-top: 4px; }

/* ── KPI CARDS ── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 24px;
}
.kpi-skeleton {
  height: 120px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-alt) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow);
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
  animation: popIn 0.4s cubic-bezier(.34,1.56,.64,1) both;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
@keyframes popIn {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi-icon { font-size: 1.5rem; }
.kpi-change {
  font-size: 0.75rem; font-weight: 600; padding: 3px 8px;
  border-radius: 99px;
}
.kpi-change.up   { background: #dcfce7; color: #15803d; }
.kpi-change.down { background: #fee2e2; color: #b91c1c; }
.dark .kpi-change.up   { background: #14532d40; color: #4ade80; }
.dark .kpi-change.down { background: #7f1d1d40; color: #f87171; }
.kpi-value { font-size: 2rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.kpi-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.kpi-bar { height: 3px; border-radius: 99px; margin-top: 14px; background: var(--border); overflow: hidden; }
.kpi-bar-fill { height: 100%; border-radius: 99px; transition: width 1s ease; }

/* ── CHARTS ── */
.charts-row {
  display: grid; grid-template-columns: 1fr 320px;
  gap: 16px; margin-bottom: 24px;
}
.chart-card { padding: 22px; }
.card-header-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.card-header-row h3 { font-size: 0.95rem; font-weight: 600; }

.donut-legend { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* ── PERF ── */
.perf-list { display: flex; flex-direction: column; gap: 16px; }
.perf-item {}
.perf-label {
  display: flex; justify-content: space-between;
  font-size: 0.85rem; margin-bottom: 6px;
  color: var(--text-muted);
}
.perf-label span:last-child { font-weight: 600; color: var(--text); }
.progress-bar {
  height: 8px; border-radius: 99px;
  background: var(--surface-alt); overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 99px;
  width: 0; transition: width 1.2s cubic-bezier(.4,0,.2,1);
}
.progress-fill.cpu  { background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.progress-fill.mem  { background: linear-gradient(90deg, #10b981, #06b6d4); }
.progress-fill.disk { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.progress-fill.net  { background: linear-gradient(90deg, #ec4899, #8b5cf6); }

/* ── CARD ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow);
  transition: background 0.3s, border-color 0.3s;
}

/* ── EVENTS ── */
.events-list { display: flex; flex-direction: column; }
.event-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
  animation: slideIn 0.3s ease;
}
.event-row:last-child { border-bottom: none; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.event-dot {
  width: 10px; height: 10px; border-radius: 99px; margin-top: 4px; flex-shrink: 0;
}
.event-dot.success { background: #10b981; }
.event-dot.warning { background: #f59e0b; }
.event-dot.error   { background: #ef4444; }
.event-dot.info    { background: #6366f1; }
.event-body { flex: 1; }
.event-title { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.event-desc  { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.event-time  { font-size: 0.75rem; color: var(--text-subtle); flex-shrink: 0; }
.event-badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 99px; font-size: 0.7rem; font-weight: 600;
  margin-left: 8px;
}
.event-badge.success { background: #dcfce7; color: #15803d; }
.event-badge.warning { background: #fef3c7; color: #b45309; }
.event-badge.error   { background: #fee2e2; color: #b91c1c; }
.event-badge.info    { background: #ede9fe; color: #6d28d9; }
.dark .event-badge.success { background: #14532d40; color: #4ade80; }
.dark .event-badge.warning { background: #78350f40; color: #fbbf24; }
.dark .event-badge.error   { background: #7f1d1d40; color: #f87171; }
.dark .event-badge.info    { background: #3730a340; color: #a5b4fc; }

.loading-state {
  text-align: center; padding: 40px;
  color: var(--text-subtle); font-size: 0.9rem;
}

/* ── FEATURES ── */
.features-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.feature-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(16px);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.feature-card.visible {
  animation: popIn 0.5s cubic-bezier(.34,1.56,.64,1) both;
}
.feature-card:hover {
  transform: translateY(-4px); box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}
.feature-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; margin-bottom: 14px;
}
.feature-card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; }
.feature-card p  { font-size: 0.82rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 12px; }
.feature-tag {
  display: inline-flex; padding: 3px 9px; border-radius: 99px;
  background: var(--surface-alt); border: 1px solid var(--border);
  font-size: 0.72rem; font-weight: 500; color: var(--text-muted);
}

/* ── MODAL ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.4); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 14px;
  width: 440px; max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.92) translateY(12px); } to { opacity: 1; transform: none; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
  width: 30px; height: 30px; border-radius: 7px;
  border: none; background: var(--surface-alt); color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--border);
}

/* ── FORMS ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.85rem; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 10px 14px;
  font-size: 0.9rem; font-family: inherit;
  color: var(--text); background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: 7px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
input::placeholder { color: var(--text-subtle); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 8px;
  font-size: 0.875rem; font-weight: 500; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--text-subtle); }

/* ── BADGE ── */
.badge { display: inline-flex; padding: 3px 9px; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.dark .badge-blue { background: #1e3a5f; color: #93c5fd; }

.text-muted { color: var(--text-muted); font-size: 0.8rem; }

/* ── TOAST ── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 999;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem; font-weight: 500;
  animation: toastIn 0.3s cubic-bezier(.34,1.56,.64,1);
  min-width: 240px;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px) scale(0.95); } to { opacity: 1; transform: none; } }
.toast.fadeout { animation: toastOut 0.3s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px) scale(0.95); } }
.toast-icon { font-size: 1rem; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .features-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .features-grid { grid-template-columns: 1fr; }
  .nav-tabs { display: none; }
  .main { padding: 20px 16px; }
}
