:root {
  --bg: #0a0f1d;
  --bg2: #0e1528;
  --panel: #131c33;
  --panel2: #19243f;
  --border: #243150;
  --text: #e7ecf7;
  --muted: #8b97b5;
  --accent: #3b82f6;
  --accent2: #06b6d4;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --purple: #8b5cf6;
  --radius: 10px;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid var(--border); background: var(--panel2); color: var(--text);
  padding: 9px 16px; border-radius: 8px; cursor: pointer; font-weight: 600;
  transition: filter .15s, transform .05s, background .15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; }
.btn-start { background: var(--green); border-color: transparent; color: #04170b; }
.btn-stop { background: var(--red); border-color: transparent; }
.btn-restart { background: var(--orange); border-color: transparent; color: #241500; }
.btn-ghost { background: transparent; }
.btn-danger-ghost { background: transparent; color: #fca5a5; border-color: #5b2330; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
label.field small { display: block; color: var(--muted); margin-top: 4px; font-size: 12px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.row { display: flex; gap: 12px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; }
.error-box { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4); color: #fecaca; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }
.info-box { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.35); color: #c7dbff; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }

/* ---------- auth screens ---------- */
.auth-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(59,130,246,.25), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(6,182,212,.18), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card p.muted { margin: 0 0 24px; }
.auth-card .btn { width: 100%; padding: 12px; margin-top: 6px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: .02em; }
.logo-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(6,182,212,.35); }
.logo-mark svg { width: 20px; height: 20px; color: #fff; }
.logo b { color: var(--accent2); }
.auth-card .logo { margin-bottom: 26px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; grid-template-rows: 60px 1fr; height: 100%; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 20px; padding: 0 20px; background: var(--bg2); border-bottom: 1px solid var(--border); }
.topbar .spacer { flex: 1; }
.sys-stats { display: flex; gap: 18px; color: var(--muted); font-size: 13px; }
.sys-stats b { color: var(--text); font-weight: 600; }
.menu-toggle { display: none; }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; background: transparent; border: 1px solid transparent; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.user-btn:hover { background: var(--panel); border-color: var(--border); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--purple), var(--accent)); display: grid; place-items: center; font-weight: 700; font-size: 13px; text-transform: uppercase; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; min-width: 190px; padding: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.4); z-index: 50; }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 6px; color: var(--text); background: none; border: 0; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { background: var(--panel2); }

.sidebar { background: var(--bg2); border-right: 1px solid var(--border); padding: 16px 12px; overflow-y: auto; }
.side-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 10px 8px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); margin-bottom: 2px; }
.side-link:hover { background: var(--panel); }
.side-link.active { background: linear-gradient(90deg, rgba(59,130,246,.22), rgba(59,130,246,.04)); box-shadow: inset 3px 0 0 var(--accent); }
.side-link svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.side-link .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { overflow-y: auto; padding: 26px 30px 40px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 16px; font-size: 16px; }

/* ---------- status ---------- */
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.running { background: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.dot.starting, .dot.stopping { background: var(--orange); animation: pulse 1s infinite; }
.dot.crashed { background: var(--red); }
@keyframes pulse { 50% { opacity: .35; } }
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: var(--panel2); color: var(--muted); }
.badge.running { background: rgba(34,197,94,.14); color: #86efac; }
.badge.starting, .badge.stopping { background: rgba(245,158,11,.14); color: #fcd34d; }
.badge.crashed { background: rgba(239,68,68,.14); color: #fca5a5; }
.role-badge { font-size: 11px; padding: 3px 8px; border-radius: 6px; background: var(--panel2); color: var(--muted); font-weight: 700; text-transform: uppercase; }
.role-badge.admin { background: rgba(139,92,246,.18); color: #c4b5fd; }

/* ---------- dashboard ---------- */
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.server-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s, transform .15s; }
.server-card:hover { border-color: #33456e; transform: translateY(-2px); }
.server-card .banner { height: 86px; position: relative; padding: 16px; display: flex; align-items: flex-end; gap: 12px; }
.banner.windrose { background: linear-gradient(135deg, #0e3a5c 0%, #136a8a 50%, #c7a35a 140%); }
.banner.custom { background: linear-gradient(135deg, #2a2f4a, #3b3f63); }
.banner > .badge { position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,.45); }
.game-icon { width: 44px; height: 44px; border-radius: 10px; background: rgba(255,255,255,.14); backdrop-filter: blur(4px); display: grid; place-items: center; border: 1px solid rgba(255,255,255,.2); }
.game-icon svg { width: 26px; height: 26px; color: #fff; }
.server-card .body { padding: 16px; flex: 1; }
.server-card h3 { margin: 0 0 2px; font-size: 16px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.mini-stats div { background: var(--bg2); border-radius: 8px; padding: 8px 10px; }
.mini-stats span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; }
.mini-stats b { font-size: 14px; }
.server-card .foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg2); }
.server-card .foot .btn { flex: 1; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty svg { width: 48px; height: 48px; margin-bottom: 10px; opacity: .5; }

/* ---------- server page ---------- */
.server-hero { border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: var(--panel); margin-bottom: 18px; }
.server-hero .banner { height: auto; padding: 22px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.server-hero .game-icon { width: 58px; height: 58px; border-radius: 12px; }
.server-hero .game-icon svg { width: 32px; height: 32px; }
.server-hero h1 { margin: 0; font-size: 22px; text-shadow: 0 2px 8px rgba(0,0,0,.3); }
.server-hero .sub { color: rgba(255,255,255,.75); font-size: 13px; margin-top: 3px; }
.server-hero .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border); }
.stat { background: var(--panel); padding: 14px 20px; }
.stat span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.stat b { font-size: 18px; }
.bar { height: 5px; border-radius: 3px; background: var(--bg2); margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 3px; transition: width .4s; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tab { padding: 10px 16px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-color: var(--accent); }

.console-wrap { background: #05080f; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.console-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: #0a0f1b; flex-wrap: wrap; }
.console-bar input[type=search] { max-width: 260px; padding: 6px 10px; }
.console-bar .check { margin: 0; font-size: 13px; color: var(--muted); }
.console-bar .spacer { flex: 1; }
.console {
  height: calc(100vh - 430px); min-height: 320px; overflow: auto; padding: 12px 14px;
  font-family: "Cascadia Mono", "Consolas", "JetBrains Mono", monospace; font-size: 12.5px; line-height: 1.5;
  color: #c9d3e6; white-space: pre-wrap; word-break: break-word;
}
.console .l-err { color: #ff8a8a; }
.console .l-warn { color: #ffd36b; }
.console .l-panel { color: #5ee6ff; font-weight: 600; }
.console .l-dim { color: #6f7c99; }
.console mark { background: rgba(245,158,11,.4); color: inherit; }
.console-note { padding: 8px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); background: #0a0f1b; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 700; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--panel2); }
.table .actions { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

/* ---------- files ---------- */
.breadcrumb { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; }
.breadcrumb a { padding: 3px 6px; border-radius: 5px; }
.breadcrumb a:hover { background: var(--panel2); }
.file-icon { width: 18px; height: 18px; vertical-align: -4px; margin-right: 8px; color: var(--muted); }
.file-icon.dir { color: #fbbf24; }
.editor { width: 100%; height: calc(100vh - 360px); min-height: 300px; font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px; line-height: 1.5; background: #05080f; resize: vertical; tab-size: 4; white-space: pre; }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(3,6,14,.7); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 100; overflow-y: auto; backdrop-filter: blur(3px); }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 520px; padding: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.modal h2 { margin: 0 0 18px; font-size: 18px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.server-checks { max-height: 180px; overflow-y: auto; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px 0; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--panel2); border: 1px solid var(--border); border-left: 4px solid var(--accent); padding: 12px 16px; border-radius: 8px; min-width: 260px; max-width: 380px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: slidein .2s; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .sys-stats { display: none; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 60px; bottom: 0; left: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 10px 0 40px rgba(0,0,0,.5); }
  .menu-toggle { display: inline-flex; }
  .main { padding: 18px 16px 30px; }
  .grid2 { grid-template-columns: 1fr; }
  .server-hero .actions { margin-left: 0; width: 100%; }
  .server-hero .actions .btn { flex: 1; }
  .console { height: 60vh; }
  .user-btn .uname { display: none; }
}
