:root {
  --bg: #121214;
  --panel: #1b1b1f;
  --panel-2: #232328;
  --line: #2e2e35;
  --text: #e8e6e3;
  --muted: #9a978f;
  --accent: #cd412b;
  --accent-2: #e5603f;
  --ok: #4caf6a;
  --warn: #e0a83a;
  --err: #e0533f;
  --chat: #6fb3e8;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
}
h2 { margin: 0 0 16px; font-size: 22px; }
h3 { margin: 28px 0 12px; font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--accent-2); }
[hidden] { display: none !important; }

/* barra lateral */
.sidebar {
  width: 220px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; font-weight: 700; line-height: 1.1; }
.brand img { width: 38px; height: 38px; }
.brand small { color: var(--accent-2); letter-spacing: .2em; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
nav a {
  color: var(--text); text-decoration: none; padding: 9px 12px; border-radius: 8px;
}
nav a:hover { background: var(--panel-2); }
nav a.active { background: var(--accent); color: #fff; }
.me { display: flex; gap: 10px; align-items: center; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.me img { width: 36px; height: 36px; border-radius: 6px; background: var(--panel-2); }
#me-name { font-weight: 600; font-size: 14px; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font: inherit; font-size: 13px; }
button.link:hover { color: var(--text); }

/* área principal */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; gap: 14px; align-items: center; padding: 12px 24px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.status { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.online { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.starting, .dot.restarting { background: var(--warn); animation: pulse 1.2s infinite; }
.dot.offline { background: var(--err); }
@keyframes pulse { 50% { opacity: .35; } }
.busy { color: var(--warn); font-size: 14px; }
.busy::before { content: "⏳ "; }
.chip {
  margin-left: auto; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px; font: 13px var(--mono); cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.page { padding: 24px; overflow: auto; flex: 1; }

/* cartões */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.card .sub { color: var(--muted); font-size: 12px; }

.cards-2 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); max-width: 620px; }
.card .value.has-update { color: var(--warn); }

/* atualizações */
.update-banner {
  background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; font-weight: 600; text-decoration: none;
}
.auto-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 10px 0 4px; }
.switch { display: inline-flex; gap: 10px; align-items: center; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 40px; height: 22px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); position: relative; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* botões */
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ok { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ok:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, var(--line)); }
.btn-danger:hover:not(:disabled) { background: var(--err); color: #fff; border-color: var(--err); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* formulários */
input, textarea, select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; font: inherit; min-width: 0;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.inline-form input { flex: 1 1 240px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; margin: 6px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; max-width: 980px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 14px; }
.field .help { color: var(--muted); font-size: 12px; }
.field .tag { font-size: 11px; font-weight: 600; color: var(--ok); margin-left: 6px; }
.field .tag.restart { color: var(--warn); }
.settings .save-row { grid-column: 1 / -1; display: flex; gap: 12px; align-items: center; }
.danger-zone { margin-top: 36px; padding: 16px 20px; border: 1px solid color-mix(in srgb, var(--err) 40%, var(--line)); border-radius: 10px; max-width: 980px; }
.danger-zone h3 { margin-top: 0; color: var(--err); }

/* tabelas */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: var(--panel); }
tr:last-child td { border-bottom: 0; }
td.actions-cell { text-align: right; display: flex; gap: 6px; justify-content: flex-end; }
.mono { font-family: var(--mono); font-size: 13px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); }
.badge.ok { color: var(--ok); }
.badge.off { color: var(--muted); }
.badge.err { color: var(--err); }

/* whitelist */
.people { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.people li { display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.people img { width: 42px; height: 42px; border-radius: 6px; background: var(--panel-2); }
.people .who { flex: 1; min-width: 0; }
.people .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* plugins */
.plugin-add { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.plugin-add .inline-form { flex: 1 1 420px; }

/* consola */
.page-console { display: flex; flex-direction: column; overflow: hidden; }
.console-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.console-head h2 { margin: 0 auto 0 0; }
.console-log {
  flex: 1; overflow: auto; background: #0b0b0c; border: 1px solid var(--line); border-radius: 10px 10px 0 0;
  padding: 10px 12px; font: 13px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word;
}
.console-log .l-time { color: #5d5b56; margin-right: 8px; user-select: none; }
.console-log .k-error { color: var(--err); }
.console-log .k-warn { color: var(--warn); }
.console-log .k-chat { color: var(--chat); }
.console-log .k-panel { color: var(--accent-2); }
.console-log .k-input { color: var(--ok); font-weight: 700; }
.console-log .k-reply { color: #cfcac0; }
.console-input {
  display: flex; gap: 8px; align-items: center; background: #0b0b0c; border: 1px solid var(--line);
  border-top: 0; border-radius: 0 0 10px 10px; padding: 8px 12px; font-family: var(--mono);
}
.console-input span { color: var(--ok); font-weight: 700; }
.console-input input { flex: 1; border: 0; background: transparent; font-family: var(--mono); padding: 6px 0; }
.console-input input:focus { outline: none; }

/* diálogo + avisos */
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 22px; width: min(560px, calc(100vw - 32px));
}
dialog.wide { width: min(900px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h3 { margin: 0 0 12px; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 18px; }
#dlg-body { display: flex; flex-direction: column; gap: 10px; }
#dlg-body textarea { width: 100%; min-height: 50vh; font: 13px/1.5 var(--mono); resize: vertical; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; max-width: calc(100vw - 32px); }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 8px; padding: 10px 14px; box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: 420px; }
.toast.err { border-left-color: var(--err); }

/* login */
.login-page { align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 36px 40px; text-align: center; width: min(380px, 100%); }
.login-logo { width: 64px; height: 64px; }
.login-card h1 { margin: 14px 0 2px; font-size: 24px; letter-spacing: .04em; }
.btn-steam { margin-top: 22px; width: 100%; padding: 12px; background: #171a21; border-color: #2a475e; color: #fff; }
.btn-steam:hover { background: #2a475e; }

/* telemóvel */
@media (max-width: 760px) {
  body { flex-direction: column; }
  .sidebar { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  nav { flex-direction: row; overflow-x: auto; order: 3; flex-basis: 100%; }
  nav a { padding: 7px 10px; font-size: 14px; }
  .me { margin-left: auto; border: 0; padding: 0; }
  .main { height: auto; min-height: 0; flex: 1; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .page { padding: 16px; }
  .page-console { height: calc(100vh - 170px); }
  .settings { grid-template-columns: 1fr; }
}
