:root {
  color-scheme: dark;
  --bg: #13151a;
  --sidebar: #191c23;
  --card: #1f232b;
  --card-2: #272c36;
  --line: #2e343f;
  --text: #e9ecf1;
  --muted: #9aa3b0;
  --faint: #6c7584;
  --green: #22b35e;
  --green-dark: #1b9650;
  --red: #e5484d;
  --red-dark: #c73a3f;
  --orange: #f0a020;
  --blue: #4c9be8;
  --terminal: #0d0f13;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }

/* Layout ------------------------------------------------------------------ */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 16px; border-bottom: 1px solid var(--line); }
.brand img { width: 40px; height: 40px; border-radius: 8px; image-rendering: pixelated; background: var(--card-2); }
.brand .name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand .state { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 3px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.online { background: var(--green); box-shadow: 0 0 0 3px rgba(34, 179, 94, .18); }
.dot.offline { background: var(--red); }
.dot.starting, .dot.stopping { background: var(--orange); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.nav { padding: 10px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 500; position: relative;
}
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.active { background: var(--card-2); color: var(--text); }
.nav a.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--green);
}
.sidebar .foot { padding: 10px; border-top: 1px solid var(--line); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 16px 28px; border-bottom: 1px solid var(--line);
  background: rgba(19, 21, 26, .85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 20px; flex: 1; }
.topbar .menu-btn { display: none; }
.content { padding: 24px 28px 48px; max-width: 1160px; width: 100%; }
.content.wide { max-width: none; }

/* Building blocks --------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card + .card, .card + .section-title, .grid + .card, .card + .grid { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font-size: 15px; flex: 1; }
.card-body { padding: 16px 18px; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 24px 2px 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap;
  text-decoration: none;
}
.btn:hover:not(:disabled) { border-color: var(--faint); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.green:hover:not(:disabled) { background: var(--green-dark); border-color: var(--green-dark); }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.red:hover:not(:disabled) { background: var(--red-dark); border-color: var(--red-dark); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.icon-only { padding: 7px; }
.btn.big { padding: 14px 28px; font-size: 16px; border-radius: 10px; }
.btn.full { width: 100%; }
.btn:focus-visible, .input:focus-visible, select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.input, select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 0;
}
.input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--card-2); color: var(--muted); }
.badge.green { background: rgba(34, 179, 94, .15); color: #4fd38a; }
.badge.red { background: rgba(229, 72, 77, .15); color: #ff7b7f; }
.badge.orange { background: rgba(240, 160, 32, .15); color: #ffc15e; }
.badge.blue { background: rgba(76, 155, 232, .15); color: #7db8f0; }

.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius);
  background: rgba(240, 160, 32, .1); border: 1px solid rgba(240, 160, 32, .35); margin-bottom: 16px;
}
.banner .text { flex: 1; }

.switch { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch .track { width: 40px; height: 22px; border-radius: 11px; background: #4a515e; position: relative; transition: background .15s; }
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--blue); outline-offset: 2px; }

.empty { padding: 28px 18px; text-align: center; color: var(--muted); }

/* Server page ------------------------------------------------------------- */
.status-card {
  display: flex; align-items: center; gap: 22px; padding: 26px 28px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card); position: relative; overflow: hidden;
}
.status-card::before { content: ""; position: absolute; inset: 0; opacity: .14; pointer-events: none; }
.status-card.online::before { background: linear-gradient(110deg, var(--green), transparent 70%); }
.status-card.offline::before { background: linear-gradient(110deg, var(--red), transparent 70%); }
.status-card.starting::before, .status-card.stopping::before { background: linear-gradient(110deg, var(--orange), transparent 70%); }
.status-card img { width: 72px; height: 72px; border-radius: 12px; image-rendering: pixelated; background: var(--card-2); position: relative; }
.status-card .info { flex: 1; position: relative; min-width: 0; }
.status-card .label { font-size: 30px; font-weight: 800; line-height: 1.1; }
.status-card.online .label { color: #4fd38a; }
.status-card.offline .label { color: #ff7b7f; }
.status-card.starting .label, .status-card.stopping .label { color: #ffc15e; }
.status-card .sub { color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.status-card .actions { display: flex; gap: 10px; position: relative; flex-wrap: wrap; }

.status-card + .card { margin-top: 16px; }
.address { display: flex; align-items: center; gap: 12px; padding: 14px 18px; }
.address .grow { flex: 1; min-width: 0; }
.address .value { font-family: var(--mono); font-size: 18px; font-weight: 600; flex: 1; overflow-wrap: anywhere; }
.address .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 16px; }
.grid > .card, .logs > .card { margin-top: 0; }
.tile { padding: 16px 18px; }
.tile .head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.tile .value { font-size: 22px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tile .hint { font-size: 12px; color: var(--faint); margin-top: 2px; }
.meter { height: 6px; background: var(--card-2); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--green); border-radius: 3px; transition: width .4s; }
.meter span.warn { background: var(--orange); }
.meter span.crit { background: var(--red); }

.player-list { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 18px; }
.player-chip { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; background: var(--card-2); border-radius: 8px; font-weight: 600; }
.head-img { width: 28px; height: 28px; border-radius: 5px; image-rendering: pixelated; background: var(--bg); flex: none; }

/* Console ----------------------------------------------------------------- */
.terminal {
  background: var(--terminal); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 360px;
}
.terminal .lines {
  flex: 1; overflow-y: auto; padding: 12px 14px; font: 13px/1.55 var(--mono);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.line { color: #cfd5de; }
.line .t { color: #5d6675; }
.line .th { color: #7a8494; }
.line.warn { color: #ffc15e; }
.line.error, .line.fatal { color: #ff7b7f; }
.line.chat { color: #9fe0b7; }
.line.join { color: #7db8f0; }
.line.cmd { color: #e9ecf1; font-weight: 700; }
.line.sep { color: var(--faint); text-align: center; margin: 6px 0; }
.terminal .prompt { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding: 10px 12px; }
.terminal .prompt .caret { color: var(--green); font: 700 15px var(--mono); }
.terminal .prompt input { flex: 1; background: transparent; border: 0; outline: none; font: 14px var(--mono); padding: 6px 0; }
.jump { position: absolute; right: 24px; bottom: 74px; }
.terminal-wrap { position: relative; }

/* Logs -------------------------------------------------------------------- */
.logs { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
.log-files { padding: 6px; max-height: calc(100vh - 150px); overflow-y: auto; }
.log-files button {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left;
  background: none; border: 0; border-radius: 8px; padding: 9px 12px; cursor: pointer; color: var(--muted);
}
.log-files button:hover { background: var(--card-2); color: var(--text); }
.log-files button.active { background: var(--card-2); color: var(--text); }
.log-files .fname { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.log-files .fmeta { font-size: 12px; color: var(--faint); }
.log-view { display: flex; flex-direction: column; min-width: 0; }
.log-toolbar { display: flex; gap: 10px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.log-toolbar .input { flex: 1; min-width: 160px; }
.log-toolbar label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.log-view .lines {
  background: var(--terminal); border-radius: 0 0 var(--radius) var(--radius); padding: 12px 14px;
  font: 13px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
  height: calc(100vh - 220px); min-height: 300px; overflow-y: auto;
}
mark { background: rgba(240, 160, 32, .35); color: inherit; border-radius: 2px; }

/* Lists (players, backups, plugins) ---------------------------------------- */
.tabs { display: flex; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  background: none; border: 0; padding: 8px 14px; border-radius: 8px; color: var(--muted);
  font-weight: 600; cursor: pointer; white-space: nowrap; display: flex; gap: 8px; align-items: center;
}
.tabs button:hover { color: var(--text); background: var(--card-2); }
.tabs button.active { color: var(--text); background: var(--card-2); }
.tabs .count { font-size: 11px; background: var(--bg); border-radius: 999px; padding: 1px 7px; color: var(--muted); }
.add-row { display: flex; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.add-row .input { flex: 1; min-width: 180px; }
.rows > div { display: flex; align-items: center; gap: 14px; padding: 12px 18px; }
.rows > div + div { border-top: 1px solid var(--line); }
.rows .grow { flex: 1; min-width: 0; }
.rows .title { font-weight: 600; overflow-wrap: anywhere; }
.rows .meta { font-size: 12px; color: var(--faint); overflow-wrap: anywhere; }
.rows .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Options ----------------------------------------------------------------- */
.opt { display: flex; align-items: center; gap: 16px; padding: 14px 18px; }
.opt + .opt { border-top: 1px solid var(--line); }
.opt .text { flex: 1; min-width: 0; }
.opt .text h3 { margin: 0; font-size: 14px; font-weight: 600; }
.opt .text p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.opt .text code { font-size: 11px; color: var(--faint); }
.opt .control { flex: none; width: 240px; display: flex; justify-content: flex-end; }
.opt .control .input, .opt .control select { width: 100%; }
.opt.changed { background: rgba(76, 155, 232, .06); }
.savebar {
  position: sticky; bottom: 16px; margin-top: 16px; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius); background: var(--card-2); border: 1px solid var(--blue);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}
.savebar .text { flex: 1; }
details.all summary { cursor: pointer; padding: 14px 18px; font-weight: 600; }
details.all[open] summary { border-bottom: 1px solid var(--line); }

/* Account and login -------------------------------------------------------- */
.form { display: grid; gap: 12px; max-width: 380px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }

.login-page { display: grid; place-items: center; min-height: 100%; padding: 16px; }
.login-box { width: 100%; max-width: 360px; padding: 28px; }
.login-box .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-box .logo h1 { font-size: 20px; margin: 0; }
.login-box .btn { width: 100%; margin-top: 4px; }
.login-box .error { color: #ff7b7f; font-size: 13px; min-height: 20px; }

/* Toast and dialog --------------------------------------------------------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--card-2); border: 1px solid var(--line); border-left: 4px solid var(--green);
  padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); max-width: 360px;
}
.toast.error { border-left-color: var(--red); }
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { width: 100%; max-width: 420px; padding: 22px; }
.modal h2 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0 0 14px; color: var(--muted); }
.modal .input { width: 100%; margin-bottom: 14px; }
.modal .acts { display: flex; justify-content: flex-end; gap: 10px; }

/* Navigation groups -------------------------------------------------------- */
.nav-title {
  display: flex; align-items: center; gap: 8px; margin: 14px 12px 4px; font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--faint);
}

/* Overview ------------------------------------------------------------------ */
.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.service { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; margin: 0 !important; }
.service-head { display: flex; align-items: center; gap: 10px; }
.service-head h3 { margin: 0; font-size: 15px; flex: 1; }
.service-detail { color: var(--muted); font-size: 13px; }
.service-facts { color: var(--faint); font-size: 12px; }
.service-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.modal.wide-modal { max-width: 900px; padding: 0; overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; flex: 1; font-size: 16px; }
.journal {
  background: var(--terminal); font: 12.5px/1.55 var(--mono); padding: 12px 14px; height: min(70vh, 640px);
  overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* Files ------------------------------------------------------------------- */
.files-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.files-bar .input { width: 220px; }
.crumbs { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; flex-wrap: wrap; font-weight: 600; }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; color: var(--text); text-decoration: none; padding: 4px 6px; border-radius: 6px; }
.crumbs a:hover { background: var(--card-2); }
.crumbs .sep { color: var(--faint); display: inline-flex; }
label.btn { position: relative; }
.upload-state { padding: 8px 14px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); }
.file-rows .file-row { cursor: pointer; padding: 9px 18px; }
.file-rows .file-row:hover { background: var(--card-2); }
.file-rows .file-row .icon { color: var(--muted); }
.file-rows .file-row[data-dir="1"] > .icon { color: var(--orange); }
.editor { display: flex; flex-direction: column; height: calc(100vh - 130px); min-height: 360px; margin: 0 !important; }
.editor textarea {
  flex: 1; border: 0; border-radius: 0 0 var(--radius) var(--radius); resize: none; background: var(--terminal);
  font: 13px/1.6 var(--mono); padding: 14px; tab-size: 4; outline: none;
}

/* Overview: Twitch extra ---------------------------------------------------- */
.service-extra { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.service-extra > div { display: flex; gap: 8px; }
.service-extra .k { color: var(--faint); min-width: 92px; }
.service-extra .v { color: var(--text); overflow-wrap: anywhere; }
.service-extra .warn-line { color: #ffc15e; }

/* Banners for key system / obfuscator -------------------------------------- */
.banner.fresh { background: rgba(34, 179, 94, .1); border-color: rgba(34, 179, 94, .4); }
.banner.fresh code { background: var(--terminal); padding: 2px 8px; border-radius: 6px; font-family: var(--mono); font-weight: 700; user-select: all; }
.banner.info { background: rgba(76, 155, 232, .08); border-color: rgba(76, 155, 232, .3); }

/* Data tables (keys, players, scripts) ------------------------------------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.data-table td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td:first-child { display: flex; align-items: center; gap: 8px; }
.data-table .empty { text-align: center; }
.keycell { background: var(--terminal); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; width: 240px; max-width: 42vw; font-size: 12.5px; cursor: pointer; }
.key-acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.key-acts .btn.small { padding: 4px 8px; }

.key-create .create-row { display: flex; gap: 12px; padding: 14px 18px; flex-wrap: wrap; align-items: flex-end; }
.key-create label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.key-create label.grow { flex: 1; min-width: 220px; }
.key-create .create-row > .btn { align-self: flex-end; }
.key-create .create-hint { margin: 0 18px 14px; font-size: 12px; }
.key-filter { align-items: center; }
.key-filter .key-search { margin-left: auto; width: 260px; max-width: 50vw; }
.key-tiles { grid-template-columns: repeat(4, 1fr); }

/* Obfuscator --------------------------------------------------------------- */
.obf { padding: 0; }
.obf-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.obf-head h2 { margin: 0; font-size: 15px; }
.obf-head #obf-info { flex: 1; font-size: 13px; }
.obf-grid { display: grid; grid-template-columns: 1fr 1fr; }
.obf-col { display: flex; flex-direction: column; min-width: 0; }
.obf-col + .obf-col { border-left: 1px solid var(--line); }
.obf-label { display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--line); min-height: 42px; }
.obf-label .btn { margin-left: auto; }
.obf textarea {
  border: 0; resize: vertical; background: var(--terminal); font: 12.5px/1.6 var(--mono);
  padding: 12px 14px; height: calc(100vh - 320px); min-height: 280px; outline: none; tab-size: 2;
}
.obf-out, #obf-out { color: var(--muted); }

/* Small screens ------------------------------------------------------------ */
@media (max-width: 980px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .key-tiles { grid-template-columns: repeat(2, 1fr); }
  .logs { grid-template-columns: 1fr; }
  .log-files { max-height: 220px; }
  .obf-grid { grid-template-columns: 1fr; }
  .obf-col + .obf-col { border-left: 0; border-top: 1px solid var(--line); }
  .obf textarea { height: 40vh; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .6); }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 40px; }
  .status-card { flex-direction: column; align-items: flex-start; padding: 20px; }
  .status-card .actions { width: 100%; }
  .status-card .actions .btn { flex: 1; }
  .opt { flex-direction: column; align-items: stretch; }
  .opt .control { width: 100%; justify-content: flex-start; }
  .terminal { height: calc(100vh - 120px); }
  .rows > div { flex-wrap: wrap; }
}
