/* Dashboard (signed-in view) and the login -> dashboard transition. */

.dash {
  position: fixed;
  inset: 0;
  display: flex;
  gap: 18px;
  padding: 18px;
  --tile: rgba(24, 24, 31, 0.62);
  --tile-edge: rgba(255, 255, 255, 0.08);
  --c1: #9b74e6; /* CPU / primary */
  --c2: #5ad1c4; /* GPU */
  --c3: #f2b866; /* memory */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}
/* Backdrop on its own layer so the login transition can fade it in separately from the tiles. */
.dash::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(1200px 700px at 15% 0%, rgba(123, 79, 209, 0.16), transparent 60%), rgba(6, 6, 9, 0.74);
  pointer-events: none;
}

/* ---- side rail ---- */

.rail {
  flex: none;
  width: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 16px 0;
  border-radius: 24px;
  background: rgba(8, 8, 11, 0.82);
  border: 1px solid var(--tile-edge);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  z-index: 5;
}
.rail-logo { border-radius: 11px; }
.rail-items { display: flex; flex-direction: column; gap: 8px; }
.rail-bottom { margin-top: auto; }

.rail-btn {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  transition: background 0.25s, transform 0.25s var(--spring);
}
.rail-btn .ico { width: 20px; height: 20px; stroke: rgba(241, 241, 244, 0.55); transition: stroke 0.2s; }
.rail-btn:hover { background: rgba(255, 255, 255, 0.06); transform: scale(1.06); }
.rail-btn:hover .ico { stroke: var(--text); }
.rail-btn.active { background: linear-gradient(145deg, #8f63e0, #6a3fc4); box-shadow: 0 6px 18px rgba(123, 79, 209, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.rail-btn.active .ico { stroke: #fff; }
.rail-btn.active::before {
  content: "";
  position: absolute;
  right: -13px;
  width: 4px;
  height: 18px;
  border-radius: 4px;
  background: var(--c1);
  box-shadow: 0 0 10px var(--c1);
}
#btn-logout:hover { background: rgba(255, 107, 107, 0.12); }
#btn-logout:hover .ico { stroke: #ff8f8f; }

.rail-btn::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 14px);
  top: 50%;
  transform: translate(-6px, -50%);
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(15, 15, 20, 0.95);
  border: 1px solid var(--tile-edge);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.25s var(--spring);
  z-index: 10;
}
.rail-btn:hover::after { opacity: 1; transform: translate(0, -50%); }

/* ---- grid ---- */

.dash-scroll { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; border-radius: 22px; padding: 2px 4px 2px 2px; }

.dash-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(270px, 0.95fr);
  grid-template-areas:
    "hero  hero  hero  clock"
    "cpu   ram   gpur  sys"
    "perf  perf  cores sys"
    "perf  perf  cores act"
    "gpu   stor  net   act";
}
#tile-hero { grid-area: hero; }
#tile-cpu { grid-area: cpu; }
#tile-ram { grid-area: ram; }
#tile-gpuring { grid-area: gpur; }
#tile-perf { grid-area: perf; }
#tile-cores { grid-area: cores; }
#tile-gpu { grid-area: gpu; }
#tile-storage { grid-area: stor; }
#tile-net { grid-area: net; }
#tile-clock { grid-area: clock; }
#tile-sys { grid-area: sys; }
#tile-activity { grid-area: act; }

@media (max-width: 1180px) {
  .dash-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "hero  hero  clock"
      "cpu   ram   gpur"
      "perf  perf  cores"
      "gpu   stor  net"
      "sys   act   act";
  }
}
@media (max-width: 820px) {
  .dash { padding: 10px; gap: 10px; }
  .rail { width: 56px; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "hero" "clock" "cpu" "ram" "gpur" "perf" "cores" "gpu" "stor" "net" "sys" "act"; }
  .hero-text { max-width: 100%; }
  .swirl { opacity: 0.35; }
}

.tile {
  position: relative;
  min-width: 0;
  padding: 18px 20px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 40%), var(--tile);
  border: 1px solid var(--tile-edge);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: border-color 0.3s, box-shadow 0.3s, translate 0.35s var(--spring);
}
.tile:hover { border-color: rgba(255, 255, 255, 0.14); translate: 0 -3px; box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.07); }
.tile.flash { animation: flash 1.1s ease; }
@keyframes flash { 0%, 100% { border-color: var(--tile-edge); } 25% { border-color: rgba(155, 116, 230, 0.9); box-shadow: 0 0 0 3px rgba(155, 116, 230, 0.25), 0 18px 40px rgba(0, 0, 0, 0.45); } }

.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.tile-head > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-head .ico { width: 18px; height: 18px; }
.tile-foot { margin: 10px 0 0; font-size: 12px; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muted-sm { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
b[data-num] { font-variant-numeric: tabular-nums; }

/* ---- hero ---- */

.hero {
  display: flex;
  align-items: center;
  overflow: hidden;
  min-height: 178px;
  padding: 24px 28px;
  background: linear-gradient(115deg, rgba(123, 79, 209, 0.55), rgba(88, 52, 170, 0.35) 45%, rgba(40, 26, 80, 0.35)), var(--tile);
  border-color: rgba(171, 140, 240, 0.28);
}
.hero-text { position: relative; z-index: 1; max-width: 64%; }
.eyebrow { margin: 0 0 4px; font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; color: rgba(241, 241, 244, 0.7); }
.hero h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: 0.2px; }
.hero-status { margin: 6px 0 16px; color: rgba(241, 241, 244, 0.8); transition: opacity 0.3s; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; font-size: 12px; background: rgba(0, 0, 0, 0.28); border: 1px solid rgba(255, 255, 255, 0.12); max-width: 100%; }
.chip > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .ico.sm { stroke: rgba(241, 241, 244, 0.75); }
.swirl {
  position: absolute;
  right: -40px;
  top: 50%;
  width: 300px;
  height: 300px;
  translate: 0 -50%;
  opacity: 0.95;
  animation: spin 70s linear infinite;
  will-change: rotate;
  pointer-events: none;
}
/* Static glow behind the swirl. A filter on the rotating image would re-render it every frame. */
.hero::after {
  content: "";
  position: absolute;
  right: -10px;
  top: 50%;
  width: 260px;
  height: 260px;
  translate: 0 -50%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(155, 116, 230, 0.45), rgba(155, 116, 230, 0) 68%);
  pointer-events: none;
}
.swirl { z-index: 1; }
@keyframes spin { to { rotate: 360deg; } }

/* ---- rings ---- */

.ring-tile { display: flex; flex-direction: column; }
.ring { position: relative; width: 132px; height: 132px; margin: 2px auto 0; }
.ring svg { width: 100%; height: 100%; rotate: -90deg; overflow: visible; }
.ring-track { fill: none; stroke: rgba(255, 255, 255, 0.07); stroke-width: 9; }
.ring-bar { fill: none; stroke-width: 9; stroke-linecap: round; stroke-dasharray: 263.9; stroke-dashoffset: 263.9; }
[data-ring="cpu"] .ring-bar { stroke: var(--c1); filter: drop-shadow(0 0 6px rgba(155, 116, 230, 0.6)); }
[data-ring="mem"] .ring-bar { stroke: var(--c3); filter: drop-shadow(0 0 6px rgba(242, 184, 102, 0.5)); }
[data-ring="gpu"] .ring-bar { stroke: var(--c2); filter: drop-shadow(0 0 6px rgba(90, 209, 196, 0.5)); }
.ring-val { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 1px; }
.ring-val b { font-size: 30px; font-weight: 700; }
.ring-val small { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ---- performance chart ---- */

.perf { display: flex; flex-direction: column; min-height: 330px; }
.tabs { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--tile-edge); }
.tab { border: 0; background: transparent; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 500; color: var(--muted); cursor: pointer; transition: background 0.25s, color 0.25s; }
.tab:hover { color: var(--text); }
.tab.active { background: rgba(255, 255, 255, 0.12); color: var(--text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--muted); margin: -2px 0 8px; min-height: 18px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-wrap { position: relative; flex: 1; min-height: 220px; }
.chart-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }

/* ---- cores ---- */

.cores { display: flex; flex-direction: column; }
.bars { flex: 1; display: flex; align-items: stretch; gap: 6px; min-height: 200px; padding-top: 4px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.bar-track { position: relative; width: 100%; max-width: 26px; flex: 1; border-radius: 9px; background: rgba(255, 255, 255, 0.05); overflow: hidden; }
.bar-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; border-radius: 9px; background: linear-gradient(180deg, #b997f5, #6a3fc4); box-shadow: 0 0 12px rgba(155, 116, 230, 0.45); }
.bar.peak .bar-fill { background: linear-gradient(180deg, #ece2ff, #9b74e6); }
.bar small { font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---- GPU detail ---- */

.gauge { position: relative; width: 170px; margin: 0 auto 6px; }
.gauge svg { width: 100%; display: block; overflow: visible; }
.gauge-track, .gauge-bar { fill: none; stroke-width: 10; stroke-linecap: round; }
.gauge-track { stroke: rgba(255, 255, 255, 0.07); }
.gauge-bar { stroke: var(--c2); stroke-dasharray: 157.1; stroke-dashoffset: 157.1; filter: drop-shadow(0 0 6px rgba(90, 209, 196, 0.5)); transition: stroke 0.6s; }
.gauge-bar.hot { stroke: #ff9b5c; filter: drop-shadow(0 0 6px rgba(255, 155, 92, 0.6)); }
.gauge-val { position: absolute; left: 0; right: 0; bottom: -2px; text-align: center; }
.gauge-val b { font-size: 26px; font-weight: 700; }
.gauge-val small { color: var(--muted); font-size: 12px; margin-left: 2px; }

.meter { margin: 8px 0 12px; }
.meter-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.meter-head span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }
.meter-track { height: 7px; border-radius: 99px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.meter-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #3fb6a8, var(--c2)); box-shadow: 0 0 10px rgba(90, 209, 196, 0.5); }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini-stats div { display: flex; align-items: baseline; justify-content: center; gap: 4px; padding: 8px 4px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); }
.mini-stats .ico.sm { align-self: center; stroke: var(--muted); }
.mini-stats b { font-size: 15px; }
.mini-stats small { font-size: 11px; color: var(--muted); }

/* ---- storage ---- */

.drives { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.drive-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin-bottom: 7px; gap: 8px; }
.drive-head b { font-size: 14px; }
.drive-head span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.drive .meter-fill { background: linear-gradient(90deg, #6a3fc4, var(--c1)); box-shadow: 0 0 10px rgba(155, 116, 230, 0.5); }
.drive .meter-fill.warn { background: linear-gradient(90deg, #c2552f, #ff8b5c); box-shadow: 0 0 10px rgba(255, 139, 92, 0.5); }
.drive.skeleton { min-height: 34px; }
.io-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); padding-top: 12px; border-top: 1px solid var(--tile-edge); }
.io-row span { white-space: nowrap; }
.io-row b { color: var(--text); font-weight: 600; margin-left: 4px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.dot.read { background: var(--c2); box-shadow: 0 0 8px var(--c2); }
.dot.write { background: var(--c1); box-shadow: 0 0 8px var(--c1); }

/* ---- network ---- */

.net-now { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.net-now > div { padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.net-label { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); }
.net-now b { font-size: 17px; font-weight: 700; white-space: nowrap; }
.net-now > div:first-child .ico.sm { stroke: var(--c2); }
.net-now > div:last-child .ico.sm { stroke: var(--c1); }
.spark { display: block; width: 100%; height: 70px; margin-top: 12px; }

/* ---- clock ---- */

.clock { display: flex; flex-direction: column; justify-content: center; }
.clock-time { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.clock-time > span:first-child { font-size: 46px; font-weight: 700; letter-spacing: 1px; line-height: 1; }
.clock-s { font-size: 20px; color: var(--c1); font-weight: 600; margin-left: -6px; }
.clock-p { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.clock-date { margin: 6px 0 14px; color: var(--muted); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.day { padding: 7px 0; border-radius: 12px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.day b { font-size: 14px; color: var(--text); font-weight: 600; }
.day.today { background: linear-gradient(160deg, #8f63e0, #5b36ad); color: rgba(255, 255, 255, 0.85); box-shadow: 0 6px 16px rgba(123, 79, 209, 0.45); }

/* ---- system list ---- */

.sys-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sys-list li { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.03); transition: background 0.2s; }
.sys-list li:hover { background: rgba(255, 255, 255, 0.06); }
.sys-ico { flex: none; width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: rgba(155, 116, 230, 0.14); }
.sys-ico .ico { stroke: #c4a8f7; }
.sys-txt { min-width: 0; display: flex; flex-direction: column; }
.sys-txt small { font-size: 11px; color: var(--muted); }
.sys-txt span { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.skeleton { position: relative; overflow: hidden; min-height: 52px; background: rgba(255, 255, 255, 0.04) !important; border-radius: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; translate: -100% 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.07), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { translate: 100% 0; } }

/* ---- activity ---- */

.live { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--ok); }
/* The pulse animates only transform/opacity: animating box-shadow forced a full repaint every frame (~30% GPU). */
.live i { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.live i::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--ok); animation: pulse 1.8s ease-out infinite; will-change: transform, opacity; }
@keyframes pulse { from { transform: scale(1); opacity: 0.7; } to { transform: scale(2.8); opacity: 0; } }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.feed li { display: flex; gap: 11px; align-items: flex-start; padding: 8px 6px; border-radius: 12px; animation: feed-in 0.6s var(--spring); }
.feed li + li { border-top: 1px solid rgba(255, 255, 255, 0.04); }
.feed .fdot { flex: none; width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--c1); box-shadow: 0 0 8px var(--c1); }
.feed .fdot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.feed .fdot.warn { background: #ffb15c; box-shadow: 0 0 8px #ffb15c; }
.feed .ftxt { flex: 1; min-width: 0; font-size: 12.5px; }
.feed .ftxt small { display: block; color: var(--faint); font-size: 11px; margin-top: 1px; }
@keyframes feed-in { from { opacity: 0; transform: translateX(-12px) scale(0.97); } }

/* ---- login -> dashboard transition ---- */

.transit-square {
  position: fixed;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(22px);
  z-index: 50;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .swirl, .live i::after, .skeleton::after { animation: none; }
}
