:root {
  --bg: #0a0a0a;
  --bg-2: #111113;
  --panel: #121214;
  --panel-2: #161618;
  --line: rgba(255, 255, 255, .09);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #7c5cff;
  --accent-dim: rgba(124, 92, 255, .16);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, .14);
  --warn: #f59e0b;
  --info: #a78bfa;
  --radius: 12px;
  --shadow: 0 20px 60px rgba(0, 0, 0, .45);
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: #0a0a0a;
}
body.desk { overflow: hidden; }

.scroll {
  scrollbar-width: thin;
  scrollbar-color: #3a3a42 #121214;
}
.scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll::-webkit-scrollbar-track { background: #121214; border-radius: 99px; }
.scroll::-webkit-scrollbar-thumb {
  background: #3a3a42;
  border-radius: 99px;
  border: 2px solid #121214;
}
.scroll::-webkit-scrollbar-thumb:hover { background: #52525b; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.muted { color: var(--muted); }
.err { color: var(--danger); min-height: 1.2em; margin-top: 6px; font-size: .9rem; }
.ok { color: var(--accent); min-height: 1.2em; }
code, .mono {
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
  font-size: .85em;
  color: #a78bfa;
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.brand {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-weight: 700; letter-spacing: -.03em;
  font-size: 1.05rem; line-height: 1.1; color: #fff;
}
.brand-tag { margin: 2px 0 0; font-size: .75rem; }
.brand-lockup { display: flex; gap: 10px; align-items: center; }
.brand-logo { height: 34px; width: auto; display: block; }
.auth-card .brand-logo { height: 64px; }
.owner-side .brand-logo { height: 32px; margin: 2px 8px 10px; }

input, button, select, textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0c1118;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .22);
  outline-offset: 1px;
  border-color: rgba(255, 255, 255, .28);
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: #f4f4f5;
  caret-color: #f4f4f5;
  box-shadow: 0 0 0 1000px #0c1118 inset;
  transition: background-color 9999s ease-out;
}
select {
  appearance: none;
  background-color: #0c1118;
  background-image: linear-gradient(45deg, transparent 50%, #a1a1aa 50%), linear-gradient(135deg, #a1a1aa 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
input[type="checkbox"] {
  appearance: none;
  width: 16px; height: 16px; min-width: 16px;
  margin: 0; padding: 0; border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: #0c1118;
  display: inline-grid; place-items: center;
  vertical-align: middle;
}
input[type="checkbox"]:checked {
  background: #1a1a1e;
  border-color: rgba(255, 255, 255, .7);
}
input[type="checkbox"]:checked::after {
  content: "";
  width: 8px; height: 4px;
  border-left: 2px solid #f4f4f5;
  border-bottom: 2px solid #f4f4f5;
  transform: rotate(-45deg) translate(0, -1px);
}
input[type="checkbox"]:disabled { opacity: .4; }
label:has(input[type="checkbox"]) {
  display: inline-flex; align-items: center; gap: 8px;
  width: auto; color: var(--text); font-size: .85rem;
}
button { cursor: pointer; font-weight: 600; transition: background .15s, border-color .15s, color .15s; }
button:hover { border-color: rgba(255, 255, 255, .28); }
button.primary, #authBtn, .auth-card button[type="submit"], .owner-main button[type="submit"].primary {
  background: #fff;
  color: #0a0a0a;
  border: 0;
  box-shadow: none;
}
button.primary:hover, #authBtn:hover, .auth-card button[type="submit"]:hover, .owner-main button[type="submit"].primary:hover {
  filter: none;
  background: #e4e4e7;
}
button.danger {
  background: transparent;
  color: var(--danger);
  border: 0;
  width: auto;
  box-shadow: none;
}
button.danger:hover { background: transparent; color: #f87171; }
button.ghost { background: transparent; }
button.sm, .row-actions button, table .sm { width: auto; height: 30px; padding: 0 10px; font-size: .8rem; }
button.link {
  width: auto; padding: 0; border: 0; background: none;
  color: #e4e4e7; font-weight: 600;
}
button.link:hover { text-decoration: underline; }

.field { display: grid; gap: 6px; font-size: .78rem; color: var(--muted); }
.field > span { font-weight: 650; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.card {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  display: grid;
  gap: 12px;
  box-shadow: none;
}
.auth-card {
  width: min(400px, 100%);
  padding: 28px;
  gap: 16px;
  text-align: left;
  box-shadow: none;
}
.auth-card h2 {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -.03em;
}
.auth-card input { height: 44px; background: #0a0a0a; }
.auth-card button.primary { height: 44px; margin-top: 4px; }
.auth-card .brand-lockup { justify-content: flex-start; text-align: left; }

#app {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  overflow: hidden;
}
#app.collapsed { grid-template-columns: 76px 1fr; }
#app.collapsed .brand-text,
#app.collapsed .aside-meta,
#app.collapsed #who,
#app.collapsed .aside-foot button { display: none; }
#app.collapsed nav button { text-align: center; padding: 10px 6px; font-size: .72rem; }
aside {
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--line);
  padding: 1.1rem .85rem 1rem .4rem;
  display: flex; flex-direction: column;
  background: transparent;
  z-index: 5;
}
.brand-lockup {
  justify-content: flex-start;
  padding: .2rem .75rem 1rem;
  margin-bottom: .15rem;
  border-bottom: 1px solid var(--line);
}
nav { overflow: auto; padding-right: 2px; flex: 1; min-height: 0; margin-top: 1rem; display: flex; flex-direction: column; gap: 2px; }
.side-label {
  margin: 18px 12px 6px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #71717a;
  font-weight: 600;
}
nav button.nav-btn {
  display: flex; align-items: center;
  width: 100%;
  background: none;
  border: 0;
  border-radius: 8px;
  color: #a1a1aa;
  text-align: left;
  margin: 0;
  padding: .5rem .75rem;
  font-weight: 500;
  font-size: .92rem;
  box-shadow: none;
}
nav button.nav-btn:hover { color: #fff; background: transparent; }
nav button.nav-btn.active {
  color: #fff;
  background: transparent;
  font-weight: 650;
  box-shadow: none;
}
.aside-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 8px; }
.aside-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin: 8px 8px 2px;
}
.role {
  font-size: 13px; text-transform: none; letter-spacing: 0;
  padding: 0; border: 0; border-radius: 0;
  color: #fff; font-weight: 600;
}
#sessionNote { font-size: 11px; white-space: nowrap; }
#logout.logout {
  display: flex; align-items: center; justify-content: flex-start;
  background: transparent;
  border: 0;
  color: #ef4444;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 600;
  box-shadow: none;
}
#logout.logout:hover { color: #f87171; background: transparent; }

main {
  padding: 18px 24px 36px;
  min-width: 0;
  height: 100vh;
  overflow: auto;
}
header {
  position: sticky; top: 0; z-index: 4;
  display: flex; justify-content: space-between; gap: 24px; align-items: center;
  margin: -18px -24px 18px; padding: 16px 24px 14px;
  background: linear-gradient(180deg, rgba(10,10,10,.98), rgba(10,10,10,.94) 80%, rgba(10,10,10,.9));
  border-bottom: 1px solid var(--line);
}
.head-copy { min-width: 180px; flex: 0 0 auto; }
.head-copy h1 { margin: 0; font-family: "Plus Jakarta Sans", system-ui, sans-serif; font-size: 1.35rem; letter-spacing: -.03em; font-weight: 650; }
.head-copy p { margin: 4px 0 0; font-size: .88rem; }
.head-tools {
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  flex: 1; min-width: 0;
}
.tool-row { display: flex; align-items: center; gap: 8px; }
.tool-row .search { width: 168px; }
.tool-row input, #refresh {
  height: 36px; padding: 0 12px; background: var(--panel);
}
#refresh {
  width: auto; padding: 0 14px; font-size: .82rem; font-weight: 650; white-space: nowrap;
  background: #fff;
  color: #0a0a0a;
  border: 0;
  box-shadow: none;
}
#refresh:hover { filter: none; background: #e4e4e7; }
.search { width: min(220px, 100%); }
.search input { background: var(--panel); }
.livebar { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.pill {
  font-size: .72rem; font-weight: 700;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 9px; color: var(--muted); white-space: nowrap;
}
.pill b { color: var(--text); }
.pill.on { color: #fff; border-color: rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .06); }
.pill.off { color: var(--muted); }
.nav-open { display: none; }
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 40;
  display: grid; gap: 8px; width: min(320px, calc(100vw - 24px));
}
.toast {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); font-size: .88rem;
}
.toast.ok { border-color: rgba(124, 92, 255, .35); }
.toast.err { border-color: rgba(251,113,133,.35); color: var(--danger); }
.ping-ok { color: var(--accent); }
.ping-mid { color: var(--warn); }
.ping-bad { color: var(--danger); }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.dash-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.stat span {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 650;
}
.stat b { font-size: 1.55rem; font-weight: 800; display: block; margin-top: 6px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat.on b { color: var(--accent); }
.stat.off b { color: var(--muted); }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.group .table-wrap { border: 0; background: transparent; border-radius: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.wide { min-width: 1080px; }
.idcell { white-space: nowrap; max-width: 220px; }
.clip {
  display: inline-block; max-width: 150px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
  color: var(--muted);
}
th, td { border-bottom: 1px solid rgba(255, 255, 255, .06); padding: 10px 12px; text-align: left; vertical-align: middle; }
th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); background: #161618; position: sticky; top: 0; font-weight: 650;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(124, 92, 255, .06); }

.row-actions { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; justify-content: flex-end; }
td.row-actions { white-space: nowrap; width: 1%; min-width: 430px; }
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  background: #1b2330; font-size: .72rem; font-weight: 700;
}
.badge.ban { color: var(--danger); background: var(--danger-dim); }
.badge.warn { color: var(--warn); background: rgba(251, 191, 36, .12); }
.badge.kick { color: var(--info); background: rgba(147, 197, 253, .12); }
.badge.ok, .badge.online { color: var(--accent); background: var(--accent-dim); }

.shot {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
}
.shot .cap { padding: 8px 10px; font-size: .8rem; color: var(--muted); }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 12px;
}
.toolbar > label { white-space: nowrap; }
.toolbar > input { flex: 1; min-width: 160px; height: 38px; }
.toolbar > select { flex: 0 0 200px; width: 200px; min-width: 160px; height: 38px; }
.toolbar > button { width: auto; height: 38px; padding: 0 14px; margin-left: auto; }
.toolbar > .row-actions { width: auto; height: auto; flex-wrap: nowrap; margin-left: auto; }
.toolbar > .row-actions button { height: 38px; padding: 0 14px; }
.settings-row {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row b { font-variant-numeric: tabular-nums; text-align: right; }
.settings-row.with-tune {
  grid-template-columns: minmax(180px, 1.5fr) 84px 118px minmax(140px, 1fr);
  min-height: 46px;
}
.settings-row.with-tune > label { font-size: .82rem; color: var(--muted); }
.settings-row select { height: 34px; padding-top: 0; padding-bottom: 0; }
.hint { color: var(--muted); font-size: .88rem; margin: 0 0 12px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.shot { cursor: zoom-in; }
.shot img { width: 100%; display: block; height: 220px; object-fit: cover; background: #0c0c0e; }
.viewer {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, .88);
  display: flex; flex-direction: column;
}
.viewer-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
#viewerTitle { margin-right: auto; font-weight: 650; }
.viewer-bar button { width: auto; height: 34px; padding: 0 12px; }
#viewerLive.on { border-color: rgba(255,255,255,.55); color: #fff; }
.viewer-stage { flex: 1; overflow: auto; display: grid; place-items: center; padding: 16px; }
#viewerImg { max-width: min(1100px, 92vw); max-height: 82vh; border-radius: 12px; background: #111; }
.group {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 16px 8px;
  margin: 0 0 12px;
}
.group h3 { margin: 0 0 10px; font-size: .95rem; font-weight: 650; }
.group-head {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  margin-bottom: 12px;
}
.group-head h3 { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.form-grid label { display: grid; gap: 6px; font-size: .78rem; color: var(--muted); }
.perm-grid { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 8px 0 12px; }
.perm-grid label { font-size: .85rem; color: var(--muted); display: flex; gap: 6px; align-items: center; width: auto; }
.stack { display: grid; gap: 10px; }
.tune { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: flex-end; }
.tune label { font-size: .75rem; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; width: auto; white-space: nowrap; }
.tune input { width: 76px; height: 32px; padding: 0 8px; }

.modal {
  position: fixed; inset: 0; background: rgba(4, 7, 12, .62);
  display: grid; place-items: center; z-index: 20; padding: 16px;
}
.modal .card { width: min(440px, 92vw); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip { width: auto; padding: 6px 10px; background: var(--panel); font-size: .8rem; }
.chip.active { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .22); }
.pickers { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.pickers button { width: auto; font-size: .72rem; padding: 5px 8px; }

.timeline { display: grid; gap: 8px; }
.tl { background: #0c1118; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tl .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.ident { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.ident span {
  font-size: .75rem; color: var(--muted); background: #0c1118;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px;
}
.counts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.count-pill {
  background: #0c1118; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; min-width: 84px;
}
.count-pill b { display: block; font-size: 1.1rem; }
.count-pill span { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.empty {
  text-align: center; color: var(--muted); padding: 22px 12px;
  border: 1px dashed var(--line); border-radius: 14px;
}
.group .empty { border: 0; padding: 8px 0 16px; }

.settings-row.changed { box-shadow: inset 3px 0 0 var(--warn); padding-left: 10px; }
.group > .row-actions { flex-wrap: wrap; align-items: center; justify-content: flex-start; margin: 0 0 12px; }
.group-head .row-actions { flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.group-head .row-actions select { width: auto; height: 32px; padding-top: 0; padding-bottom: 0; }
button:disabled { opacity: .45; cursor: not-allowed; }
#dirtyNote { align-self: center; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dash-split { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  #app, #app.collapsed { grid-template-columns: 1fr; }
  aside {
    position: fixed; left: 0; top: 0; transform: translateX(-105%);
    width: min(280px, 86vw); transition: transform .2s ease;
  }
  #app.menu-open aside { transform: none; box-shadow: var(--shadow); }
  .nav-open { display: inline-flex; }
  header { flex-direction: column; align-items: stretch; }
  .head-tools, .livebar, .tool-row { align-items: stretch; width: 100%; }
  .tool-row { flex-wrap: wrap; }
  .tool-row .search, .search { width: 100%; }
  #refresh { width: auto; align-self: flex-end; }
  .form-grid, .settings-row, .settings-row.with-tune, .toolbar { grid-template-columns: 1fr; }
  .grid, .stats-grid { grid-template-columns: 1fr 1fr; }
}

.site-wait { display: none; margin: 0; }
body.site .staff-only { display: none !important; }
body.site .site-wait { display: block; }

.owner-app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}
.owner-side {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.owner-side .brand { padding: 4px 12px 0; }
.owner-side .brand-tag { padding: 6px 12px 14px; margin: 0; border-bottom: 1px solid var(--line); font-size: .8rem; }
.owner-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; flex: 1; }
.owner-side a, .owner-side button.side-out {
  display: flex;
  align-items: center;
  padding: .5rem .75rem;
  border-radius: 8px;
  border: 0;
  color: #a1a1aa;
  text-decoration: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-weight: 500;
  font-size: .92rem;
  box-shadow: none;
}
.owner-side a:hover { color: #fff; background: transparent; }
.owner-side a.active { color: #fff; font-weight: 650; background: transparent; }
.owner-side form { margin-top: auto; }
.owner-side button.side-out { color: #ef4444; }
.owner-side button.side-out:hover { color: #f87171; background: transparent; }
.owner-main { padding: 28px; max-width: 980px; }
.owner-main h2 { font-family: "Plus Jakarta Sans", system-ui, sans-serif; letter-spacing: -.03em; font-weight: 650; margin: 0 0 16px; }
.owner-main .card { width: auto; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat-row .card { padding: 16px; }
.stat-row strong { display: block; font-size: 1.6rem; margin-top: 6px; font-variant-numeric: tabular-nums; }
.owner-main table { width: 100%; border-collapse: collapse; }
.owner-main td, .owner-main th { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.owner-main th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.owner-main td form { margin: 0; }
.guide { display: grid; gap: 12px; margin-top: 16px; }
.guide h2 { margin: 0; }
.steps { margin: 0; padding-left: 1.15rem; display: grid; gap: 12px; }
.steps li { padding-left: 4px; }
.steps b { display: block; font-weight: 650; }
.steps span { display: block; color: var(--muted); margin-top: 2px; }
.zip-progress { display: grid; gap: 8px; }
.zip-progress[hidden] { display: none; }
.zip-bar { height: 6px; background: #1a1a1e; border-radius: 99px; overflow: hidden; }
.zip-bar span { display: block; height: 100%; width: 0; background: #fff; }
.zip-bar span.busy { width: 35%; animation: zip-slide 1s ease-in-out infinite; }
@keyframes zip-slide { from { transform: translateX(-120%); } to { transform: translateX(320%); } }
@media (max-width: 800px) {
  .owner-app { grid-template-columns: 1fr; }
  .owner-side { position: static; height: auto; }
  .stat-row { grid-template-columns: 1fr; }
}
