:root {
  --bg: #0e1013;
  --surface: #161a20;
  --surface-2: #1d222a;
  --border: #2a303a;
  --text: #e7e9ee;
  --muted: #8d95a5;
  --accent: #5fbf4a;
  --accent-ink: #0b1a08;
  --blue: #5b9cf5;
  --amber: #e8b14a;
  --red: #ef5f5f;
  --radius: 10px;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
code { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px;
  background: rgba(14, 16, 19, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; font-size: 15px; }
main { max-width: 1180px; margin: 0 auto; padding: 24px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: #252b35; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #6fd259; }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 28px; padding: 0; }
.btn svg { flex: none; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; height: 36px; padding: 0 11px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; outline: none;
}
textarea { height: auto; padding: 10px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(95, 191, 74, .15); }
input[type=range] { width: 100%; accent-color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* toggle switch */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; cursor: pointer; }
.switch input { appearance: none; flex: none; width: 36px; height: 20px; border-radius: 99px; background: #3a414d; position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.switch .title { font-weight: 500; }
.switch .hint { font-size: 12px; color: var(--muted); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }

.servers { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.server-card { cursor: pointer; display: flex; flex-direction: column; gap: 12px; transition: border-color .12s, transform .12s; }
.server-card:hover { border-color: #3b4350; }
.server-card .title-row { display: flex; align-items: center; gap: 10px; }
.server-card h3 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-card .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }

.empty { text-align: center; padding: 64px 24px; }
.empty img { width: 56px; height: 56px; margin-bottom: 12px; }
.empty p { color: var(--muted); margin: 8px 0 20px; }

/* status pill */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.running { color: var(--accent); background: rgba(95, 191, 74, .12); }
.pill.starting, .pill.busy { color: var(--amber); background: rgba(232, 177, 74, .12); }
.pill.starting::before, .pill.busy::before { animation: pulse 1.2s infinite; }
.pill.crashed, .pill.unhealthy { color: var(--red); background: rgba(239, 95, 95, .12); }
@keyframes pulse { 50% { opacity: .3; } }

.addr { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.addr code { color: var(--text); }
.addr-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-right: 2px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: 12px; }

/* ---------- server detail ---------- */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 13px; margin-bottom: 14px; }
.back:hover { color: var(--text); }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.detail-head .title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-head .sub { margin-top: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.banner { margin-top: 16px; padding: 10px 14px; border-radius: 8px; display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.banner.warn { background: rgba(232, 177, 74, .1); border: 1px solid rgba(232, 177, 74, .3); color: #f1cf8c; }
.banner.error { background: rgba(239, 95, 95, .1); border: 1px solid rgba(239, 95, 95, .3); color: #f5a3a3; }
.banner.info { background: rgba(91, 156, 245, .1); border: 1px solid rgba(91, 156, 245, .3); color: #a9c8f8; }
.banner .spacer { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 19px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.bar { height: 4px; border-radius: 4px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s; }

.tabs { display: flex; gap: 2px; margin: 22px 0 16px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

/* console */
.console { background: #08090b; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.log { height: calc(100vh - 430px); min-height: 320px; overflow-y: auto; padding: 12px 14px; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; color: #c9ced8; }
.log .warn { color: var(--amber); }
.log .err { color: var(--red); }
.log .sys { color: var(--blue); }
.log .cmd { color: var(--accent); }
.log .out { color: #e7e9ee; }
.cmd-row { display: flex; align-items: center; gap: 8px; padding: 8px; border-top: 1px solid var(--border); background: var(--surface); }
.cmd-row .prompt { font-family: var(--mono); color: var(--accent); padding-left: 6px; }
.cmd-row input { border: none; background: transparent; box-shadow: none !important; font-family: var(--mono); font-size: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip { padding: 3px 10px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: 12.5px var(--mono); cursor: pointer; }
.chip:hover { color: var(--text); border-color: #3b4350; }

/* players */
.player-list { display: flex; flex-direction: column; }
.player { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.player:last-child { border-bottom: none; }
.player img { width: 24px; height: 24px; border-radius: 4px; image-rendering: pixelated; background: var(--surface-2); }
.player .name { flex: 1; font-weight: 500; }
.add-row { display: flex; gap: 8px; margin-top: 12px; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table td.actions { text-align: right; white-space: nowrap; }
.table .file-name { display: flex; align-items: center; gap: 8px; cursor: default; }
.table .file-name.dir { cursor: pointer; font-weight: 500; }
.table .file-name.dir:hover { color: var(--accent); }
.table .file-name svg { color: var(--muted); flex: none; }
.table .file-name.dir svg { color: var(--amber); }
.table-wrap { overflow-x: auto; }

.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-family: var(--mono); font-size: 13px; }
.crumbs a { color: var(--muted); text-decoration: none; cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.crumbs a:hover { color: var(--text); background: var(--surface-2); }
.crumbs span { color: #4a515e; }

.dropzone { position: relative; }
.dropzone.drag::after { content: "Drop files to upload"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(95, 191, 74, .1); border: 2px dashed var(--accent); border-radius: var(--radius); color: var(--accent); font-weight: 600; font-size: 15px; }

.progress { margin-top: 12px; }
.progress .bar { height: 6px; }

/* ---------- type picker ---------- */
.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.type { position: relative; display: block; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); cursor: pointer; transition: border-color .12s, background .12s; }
.type input { position: absolute; opacity: 0; pointer-events: none; }
.type b { display: block; font-weight: 600; font-size: 13.5px; }
.type span { font-size: 12px; color: var(--muted); }
.type:hover { border-color: #3b4350; }
.type:has(input:checked) { border-color: var(--accent); background: rgba(95, 191, 74, .08); }

details.advanced { border-top: 1px solid var(--border); padding-top: 12px; }
details.advanced summary { cursor: pointer; color: var(--muted); font-weight: 500; user-select: none; }
details.advanced[open] summary { margin-bottom: 14px; }

.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 0 -4px; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; animation: fade .12s; }
.modal { width: 100%; max-width: 620px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); animation: rise .15s; }
.modal.wide { max-width: 960px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.editor { width: 100%; height: 60vh; font: 12.5px/1.55 var(--mono); white-space: pre; tab-size: 2; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); font-size: 13.5px; animation: rise .15s; }
.toast.error { border-color: rgba(239, 95, 95, .5); }
.toast.ok { border-color: rgba(95, 191, 74, .5); }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 360px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.auth .logo { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; margin-bottom: 4px; }
.auth .logo img { width: 48px; height: 48px; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  main { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .topbar .btn span { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .servers { grid-template-columns: 1fr; }
  .log { height: 55vh; }
  .hide-sm { display: none; }
}
