/* ─────────────────────────────────────────
   Reset & Base
───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Palette */
  --bg-base:     #1b2838;
  --bg-elevated: #2a475e;
  --bg-card:     #1e3a4f;
  --bg-input:    #142030;
  --bg-hover:    #28526e;
  --bg-row-alt:  #1c3448;

  /* Text */
  --txt-primary:   #c7d5e0;
  --txt-secondary: #8f98a0;
  --txt-muted:     #4a7090;

  /* Accent */
  --accent:        #66c0f4;
  --accent-dark:   #4fa3d1;
  --accent-dim:    rgba(102, 192, 244, 0.12);
  --accent-glow:   rgba(102, 192, 244, 0.25);

  /* Status */
  --green:  #5ba85e;
  --yellow: #e2b96f;
  --red:    #c0392b;

  /* Structure */
  --border:    rgba(102, 192, 244, 0.10);
  --border-md: rgba(102, 192, 244, 0.20);
  --shadow:    0 6px 24px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);

  --r-sm: 4px;
  --r:    8px;
  --r-lg: 12px;

  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

html { scroll-behavior: smooth; color-scheme: dark; }

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--txt-primary);
  line-height: 1.55;
  min-height: 100vh;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─────────────────────────────────────────
   Header
───────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(27, 40, 56, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  color: var(--accent);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .5px;
}
.logo-icon { width: 22px; height: 22px; flex-shrink: 0; }

.search-form {
  display: flex;
  gap: 8px;
  flex: 1;
  max-width: 580px;
}

.search-input {
  flex: 1;
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-md);
  border-radius: var(--r-sm);
  color: var(--txt-primary);
  font: 13px/1 var(--font);
  outline: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--txt-muted); }

/* ─────────────────────────────────────────
   Buttons
───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--r-sm);
  font: 500 13px/1 var(--font);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.btn-sm { padding: 5px 11px; font-size: 12px; }

.btn-primary {
  background: var(--accent);
  color: #1b2838;
}
.btn-primary:hover { background: var(--accent-dark); }

.btn-ghost {
  background: transparent;
  color: var(--txt-secondary);
  border: 1px solid var(--border-md);
}
.btn-ghost:hover { background: var(--accent-dim); color: var(--txt-primary); border-color: var(--accent); }
.btn-ghost.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* ─────────────────────────────────────────
   Select / filter input
───────────────────────────────────────── */
.filter-input {
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-md);
  border-radius: var(--r-sm);
  color: var(--txt-primary);
  font: 13px/1 var(--font);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
.filter-input:focus { border-color: var(--accent); }
.filter-input::placeholder { color: var(--txt-muted); }
.filter-input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(.5) sepia(1) hue-rotate(180deg);
  cursor: pointer;
}

/* ── Custom Select ── */
.custom-select {
  position: relative;
  user-select: none;
  outline: none;
}

.custom-select__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-md);
  border-radius: var(--r-sm);
  color: var(--txt-primary);
  font: 13px/1 var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s;
}
.custom-select:focus .custom-select__trigger,
.custom-select.open  .custom-select__trigger { border-color: var(--accent); }

.custom-select__arrow {
  flex-shrink: 0;
  color: var(--txt-muted);
  transition: transform .15s;
}
.custom-select.open .custom-select__arrow { transform: rotate(180deg); }

.custom-select__dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-md);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  z-index: 300;
  overflow: hidden;
}
.custom-select.open .custom-select__dropdown { display: block; }

.custom-select__option {
  padding: 8px 14px;
  font: 13px/1 var(--font);
  color: var(--txt-secondary);
  cursor: pointer;
  transition: background .1s, color .1s;
}
.custom-select__option:hover             { background: var(--bg-hover); color: var(--txt-primary); }
.custom-select__option.selected          { color: var(--accent); }
.custom-select__option + .custom-select__option { margin-top: 2px; }

/* ─────────────────────────────────────────
   Layout utilities
───────────────────────────────────────── */
.hidden { display: none !important; }

.main-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

/* ─────────────────────────────────────────
   Empty State
───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 110px 24px;
  color: var(--txt-secondary);
}
.empty-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  color: var(--txt-muted);
}
.empty-state h2 { font-size: 22px; color: var(--txt-primary); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; }

/* ─────────────────────────────────────────
   Top Row — Profile + Stats
───────────────────────────────────────── */
.top-row {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  margin-bottom: 16px;
  align-items: end;
}

/* ─────────────────────────────────────────
   Profile Card
───────────────────────────────────────── */
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 160px;
}

.profile-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: var(--r);
  object-fit: cover;
  border: 2px solid var(--border-md);
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.profile-avatar-placeholder {
  width: 72px;
  height: 72px;
  border-radius: var(--r);
  background: var(--bg-elevated);
  border: 2px solid var(--border-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--txt-muted);
  font-size: 28px;
  flex-shrink: 0;
}

.profile-name-block { flex: 1; min-width: 0; }

.profile-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-realname {
  font-size: 12px;
  color: var(--txt-secondary);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  margin-top: 7px;
}
.status-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-online  { background: rgba(91,168,94,.18);  color: var(--green); }
.status-ingame  { background: rgba(102,192,244,.15); color: var(--accent); }
.status-offline { background: rgba(143,152,160,.12); color: var(--txt-secondary); }

/* Profile meta rows */
.profile-meta { display: flex; flex-direction: column; gap: 5px; }
.meta-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}
.meta-key {
  color: var(--txt-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  width: 76px;
  flex-shrink: 0;
}
.meta-val { color: var(--txt-secondary); word-break: break-all; }

.vac-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(192,57,43,.2);
  color: #e74c3c;
  margin-top: 4px;
}

.private-note {
  font-size: 12px;
  color: var(--yellow);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Skeleton loading */
.skeleton { background: var(--bg-elevated); border-radius: var(--r-sm); animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer {
  0%, 100% { opacity: .5; }
  50%       { opacity: 1;  }
}

/* ─────────────────────────────────────────
   Stats Grid
───────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  align-content: start;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  transition: border-color .15s;
}
.stat-card:hover { border-color: var(--border-md); }

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--txt-muted);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.stat-sub {
  font-size: 11px;
  color: var(--txt-muted);
  margin-top: 5px;
}

/* ─────────────────────────────────────────
   Card (generic section wrapper)
───────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.section-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─────────────────────────────────────────
   Live dot
───────────────────────────────────────── */
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: livepulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes livepulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(91,168,94,.6); }
  50%       { opacity: .7; box-shadow: 0 0 0 5px rgba(91,168,94,0); }
}

/* ─────────────────────────────────────────
   Active Sessions
───────────────────────────────────────── */
.active-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.active-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-md);
  border-radius: var(--r);
  padding: 10px 14px;
  min-width: 260px;
  max-width: 360px;
  transition: border-color .15s;
}
.active-card:hover { border-color: var(--accent); }

.active-thumb {
  width: 68px;
  height: 32px;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--bg-input);
  flex-shrink: 0;
}
.active-thumb-ph {
  width: 68px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--txt-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.active-info { flex: 1; min-width: 0; }
.active-name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.active-since {
  font-size: 11px;
  color: var(--txt-secondary);
  margin-top: 2px;
}

/* ─────────────────────────────────────────
   Filter Panel
───────────────────────────────────────── */
.filter-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 16px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
}

.filter-group { display: flex; flex-direction: column; gap: 5px; }

.filter-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--txt-muted);
}

.filter-actions { justify-content: flex-end; }
.filter-btn-row { display: flex; gap: 8px; }

/* ─────────────────────────────────────────
   Table
───────────────────────────────────────── */
.table-wrap {
  position: relative;
  overflow-x: auto;
  border-radius: var(--r);
  border: 1px solid var(--border);
}

.sessions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.sessions-table thead th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--txt-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.sessions-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color .15s;
}
.sessions-table th.sortable:hover { color: var(--txt-primary); }
.sessions-table th.sort-active    { color: var(--accent); }

.sort-ind { font-size: 9px; margin-left: 3px; opacity: .8; }

.sessions-table tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.sessions-table tbody tr:last-child td { border-bottom: none; }
.sessions-table tbody tr:nth-child(even) { background: var(--bg-row-alt); }
.sessions-table tbody tr:hover { background: var(--bg-hover); }

/* Column widths */
.col-game  { min-width: 220px; }
.col-appid { white-space: nowrap; }
.col-dur   { white-space: nowrap; }

/* App ID cell */
.cell-appid {
  white-space: nowrap;
  font-size: 12px;
  font-family: monospace;
  color: var(--txt-secondary);
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 5px;
  padding: 2px 4px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--txt-muted);
  cursor: pointer;
  vertical-align: middle;
  transition: color .15s;
}
.copy-btn:hover { color: var(--accent); }
.copy-btn--ok   { color: var(--green) !important; }

/* Game cell */
.game-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-thumb {
  width: 64px;
  height: 30px;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--bg-input);
  flex-shrink: 0;
}

.game-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.game-name a { color: var(--txt-primary); }
.game-name a:hover { color: var(--accent); text-decoration: none; }
.game-name-ph { color: var(--txt-muted); font-style: italic; }

/* Time / playtime cells */
.cell-time     { font-size: 12px; color: var(--txt-secondary); white-space: nowrap; }
.cell-dur      { font-weight: 500; white-space: nowrap; }
.cell-playtime { font-size: 12px; white-space: nowrap; }

/* Empty table row */
.table-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--txt-muted);
  font-size: 13px;
}

/* Table loading overlay */
.table-overlay {
  position: absolute;
  inset: 0;
  background: rgba(27, 40, 56, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r);
  backdrop-filter: blur(2px);
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border-md);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────────────────────
   Pagination
───────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  background: transparent;
  border: 1px solid var(--border-md);
  border-radius: var(--r-sm);
  color: var(--txt-secondary);
  font: 12px/1 var(--font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.page-btn:hover:not(:disabled) {
  background: var(--accent-dim);
  color: var(--txt-primary);
  border-color: var(--accent);
}
.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #1b2838;
  font-weight: 600;
}
.page-btn:disabled { opacity: .3; cursor: default; pointer-events: none; }

.page-ellipsis {
  padding: 0 6px;
  color: var(--txt-muted);
  font-size: 13px;
  line-height: 30px;
}

.page-info {
  font-size: 12px;
  color: var(--txt-muted);
  margin-left: 8px;
}

/* ─────────────────────────────────────────
   Responsive
───────────────────────────────────────── */
@media (max-width: 960px) {
  .top-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

@media (max-width: 640px) {
  .main-content { padding: 12px; }
  .header-inner { flex-direction: column; align-items: stretch; gap: 10px; }
  .search-form { max-width: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-grid { grid-template-columns: 1fr; }
  .card { padding: 14px; }
}
