:root {
  --bg: #07080b;
  --panel: rgba(19, 21, 27, .82);
  --panel-2: rgba(255, 255, 255, .055);
  --text: #f8fafc;
  --soft: #cbd5e1;
  --muted: #64748b;
  --line: rgba(255, 255, 255, .1);
  --line-2: rgba(255, 255, 255, .16);
  --accent: #e2e8f0;
  --accent-rgb: 226, 232, 240;
  --ok: #4ade80;
  --warn: #facc15;
  --bad: #fb7185;
  --shadow: 0 28px 90px rgba(0, 0, 0, .42);
  --radius: 24px;
}

:root[data-accent="blue"] { --accent: #60a5fa; --accent-rgb: 96, 165, 250; }
:root[data-accent="violet"] { --accent: #a78bfa; --accent-rgb: 167, 139, 250; }
:root[data-accent="green"] { --accent: #34d399; --accent-rgb: 52, 211, 153; }
:root[data-accent="orange"] { --accent: #fb923c; --accent-rgb: 251, 146, 60; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% -10%, rgba(var(--accent-rgb), .22), transparent 34rem),
    radial-gradient(circle at 90% 12%, rgba(148, 163, 184, .14), transparent 26rem),
    linear-gradient(135deg, #06070a 0%, #0b0d12 42%, #08090d 100%);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button {
  border: 1px solid rgba(var(--accent-rgb), .24);
  border-radius: 11px;
  padding: 10px 13px;
  color: var(--text);
  background: rgba(var(--accent-rgb), .1);
  font-weight: 850;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, opacity .16s ease;
  box-shadow: none;
}
button:hover { background: rgba(var(--accent-rgb), .16); border-color: rgba(var(--accent-rgb), .34); }
button:disabled { opacity: .48; cursor: not-allowed; }

input, select {
  width: 100%;
  min-width: 0;
  padding: 12px 13px;
  border-radius: 15px;
  border: 1px solid var(--line);
  outline: 0;
  color: var(--text);
  color-scheme: dark;
  background: rgba(4, 6, 11, .56);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input::placeholder { color: #475569; }
input:focus, select:focus {
  border-color: rgba(var(--accent-rgb), .55);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .08);
  background: rgba(4, 6, 11, .72);
}
select option { background: #0f1117; color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: clamp(30px, 5vw, 52px); line-height: .96; letter-spacing: -.06em; }
h2 { margin: 0; font-size: 21px; letter-spacing: -.035em; }
h3 { margin-bottom: 7px; letter-spacing: -.02em; }

.shell { display: grid; grid-template-columns: 292px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(8, 10, 14, .74);
  backdrop-filter: blur(22px);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark, .login-mark {
  display: grid;
  place-items: center;
  color: #08090d;
  background: linear-gradient(145deg, #fff, var(--accent));
  font-weight: 950;
}
.brand-mark { width: 44px; height: 44px; border-radius: 15px; box-shadow: 0 18px 40px rgba(var(--accent-rgb), .18); }
.brand strong { display: block; font-size: 15px; letter-spacing: -.03em; }

.side-nav { display: grid; gap: 8px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: flex-start;
  color: var(--soft);
  background: transparent;
  border-color: transparent;
}
.nav-item span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 10px; background: var(--panel-2); }
.nav-item:hover, .nav-item.active { color: var(--text); border-color: var(--line); background: rgba(255, 255, 255, .055); }
.nav-item.active span { color: #050608; background: var(--accent); }

.side-card {
  margin-top: auto;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
}
.side-card small { display: block; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.side-footer { display: grid; gap: 10px; }
.user-badge {
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05);
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.main { min-width: 0; padding: 28px clamp(18px, 4vw, 42px) 70px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 24px; }
.mobile-menu { display: none; }
.view { display: none; animation: rise .28s ease both; }
.view.active { display: block; }
.hidden { display: none !important; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.panel, .metric-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.panel { padding: 22px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(180px, .55fr); gap: 16px; margin-bottom: 18px; }
.metric-card { padding: 20px; min-height: 114px; overflow: hidden; }
.metric-card::after {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  right: -55px;
  bottom: -65px;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), .16);
  filter: blur(6px);
}
.metric-label, .field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .1em;
}
.games-metric strong { display: block; margin: 12px 0 0; font-size: clamp(26px, 4vw, 38px); letter-spacing: -.06em; }

.current-profile { display: flex; align-items: center; gap: 14px; margin-top: 14px; min-width: 0; }
.mini-avatar { width: 62px; height: 62px; padding: 2px; flex: 0 0 auto; border-radius: 18px; background: linear-gradient(145deg, var(--accent), rgba(255,255,255,.1)); }
.mini-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 16px; background: #0f1117; }
.profile-info-mini { min-width: 0; }
.profile-info-mini > strong { display: block; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(21px, 3vw, 30px); letter-spacing: -.045em; }
.inline-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 12px; font-weight: 750; }

.search-row, .button-row { display: flex; gap: 12px; align-items: end; }
.tools-section { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: end; }
.inline-count { min-height: 45px; display: flex; align-items: center; margin: 0; color: var(--muted); font-size: 12px; font-weight: 850; white-space: nowrap; }
.button-row { flex-wrap: wrap; align-items: center; margin-top: 14px; }
.grow { flex: 1; }
.field { display: grid; gap: 8px; min-width: 0; }
.field.mini { gap: 4px; }
.field.mini span { font-size: 8px; letter-spacing: .1em; }
.field.mini input, .field.mini select { min-height: 36px; padding: 8px 10px; border-radius: 11px; font-size: 12px; font-weight: 800; }
.message { min-height: 20px; margin: 13px 0 0; color: var(--muted); font-size: 13px; font-weight: 800; }
.message.loading, .row-status.loading { color: var(--accent); }
.message.success, .row-status.success { color: var(--ok); }
.message.warning, .row-status.warning { color: var(--warn); }
.message.error, .row-status.error { color: var(--bad); }
.center { text-align: center; }

.ghost { color: var(--text); background: rgba(var(--accent-rgb), .1); border-color: rgba(var(--accent-rgb), .24); }
.ghost:hover { background: rgba(var(--accent-rgb), .16); border-color: rgba(var(--accent-rgb), .34); }
.ghost.danger, .danger { color: #fecdd3; background: rgba(251, 113, 133, .1); border-color: rgba(251, 113, 133, .2); }
.small { padding: 8px 12px; border-radius: 12px; font-size: 12px; }

.status-badge {
  display: inline-flex;
  width: fit-content;
  padding: 7px 11px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, .055);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.status-badge.connected { color: var(--ok); background: rgba(74, 222, 128, .12); border-color: rgba(74, 222, 128, .24); }
.status-badge.disconnected { color: #fda4af; background: rgba(251, 113, 133, .11); border-color: rgba(251, 113, 133, .24); }

.custom-panel { padding: 0; overflow: hidden; }
.custom-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}
.custom-toggle:hover { background: rgba(255, 255, 255, .035); }
.custom-toggle small { display: block; margin-bottom: 8px; color: var(--accent); font-size: 11px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.custom-toggle strong { display: block; font-size: 21px; letter-spacing: -.035em; }
.custom-toggle b { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.custom-body { padding: 0 22px 22px; }
.custom-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(110px, .4fr) minmax(110px, .4fr) minmax(200px, .9fr); gap: 12px; align-items: end; }
.custom-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; margin-top: 12px; }
.custom-footer .row-status { min-height: 38px; }
.custom-footer button { min-width: 102px; }

.inline-games { margin-top: 14px; }
.games-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 10px; }
.game-card {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(20, 22, 29, .82), rgba(14, 16, 22, .78));
  box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.game-card:hover { transform: translateY(-1px); border-color: var(--line-2); box-shadow: 0 14px 34px rgba(0, 0, 0, .24); }
.game-side { display: grid; align-content: start; gap: 7px; min-width: 0; }
.game-art { width: 68px; height: 68px; border-radius: 14px; overflow: hidden; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.game-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.title-id {
  display: block;
  width: 68px;
  margin: 0;
  padding: 4px 5px;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 8px;
  color: var(--accent);
  background: rgba(var(--accent-rgb), .1);
  border: 1px solid rgba(var(--accent-rgb), .18);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 900;
}
.game-copy { min-width: 0; overflow: hidden; }
.game-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.game-top h3 { margin: 0 0 6px; font-size: 13px; line-height: 1.22; letter-spacing: -.025em; }
.last-played { margin: 0; color: var(--muted); font-size: 10px; font-weight: 750; }
.hours-pill { min-width: 54px; padding: 6px 7px; border-radius: 13px; text-align: center; color: var(--ok); background: rgba(74, 222, 128, .1); border: 1px solid rgba(74, 222, 128, .17); }
.hours-pill strong { display: block; font-size: 15px; line-height: 1; }
.hours-pill span { display: block; margin-top: 2px; font-size: 8px; font-weight: 900; text-transform: uppercase; }
.send-row { display: grid; grid-template-columns: minmax(78px, .58fr) minmax(140px, 1fr); gap: 7px; align-items: stretch; margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); }
.card-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(72px, auto) auto; gap: 7px; align-items: center; margin-top: 7px; }
.send-btn { min-height: 34px; min-width: 86px; width: auto; padding: 8px 12px; font-size: 12px; white-space: nowrap; }
.row-status {
  min-height: 34px;
  margin: 0;
  padding: 8px 10px;
  overflow: hidden;
  border-radius: 11px;
  background: rgba(255, 255, 255, .04);
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-status.success { background: rgba(74, 222, 128, .1); }
.row-status.warning { background: rgba(250, 204, 21, .09); }
.row-status.error { background: rgba(251, 113, 133, .1); }
.empty-card { grid-column: 1 / -1; padding: 32px 20px; text-align: center; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); }
.pager { display: flex; align-items: center; justify-content: center; gap: 9px; }
.top-pager { margin: 0 0 12px; }
.bottom-pager { margin: 12px 0 0; }
.pager span { min-width: 96px; text-align: center; color: var(--muted); font-size: 12px; font-weight: 900; }
.pager button { min-width: 96px; padding: 10px 13px; border-radius: 13px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-stack { display: grid; gap: 15px; }
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .045);
}
.toggle-row strong { display: block; margin-bottom: 4px; }
.toggle-row small { color: var(--muted); font-weight: 700; }
.toggle-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.token-link { display: inline-flex; margin: -4px 0 18px; font-weight: 850; }
#npssoInput { min-height: 58px; }

.login-body { display: grid; place-items: center; padding: 24px; overflow: hidden; }
.login-simple { width: min(430px, 100%); }
.simple-card { padding: 34px; }
.simple-card h1 { margin: 0 0 24px; font-size: 30px; letter-spacing: -.04em; text-align: center; }
.login-mark { width: 48px; height: 48px; margin: 0 auto 18px; border-radius: 16px; box-shadow: 0 18px 40px rgba(var(--accent-rgb), .18); }
.auth-form { display: grid; gap: 16px; }

.compact .games-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 9px; }
.compact .game-card { grid-template-columns: 60px minmax(0, 1fr); padding: 8px; gap: 8px; border-radius: 16px; }
.compact .game-art { width: 60px; height: 60px; border-radius: 12px; }
.compact .title-id { width: 60px; font-size: 8px; padding: 3px 4px; }
.compact .game-top h3 { font-size: 12px; }
.compact .last-played { font-size: 9px; }
.compact .hours-pill { min-width: 50px; padding: 5px 6px; }
.compact .hours-pill strong { font-size: 14px; }
.compact .send-row { margin-top: 8px; padding-top: 8px; gap: 6px; }
.compact .field.mini input, .compact .field.mini select { min-height: 34px; padding: 7px 9px; font-size: 11px; }
.compact .row-status, .compact .send-btn { min-height: 32px; }
.no-motion *, .no-motion *::before, .no-motion *::after { animation: none !important; transition: none !important; }
.no-motion button:hover, .no-motion .game-card:hover { transform: none; }

@media (max-width: 1100px) {
  .hero-grid, .settings-grid { grid-template-columns: 1fr; }
  .custom-grid { grid-template-columns: 1fr 1fr; }
  .custom-grid .field:last-child { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 292px;
    transform: translateX(-105%);
    transition: transform .2s ease;
    z-index: 20;
  }
  .sidebar-open .sidebar { transform: none; }
  .main { padding-top: 20px; }
  .mobile-menu { display: inline-flex; }
}

@media (max-width: 620px) {
  .topbar, .panel-head { flex-direction: column; align-items: stretch; }
  .search-row, .button-row { flex-direction: column; align-items: stretch; }
  .button-row { gap: 10px; margin-top: 16px; }
  .tools-section { grid-template-columns: 1fr; align-items: stretch; }
  .inline-count { min-height: 0; align-items: flex-start; white-space: normal; }
  .custom-grid, .custom-footer { grid-template-columns: 1fr; }
  .custom-grid .field:last-child { grid-column: auto; }
  .games-grid, .compact .games-grid { grid-template-columns: 1fr; gap: 11px; }
  .game-card, .compact .game-card { grid-template-columns: 58px minmax(0, 1fr); padding: 9px; }
  .game-art, .compact .game-art { width: 58px; height: 58px; border-radius: 12px; }
  .title-id, .compact .title-id { width: 58px; font-size: 8px; padding: 3px 4px; }
  .game-top { gap: 7px; }
  .game-top h3 { font-size: 12px; }
  .last-played { font-size: 9px; }
  .hours-pill { min-width: 48px; padding: 5px 6px; }
  .hours-pill strong { font-size: 14px; }
  .send-row { grid-template-columns: 1fr; gap: 6px; margin-top: 8px; padding-top: 8px; }
  .card-actions { gap: 6px; }
  .row-status, .send-btn { min-height: 32px; }
  .send-btn { min-width: 78px; }
  .pager { display: grid; grid-template-columns: 1fr; }
  .pager button, button { width: 100%; }
  .ghost.small { width: auto; }
  .current-profile { align-items: flex-start; }
  .profile-info-mini > strong { white-space: normal; }
  .simple-card { padding: 26px; }
}