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

:root {
  --bg:       #080c14;
  --surface:  #0f1623;
  --surface2: #131e2e;
  --border:   #1e2d45;
  --border2:  #243450;
  --text:     #c8d6ea;
  --muted:    #4a6080;
  --accent:   #3b82f6;
  --accent-h: #2563eb;
  --green:    #22c55e;
  --red:      #ef4444;
  --yellow:   #f59e0b;
  --mono:     ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--mono); font-size: 13px; }

.layout { display: flex; flex-direction: column; min-height: 100vh; }

header {
  display: flex; align-items: center; flex-wrap: wrap;
  padding: 0 24px; border-bottom: 1px solid var(--border);
  background: var(--surface); min-height: 52px; gap: 8px 16px;
}
header .brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; padding: 8px 0; }
header .brand a { color: var(--accent); font-weight: 700; font-size: 15px; text-decoration: none; }
header .brand a:hover { color: #60a5fa; }
header .sep { color: var(--muted); }
header .title { color: var(--text); font-weight: 600; }

/* ── Header nav (main sections) — right-aligned ───────────────────────────── */
.header-nav {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
  margin-left: auto;
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  border-radius: 8px; padding: 3px;
}
.hnav-btn {
  background: none; border: none; border-radius: 5px;
  color: var(--muted); font-family: var(--mono); font-size: 11px; font-weight: 600;
  padding: 5px 12px; cursor: pointer; white-space: nowrap;
  transition: color .15s, background .15s; letter-spacing: .05em; text-transform: uppercase;
}
.hnav-btn:hover  { color: var(--text); background: rgba(255,255,255,.06); }
.hnav-btn.active {
  color: #0f1623; background: var(--green);
  box-shadow: 0 1px 8px rgba(34,197,94,.35);
}

.ws-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; color: var(--muted); padding: 2px 8px;
  border: 1px solid var(--border); border-radius: 3px;
}
.ws-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.ws-badge.connected .dot { background: var(--green); box-shadow: 0 0 5px var(--green); }
.ws-badge.connected { color: #86efac; border-color: rgba(34,197,94,.3); }
.user-tag { color: var(--green); font-size: 12px; }

main { flex: 1; width: 100%; padding: 24px max(16px, 3vw) 64px; }
@media (min-width: 1400px) { main { padding: 24px max(24px, 2vw) 64px; } }

/* ── WebGL login bg canvas ── */
#adminBg {
  position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0;
  background: #010a03;
}
.admin-scanlines {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,.03) 2px, rgba(0,0,0,.03) 4px);
}
.admin-corner {
  position: fixed; width: 80px; height: 80px; z-index: 2; pointer-events: none;
}
.admin-corner svg { width: 100%; height: 100%; }
.admin-corner-tl { top: 0; left: 0; }
.admin-corner-tr { top: 0; right: 0; transform: scaleX(-1); }
.admin-corner-bl { bottom: 0; left: 0; transform: scaleY(-1); }
.admin-corner-br { bottom: 0; right: 0; transform: scale(-1); }

/* login */
.login-wrap {
  position: relative; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 40px 24px;
}
.login-wordmark {
  text-align: center; margin-bottom: 28px;
}
.login-product {
  font-family: 'Orbitron', monospace;
  font-size: clamp(20px, 4vw, 30px);
  font-weight: 900;
  color: #00ff41;
  letter-spacing: .12em;
  text-shadow: 0 0 10px rgba(0,255,65,.9), 0 0 30px rgba(0,255,65,.5), 0 0 60px rgba(0,255,65,.25);
  animation: login-pulse 3s ease-in-out infinite;
}
.login-sub {
  font-size: 10px; letter-spacing: .2em; color: #2d6a3f;
  text-transform: uppercase; margin-top: 6px;
  font-family: 'Share Tech Mono', monospace;
}
@keyframes login-pulse {
  0%,100% { text-shadow: 0 0 10px rgba(0,255,65,.9), 0 0 30px rgba(0,255,65,.5), 0 0 60px rgba(0,255,65,.25); }
  50%      { text-shadow: 0 0 20px rgba(0,255,65,1),  0 0 50px rgba(0,255,65,.7), 0 0 90px rgba(0,255,65,.4); }
}
.login-card {
  width: min(380px, 95vw);
  background: rgba(1,10,3,.85);
  border: 1px solid rgba(0,255,65,.15);
  border-radius: 4px;
  padding: 32px;
  backdrop-filter: blur(12px);
  box-shadow: 0 0 0 1px rgba(0,255,65,.05), 0 20px 60px rgba(0,0,0,.6), 0 0 40px rgba(0,255,65,.04) inset;
  position: relative;
}
.login-card::before, .login-card::after {
  content: ''; position: absolute;
  width: 12px; height: 12px;
  border-color: rgba(0,255,65,.5); border-style: solid;
}
.login-card::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.login-card::after  { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }
.login-card .field { margin-bottom: 16px; }
.login-card label {
  font-size: 10px; letter-spacing: .12em; color: #2d6a3f;
  text-transform: uppercase; margin-bottom: 6px;
}
.login-card input[type=text],
.login-card input[type=password] {
  background: rgba(0,255,65,.03);
  border: 1px solid rgba(0,255,65,.12);
  border-radius: 2px;
  color: #c8e6c9;
  padding: 9px 12px;
  font-size: 13px;
  font-family: 'Share Tech Mono', monospace;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input::placeholder { color: rgba(45,106,63,.5); }
.login-card input:focus {
  border-color: rgba(0,255,65,.4);
  box-shadow: 0 0 12px rgba(0,255,65,.08);
}
.login-err {
  min-height: 0;
  margin-bottom: 12px;
}
.login-err:empty { display: none; }
.login-err .notice-err {
  font-size: 11px; color: #ef4444;
  background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25);
  border-radius: 2px; padding: 7px 10px;
  font-family: 'Share Tech Mono', monospace;
}
.btn-login {
  width: 100%; padding: 11px 0; border-radius: 2px; border: none;
  background: #00ff41; color: #010a03;
  font-family: 'Orbitron', monospace; font-size: 11px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
  cursor: pointer; transition: box-shadow .2s, transform .15s;
  position: relative; overflow: hidden;
}
.btn-login::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.2), transparent);
  transform: translateX(-100%); transition: transform .4s;
}
.btn-login:hover::before { transform: translateX(100%); }
.btn-login:hover { box-shadow: 0 0 20px rgba(0,255,65,.5), 0 0 40px rgba(0,255,65,.25); transform: translateY(-1px); }
.btn-login:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* panels */
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel-grid.full { grid-template-columns: 1fr; }
@media (max-width: 700px) { .panel-grid { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.02);
}
.panel-head h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.panel-body { padding: 16px; }

/* form */
label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], select {
  width: 100%; padding: 7px 10px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border2);
  border-radius: 5px; font-family: var(--mono); font-size: 12px; outline: none;
  transition: border-color .15s;
}
input[type=text]:focus, input[type=password]:focus, select:focus { border-color: var(--accent); }
input[readonly] { opacity: .6; cursor: default; }
select option { background: var(--surface); }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 18px; border: none; border-radius: 5px; cursor: pointer;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-danger  { background: #7f1d1d; color: #fca5a5; }
.btn-danger:hover:not(:disabled)  { background: #991b1b; }
.btn-ghost   { background: transparent; border: 1px solid var(--border2); color: var(--muted); }
.btn-ghost:hover:not(:disabled)   { border-color: var(--accent); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-full { width: 100%; justify-content: center; }

/* rom list */
.search-wrap { position: relative; }
.search-wrap input { padding-left: 30px; }
.search-wrap::before {
  content: '⌕'; position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px; pointer-events: none;
}
.rom-list { max-height: 320px; overflow-y: auto; margin-top: 10px; }
.rom-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 5px; cursor: pointer; transition: background .1s;
  border: 1px solid transparent;
}
.rom-item:hover { background: rgba(59,130,246,.08); }
.rom-item.selected { background: rgba(59,130,246,.15); border-color: rgba(59,130,246,.3); }
.rom-badge {
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 3px;
  background: #1e3a8a; color: #93c5fd; white-space: nowrap; flex-shrink: 0;
}
.rom-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rom-path  { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* previous sessions */
.prev-session-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-bottom: 1px solid rgba(30,45,69,.5);
  cursor: pointer; transition: background .1s;
}
.prev-session-row:hover { background: rgba(59,130,246,.07); }
.prev-session-row:last-child { border-bottom: none; }
.prev-session-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.prev-session-dot.active { background: var(--green); box-shadow: 0 0 5px var(--green); }
.prev-session-info { flex: 1; min-width: 0; }
.prev-session-title { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prev-session-id    { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prev-session-time  { font-size: 10px; color: var(--muted); flex-shrink: 0; }
.prev-session-use   {
  font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 3px;
  background: rgba(59,130,246,.12); color: #93c5fd; border: 1px solid rgba(59,130,246,.2);
  white-space: nowrap; flex-shrink: 0; cursor: pointer; transition: background .1s;
}
.prev-session-use:hover { background: rgba(59,130,246,.25); }

.prev-bulk-bar {
  display: flex; align-items: center; gap: 8px; padding: 6px 14px;
  border-bottom: 1px solid var(--border); background: rgba(0,0,0,.15);
}
.prev-del-btn {
  font-size: 10px; color: var(--muted); cursor: pointer; padding: 2px 6px;
  border-radius: 3px; flex-shrink: 0; transition: color .1s, background .1s;
}
.prev-del-btn:hover { color: #fca5a5; background: rgba(239,68,68,.12); }
.prev-confirm {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: rgba(239,68,68,.08); border-bottom: 1px solid rgba(239,68,68,.2);
}
.prev-session-row input[type=checkbox] { flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }

/* instances */
.instance-list { display: flex; flex-direction: column; gap: 8px; min-height: 48px; }
.instance-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.conn-dot.on  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.conn-dot.off { background: var(--muted); }
.inst-id { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #93c5fd; }
a.inst-id { text-decoration: none; }
a.inst-id:hover { text-decoration: underline; color: #60a5fa; }
.inst-status { font-size: 10px; color: var(--muted); }

/* notice */
.notice { padding: 8px 12px; border-radius: 5px; font-size: 12px; margin-top: 10px; }
.notice-err  { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.25); }
.notice-ok   { background: rgba(34,197,94,.1);  color: #86efac;  border: 1px solid rgba(34,197,94,.25); }

/* spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }

/* emulator table */
thead th {
  position: sticky; top: 0; background: var(--surface);
  padding: 7px 10px; font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

/* import section */
.import-layout { display: grid; grid-template-columns: 220px 1fr; gap: 0; min-height: 400px; }
@media (max-width: 700px) { .import-layout { grid-template-columns: 1fr; } }

.dir-sidebar { border-right: 1px solid var(--border); overflow-y: auto; max-height: 520px; }
.dir-item {
  padding: 9px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.dir-item:hover { background: rgba(59,130,246,.07); }
.dir-item.active { background: rgba(59,130,246,.15); border-left: 2px solid var(--accent); }
.dir-name { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-meta { font-size: 10px; color: var(--muted); margin-top: 2px; }
.dir-labels { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.lbl { font-size: 10px; padding: 1px 5px; border-radius: 3px; background: #1e3a5a; color: #7dd3fc; }

.import-body { display: flex; flex-direction: column; overflow: hidden; }
.filter-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: rgba(0,0,0,.2);
}
.filter-bar input[type=text] { flex: 1; min-width: 120px; width: auto; }
.filter-bar select { width: auto; min-width: 80px; }
.filter-bar .pill-group { display: flex; gap: 4px; flex-wrap: wrap; }
.ext-pill {
  font-size: 10px; padding: 3px 8px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border2); color: var(--muted); background: transparent;
  transition: all .1s; white-space: nowrap;
}
.ext-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.file-table-wrap { flex: 1; overflow-y: auto; max-height: clamp(280px, 55vh, 620px); }
table { width: 100%; border-collapse: collapse; }
tbody tr { border-bottom: 1px solid rgba(30,45,69,.6); transition: background .1s; }
tbody tr:hover { background: rgba(59,130,246,.05); }
tbody tr.imported { opacity: .45; }
td { padding: 6px 10px; font-size: 12px; vertical-align: middle; }
td.td-check { width: 28px; }
td.td-name  { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.td-ext   { width: 50px; }
td.td-size  { width: 80px; color: var(--muted); font-size: 11px; white-space: nowrap; }
td.td-plat  { width: 110px; }
.tag-imported { font-size: 10px; color: var(--green); }

.import-footer {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  border-top: 1px solid var(--border); background: rgba(0,0,0,.2); flex-wrap: wrap;
}
.sel-count { font-size: 11px; color: var(--muted); }

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination-bar {
  display: flex; align-items: center; gap: 6px; flex: 1; justify-content: center;
}
.page-btn {
  background: none; border: 1px solid var(--border2); border-radius: 4px;
  color: var(--muted); font-family: var(--mono); font-size: 11px;
  padding: 3px 8px; cursor: pointer; min-width: 28px; text-align: center;
  transition: color .12s, background .12s, border-color .12s;
}
.page-btn:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.page-btn:disabled { opacity: .3; cursor: default; }
.page-ellipsis { color: var(--muted); font-size: 11px; padding: 0 2px; }
.page-size-select {
  background: var(--bg); border: 1px solid var(--border2); border-radius: 4px;
  color: var(--muted); font-family: var(--mono); font-size: 11px;
  padding: 3px 6px; cursor: pointer; outline: none;
}
.page-size-select:focus { border-color: var(--accent); color: var(--text); }
.page-info { font-size: 11px; color: var(--muted); white-space: nowrap; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Sub-bar (below header, Gate section) — right-aligned ─────────────────── */
.sub-bar {
  background: rgba(0,0,0,.25); border-bottom: 1px solid var(--border);
  padding: 0 max(16px, 3vw); display: flex; justify-content: flex-end;
  overflow-x: auto;
}
@media (min-width: 1400px) { .sub-bar { padding: 0 max(24px, 2vw); } }
.sub-nav { display: flex; gap: 0; flex-shrink: 0; }
.snav-btn {
  position: relative; background: none; border: none;
  color: var(--muted); font-family: var(--mono); font-size: 11px; font-weight: 600;
  padding: 9px 20px 10px; cursor: pointer; letter-spacing: .06em; text-transform: uppercase;
  transition: color .15s;
}
.snav-btn::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0;
  transform: scaleX(0); transition: transform .18s ease;
}
.snav-btn:hover { color: var(--text); }
.snav-btn:hover::after { transform: scaleX(0.5); background: var(--border2); }
.snav-btn.active { color: #93c5fd; }
.snav-btn.active::after { transform: scaleX(1); }
.section-body { width: 100%; }

/* ── Bottom bar ───────────────────────────────────────────────────────────── */
.bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 40px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0,0,0,.4);
}
.bottom-bar-left  { display: flex; align-items: center; gap: 10px; }
.bottom-bar-right { display: flex; align-items: center; gap: 10px; }

/* ── Data table (users) ───────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  text-align: left; padding: 7px 10px; font-size: 11px; color: var(--muted);
  border-bottom: 1px solid var(--border); font-weight: 500;
}
.data-table td { padding: 7px 10px; border-bottom: 1px solid rgba(255,255,255,.04); }
.data-table td.muted { color: var(--muted); }
.data-table td.row-actions { text-align: right; white-space: nowrap; }
.data-table .badge { font-size: 10px; padding: 2px 6px; border-radius: 3px; }
.data-table .badge-green { background: rgba(34,197,94,.12); color: var(--green); }
.data-table .badge-dim   { background: rgba(255,255,255,.05); color: var(--muted); }
.btn-xs { padding: 2px 8px; font-size: 11px; }

/* ── Inline edit form ─────────────────────────────────────────────────────── */
.edit-form {
  background: rgba(255,255,255,.03); border: 1px solid var(--border);
  border-radius: 6px; padding: 14px; margin-top: 10px;
}
.edit-form-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px;
  margin-bottom: 12px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; color: var(--muted); }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field select {
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text); padding: 5px 8px; border-radius: 4px; font-size: 12px; outline: none;
  font-family: var(--mono); width: 100%;
}
.field input:focus,
.field select:focus { border-color: var(--green); outline: none; }
.field-inline { flex-direction: row; align-items: center; }
.field-inline label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; color: var(--text); }
.field-checks { flex-direction: row; flex-wrap: wrap; gap: 10px; }
.check-label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text); cursor: pointer; white-space: nowrap; }
.check-label input[type="checkbox"] { accent-color: var(--green); }
.edit-form-footer {
  display: flex; align-items: center; gap: 8px; justify-content: flex-end;
}
.edit-form-footer .notice { flex: 1; font-size: 11px; }
.empty-state { padding: 24px; text-align: center; color: var(--muted); font-size: 12px; }

/* ── Dashboard ────────────────────────────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px 24px;
}
.stat-val  { font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1; margin-bottom: 6px; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* ── Admin broadcast toast ───────────────────────────────────────────────── */
#adminToast {
  position: fixed;
  bottom: 52px; /* sit above bottom bar */
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--green);
  color: var(--text);
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  pointer-events: auto;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
  z-index: 9999;
}
#adminToast.admin-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#adminToast.admin-toast-hide {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
}

/* ── Instance user badge ─────────────────────────────────────────────────── */
.inst-users {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px;
  cursor: default;
  white-space: nowrap;
  position: relative;
}
.inst-users.has-users {
  color: var(--green);
  border-color: rgba(110,231,183,.25);
  background: rgba(110,231,183,.07);
}
.inst-users svg { flex-shrink: 0; }
.iu-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 180px;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
  z-index: 200;
  white-space: normal;
}
.inst-users:hover .iu-tooltip { display: block; }
.iu-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  padding: 2px 0;
  color: var(--text);
}
.iu-row + .iu-row { border-top: 1px solid var(--border); margin-top: 3px; padding-top: 3px; }
.iu-name { font-weight: 600; }
.iu-ip   { color: var(--muted); font-family: monospace; font-size: 10px; }
.iu-empty { color: var(--muted); font-size: 11px; justify-content: center; }

/* ── Gate Workers ──────────────────────────────────────────────────────────── */
.worker-edit-form  { border: 1px solid var(--border2); border-radius: 6px; padding: 16px; margin-bottom: 16px; }
.worker-form-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.worker-form-json  { grid-column: 1 / -1; }
.worker-form-json textarea {
  width: 100%; padding: 8px 10px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border2);
  border-radius: 5px; font-family: var(--mono); font-size: 11px;
  resize: vertical; outline: none;
}
.worker-form-json textarea:focus { border-color: var(--accent); }
.worker-form-footer { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.worker-form-footer .notice { flex: 1; }

.worker-inline-edit { padding: 12px 16px; background: rgba(255,255,255,.02); border-top: 1px solid var(--border); }
.worker-binary      { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.dir-add-worker {
  margin-top: 6px; font-size: 10px; padding: 2px 8px;
  opacity: 0;
  transition: opacity .15s;
}
.dir-item:hover .dir-add-worker { opacity: 1; }

@media (max-width: 700px) { .worker-form-grid { grid-template-columns: 1fr; } }

/* ── Active Sessions ──────────────────────────────────────────────────────── */
.sessions-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sessions-table th {
  text-align: left; padding: 6px 12px;
  color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.sessions-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.sessions-table tbody tr:hover { background: rgba(255,255,255,.02); }
.td-ua { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cap-badge {
  display: inline-block; padding: 2px 7px; border-radius: 3px;
  font-size: 10px; font-weight: 600; letter-spacing: .03em; white-space: nowrap;
}
.cap-yes     { background: rgba(34,197,94,.15);  color: #22c55e; }
.cap-no      { background: rgba(239,68,68,.15);  color: #ef4444; }
.cap-unknown { background: rgba(74,96,128,.2);   color: var(--muted); }

/* ── Kick / Ban inline enforcement ───────────────────────────────────────── */
.enf-row-cell   { padding: 0 !important; border-bottom: 1px solid var(--border); }
.enf-inline     { padding: 12px 16px; background: rgba(239,68,68,.04); display: flex; flex-direction: column; gap: 8px; }
.enf-reason     { width: 100%; max-width: 520px; padding: 6px 10px; background: var(--bg); color: var(--text); border: 1px solid var(--border2); border-radius: 4px; font-family: var(--mono); font-size: 12px; }
.enf-actions    { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.enf-scope      { padding: 4px 8px; background: var(--bg); color: var(--text); border: 1px solid var(--border2); border-radius: 4px; font-family: var(--mono); font-size: 11px; }
.enf-kick-btn   { background: rgba(245,158,11,.15); color: #f59e0b; border: 1px solid rgba(245,158,11,.3); }
.enf-kick-btn:hover { background: rgba(245,158,11,.25); }
.enf-ban-btn    { background: rgba(239,68,68,.15); color: #ef4444; border: 1px solid rgba(239,68,68,.3); }
.enf-ban-btn:hover  { background: rgba(239,68,68,.25); }
.enf-notice     { font-size: 11px; min-height: 16px; }
.td-actions     { white-space: nowrap; text-align: right; padding-right: 8px; }
