:root {
  --bg: #000;
  --card-border: #2f6fed;
  --chip-bg: #2b2b2b;
  --input-bg: #101010;
  --input-border: #3a3a3a;
  --text: #f2f2f2;
  --muted: #8a8a8a;
  --blue: #1d6ef5;
  --red: #e5484d;
  --green: #30a46c;
  --accent: #00e0a4;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 24px 28px 80px;
  background: var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
}

/* ---------- top bar ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.topbar h1 { font-size: 26px; margin: 0; font-weight: 700; letter-spacing: -0.5px; }
.rr-badge { font-size: 11px; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px; padding: 3px 8px; vertical-align: middle; margin-left: 10px; font-weight: 400; }
.topbar-right { display: flex; gap: 10px; align-items: center; }

.btn {
  border: none; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 10px 16px; color: #fff; line-height: 1.25;
}
.btn-blue { background: var(--blue); }
.btn-blue:hover { background: #3b82f6; }
.btn-gray { background: #2c2c2c; }
.btn-gray:hover { background: #3a3a3a; }
.btn-red { background: var(--red); }
.btn-mini { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- main card ---------- */
.card {
  border: 1px dashed var(--card-border);
  border-radius: 4px;
  padding: 28px 34px;
  position: relative;
}

.row { display: flex; gap: 14px; margin-bottom: 14px; }
.grow { flex: 1; }

.field { display: flex; align-items: stretch; min-width: 0; }
.field .chip {
  background: var(--chip-bg); color: #fff;
  display: flex; align-items: center;
  padding: 0 14px; border-radius: 8px 0 0 8px;
  white-space: nowrap; font-weight: 600; font-size: 13px;
}
.chip-accent { color: var(--accent); }

.field input, .field select, .field textarea {
  flex: 1; min-width: 0;
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--input-border); border-left: none;
  border-radius: 0 8px 8px 0;
  padding: 10px 12px; font-family: inherit; font-size: 13px;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--card-border); }
.field textarea { resize: vertical; }
.field select[multiple] { padding: 6px; }

.name-preview { color: var(--muted); font-size: 12px; margin: -6px 0 16px 2px; min-height: 15px; word-break: break-all; }

/* ---------- searchable multi-select (weapon-style dropdown) ---------- */
.msel-root { flex: 1; position: relative; min-width: 0; }
.msel-control {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 42px; padding: 5px 8px;
  background: var(--input-bg); border: 1px solid var(--input-border); border-left: none;
  border-radius: 0 8px 8px 0; cursor: text;
}
.msel-control.focus { border-color: var(--card-border); }
.msel-tags { display: contents; }
.mtag {
  display: inline-flex; align-items: center; gap: 6px;
  background: #1d2833; border: 1px solid #2c4257; color: #cfe3f5;
  border-radius: 6px; padding: 3px 6px 3px 9px; font-size: 12px; white-space: nowrap;
}
.mtag-banned { background: #2b1517; border-color: #5c2a2d; color: #e8a0a3; }
.mtag-foreign { opacity: 0.55; border-style: dashed; }
.mtag-x { background: none; border: none; color: inherit; opacity: 0.6; cursor: pointer; font-size: 11px; padding: 0 2px; }
.mtag-x:hover { opacity: 1; }
.msel-input {
  flex: 1; min-width: 110px; border: none; outline: none;
  background: transparent; color: var(--text); font-family: inherit; font-size: 13px; padding: 4px 4px;
}
.msel-panel {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 50;
  background: #17191d; border: 1px solid #33363c; border-radius: 10px;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  animation: msel-in 0.16s ease-out;
}
@keyframes msel-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.msel-opts { max-height: 320px; overflow-y: auto; padding: 6px 0; }
.msel-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 16px; cursor: pointer; min-height: 44px;
}
.msel-opt:hover, .msel-opt.active { background: #23262c; }
.msel-opt-title { font-size: 14px; font-weight: 600; color: #f2f2f2; }
.msel-opt-sub { font-size: 12px; color: #7d838d; margin-top: 2px; }
.msel-status { font-weight: 600; font-size: 13px; }
.msel-status.st-good { color: var(--green); }
.msel-status.st-bad { color: var(--red); }
.msel-badge {
  font-size: 10px; color: var(--red); border: 1px dashed var(--red);
  border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px;
}
.msel-opt.banned .msel-opt-title { color: #d7898c; }
.msel-opt.foreign { opacity: 0.5; }
.msel-check { color: var(--accent); font-weight: 700; width: 16px; text-align: center; flex: none; }
.msel-empty { padding: 16px; color: var(--muted); font-size: 12px; text-align: center; }
.msel-foot {
  display: flex; align-items: center; gap: 12px;
  border-top: 1px solid #26292f; padding: 8px 14px; background: #131519;
}
.msel-panel { min-width: 340px; }
.msel-act {
  background: none; border: none; color: #6ea8fe; cursor: pointer;
  font-family: inherit; font-size: 12px; padding: 4px 2px; white-space: nowrap;
}
.msel-count { white-space: nowrap; }
.msel-act:hover { text-decoration: underline; }
.msel-foreign { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; cursor: pointer; }
.msel-count { margin-left: auto; color: var(--muted); font-size: 11px; }

.host-status { display: inline-flex; align-items: center; color: var(--muted); font-size: 11px; margin-right: auto; }
.profile-field { flex: 0 0 300px; }
.pixel-field { flex: 0 0 320px; }
.pixel-display {
  flex: 1; display: flex; align-items: center; min-width: 0;
  background: var(--input-bg); border: 1px solid var(--input-border); border-left: none;
  border-radius: 0 8px 8px 0; padding: 10px 12px; font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pixel-display.ok { color: var(--green); }
.pixel-display.err { color: var(--red); border-color: rgba(229, 72, 77, 0.55); }

/* accounts / pages chip boxes */
.multi .chipbox {
  flex: 1; display: flex; flex-wrap: wrap; gap: 6px;
  background: var(--input-bg); border: 1px solid var(--input-border); border-left: none;
  border-radius: 0 8px 8px 0; padding: 8px; min-height: 42px;
}
.pick {
  border: 1px solid var(--input-border); border-radius: 6px;
  padding: 5px 10px; cursor: pointer; user-select: none; font-size: 12px; color: var(--muted);
}
.pick.on { border-color: var(--accent); color: var(--accent); background: rgba(0, 224, 164, 0.08); }
.pick.banned { border-color: rgba(229, 72, 77, 0.55); color: #b96467; }
.pick.banned.on { border-color: var(--red); color: var(--red); background: rgba(229, 72, 77, 0.08); }
.pick-empty { color: var(--muted); font-size: 12px; align-self: center; padding-left: 4px; }
.pick.foreign { opacity: 0.45; border-style: dashed; }
.foreign-toggle {
  display: flex; align-items: center; gap: 5px;
  color: var(--muted); font-size: 11px; padding: 0 10px;
  border: 1px solid var(--input-border); border-left: none; border-radius: 0 8px 8px 0;
  background: var(--input-bg); cursor: pointer; white-space: nowrap;
}
.multi .chipbox:not(:last-child) { border-radius: 0; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-green { background: var(--green); }
.dot-red { background: var(--red); }

/* section titles */
.section-title {
  text-align: center; font-weight: 700; margin: 26px 0 18px;
  display: flex; align-items: center; gap: 16px;
}
.section-title::before, .section-title::after { content: ""; flex: 1; border-top: 1px solid #2a2a2a; }

/* advertising grid */
.adv-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }
.adv-left .field { margin-bottom: 12px; }
.adv-left .field:last-child { margin-bottom: 0; }

.dropzone {
  border: 1px dashed var(--card-border); border-radius: 6px;
  height: calc(100% - 44px); min-height: 280px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; text-align: center;
}
.dropzone.dragover { background: rgba(47, 111, 237, 0.08); }
.dz-title { font-size: 15px; }
.dz-sub { color: var(--muted); font-size: 11px; margin-top: 8px; }
.dz-count { color: var(--accent); font-size: 13px; margin-top: 12px; font-weight: 700; }
.dz-progress { width: 220px; height: 6px; background: #222; border-radius: 3px; margin: 12px auto 0; overflow: hidden; }
.dz-bar { height: 100%; width: 0%; background: var(--blue); transition: width 0.2s; }
.dz-actions { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }

/* panels */
.panel { border: 1px solid #222; border-radius: 8px; margin-top: 22px; padding: 16px 20px; }
.panel-title { font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 12px; }
.panel-title span { color: var(--muted); font-weight: 400; font-size: 12px; }
.auto-note { color: var(--muted); font-size: 11px; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid #1e1e1e; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
td.wrap { white-space: normal; word-break: break-all; }
.st-ok { color: var(--green); font-weight: 700; }
.st-err { color: var(--red); font-weight: 700; }
.st-run { color: #e8b93c; font-weight: 700; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #191919; border: 1px solid var(--input-border); border-radius: 8px;
  padding: 12px 20px; font-size: 13px; z-index: 200; max-width: 720px;
}
.toast.err { border-color: var(--red); color: #ff9b9e; }
.toast.ok { border-color: var(--green); color: #7ee2b8; }

/* settings modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.75);
  display: flex; align-items: flex-start; justify-content: center; z-index: 100;
  overflow-y: auto; padding: 40px 0;
}
.modal {
  background: #0b0b0b; border: 1px solid #333; border-radius: 10px;
  width: 720px; max-width: 94vw; padding: 22px 26px;
}
.modal-head { font-size: 18px; font-weight: 700; display: flex; justify-content: space-between; margin-bottom: 16px; }
.modal-head .x { background: none; border: none; color: var(--red); font-size: 16px; cursor: pointer; }
.modal .field { margin-bottom: 10px; }
.set-section { font-weight: 700; margin: 18px 0 10px; color: var(--accent); display: flex; align-items: center; gap: 10px; }
.set-table .set-row { display: flex; gap: 8px; margin-bottom: 8px; }
.set-table input { flex: 1; min-width: 0; background: var(--input-bg); color: var(--text); border: 1px solid var(--input-border); border-radius: 6px; padding: 8px 10px; font-family: inherit; font-size: 12px; }
.set-table .del { background: none; border: 1px solid var(--red); color: var(--red); border-radius: 6px; cursor: pointer; padding: 0 10px; }
.modal-foot { margin-top: 20px; display: flex; justify-content: flex-end; }

.highlight-field input { border-color: rgba(0, 224, 164, 0.45); }

/* ---------- Stats page ---------- */
.stats-body { padding-bottom: 40px; }
.auto-wrap { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.auto-wrap select { background: var(--input-bg); color: var(--text); border: 1px solid var(--input-border); border-radius: 6px; padding: 6px 8px; font-family: inherit; font-size: 12px; }
.topbar-right a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.tiles { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; margin: 6px 0 14px; }
.tile { border: 1px solid #222; border-radius: 8px; padding: 10px 12px; background: #0b0b0b; }
.tile-k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.tile-v { font-size: 18px; font-weight: 700; margin-top: 4px; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters .field input, .filters .field select { padding: 8px 10px; }
.filters input[type="date"] { color-scheme: dark; }
.chk { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.bulkbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin-bottom: 10px;
  border: 1px solid rgba(0,224,164,.35); border-radius: 8px; background: rgba(0,224,164,.05); font-size: 12px; }
.bulkbar input { width: 150px; background: var(--input-bg); color: var(--text); border: 1px solid var(--input-border); border-radius: 6px; padding: 5px 8px; font-family: inherit; font-size: 12px; }
.bulkbar .sep { width: 1px; height: 18px; background: #2a2a2a; margin: 0 4px; }
.stats-wrap { border: 1px solid #222; border-radius: 8px; max-height: calc(100vh - 290px); overflow: auto; }
table.stats th { position: sticky; top: 0; background: #0d0d0d; z-index: 2; cursor: pointer; user-select: none; }
table.stats th.sorted { color: var(--accent); }
table.stats th.num, table.stats td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.stats td { vertical-align: top; }
table.stats td.camp { max-width: 340px; }
table.stats .sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
table.stats tfoot td { position: sticky; bottom: 0; background: #0d0d0d; font-weight: 700; border-top: 1px solid #333; z-index: 2; }
table.stats tr.selrow td { background: rgba(0,224,164,.06); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 700; border: 1px solid currentColor; }
.st-muted { color: var(--muted); }
.warn { color: #e8b93c; }

table.stats td.vdim { color: #9aa4b2; }
.field .chip.mid { border-radius: 0; padding: 0 8px; }
.tiles { grid-template-columns: repeat(10, 1fr); }

/* ---------- Stats v30: grid cells, on/off switch, two-line V-metrics, fixed totals bar ---------- */
.stats-wrap { border: 1px solid #262626; border-radius: 10px; height: calc(100vh - 300px); min-height: 360px; overflow: auto; background: #0a0a0a; }
.stats-wrap::-webkit-scrollbar { height: 12px; width: 12px; }
.stats-wrap::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 6px; border: 3px solid #0a0a0a; }
.stats-wrap::-webkit-scrollbar-track { background: #111; }
table.stats { min-width: 2300px; border-collapse: separate; border-spacing: 0; }
table.stats th, table.stats td { border-right: 1px solid #1f1f1f; border-bottom: 1px solid #1f1f1f; padding: 9px 12px; white-space: nowrap; }
table.stats th { background: #101010; font-size: 12px; color: #b9b9b9; height: 46px; }
table.stats th.sorted { color: var(--accent); }
table.stats td { background: #0d0d0d; font-size: 13px; }
table.stats tbody tr:hover td { background: #141414; }
table.stats tr.row-off td { color: #8a8a8a; }
table.stats tr.row-off td .v1 { color: #a0a0a0; }
table.stats td.camp { white-space: normal; min-width: 340px; max-width: 380px; }
table.stats td.wrap { white-space: normal; }
table.stats .c-sel { width: 36px; text-align: center; }
table.stats .c-onoff { width: 70px; text-align: center; }
.v1 { font-weight: 600; font-variant-numeric: tabular-nums; }
.v2 { color: #8a94a3; font-size: 11px; margin-top: 2px; font-variant-numeric: tabular-nums; }
/* totals bar: tall, pinned at the bottom of the scroll window */
table.stats tfoot td { position: sticky; bottom: 0; z-index: 3; background: #000; border-top: 2px solid #333; border-bottom: none;
  height: 64px; padding: 10px 12px; font-size: 14px; font-weight: 700; }
table.stats tfoot .v2 { font-size: 12px; }
/* on/off switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .knob { position: absolute; inset: 0; background: #3a3a3a; border-radius: 22px; transition: background .18s ease-out; }
.switch .knob::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .18s ease-out; }
.switch input:checked + .knob { background: var(--green); }
.switch input:checked + .knob::after { transform: translateX(18px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--card-border); outline-offset: 2px; }
.switch.busy { opacity: .5; cursor: progress; }
/* tiles: virtual line */
.tiles { grid-template-columns: repeat(9, 1fr); }
.tile-virt { color: #8a94a3; font-size: 11px; margin-top: 2px; }

/* include / exclude search fields (stats) */
.incl-row { display: flex; gap: 8px; flex: 1; min-width: 560px; }
.incl-row input { flex: 1; min-width: 0; background: var(--input-bg); color: var(--text); border: 1px solid var(--input-border);
  border-radius: 8px; padding: 8px 12px; font-family: inherit; font-size: 13px; outline: none; }
.incl-row input:focus { border-color: var(--card-border); }
.incl-row input.excl { border-color: rgba(229,72,77,.45); }
.incl-row input.excl:focus { border-color: var(--red); }
.incl-row input::placeholder { color: #6f6f6f; }

/* ---------- admin page / role UI ---------- */
.adm-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.adm-form .field { min-width: 180px; }
.adm-form .field.grow { flex: 1; min-width: 320px; }
.adm-actions { white-space: nowrap; }
.adm-actions .btn { margin-right: 4px; }
.edit-row td { background: #0b0b0b; }
.acting-banner { background: rgba(232,185,60,.12); border: 1px solid rgba(232,185,60,.5); color: #f0cf6e; border-radius: 8px;
  padding: 8px 14px; margin-bottom: 12px; font-size: 12px; display: flex; align-items: center; gap: 12px; }
.acting-banner .btn { margin-left: auto; }
.managed { color: var(--muted); font-size: 12px; padding: 8px 2px 4px; }
