:root {
  --bg: #0d1013;
  --bg-2: #12161a;
  --panel: #161b20;
  --panel-2: #1c2228;
  --line: #262e36;
  --line-2: #323c46;
  --text: #e6e2d8;
  --text-2: #a9adb1;
  --muted: #7b828a;
  --ember: #e39a3b;
  --ember-2: #f2b25c;
  --ember-dim: rgba(227, 154, 59, 0.14);
  --green: #5cc08a;
  --green-dim: rgba(92, 192, 138, 0.14);
  --red: #e5665a;
  --red-dim: rgba(229, 102, 90, 0.14);
  --blue: #6aa6e6;
  --blue-dim: rgba(106, 166, 230, 0.14);
  --steam: #6aa6e6;
  --xbox: #6cc24a;
  --radius: 10px;
  --radius-sm: 7px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, rgba(227, 154, 59, 0.06), transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
a { color: var(--ember-2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error-text { color: var(--red); min-height: 1.5em; margin: 10px 0 0; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-family: 'Cinzel', serif; font-weight: 700; letter-spacing: 0.04em; font-size: 16px; }
.brand-lg { font-size: 22px; justify-content: center; margin-bottom: 6px; }
.rune {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(145deg, #3a2a14, #1d150b); color: var(--ember-2);
  border: 1px solid rgba(227, 154, 59, 0.35); font-family: serif; font-size: 18px;
}

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login-card .field { text-align: left; margin: 18px 0 16px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav button {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 11px; border: 0; background: none;
  border-radius: var(--radius-sm); color: var(--text-2); cursor: pointer; text-align: left; font-weight: 500;
}
.nav button svg { width: 18px; height: 18px; fill: currentColor; flex: none; opacity: .85; }
.nav button:hover { background: var(--panel); color: var(--text); }
.nav button.active { background: var(--ember-dim); color: var(--ember-2); }
.pill-count { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 700; background: var(--green); color: #0b1a12; border-radius: 99px; padding: 0 7px; line-height: 18px; }
.sidebar-foot { margin-top: auto; }

.main { min-width: 0; padding: 0 28px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 18px 0; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-width: 0; }
.topbar-title { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.topbar-title strong { font-size: 16px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; cursor: pointer; }
.chip:hover { border-color: var(--line-2); }
.chip-label { color: var(--muted); font-size: 12px; }
.chip code { color: var(--text); }

.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 10px; border-radius: 99px; font-weight: 600; font-size: 12.5px; background: var(--panel); border: 1px solid var(--line); white-space: nowrap; }
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-pill.online { color: var(--green); border-color: rgba(92,192,138,.35); background: var(--green-dim); }
.status-pill.online i { background: var(--green); box-shadow: 0 0 0 3px rgba(92,192,138,.2); }
.status-pill.starting { color: var(--ember-2); border-color: rgba(227,154,59,.35); background: var(--ember-dim); }
.status-pill.starting i { background: var(--ember); animation: pulse 1.2s infinite; }
.status-pill.stopped { color: var(--red); border-color: rgba(229,102,90,.35); background: var(--red-dim); }
.status-pill.stopped i { background: var(--red); }
@keyframes pulse { 50% { opacity: .3; } }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 11px 14px; margin-bottom: 20px; border-radius: var(--radius); background: var(--ember-dim); border: 1px solid rgba(227,154,59,.35); color: var(--ember-2); font-weight: 500; }

.view { display: none; }
.view.active { display: block; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.view-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.view-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- panels / grid ---------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.panel h3 { margin: 0 0 14px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.panel h3 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.panel + .panel { margin-top: 16px; }
.stack > * + * { margin-top: 16px; }

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-value { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 12.5px; }
.meter { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.meter > div { height: 100%; background: var(--ember); border-radius: inherit; transition: width .4s; }

.controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.control { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; padding: 13px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.control:hover:not(:disabled) { border-color: var(--line-2); background: #20272e; }
.control strong { font-weight: 600; }
.control span { color: var(--muted); font-size: 12.5px; }
.control.danger strong { color: var(--red); }
.control.primary strong { color: var(--ember-2); }
.control:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- buttons / fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover:not(:disabled) { background: #232b33; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ember); border-color: var(--ember); color: #1b1206; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--ember-2); }
.btn-danger { color: var(--red); border-color: rgba(229,102,90,.4); background: transparent; }
.btn-danger:hover:not(:disabled) { background: var(--red-dim); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--panel); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field small { color: var(--muted); font-size: 12px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 8px 11px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--ember); box-shadow: 0 0 0 3px var(--ember-dim); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.input-group { display: flex; gap: 6px; }
.input-group input { flex: 1; min-width: 0; }

.toggle { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; padding: 4px 0; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track { flex: none; width: 36px; height: 20px; border-radius: 99px; background: var(--line-2); position: relative; transition: background .2s; margin-top: 1px; }
.toggle .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #cfd3d6; transition: transform .2s; }
.toggle input:checked + .track { background: var(--ember); }
.toggle input:checked + .track::after { transform: translateX(16px); background: #fff; }
.toggle input:focus-visible + .track { box-shadow: 0 0 0 3px var(--ember-dim); }
.toggle-text { display: flex; flex-direction: column; }
.toggle-text small { color: var(--muted); font-size: 12px; }

.callout { padding: 11px 13px; border-radius: var(--radius-sm); background: var(--blue-dim); border: 1px solid rgba(106,166,230,.3); color: #bcd6f2; font-size: 13px; }
.callout.warn { background: var(--ember-dim); border-color: rgba(227,154,59,.3); color: #f0cf9f; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 0 10px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.player-name { font-weight: 600; }
.player-sub { color: var(--muted); font-size: 12px; }
.id-cell { display: flex; align-items: center; gap: 8px; }
.id-cell code { color: var(--text-2); }
.copy-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 4px; border-radius: 4px; font-size: 12px; }
.copy-btn:hover { color: var(--text); background: var(--panel-2); }
.empty { padding: 26px 0; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--panel-2); color: var(--text-2); border: 1px solid var(--line-2); white-space: nowrap; }
.badge.steam { color: var(--steam); border-color: rgba(106,166,230,.35); background: var(--blue-dim); }
.badge.xbox { color: var(--xbox); border-color: rgba(108,194,74,.35); background: rgba(108,194,74,.12); }
.badge.admin { color: var(--ember-2); border-color: rgba(227,154,59,.4); background: var(--ember-dim); }
.badge.banned { color: var(--red); border-color: rgba(229,102,90,.4); background: var(--red-dim); }
.badge.ok { color: var(--green); border-color: rgba(92,192,138,.35); background: var(--green-dim); }
.badges { display: flex; gap: 5px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.on { background: var(--green); }

/* ---------- lists / events ---------- */
.event-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.event-list li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.event-list li:last-child { border-bottom: 0; }
.event-list time { color: var(--muted); font-family: var(--mono); font-size: 12px; flex: none; }
.ev-join { color: var(--green); }
.ev-leave { color: var(--text-2); }
.ev-death { color: var(--red); }
.ev-warn { color: var(--ember-2); }
.list-entries { display: flex; flex-direction: column; gap: 6px; }
.list-entry { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; background: var(--panel-2); border-radius: var(--radius-sm); }
.list-entry code { overflow: hidden; text-overflow: ellipsis; }

/* ---------- console ---------- */
.console { background: #090b0d; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; height: calc(100vh - 250px); min-height: 380px; }
.console-bar { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.console-bar input[type=search] { max-width: 260px; padding: 5px 10px; font-size: 13px; }
.console-bar .spacer { flex: 1; }
.console-bar label { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12.5px; cursor: pointer; }
.console-out { flex: 1; overflow: auto; padding: 10px 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.console-out .ln { color: #b9bfc4; }
.console-out .ln time { color: #555d65; margin-right: 10px; user-select: none; }
.console-out .ln.manager { color: var(--ember-2); }
.console-out .ln.command { color: #fff; font-weight: 500; margin-top: 6px; }
.console-out .ln.output { color: #9fd7b8; }
.console-out .ln.err { color: #f0998f; }
.console-out .ln.warnl { color: #e8c07a; }
.console-out .ln.hl { color: #cfe3ff; }
.console-in { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.console-in span { color: var(--ember); font-family: var(--mono); font-weight: 600; }
.console-in input { flex: 1; background: transparent; border: 0; box-shadow: none !important; font-family: var(--mono); font-size: 13px; padding: 4px 0; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.quick button { font-family: var(--mono); font-size: 12px; }

/* ---------- mods ---------- */
.mod-list { display: flex; flex-direction: column; }
.mod { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.mod:last-child { border-bottom: 0; }
.mod img, .mod .mod-icon { width: 44px; height: 44px; border-radius: 8px; background: var(--panel-2); object-fit: cover; }
.mod .mod-icon { display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.mod-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mod-title strong { font-weight: 600; }
.mod-desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mod-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.mod.disabled { opacity: .55; }
.mod-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.search-row { display: flex; gap: 8px; margin-bottom: 6px; }
.search-row input { flex: 1; }
.editor { width: 100%; min-height: 420px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; resize: vertical; tab-size: 4; white-space: pre; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 9px 14px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs button.active { color: var(--ember-2); border-bottom-color: var(--ember); }
.dropzone { border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 20px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.drag { border-color: var(--ember); background: var(--ember-dim); color: var(--ember-2); }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(4,6,8,.7); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.modal-card h3 { margin: 0 0 8px; font-size: 17px; }
.modal-card p { margin: 0 0 20px; color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: calc(100vw - 32px); }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--green); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: 380px; animation: slide .2s ease-out; }
.toast.error { border-left-color: var(--red); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; padding: 10px 16px; gap: 12px; overflow-x: auto; }
  .sidebar .brand span:last-child, .sidebar-foot { display: none; }
  .nav { flex-direction: row; gap: 2px; }
  .nav button { padding: 8px 10px; white-space: nowrap; }
  .nav button span { display: none; }
  .nav button.active span { display: inline; }
  .main { padding: 0 16px 32px; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
  .console { height: calc(100vh - 230px); }
  .mod { grid-template-columns: 36px minmax(0, 1fr); }
  .mod img, .mod .mod-icon { width: 36px; height: 36px; }
  .mod-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 20px; }
  .topbar-right { width: 100%; }
}
