:root {
  --bg: #050310;
  --bg-2: #0a0616;
  --surface: rgba(255,255,255,0.035);
  --surface-strong: rgba(255,255,255,0.06);
  --border: rgba(168,120,255,0.18);
  --border-hover: rgba(168,120,255,0.42);

  --text: #f4eefe;
  --text-dim: #a99bc9;
  --text-faint: #746793;

  --violet: #9b5cff;
  --violet-2: #7c3aed;
  --violet-soft: #c9a8ff;
  --magenta: #ff53d4;

  --ok: #3cf295;
  --warn: #ffcf4d;
  --down: #ff4d6d;

  --radius: 16px;
  --radius-sm: 11px;

  --font-display: 'Unbounded', system-ui, sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  position: relative;
}

::selection { background: var(--violet); color: #fff; }

/* ===== Ambient background ===== */
#particles {
  position: fixed;
  inset: 0;
  z-index: -3;
  width: 100%;
  height: 100%;
  opacity: 0.55;
  pointer-events: none;
}
.mesh-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  will-change: transform;
}
.blob-a { width: 42vw; height: 42vw; top: -16vw; left: -8vw; background: radial-gradient(circle, var(--violet-2), transparent 70%); animation: driftA 20s ease-in-out infinite alternate; }
.blob-b { width: 34vw; height: 34vw; top: -6vw; right: -8vw; background: radial-gradient(circle, var(--magenta), transparent 70%); opacity: 0.34; animation: driftB 24s ease-in-out infinite alternate; }
.blob-c { width: 30vw; height: 30vw; bottom: -16vw; left: 32vw; background: radial-gradient(circle, var(--violet), transparent 72%); opacity: 0.26; animation: driftC 28s ease-in-out infinite alternate; }
@keyframes driftA { from { transform: translate(0,0) scale(1); } to { transform: translate(5vw, 4vw) scale(1.1); } }
@keyframes driftB { from { transform: translate(0,0) scale(1); } to { transform: translate(-4vw, 5vw) scale(0.95); } }
@keyframes driftC { from { transform: translate(0,0) scale(1); } to { transform: translate(3vw, -5vw) scale(1.08); } }

.grid-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(155,92,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(155,92,255,0.06) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, rgba(0,0,0,0.85), transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, rgba(0,0,0,0.85), transparent 75%);
}

.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.scanline {
  position: fixed;
  left: 0; right: 0;
  height: 140px;
  top: -140px;
  z-index: 39;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(155,92,255,0.05) 45%, rgba(255,83,212,0.07) 55%, transparent);
  animation: scan 9s linear infinite;
}
@keyframes scan { 0% { transform: translateY(0); } 100% { transform: translateY(calc(100vh + 140px)); } }

.hidden { display: none !important; }

/* ===================== BOOT LOADER ===================== */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, filter 0.6s ease;
}
.loader.loader-hide {
  opacity: 0;
  filter: blur(14px);
  pointer-events: none;
}
.loader-bg { position: absolute; inset: 0; overflow: hidden; }
.loader-bg .blob-a { width: 50vw; height: 50vw; top: -10vw; left: -10vw; }
.loader-bg .blob-b { width: 40vw; height: 40vw; bottom: -14vw; right: -10vw; background: radial-gradient(circle, var(--magenta), transparent 70%); opacity: 0.3; }
.loader-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.loader-mark {
  position: relative;
  width: 110px; height: 110px;
  display: flex; align-items: center; justify-content: center;
}
.loader-ring { width: 110px; height: 110px; transform: rotate(-90deg); filter: drop-shadow(0 0 16px var(--violet)); }
.loader-ring-track { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 6; }
.loader-ring-fill {
  fill: none; stroke: url(#none); stroke: var(--violet); stroke-width: 6; stroke-linecap: round;
  stroke-dasharray: 314; stroke-dashoffset: 235;
  animation: loaderSpin 1.1s linear infinite;
}
@keyframes loaderSpin { to { transform: rotate(360deg); transform-origin: 60px 60px; } }
.loader-mark-icon {
  position: absolute;
  font-size: 30px;
  color: var(--violet-soft);
  animation: iconPulse 1.6s ease-in-out infinite;
  filter: drop-shadow(0 0 10px var(--violet));
}
@keyframes iconPulse { 0%,100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.12); opacity: 1; } }
.loader-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--text);
}
.loader-brand span {
  background: linear-gradient(90deg, var(--violet-soft), var(--magenta));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.loader-line {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
  min-height: 1.2em;
  letter-spacing: 0.02em;
}
.loader-bar-track {
  width: 220px; height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
}
.loader-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--violet), var(--magenta));
  box-shadow: 0 0 12px var(--violet);
  transition: width 0.35s ease;
}

/* ===================== DASHBOARD SHELL ===================== */
.dashboard {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 26px 16px;
  gap: 14px;
  opacity: 0;
  animation: dashIn 0.7s ease 0.15s forwards;
}
@keyframes dashIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Topbar ===== */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px; object-fit: cover; display: none;
  box-shadow: 0 0 0 1px var(--border), 0 0 18px rgba(155,92,255,0.4);
}
.brand-logo.loaded { display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--violet-soft), var(--magenta));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-tag { color: var(--text-faint); font-size: 11px; font-weight: 600; }

.ring-block { display: flex; align-items: center; gap: 18px; justify-self: center; perspective: 600px; }
.ring-wrap { position: relative; width: 108px; height: 108px; flex-shrink: 0; transition: transform 0.25s ease; transform-style: preserve-3d; }
.ring-wrap::before {
  content: "";
  position: absolute; inset: -14px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--violet), var(--magenta), var(--violet-2), var(--violet));
  filter: blur(18px);
  opacity: 0.55;
  animation: spin 6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ring { position: relative; width: 108px; height: 108px; transform: rotate(-90deg); filter: drop-shadow(0 0 10px var(--dot-color, var(--violet))); }
.ring-track { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 9; }
.ring-fill {
  fill: none; stroke: var(--dot-color, var(--violet)); stroke-width: 9; stroke-linecap: round;
  stroke-dasharray: 339.3; stroke-dashoffset: 339.3;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.65,0,0.35,1), stroke 0.5s ease;
}
.ring-fill.indeterminate { stroke-dashoffset: 260; animation: ringSpin 1.3s linear infinite; }
@keyframes ringSpin { to { transform: rotate(360deg); transform-origin: 70px 70px; } }
.ring-fill.pulse-flash { animation: ringFlash 0.7s ease; }
@keyframes ringFlash { 0% { filter: drop-shadow(0 0 4px var(--dot-color)); } 40% { filter: drop-shadow(0 0 20px var(--dot-color)); } 100% { filter: drop-shadow(0 0 4px var(--dot-color)); } }
.ring-core { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.counter-big { font-family: var(--font-display); font-size: 22px; font-weight: 800; color: var(--text); transition: color 0.4s ease; }

.ring-text { text-align: left; max-width: 340px; }
.overall-headline {
  font-family: var(--font-display);
  font-size: clamp(14px, 1.5vw, 17px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 8px;
  transition: color 0.4s ease;
}
.quick-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.q-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  backdrop-filter: blur(8px);
}

.topbar-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; justify-self: end; }
.streak-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(60,242,149,0.1); border: 1px solid rgba(60,242,149,0.32);
  color: var(--ok); padding: 4px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.meta-row {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  display: flex; align-items: center; gap: 8px;
}
.meta-row .dot { opacity: 0.4; }
.live-indicator { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 700; font-size: 12px; font-family: var(--font-mono); }
.live-indicator.offline { color: var(--down); }
.live-indicator.offline .pulse { background: var(--down); animation: none; box-shadow: 0 0 8px var(--down); }
.pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 0 rgba(60,242,149,0.6);
  animation: pulse 1.8s infinite;
}
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(60,242,149,0.5); } 70% { box-shadow: 0 0 0 7px rgba(60,242,149,0); } 100% { box-shadow: 0 0 0 0 rgba(60,242,149,0); } }

/* ===== Skeleton ===== */
.skeleton {
  display: inline-block;
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.12) 37%, rgba(255,255,255,0.05) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.6s ease infinite;
  border-radius: 6px;
}
.skeleton-headline { width: min(260px, 40vw); height: 1em; }
.core-card.skeleton-card {
  background: linear-gradient(90deg, rgba(255,255,255,0.025) 25%, rgba(255,255,255,0.05) 37%, rgba(255,255,255,0.025) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.6s ease infinite;
  border-color: var(--border);
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ===================== MAIN GRID (no page scroll) ===================== */
.main-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 14px;
}
.left-col { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.panel-label {
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.eyebrow { background: linear-gradient(90deg, var(--violet), var(--magenta)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Core grid: 2x2 compact */
.core-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.core-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
  opacity: 0;
  animation: cardIn 0.5s ease forwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.core-card:hover { transform: translateY(-2px); border-color: var(--dot-color, var(--border-hover)); box-shadow: 0 10px 26px -12px rgba(155,92,255,0.4); }
.core-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--dot-color, var(--text-dim)); box-shadow: 0 0 10px var(--dot-color, transparent); }
.core-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.core-card-name { font-weight: 700; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot-color, var(--text-dim)); box-shadow: 0 0 8px var(--dot-color, transparent); }
.status-dot.live { animation: dotPulse 1.8s infinite; }
@keyframes dotPulse { 0% { box-shadow: 0 0 0 0 var(--dot-color); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.core-card-value { font-size: 13px; font-weight: 700; line-height: 1.35; font-family: var(--font-mono); }
.core-card-extra { color: var(--text-faint); font-weight: 500; font-size: 10.5px; font-family: var(--font-body); }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Resources */
.resources-card { flex-shrink: 0; }
.res-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.res-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px; transition: border-color 0.25s ease; }
.res-item:hover { border-color: var(--border-hover); }
.res-item .label { font-size: 9.5px; color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 4px; }
.res-item .value { font-family: var(--font-mono); font-size: 14px; font-weight: 700; background: linear-gradient(90deg, var(--violet-soft), var(--magenta)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ===== Modules panel: fills remaining space, dense grid ===== */
.modules-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.modules-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 10px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hover) transparent;
}
.modules-grid::-webkit-scrollbar { width: 6px; }
.modules-grid::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 999px; }

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  backdrop-filter: blur(10px);
  transition: border-color 0.25s ease, transform 0.25s ease;
  opacity: 0;
  animation: cardIn 0.45s ease forwards;
  animation-delay: calc(var(--i, 0) * 45ms);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.module-card:hover { transform: translateY(-1px); border-color: var(--border-hover); }
.module-card-title { font-weight: 700; font-size: 11.5px; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; color: var(--text); flex-shrink: 0; }
.module-list { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.module-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-faint); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.module-row.ok { color: var(--text-dim); }
.module-row .status-dot { width: 5px; height: 5px; flex-shrink: 0; }

/* ===================== Responsive ===================== */
@media (max-width: 900px) {
  html, body { height: auto; overflow: auto; }
  .dashboard { height: auto; padding: 14px 16px 20px; }
  .topbar { grid-template-columns: 1fr; text-align: center; gap: 12px; }
  .ring-block { flex-direction: column; justify-self: center; }
  .ring-text { text-align: center; }
  .quick-strip { justify-content: center; }
  .topbar-meta { align-items: center; }
  .main-grid { grid-template-columns: 1fr; }
  .core-grid { grid-template-columns: 1fr 1fr; }
  .modules-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    grid-auto-rows: auto;
    max-height: 52vh;
  }
  .module-list { overflow: visible; }
  .module-row { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  #particles, .scanline { display: none; }
}
