/* ============================================================
   GRAPHITE-X  —  Premium Design System
   Warm White + Blue + Soft Glow Theme
   ============================================================ */

:root {
  /* Core palette */
  --bg-base:        #f0f4ff;
  --bg-warm:        #faf9f7;
  --bg-surface:     #ffffff;
  --bg-card:        #ffffff;
  --bg-card-hover:  #f8faff;
  --bg-sidebar:     #0f1b3d;
  --bg-topbar:      rgba(255,255,255,0.92);

  /* Blues */
  --accent-primary: #2563eb;
  --accent-sky:     #0ea5e9;
  --accent-indigo:  #6366f1;
  --accent-cyan:    #06b6d4;

  /* Semantic */
  --accent-green:   #10b981;
  --accent-amber:   #f59e0b;
  --accent-red:     #ef4444;
  --accent-pink:    #ec4899;

  /* Text */
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-sidebar:   rgba(255,255,255,0.75);
  --text-sidebar-active: #ffffff;

  /* Borders */
  --border:         #e2e8f0;
  --border-hover:   #bfdbfe;
  --border-focus:   #2563eb;

  /* Sidebar */
  --sidebar-w:      240px;
  --topbar-h:       62px;
  --radius:         14px;
  --radius-sm:      9px;
  --radius-xs:      6px;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-card: 0 4px 20px rgba(37,99,235,0.06), 0 1px 4px rgba(15,23,42,0.05);
  --shadow-hover:0 8px 32px rgba(37,99,235,0.12), 0 2px 6px rgba(15,23,42,0.06);
  --shadow-glow: 0 0 0 3px rgba(37,99,235,0.12);

  --font: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ─── Decorative Background ───────────────────────────────── */

.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(37,99,235,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(14,165,233,0.06) 0%, transparent 60%),
    linear-gradient(rgba(37,99,235,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,0.025) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
}

.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: drift 20s ease-in-out infinite alternate;
}
.orb-1 { width: 500px; height: 500px; background: rgba(37,99,235,0.09); top: -120px; left: -100px; }
.orb-2 { width: 400px; height: 400px; background: rgba(14,165,233,0.07); bottom: -80px; right: -80px; animation-duration: 26s; animation-delay: -8s; }
.orb-3 { width: 300px; height: 300px; background: rgba(99,102,241,0.06); top: 40%; left: 55%; animation-duration: 32s; animation-delay: -14s; }

@keyframes drift {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(50px,30px) scale(1.08); }
}

/* ─── Layout ──────────────────────────────────────────────── */

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  box-shadow: 4px 0 24px rgba(15,23,42,0.12);
  transition: transform 0.3s ease;
}

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
}

body.sidebar-collapsed .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
body.sidebar-collapsed .main { margin-left: 0; }

/* ─── Sidebar ─────────────────────────────────────────────── */

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(37,99,235,0.4);
}
.logo-text { font-size: 16px; font-weight: 700; letter-spacing: 0.04em; color: #fff; }
.logo-accent { color: #60a5fa; }

.sidebar-search {
  display: flex; align-items: center; gap: 8px;
  margin: 12px; padding: 8px 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.4);
}
.sidebar-search input {
  background: none; border: none; outline: none;
  color: #fff; font-size: 13px; width: 100%;
}
.sidebar-search input::placeholder { color: rgba(255,255,255,0.35); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.nav-section-label {
  padding: 16px 18px 5px;
  font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px;
  color: var(--text-sidebar);
  text-decoration: none; font-size: 13px;
  cursor: pointer; transition: all 0.15s;
  position: relative;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.06); }
.nav-item.active {
  color: #fff;
  background: rgba(37,99,235,0.3);
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  border-radius: 0 3px 3px 0;
}

.badge-alert {
  margin-left: auto;
  background: var(--accent-red);
  color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 20px;
  min-width: 18px; text-align: center;
}

.source-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.source-dot.green { background: var(--accent-green); box-shadow: 0 0 5px var(--accent-green); }
.source-dot.yellow { background: var(--accent-amber); box-shadow: 0 0 5px var(--accent-amber); }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,0.4);
}
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.4); }

/* ─── Topbar ──────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  height: var(--topbar-h);
  background: var(--bg-topbar);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 8px rgba(37,99,235,0.04);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.page-title { font-size: 18px; font-weight: 800; color: var(--text-primary); }

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
}
.breadcrumb .active { color: var(--accent-primary); font-weight: 500; }

.time-range-picker {
  display: flex; gap: 2px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 9px; padding: 3px;
}
.time-btn {
  padding: 5px 11px;
  background: none; border: none;
  color: var(--text-secondary); font-size: 12px; font-weight: 500;
  cursor: pointer; border-radius: 6px; transition: all 0.15s;
}
.time-btn:hover { color: var(--accent-primary); background: rgba(37,99,235,0.06); }
.time-btn.active {
  background: var(--accent-primary);
  color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.live-indicator {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--accent-green);
}
.live-dot {
  width: 7px; height: 7px;
  background: var(--accent-green); border-radius: 50%;
  box-shadow: 0 0 6px var(--accent-green);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:0.5; transform:scale(0.85); } }

/* ─── Buttons ─────────────────────────────────────────────── */

.btn-icon {
  width: 34px; height: 34px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  cursor: pointer; transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--accent-primary);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow);
}

.btn-icon-sm {
  width: 26px; height: 26px;
  background: none; border: 1px solid transparent;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: pointer; transition: all 0.15s;
}
.btn-icon-sm:hover { background: var(--bg-base); color: var(--accent-primary); border-color: var(--border); }

.btn-primary {
  padding: 8px 18px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: none; border-radius: var(--radius-sm);
  color: #fff; font-weight: 700; font-size: 13px;
  cursor: pointer; transition: all 0.15s;
  box-shadow: 0 2px 10px rgba(37,99,235,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,0.45); }

.btn-outline {
  padding: 7px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13px;
  cursor: pointer; transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.btn-outline:hover { border-color: var(--border-hover); color: var(--accent-primary); }

/* ─── Stat Cards ──────────────────────────────────────────── */

.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  padding: 24px 24px 0;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: all 0.22s;
  cursor: default;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  opacity: 0;
  transition: opacity 0.2s;
}
.stat-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
}
.stat-card:hover::before { opacity: 1; }
.stat-card[data-metric="cpu"]::before     { background: linear-gradient(90deg,#2563eb,#0ea5e9); }
.stat-card[data-metric="memory"]::before  { background: linear-gradient(90deg,#6366f1,#8b5cf6); }
.stat-card[data-metric="requests"]::before{ background: linear-gradient(90deg,#10b981,#06b6d4); }
.stat-card[data-metric="latency"]::before { background: linear-gradient(90deg,#f59e0b,#f97316); }
.stat-card[data-metric="errors"]::before  { background: linear-gradient(90deg,#ef4444,#ec4899); }

.stat-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }

.stat-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
}

.stat-trend {
  display: flex; align-items: center; gap: 3px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
}
.stat-trend.up      { color: var(--accent-green); background: rgba(16,185,129,0.1); }
.stat-trend.down    { color: var(--accent-green); background: rgba(16,185,129,0.1); }
.stat-trend.up-bad  { color: var(--accent-red);   background: rgba(239,68,68,0.1); }

.stat-value {
  font-size: 30px; font-weight: 800;
  line-height: 1.05; margin-bottom: 3px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.stat-unit { font-size: 14px; font-weight: 500; color: var(--text-muted); margin-left: 2px; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.stat-sparkline { height: 42px; }

/* ─── Charts Grid ─────────────────────────────────────────── */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 16px 24px 24px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: all 0.2s;
  display: flex; flex-direction: column;
  min-height: 290px;
}
.chart-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-hover); }
.chart-card.span-2 { grid-column: span 2; }
.chart-card.span-3 { grid-column: span 3; }

.chart-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px;
}
.chart-title-group h3 { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.chart-subtitle { font-size: 11px; color: var(--text-muted); }

.chart-actions { display: flex; align-items: center; gap: 6px; }
.chart-legend { display: flex; gap: 14px; }
.legend-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-secondary); cursor: pointer;
}
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.chart-body { flex: 1; position: relative; min-height: 200px; }
.chart-body canvas { max-height: 230px; }
.chart-body.chart-center {
  display: flex; align-items: center; justify-content: center; position: relative;
}
.gauge-label {
  position: absolute; display: flex; flex-direction: column; align-items: center; pointer-events: none;
}
.gauge-label span { font-size: 28px; font-weight: 800; color: var(--text-primary); }
.gauge-label small { font-size: 11px; color: var(--text-muted); }

.anomaly-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--accent-amber);
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  padding: 3px 8px; border-radius: 20px;
}

/* ─── Metrics Table ───────────────────────────────────────── */

.metrics-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.metrics-table thead tr { border-bottom: 1px solid var(--border); }
.metrics-table th {
  padding: 7px 10px; text-align: left;
  color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; font-size: 10px; letter-spacing: 0.08em;
}
.metrics-table td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; }
.metrics-table tbody tr:hover { background: #f8faff; }

.host-bar { display: flex; align-items: center; gap: 8px; }
.host-bar-bg { flex: 1; height: 5px; background: #e2e8f0; border-radius: 5px; overflow: hidden; }
.host-bar-fill { height: 100%; border-radius: 5px; transition: width 0.5s ease; }

.status-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; letter-spacing: 0.04em;
}
.status-chip.ok   { color: #059669; background: #ecfdf5; border: 1px solid #a7f3d0; }
.status-chip.warn { color: #b45309; background: #fffbeb; border: 1px solid #fde68a; }
.status-chip.crit { color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; }

/* ─── Alert Drawer ────────────────────────────────────────── */

.alert-drawer {
  position: fixed; right: -380px; top: 0; bottom: 0; z-index: 200;
  width: 360px; background: var(--bg-surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(37,99,235,0.08);
  transition: right 0.3s ease; display: flex; flex-direction: column;
}
.alert-drawer.open { right: 0; }
.alert-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border);
}
.alert-drawer-header h3 { font-size: 15px; font-weight: 700; }
.alert-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }

.alert-item {
  padding: 13px 15px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-left: 3px solid;
  box-shadow: var(--shadow-sm);
}
.alert-item.critical { border-left-color: var(--accent-red); }
.alert-item.warning  { border-left-color: var(--accent-amber); }
.alert-item.info     { border-left-color: var(--accent-primary); }
.alert-item-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.alert-item-meta  { font-size: 11px; color: var(--text-muted); }

/* ─── Modal ───────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15,23,42,0.4);
  backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 520px; max-width: 95vw;
  box-shadow: 0 24px 60px rgba(15,23,42,0.18), 0 0 0 1px rgba(37,99,235,0.08);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity:0; transform:scale(0.97) translateY(-8px); } to { opacity:1; transform:none; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px 16px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--border);
}

.panel-type-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 20px; }
.panel-type {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 10px;
  background: var(--bg-base); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.15s;
  color: var(--text-secondary); font-size: 12px; font-weight: 500;
}
.panel-type:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(37,99,235,0.04);
  box-shadow: var(--shadow-glow);
}

.modal-query { display: flex; flex-direction: column; gap: 8px; }
.modal-query label { font-size: 11px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-top: 6px; }

.query-input {
  background: var(--bg-base);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px; color: var(--text-primary);
  font-size: 13px; font-family: var(--font-mono);
  width: 100%; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.query-input:focus { border-color: var(--accent-primary); box-shadow: var(--shadow-glow); background: #fff; }
.query-input::placeholder { color: var(--text-muted); }

/* ─── Tooltip ─────────────────────────────────────────────── */

.metric-tooltip {
  position: fixed; z-index: 1000;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 12px;
  pointer-events: none; opacity: 0; transition: opacity 0.1s;
  box-shadow: 0 8px 24px rgba(37,99,235,0.12);
}
.metric-tooltip.visible { opacity: 1; }

/* ─── Explore ─────────────────────────────────────────────── */

.explore-layout { display: grid; grid-template-columns: 280px 1fr; flex: 1; }

.metric-tree {
  border-right: 1px solid var(--border); padding: 16px;
  overflow-y: auto; height: calc(100vh - var(--topbar-h));
  position: sticky; top: var(--topbar-h); background: var(--bg-surface);
}
.metric-tree-search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg-base); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 12px; color: var(--text-muted);
}
.metric-tree-search input { background: none; border: none; outline: none; color: var(--text-primary); font-size: 13px; width: 100%; }

.tree-node { font-size: 13px; }
.tree-node-label {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px; border-radius: 7px;
  cursor: pointer; color: var(--text-secondary);
  transition: all 0.1s; user-select: none;
}
.tree-node-label:hover { background: #f0f4ff; color: var(--accent-primary); }
.tree-node-label.active { color: var(--accent-primary); background: rgba(37,99,235,0.06); font-weight: 600; }
.tree-node-children { padding-left: 16px; }

.explore-main { padding: 24px; overflow-y: auto; }

.query-builder {
  background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.qb-row { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.qb-input {
  flex: 1; background: var(--bg-base);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; color: var(--text-primary);
  font-family: var(--font-mono); font-size: 13px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.qb-input:focus { border-color: var(--accent-primary); box-shadow: var(--shadow-glow); background: #fff; }

.qb-func-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.func-pill {
  padding: 4px 11px; font-size: 12px;
  background: var(--bg-base); border: 1.5px solid var(--border);
  border-radius: 20px; color: var(--text-secondary);
  cursor: pointer; font-family: var(--font-mono); transition: all 0.12s;
}
.func-pill:hover { border-color: var(--accent-primary); color: var(--accent-primary); background: rgba(37,99,235,0.05); }

/* ─── Alerts ──────────────────────────────────────────────── */

.alerts-layout { padding: 24px; }
.alerts-toolbar { display: flex; gap: 10px; margin-bottom: 20px; align-items: center; flex-wrap: wrap; }
.alerts-grid { display: grid; gap: 12px; }

.alert-rule-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: grid; grid-template-columns: auto 1fr auto auto;
  align-items: center; gap: 16px;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.alert-rule-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-hover); }

.alert-severity { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.alert-severity.critical { background: var(--accent-red); box-shadow: 0 0 8px rgba(239,68,68,0.5); }
.alert-severity.warning  { background: var(--accent-amber); box-shadow: 0 0 8px rgba(245,158,11,0.5); }
.alert-severity.ok       { background: var(--accent-green); box-shadow: 0 0 8px rgba(16,185,129,0.5); }

.alert-rule-name { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 3px; }
.alert-rule-desc { font-size: 12px; color: var(--text-secondary); }
.alert-rule-metric { font-family: var(--font-mono); font-size: 11px; color: var(--accent-primary); margin-top: 4px; }

/* ─── Topology ────────────────────────────────────────────── */

.topology-container { flex: 1; position: relative; overflow: hidden; }
.topology-legend {
  position: absolute; bottom: 24px; left: 24px;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-card);
}
.topology-legend h4 { font-size: 10px; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 6px; color: var(--text-secondary); }
.legend-node { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.topology-controls { position: absolute; top: 24px; right: 24px; display: flex; flex-direction: column; gap: 6px; }

.node-tooltip {
  position: absolute; z-index: 10;
  background: rgba(255,255,255,0.97);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 12px;
  pointer-events: none; display: none;
  box-shadow: var(--shadow-hover);
  min-width: 180px;
}

/* ─── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Select ──────────────────────────────────────────────── */
select.gx-select {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 7px 12px; font-size: 13px;
  cursor: pointer; outline: none;
  box-shadow: var(--shadow-sm);
}
select.gx-select:focus { border-color: var(--accent-primary); box-shadow: var(--shadow-glow); }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 1400px) { .stats-row { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 1100px) { .charts-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px) {
  .stats-row { grid-template-columns: repeat(2,1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .chart-card.span-2 { grid-column: span 1; }
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  body.sidebar-open .sidebar { transform: none; }
  .explore-layout { grid-template-columns: 1fr; }
}

/* ─── Animations ──────────────────────────────────────────── */
.fade-in { animation: fadeIn 0.35s ease forwards; }
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

.chart-card, .stat-card { animation: fadeIn 0.4s ease both; }
.stat-card:nth-child(1) { animation-delay:.05s; }
.stat-card:nth-child(2) { animation-delay:.10s; }
.stat-card:nth-child(3) { animation-delay:.15s; }
.stat-card:nth-child(4) { animation-delay:.20s; }
.stat-card:nth-child(5) { animation-delay:.25s; }

/* ─── Toasts ──────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 24px rgba(37,99,235,0.12);
  animation: toastIn 0.25s ease;
  pointer-events: all; min-width: 240px;
}
.toast-success { border-left: 3px solid var(--accent-green); }
.toast-error   { border-left: 3px solid var(--accent-red); }
.toast-info    { border-left: 3px solid var(--accent-primary); }
@keyframes toastIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:none; } }

/* ─── Skeleton ────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position:200% 0; } 100% { background-position:-200% 0; } }
