/* Sparky site layout — plain CSS on top of tokens.css. Mobile-first &
   responsive by construction (auto-fit grids + an off-canvas nav drawer).
   A product of ChargedStudios.dev. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg-0); color: var(--fg-0); font-family: var(--font-sans); }
a { color: inherit; text-decoration: none; }

/* ── App frame ───────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* Server rail (always visible, narrow) */
.rail {
  width: 60px; flex-shrink: 0; background: var(--bg-0);
  border-right: 1px solid var(--line-1);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 0;
}
.rail a, .rail button {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--fg-1); display: grid; place-items: center;
  cursor: pointer; font-weight: 700; font-size: 13px;
}
.rail a.active { border-color: var(--line-hot); box-shadow: var(--glow-cyan-sm); color: var(--fg-0); }
.rail a { position: relative; text-decoration: none; }
.rail a img.srv-ico { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.rail a.addable { opacity: .45; border-style: dashed; }
.rail a.addable:hover { opacity: 1; border-color: var(--line-hot); }
.rail a .add-badge { position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--c-500); color: #042027; font: 800 11px/1 var(--font-sans); display: grid; place-items: center; }
.rail a.add-new { border-style: dashed; color: var(--c-300); font-size: 20px; font-weight: 400; }
.rail a.add-new:hover { border-color: var(--line-hot); background: var(--bg-3); color: var(--fg-0); }

/* Section nav — drawer on mobile, column on desktop */
.drawer {
  position: fixed; inset: 0 auto 0 60px; width: 248px; z-index: 40;
  background: var(--bg-1); border-right: 1px solid var(--line-1);
  transform: translateX(-110%); transition: transform .2s ease;
  overflow-y: auto; padding-bottom: 24px;
}
.app.nav-open .drawer { transform: translateX(0); }
.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 35;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.app.nav-open .scrim { opacity: 1; pointer-events: auto; }

.drawer .srv { display: flex; align-items: center; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line-1); }
.drawer nav { display: flex; flex-direction: column; gap: 2px; padding: 8px; }
.drawer .sec { padding: 14px 10px 6px; font: 500 10px/1 var(--font-mono); text-transform: uppercase; letter-spacing: .12em; color: var(--fg-3); }
.drawer a.nav {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--fg-1); font-size: 13px; font-weight: 500;
}
.drawer a.nav:hover { background: var(--bg-3); color: var(--fg-0); }
.drawer a.nav.active { background: linear-gradient(90deg, rgba(34,211,238,.12), transparent); color: var(--fg-0); box-shadow: inset 2px 0 0 var(--c-400); }
.drawer a.nav .badge { margin-left: auto; font: 500 10px/1 var(--font-mono); padding: 2px 6px; border-radius: 4px; background: var(--bg-3); color: var(--fg-2); }

/* Main column */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 56px; padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-glass); backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line-1);
}
.topbar .crumbs { font-size: 14px; color: var(--fg-1); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.hamburger { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--fg-1); cursor: pointer; }

.content { padding: 20px 16px 64px; max-width: 1240px; width: 100%; margin: 0 auto; }

/* ── Reusable bits ───────────────────────────────────────────────────────── */
.page-head { padding: 4px 4px 18px; border-bottom: 1px solid var(--line-1); margin-bottom: 20px; }
.page-head h1 { margin: 0; font: 700 26px/1.05 var(--font-display); letter-spacing: -.03em; }
.page-head .sub { margin: 8px 0 0; color: var(--fg-2); font-size: 14px; }

/* Auto-reflowing grids — responsive WITHOUT media queries */
.grid { display: grid; gap: 14px; }
.grid.stats   { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.cards   { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.two     { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.tile { background: var(--bg-2); border: 1px solid var(--line-1); border-radius: var(--r-5); padding: 16px; box-shadow: var(--shadow-card); }
.tile .k { font: 500 11px/1 var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--fg-3); }
.tile .v { font: 700 26px/1 var(--font-display); margin-top: 10px; }
.tile .d { font-size: 12px; color: var(--fg-2); margin-top: 6px; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--fg-2); }
.skeleton { background: linear-gradient(90deg, var(--bg-2), var(--bg-3), var(--bg-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--r-4); }
.toast-wrap { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow-pop); }
.toast.err { border-color: rgba(239,68,68,.4); color: #fca5a5; }
.toast.ok  { border-color: rgba(16,185,129,.4); color: var(--ok-400); }

/* ── Desktop: drawer becomes a static column ─────────────────────────────── */
@media (min-width: 980px) {
  .hamburger { display: none; }
  .drawer { position: static; transform: none; width: 248px; inset: auto; }
  .scrim { display: none; }
}

/* ── Login ───────────────────────────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: 100%; max-width: 420px; text-align: center; }
.auth .logo { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 18px; display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(34,211,238,.18), rgba(139,92,246,.18)); border: 1px solid var(--line-hot); box-shadow: var(--glow-cyan-sm); }
