:root {
  --bg: #0e1116;
  --bg-2: #12161d;
  --surface: #181d26;
  --surface-2: #1f2531;
  --surface-3: #27303d;
  --border: #2a3140;
  --border-strong: #3a4455;
  --text: #e8ebf1;
  --text-2: #aab2c3;
  --muted: #7d8699;
  --accent: #3ecf6e;
  --accent-2: #2fb45b;
  --accent-soft: rgba(62, 207, 110, 0.14);
  --blue: #5b9dff;
  --blue-soft: rgba(91, 157, 255, 0.14);
  --amber: #f3b64a;
  --amber-soft: rgba(243, 182, 74, 0.14);
  --red: #f06161;
  --red-soft: rgba(240, 97, 97, 0.14);
  --purple: #a78bfa;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --sidebar: 248px;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14.5px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(62, 207, 110, 0.3); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.flex { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 15px; height: 15px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #22c55e, #15803d); display: grid; place-items: center; font-weight: 800; font-size: 13px; color: white; letter-spacing: 0.02em; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: -2px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 9px; color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a .icon { opacity: 0.9; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 14px 11px 6px; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-weight: 700; font-size: 12px; color: var(--text-2); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: rgba(14, 17, 22, 0.85);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; }
.content { padding: 22px 24px 60px; max-width: 1280px; width: 100%; }
.menu-btn { display: none; }

/* ---------- status pill ---------- */
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.s-running .dot { background: var(--accent); box-shadow: 0 0 0 4px rgba(62, 207, 110, 0.18); }
.s-starting .dot, .s-stopping .dot, .s-installing .dot, .s-updating .dot { background: var(--amber); animation: pulse 1.2s infinite; }
.s-stopped .dot { background: var(--muted); }
.s-not_installed .dot { background: var(--red); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--surface-2); cursor: pointer; font-weight: 600; font-size: 13.5px; line-height: 1.2; white-space: nowrap; transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #06230f; }
.btn-primary:hover { background: #55d980; }
.btn-danger { background: var(--red-soft); border-color: rgba(240, 97, 97, 0.4); color: #ff8b8b; }
.btn-danger:hover { background: rgba(240, 97, 97, 0.25); }
.btn-amber { background: var(--amber-soft); border-color: rgba(243, 182, 74, 0.4); color: var(--amber); }
.btn-amber:hover { background: rgba(243, 182, 74, 0.25); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-icon { padding: 7px; }
.btn-sm.btn-icon { padding: 5px; }
.btn-block { width: 100%; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { display: flex; align-items: center; gap: 9px; }
.card-head .icon { color: var(--accent); }
.card-body { padding: 18px; }
.card-desc { color: var(--muted); font-size: 13px; margin-top: 2px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-wide { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.grid-wide-32 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.table-wrap { overflow-x: auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.tile-value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-sub { font-size: 12.5px; color: var(--text-2); }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; opacity: 0.5; margin-bottom: 10px; }
.empty h3 { color: var(--text-2); margin-bottom: 6px; }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid; font-size: 13.5px; }
.banner-amber { background: var(--amber-soft); border-color: rgba(243, 182, 74, 0.35); color: #ffd58a; }
.banner-blue { background: var(--blue-soft); border-color: rgba(91, 157, 255, 0.35); color: #9fc4ff; }
.banner-red { background: var(--red-soft); border-color: rgba(240, 97, 97, 0.35); color: #ff9c9c; }
.banner .icon { flex: none; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border-strong); }
.chip-green { background: var(--accent-soft); color: var(--accent); border-color: rgba(62, 207, 110, 0.3); }
.chip-amber { background: var(--amber-soft); color: var(--amber); border-color: rgba(243, 182, 74, 0.3); }
.chip-red { background: var(--red-soft); color: #ff8b8b; border-color: rgba(240, 97, 97, 0.3); }
.chip-blue { background: var(--blue-soft); color: var(--blue); border-color: rgba(91, 157, 255, 0.3); }
.chip-purple { background: rgba(167, 139, 250, 0.14); color: var(--purple); border-color: rgba(167, 139, 250, 0.3); }
.chip-btn { cursor: pointer; user-select: none; }
.chip-btn:hover { filter: brightness(1.15); }
.chip-off { opacity: 0.55; text-decoration: line-through; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.help { font-size: 12.5px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--bg-2); color: var(--text); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(62, 207, 110, 0.18); }
.input:disabled { opacity: 0.6; }
.input-sm { padding: 6px 10px; font-size: 13px; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d8699' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
textarea.input { min-height: 90px; resize: vertical; line-height: 1.45; }
textarea.code { font-family: var(--mono); font-size: 12.5px; min-height: 420px; white-space: pre; tab-size: 4; }
.input-group { display: flex; }
.input-group .input { border-radius: 9px 0 0 9px; }
.input-group .btn { border-radius: 0 9px 9px 0; border-left: 0; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track { position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 999px; cursor: pointer; transition: background .15s, border-color .15s; }
.switch .track::after { content: ''; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; border-radius: 50%; background: #9aa3b5; transition: transform .15s, background .15s; }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); background: #06230f; }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(62, 207, 110, 0.3); }
.setting-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 320px); gap: 18px; align-items: center; padding: 13px 0; border-top: 1px solid var(--border); }
.setting-row:first-child { border-top: 0; padding-top: 0; }
.setting-row:last-child { padding-bottom: 0; }
.setting-row .label { color: var(--text); }
.setting-row .key { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: 6px; opacity: 0.8; }
.setting-row.changed .label::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); margin-left: 7px; vertical-align: middle; }
.setting-ctl { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.setting-ctl .input { max-width: 320px; }
.range-wrap { display: flex; align-items: center; gap: 10px; width: 100%; }
.range-wrap input[type=number] { width: 92px; }
.pw-wrap { position: relative; width: 100%; }
.pw-wrap .input { padding-right: 38px; }
.pw-wrap .btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

/* ---------- save bar ---------- */
.savebar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(calc(-50% + var(--sidebar) / 2)); z-index: 30; display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 14px; padding: 10px 12px 10px 16px; box-shadow: var(--shadow);
  animation: rise .18s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateX(calc(-50% + var(--sidebar) / 2)) translateY(10px); } }

/* ---------- console ---------- */
.console { background: #0a0d12; border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--mono); font-size: 12.5px; line-height: 1.5; overflow: auto; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; }
.console-line { display: flex; gap: 10px; }
.console-line .t { color: #4f5969; flex: none; user-select: none; }
.console-line.src-steam .l { color: #8fb4ff; }
.console-line.src-panel .l { color: var(--amber); }
.console-line.src-input .l { color: var(--accent); font-weight: 600; }
.console-line.lvl-warn .l { color: #ffd27a; }
.console-line.lvl-error .l { color: #ff8b8b; }
.console-wrap { display: flex; flex-direction: column; gap: 10px; }
.console-tall { height: calc(100vh - 290px); min-height: 320px; }
.console-short { height: 320px; }
.cmd-input { font-family: var(--mono); }
.quick-cmds { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- tables ---------- */
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--border); font-weight: 600; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: rgba(255, 255, 255, 0.015); }
.actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- tabs / subnav ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs button { background: none; border: 0; padding: 10px 14px; color: var(--text-2); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 7px; align-items: center; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.config-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; align-items: start; }
.subnav { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; }
.subnav a { padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-size: 13.5px; display: flex; gap: 8px; align-items: center; }
.subnav a:hover { background: var(--surface); text-decoration: none; color: var(--text); }
.subnav a.active { color: var(--accent); background: var(--accent-soft); }
.config-groups { display: flex; flex-direction: column; gap: 16px; }
.search-wrap { position: relative; }
.search-wrap .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-wrap .input { padding-left: 36px; }

/* ---------- mods ---------- */
.mod-card { display: grid; grid-template-columns: 28px 84px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 14px 16px; border-top: 1px solid var(--border); }
.mod-card:first-child { border-top: 0; }
.mod-card.disabled { opacity: 0.55; }
.mod-card.dragging { opacity: 0.4; }
.mod-card.drag-over { box-shadow: inset 0 3px 0 var(--accent); }
.mod-thumb { width: 84px; height: 84px; border-radius: 9px; object-fit: cover; background: var(--surface-3); display: block; }
.grip { color: var(--muted); cursor: grab; display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 4px; }
.grip:active { cursor: grabbing; }
.mod-title { font-weight: 650; font-size: 15px; }
.mod-meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.mod-ids { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.mod-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.ini-preview { background: var(--bg-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; font-family: var(--mono); font-size: 12px; word-break: break-all; color: var(--text-2); }
.ini-preview b { color: var(--accent); font-weight: 600; }

/* ---------- players ---------- */
.player-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.player-row:first-child { border-top: 0; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, rgba(62, 207, 110, 0.12), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; padding: 28px; }
.auth-card .brand { justify-content: center; padding-bottom: 10px; }
.auth-card h1 { text-align: center; font-size: 20px; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 20px; }
.form-error { color: #ff8b8b; font-size: 13px; background: var(--red-soft); border: 1px solid rgba(240, 97, 97, 0.3); padding: 8px 12px; border-radius: 8px; }

/* ---------- toasts & modals ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--surface-2); border: 1px solid var(--border-strong); border-left: 3px solid var(--blue); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 380px; font-size: 13.5px; animation: rise2 .18s ease-out; }
.toast.ok { border-left-color: var(--accent); } .toast.err { border-left-color: var(--red); } .toast.warn { border-left-color: var(--amber); }
@keyframes rise2 { from { opacity: 0; transform: translateY(8px); } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; z-index: 90; padding: 20px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); }
.modal-wide { max-width: 640px; }
.modal-head { padding: 16px 20px 0; }
.modal-body { padding: 12px 20px 20px; color: var(--text-2); display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }
.kbd { font-family: var(--mono); font-size: 11.5px; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 5px; padding: 1px 5px; }
.copy-row { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 8px 8px 12px; }
.copy-row code { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; animation: indet 1.4s infinite; width: 35%; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .config-layout { grid-template-columns: 1fr; }
  .subnav { position: static; flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar); z-index: 40; transform: translateX(-100%); transition: transform .18s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 39; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .topbar h1 { font-size: 16px; }
  .content { padding: 16px 14px 90px; }
  .grid-2, .grid-3, .grid-wide, .grid-wide-32 { grid-template-columns: 1fr; }
  .setting-row { grid-template-columns: 1fr; gap: 8px; }
  .setting-ctl { justify-content: flex-start; }
  .setting-ctl .input { max-width: none; }
  .savebar { left: 14px; right: 14px; transform: none; justify-content: space-between; }
  @keyframes rise { from { opacity: 0; } }
  .mod-card { grid-template-columns: 24px 64px minmax(0, 1fr); }
  .mod-thumb { width: 64px; height: 64px; }
  .mod-actions { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; flex-wrap: wrap; }
  .console-tall { height: calc(100vh - 330px); }
}
