/* Pulse dashboard — base, layout & shell */
:root {
  --side-w: 256px;
  --side-w-collapsed: 72px;
  --top-h: 64px;
  --panel: rgba(17, 21, 38, 0.72);
  --panel-2: rgba(25, 30, 52, 0.66);
  --field-bg: rgba(8, 10, 20, 0.55);
  --tone-violet: var(--violet-2);
  --tone-mint: var(--mint);
  --tone-sky: var(--sky);
  --tone-amber: var(--amber);
  --tone-ember: var(--ember);
  --tone-dim: var(--text-3);
}

html { scrollbar-color: var(--ink-600) transparent; }
body {
  min-height: 100vh;
  background:
    radial-gradient(900px 520px at 12% -10%, rgba(124, 92, 255, .16), transparent 70%),
    radial-gradient(700px 420px at 100% 0%, rgba(76, 201, 255, .07), transparent 70%),
    var(--ink-900);
  background-attachment: fixed;
  overflow-x: hidden;
  font-size: 15px;
}
body.modal-open { overflow: hidden; }
img { max-width: 100%; }
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0; }
code, .mono { font-family: var(--font-mono); font-size: .92em; }
code { background: rgba(160, 170, 255, .1); padding: .08em .38em; border-radius: 6px; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.grow { flex: 1; }
.center { text-align: center; margin-top: 16px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--mint); color: var(--ink-950); padding: 8px 14px; border-radius: var(--r-sm); font-weight: 700; }
.skip-link:focus { top: 12px; }
[hidden] { display: none !important; }

/* boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-mark path { stroke-dasharray: 120; stroke-dashoffset: 120; animation: draw 1.4s var(--ease-out) infinite; }
@keyframes draw { 60%, 100% { stroke-dashoffset: 0; } }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns var(--dur-2) var(--ease-out); }
.shell.collapsed { grid-template-columns: var(--side-w-collapsed) minmax(0, 1fr); }
.main { min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; outline: none; padding: 28px clamp(16px, 3vw, 40px) 120px; min-width: 0; }
.page { max-width: 1320px; margin: 0 auto; min-width: 0; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: linear-gradient(180deg, rgba(14, 17, 32, .92), rgba(9, 11, 22, .92));
  backdrop-filter: blur(14px); z-index: 30; min-width: 0;
}
.side-head { display: flex; align-items: center; gap: 8px; height: var(--top-h); padding: 0 14px 0 18px; border-bottom: 1px solid var(--line); flex: none; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.side-head .brand { flex: 1; min-width: 0; }
.collapse-btn svg { transition: transform var(--dur-2) var(--ease-out); }
.shell.collapsed .collapse-btn svg { transform: rotate(180deg); }
.icon-btn.drawer-close { display: none; }
.nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 10px 16px; scrollbar-width: thin; }
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-group { margin-top: 14px; }
.nav-heading { font: 600 12px/1 var(--font-body); color: var(--text-3); padding: 0 12px 8px; letter-spacing: .02em; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 7px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 600; font-size: 14px; position: relative; white-space: nowrap;
  transition: background var(--dur-1), color var(--dur-1);
}
.nav-link:hover { background: rgba(160, 170, 255, .07); color: var(--text); text-decoration: none; }
.nav-link.active { background: rgba(124, 92, 255, .16); color: var(--text); }
.nav-link.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad-signal); }
.nav-link .ic { flex: none; opacity: .9; }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.mod-state { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.mod-state.on { background: var(--mint); box-shadow: 0 0 0 3px rgba(61, 245, 176, .14); }
.mod-state.off { background: transparent; border: 1.5px solid var(--text-3); }
.side-foot { padding: 12px 18px; border-top: 1px solid var(--line); min-height: 52px; display: flex; align-items: center; }
.shell.collapsed .brand-word, .shell.collapsed .nav-label, .shell.collapsed .nav-heading, .shell.collapsed .side-foot .badge { display: none; }
.shell.collapsed .side-head { padding: 0 10px; justify-content: center; flex-direction: column; gap: 2px; height: auto; min-height: var(--top-h); padding-top: 10px; padding-bottom: 8px; }
.shell.collapsed .side-head .brand { flex: none; }
.shell.collapsed .nav-link { justify-content: center; padding: 10px; }
.shell.collapsed .nav-link .mod-state { position: absolute; right: 8px; top: 8px; width: 6px; height: 6px; }
.shell.collapsed .nav-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }

.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 12px;
  padding: 0 clamp(12px, 3vw, 32px); border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 22, .78); backdrop-filter: blur(14px);
}
.icon-btn.menu-btn { display: none; }
.scrim { display: none; }

/* live indicator */
.live { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(8, 10, 20, .5); font-size: 13px; font-weight: 600; white-space: nowrap; }
.hb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); position: relative; }
.live[data-state="live"] .hb-dot { background: var(--mint); }
.live[data-state="live"] .hb-dot::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--mint); opacity: 0; animation: ring 2.4s var(--ease-out) infinite; }
.live[data-state="reconnecting"] .hb-dot, .live[data-state="connecting"] .hb-dot { background: var(--amber); animation: blink 1s steps(2) infinite; }
.live[data-state="offline"] .hb-dot { background: var(--ember); }
.hb-dot.beat { animation: beat .5s var(--ease-spring); }
.hb-ping { color: var(--text-3); font-size: 12px; padding-left: 8px; border-left: 1px solid var(--line); }
.hb-ping:empty { display: none; }
@keyframes ring { 0% { transform: scale(.6); opacity: .8; } 70%, 100% { transform: scale(1.6); opacity: 0; } }
@keyframes blink { 50% { opacity: .3; } }
@keyframes beat { 0% { transform: scale(1); } 30% { transform: scale(1.8); } 60% { transform: scale(.9); } 100% { transform: scale(1); } }

/* switcher / user menu */
.menu-anchor { position: relative; min-width: 0; }
.switcher, .user-btn { display: flex; align-items: center; gap: 10px; background: transparent; border: 1px solid transparent; border-radius: 12px; padding: 5px 10px 5px 6px; font-weight: 700; min-width: 0; max-width: 100%; }
.switcher:hover, .user-btn:hover, .switcher[aria-expanded="true"], .user-btn[aria-expanded="true"] { background: rgba(160, 170, 255, .07); border-color: var(--line); }
.switcher-name { font-family: var(--font-display); font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-name { font-size: 14px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu {
  position: absolute; top: calc(100% + 8px); z-index: 50; min-width: 230px; padding: 6px;
  background: var(--ink-800); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .8); animation: pop var(--dur-2) var(--ease-out);
}
.menu-right { right: 0; } .menu-left { left: 0; }
.menu-wide { min-width: 280px; max-width: calc(100vw - 24px); }
.menu-head { display: flex; gap: 10px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-head div { display: grid; }
.menu-head .muted { font-size: 12px; }
.menu-label { font-size: 12px; color: var(--text-3); padding: 8px 10px 6px; font-weight: 600; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--text); font-weight: 600; font-size: 14px; }
.menu-item:hover, .menu-item:focus-visible { background: rgba(160, 170, 255, .09); text-decoration: none; outline-offset: -2px; }
.menu-item.current { color: var(--violet-2); }
.menu-item.dim { color: var(--text-2); }
.menu-item.danger { color: var(--ember); }
.menu-hint { font-size: 12px; color: var(--sky); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* avatars */
.avatar { border-radius: 50%; flex: none; object-fit: cover; background: var(--ink-700); }
.avatar-fb { display: inline-grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, hsl(var(--h) 70% 52%), hsl(calc(var(--h) + 40) 70% 38%)); letter-spacing: -.02em; font-family: var(--font-body); }
.g-icon { border-radius: 30%; }
.g-icon.avatar-fb { border-radius: 30%; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge-demo { color: var(--amber); background: rgba(255, 196, 77, .1); border: 1px solid rgba(255, 196, 77, .3); }
.badge-on { color: var(--mint); background: rgba(61, 245, 176, .1); }
.badge-off { color: var(--text-3); background: rgba(160, 170, 255, .08); }
.badge-warn { color: var(--amber); background: rgba(255, 196, 77, .1); }
.badge-danger { color: var(--ember); background: rgba(255, 93, 115, .12); }
.badge-sky { color: var(--sky); background: rgba(76, 201, 255, .1); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--mint); box-shadow: 0 0 10px var(--mint); }

/* ---------- responsive shell ---------- */
@media (max-width: 960px) {
  .shell, .shell.collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform var(--dur-2) var(--ease-out); box-shadow: 30px 0 80px -30px #000; }
  .shell.collapsed .brand-word, .shell.collapsed .nav-label, .shell.collapsed .nav-heading, .shell.collapsed .side-foot .badge { display: revert; }
  .shell.collapsed .nav-link { justify-content: flex-start; padding: 8px 12px; }
  .shell.collapsed .nav-link .mod-state { position: static; }
  .shell.collapsed .side-head { flex-direction: row; padding: 0 14px 0 18px; height: var(--top-h); }
  .shell.collapsed .nav-group { border-top: 0; margin-top: 18px; padding-top: 0; }
  .drawer-open .sidebar { transform: none; }
  .drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgba(3, 4, 10, .6); z-index: 25; animation: fade var(--dur-2); }
  .icon-btn.collapse-btn { display: none; }
  .icon-btn.drawer-close { display: inline-grid; }
  .icon-btn.menu-btn { display: inline-grid; }
  .content { padding-top: 20px; }
}
@media (max-width: 560px) {
  .topbar { gap: 6px; padding: 0 10px; }
  .user-name, .user-btn .ic-chevronDown { display: none; }
  .hb-label { display: none; }
  .live { padding: 6px 10px; }
  .switcher-name { max-width: 34vw; }
  .content { padding-left: 16px; padding-right: 16px; }
}
@keyframes fade { from { opacity: 0; } }
