*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:      #0f0a1e;
  --surface: #1a1030;
  --card:    #201540;
  --primary: #b87bff;
  --pink:    #ff6bba;
  --amber:   #ffb347;
  --blue:    #6bc5ff;
  --success: #5cffa0;
  --danger:  #ff5f7e;
  --warn:    #ffe066;
  --text:    #f0e8ff;
  --muted:   rgba(220,200,255,0.5);
  --border:  rgba(180,140,255,0.14);
}

html, body {
  height: 100%; overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 60% 40% at 5%  10%, rgba(184,123,255,.14) 0%, transparent 65%),
    radial-gradient(ellipse 50% 45% at 95% 90%, rgba(107,197,255,.10) 0%, transparent 65%);
}

/* ── Layout ─────────────────────────────────────────────── */
#app {
  position: relative; z-index: 1;
  height: 100%; display: flex; flex-direction: column; overflow: hidden;
}

/* ── Login ──────────────────────────────────────────────── */
#login-screen {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 24px;
}
.login-logo {
  font-size: 48px; font-weight: 900;
  background: linear-gradient(130deg, var(--primary), var(--pink));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 4px;
}
.login-sub  { font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 36px; }
.login-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 32px; width: 100%; max-width: 360px;
  box-shadow: 0 16px 48px rgba(0,0,0,.45);
}
.login-card h2 { font-size: 17px; font-weight: 800; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.login-card h2 svg { color: var(--primary); }
.field-wrap { position: relative; margin-bottom: 16px; }
.field-wrap input {
  width: 100%; padding: 13px 16px;
  background: rgba(255,255,255,.06); border: 1.5px solid var(--border);
  border-radius: 12px; color: var(--text); font-family: inherit;
  font-size: 14px; font-weight: 600; outline: none; transition: border-color .2s;
}
.field-wrap input:focus { border-color: var(--primary); }
.field-wrap input::placeholder { color: var(--muted); }
#login-error {
  display: none; color: var(--danger); font-size: 12px; font-weight: 700;
  margin-bottom: 12px;
}
.btn-login {
  width: 100%; padding: 14px; border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(130deg, var(--primary), var(--pink));
  color: #fff; font-size: 16px; font-weight: 800; font-family: inherit;
  box-shadow: 0 6px 24px rgba(184,123,255,.4);
  transition: transform .15s, box-shadow .2s;
}
.btn-login:hover  { transform: translateY(-2px); }
.btn-login:active { transform: scale(.96); }

/* ── Dashboard ──────────────────────────────────────────── */
#dashboard {
  display: none; flex-direction: column;
  flex: 1; min-height: 0; overflow: hidden;
}

/* Topbar */
.topbar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  background: rgba(15,10,30,.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}
.topbar-logo  { font-size: 20px; font-weight: 900; color: var(--primary); }
.topbar-title { font-size: 13px; font-weight: 700; color: var(--muted); flex: 1; }
.conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success); box-shadow: 0 0 8px var(--success);
  transition: background .3s;
}
.conn-dot.off { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.conn-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.btn-signout {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: none; color: var(--muted); font-size: 12px; font-weight: 700;
  font-family: inherit; cursor: pointer; transition: all .15s;
}
.btn-signout:hover { background: rgba(255,255,255,.07); color: var(--text); }
.btn-signout svg { width: 13px; height: 13px; }

/* Stats bar */
.stats-bar {
  flex-shrink: 0;
  display: flex; gap: 10px; padding: 12px 20px;
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.stats-bar::-webkit-scrollbar { display: none; }
.stat-chip {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 100px;
  background: var(--card); border: 1px solid var(--border);
  font-size: 12px; font-weight: 800;
  cursor: pointer; transition: border-color .15s;
}
.stat-chip svg    { width: 13px; height: 13px; }
.stat-chip.rooms  { color: var(--primary); border-color: rgba(184,123,255,.3); }
.stat-chip.queue  { color: var(--amber);   border-color: rgba(255,179,71,.3);  }
.stat-chip.online { color: var(--blue);    border-color: rgba(107,197,255,.3); }
.stat-chip.banned { color: var(--danger);  border-color: rgba(255,95,126,.3);  }
.stat-chip:hover  { border-color: rgba(255,255,255,.25); }

/* ── Tab nav ────────────────────────────────────────────── */
.tab-nav {
  flex-shrink: 0;
  display: flex; align-items: stretch;
  background: rgba(15,10,30,.82);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 0 18px; min-height: 46px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 13px; font-weight: 800; font-family: inherit;
  cursor: pointer; transition: color .15s, border-color .15s;
}
.tab-btn svg    { width: 14px; height: 14px; }
.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 100px; font-size: 10px; font-weight: 800;
  background: rgba(255,95,126,.18); color: var(--danger);
  border: 1px solid rgba(255,95,126,.4);
}
.tab-badge.blue {
  background: rgba(107,197,255,.15); color: var(--blue);
  border-color: rgba(107,197,255,.35);
}

/* ── Tab panels ─────────────────────────────────────────── */
.tab-panels {
  flex: 1; min-height: 0; overflow: hidden; position: relative;
}
.tab-panel {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 20px 20px 100px;
  display: none;
}
.tab-panel.active { display: block; }

/* Section titles */
.section-title {
  font-size: 12px; font-weight: 800; letter-spacing: .8px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 12px;
  display: flex; align-items: center; gap: 7px;
}
.section-title svg { width: 14px; height: 14px; }

/* Empty state */
.empty {
  text-align: center; padding: 40px 20px;
  font-size: 13px; font-weight: 700; color: rgba(200,180,255,.3);
}

/* ── Room cards ─────────────────────────────────────────── */
.room-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; margin-bottom: 10px;
  transition: border-color .2s;
}
.room-card.monitored { border-color: rgba(184,123,255,.45); }
.room-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.room-id  { font-size: 12px; font-weight: 800; font-family: monospace; color: var(--primary); flex: 1; }
.room-age { font-size: 11px; font-weight: 700; color: var(--muted); }
.monitor-badge {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  background: rgba(184,123,255,.15); border: 1px solid rgba(184,123,255,.35);
  font-size: 11px; font-weight: 800; color: var(--primary);
}
.monitor-badge svg { width: 11px; height: 11px; }
.room-ips { display: flex; gap: 10px; margin-bottom: 12px; }
.ip-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 8px;
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  font-size: 11px; font-weight: 700; font-family: monospace; color: var(--muted);
}
.ip-chip svg { width: 11px; height: 11px; }
.ip-chip.a { color: var(--blue);  border-color: rgba(107,197,255,.25); }
.ip-chip.b { color: var(--amber); border-color: rgba(255,179,71,.25);  }
.member-badge {
  font-family: 'Nunito', sans-serif; font-size: 9px; font-weight: 800;
  padding: 1px 6px; border-radius: 100px;
  background: rgba(92,255,160,.14); border: 1px solid rgba(92,255,160,.35);
  color: var(--success);
}
.room-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.action-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 13px; border-radius: 10px; border: none; cursor: pointer;
  font-size: 12px; font-weight: 800; font-family: inherit;
  transition: transform .15s;
}
.action-btn:hover  { transform: translateY(-1px); }
.action-btn:active { transform: scale(.93); }
.action-btn svg    { width: 13px; height: 13px; }
.action-btn.monitor      { background: rgba(184,123,255,.18); color: var(--primary); border: 1px solid rgba(184,123,255,.35); }
.action-btn.stop-monitor { background: rgba(255,224,102,.15); color: var(--warn);    border: 1px solid rgba(255,224,102,.35); }
.action-btn.ban-a        { background: rgba(107,197,255,.12); color: var(--blue);    border: 1px solid rgba(107,197,255,.3); }
.action-btn.ban-b        { background: rgba(255,179,71,.12);  color: var(--amber);   border: 1px solid rgba(255,179,71,.3); }

/* ── Monitor panel (fixed bottom) ───────────────────────── */
#monitor-panel {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: var(--card);
  border-top: 1px solid rgba(184,123,255,.35);
  padding: 16px 20px 24px;
  box-shadow: 0 -12px 40px rgba(0,0,0,.5);
}
#monitor-panel.visible { display: block; }
.monitor-panel-title {
  font-size: 13px; font-weight: 800; color: var(--primary);
  display: flex; align-items: center; gap: 7px; margin-bottom: 14px;
}
.monitor-panel-title svg { width: 15px; height: 15px; }
.monitor-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.monitor-label { font-size: 12px; font-weight: 800; width: 28px; flex-shrink: 0; }
.monitor-label.a { color: var(--blue);  }
.monitor-label.b { color: var(--amber); }
.level-bar  { flex: 1; height: 10px; border-radius: 5px; background: rgba(255,255,255,.08); overflow: hidden; }
.level-fill { height: 100%; width: 0%; border-radius: 5px; transition: width .08s; }
.level-fill.a { background: linear-gradient(90deg, var(--blue),  #6bc5ff88); }
.level-fill.b { background: linear-gradient(90deg, var(--amber), #ffb34788); }
.monitor-status { font-size: 11px; font-weight: 800; color: var(--muted); width: 70px; text-align: right; flex-shrink: 0; }
.monitor-footer { display: flex; gap: 8px; margin-top: 14px; }
.btn-stop-monitor {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px; border-radius: 10px; cursor: pointer;
  background: rgba(255,224,102,.15); color: var(--warn);
  border: 1px solid rgba(255,224,102,.35);
  font-size: 13px; font-weight: 800; font-family: inherit; transition: all .15s;
}
.btn-stop-monitor:hover  { background: rgba(255,224,102,.25); }
.btn-stop-monitor:active { transform: scale(.96); }
.btn-stop-monitor svg { width: 14px; height: 14px; }
.btn-ban-row {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px; border-radius: 10px;
  background: rgba(255,95,126,.12); color: var(--danger);
  border: 1px solid rgba(255,95,126,.35);
  font-size: 12px; font-weight: 800; font-family: inherit; cursor: pointer; transition: all .15s;
}
.btn-ban-row:hover  { background: rgba(255,95,126,.22); }
.btn-ban-row:active { transform: scale(.96); }
.btn-ban-row svg { width: 13px; height: 13px; }

/* ── Banned rows ────────────────────────────────────────── */
.ban-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid rgba(255,95,126,.2);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.ban-ip { font-size: 12px; font-weight: 800; font-family: monospace; color: var(--danger); flex: 1; }
.ban-meta {
  font-size: 11px; font-weight: 700; color: var(--muted);
  display: flex; flex-direction: column; gap: 2px; align-items: flex-end;
}
.ban-countdown { font-variant-numeric: tabular-nums; }
.btn-unban {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 8px;
  background: rgba(92,255,160,.1); border: 1px solid rgba(92,255,160,.3);
  color: var(--success); font-size: 11px; font-weight: 800;
  font-family: inherit; cursor: pointer; transition: all .15s;
}
.btn-unban:hover { background: rgba(92,255,160,.2); }
.btn-unban svg   { width: 11px; height: 11px; }

/* Manual ban form */
.manual-ban-form {
  display: flex; gap: 8px; margin-bottom: 14px; align-items: center; flex-wrap: wrap;
}
.manual-ban-input {
  flex: 1; min-width: 120px; padding: 9px 13px;
  background: rgba(255,255,255,.06); border: 1.5px solid var(--border);
  border-radius: 10px; color: var(--text); font-family: inherit;
  font-size: 13px; font-weight: 600; outline: none; transition: border-color .2s;
}
.manual-ban-input:focus { border-color: var(--danger); }
.manual-ban-input::placeholder { color: var(--muted); }
.btn-manual-ban {
  display: flex; align-items: center; gap: 5px; flex-shrink: 0;
  padding: 9px 16px; border-radius: 10px;
  background: rgba(255,95,126,.15); border: 1px solid rgba(255,95,126,.4);
  color: var(--danger); font-size: 13px; font-weight: 800;
  font-family: inherit; cursor: pointer; transition: all .15s;
}
.btn-manual-ban:hover { background: rgba(255,95,126,.25); }
.btn-manual-ban:active { transform: scale(.96); }
.btn-manual-ban svg { width: 14px; height: 14px; }

/* ── Toast ──────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 100px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 20px; border-radius: 100px;
  background: var(--card); border: 1px solid var(--border);
  font-size: 13px; font-weight: 700;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; z-index: 100;
  transition: opacity .25s, transform .25s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── History ────────────────────────────────────────────── */
.history-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.history-search {
  flex: 1; padding: 9px 13px;
  background: rgba(255,255,255,.06); border: 1.5px solid var(--border);
  border-radius: 10px; color: var(--text); font-family: inherit;
  font-size: 13px; font-weight: 600; outline: none; transition: border-color .2s;
}
.history-search:focus       { border-color: var(--primary); }
.history-search::placeholder { color: var(--muted); }
.btn-refresh {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 13px; border-radius: 10px;
  background: rgba(184,123,255,.14); border: 1px solid rgba(184,123,255,.3);
  color: var(--primary); font-size: 12px; font-weight: 800;
  font-family: inherit; cursor: pointer; transition: all .15s;
}
.btn-refresh:hover { background: rgba(184,123,255,.24); }
.btn-refresh svg   { width: 13px; height: 13px; }
.history-table { width: 100%; border-collapse: collapse; }
.history-table th {
  text-align: left; padding: 7px 10px;
  font-size: 10px; font-weight: 800; letter-spacing: .7px;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.history-table td {
  padding: 9px 10px; font-size: 12px; font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle;
}
.history-table tbody tr:hover td { background: rgba(255,255,255,.03); }
.history-tgid         { font-family: monospace; color: var(--blue); }
.history-tgid.banned  { color: var(--danger); }
.history-badge-banned {
  display: inline-block; margin-left: 6px;
  padding: 1px 6px; border-radius: 100px; font-size: 9px; font-weight: 800;
  background: rgba(255,95,126,.15); border: 1px solid rgba(255,95,126,.4);
  color: var(--danger); vertical-align: middle;
}
.history-count { color: var(--primary); font-variant-numeric: tabular-nums; }
.history-date  { color: var(--muted); font-family: monospace; font-size: 11px; }

/* ── Responsive / desktop tidy-up ───────────────────────── */
.stats-bar,
.tab-nav,
.tab-panels {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Room / report / ban lists → responsive grids */
#rooms-list,
#report-list,
#ban-list {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
#rooms-list > .empty,
#report-list > .empty,
#ban-list > .empty {
  grid-column: 1 / -1;
}
.room-card { margin-bottom: 0; }
.ban-row   { margin-bottom: 0; }

@media (min-width: 900px) {
  .stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    overflow: visible;
  }
  .stat-chip {
    flex: 1;
    justify-content: flex-start;
    padding: 16px 20px;
    font-size: 15px;
    border-radius: 14px;
  }
  .stat-chip svg { width: 18px; height: 18px; }

  .tab-nav { justify-content: center; gap: 4px; }
  .tab-btn  { flex: 1; justify-content: center; }

  .tab-panel { padding: 24px 28px 100px; }

  #rooms-list,
  #ban-list {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Monitor dock: centered, meters side-by-side */
  #monitor-panel {
    left: 0; right: 0; margin: 0 auto;
    max-width: 1200px;
    border-radius: 18px 18px 0 0;
  }
  #monitor-panel.visible {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 24px;
    align-items: center;
  }
  #monitor-panel .monitor-panel-title { grid-column: 1 / -1; }
  #monitor-panel .monitor-footer     { grid-column: 1 / -1; }
  .monitor-row { margin-bottom: 0; }
}

@media (min-width: 1200px) {
  #rooms-list  { grid-template-columns: repeat(3, 1fr); }
  #report-list { grid-template-columns: repeat(2, 1fr); }
}

/* Toast: keep visible above the monitor dock when monitoring */
#monitor-panel.visible ~ #toast { bottom: 240px; }
