:root {
  --bg: #0d0f10;
  --bg-2: #121518;
  --surface: #181c20;
  --surface-2: #20252a;
  --line: #2b3137;
  --text: #e9e6df;
  --muted: #949aa1;
  --accent: #e0301e;
  --accent-2: #ff5a3c;
  --ok: #3ccf6e;
  --warn: #f2b33d;
  --err: #ff6b5a;
  --info: #7aa8ff;
  --radius: 10px;
  --display: "Oswald", "Arial Narrow", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-2); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }
.hidden { display: none !important; }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: 600 .88rem/1.1 var(--body); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #3d444b; background: #262c32; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { color: var(--err); }
.btn-danger:hover { border-color: var(--err); background: rgba(255,107,90,.08); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: .8rem; }
.btn-block { width: 100%; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: 400 .93rem var(--body);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.hint { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.row { display: grid; grid-template-columns: 1fr 140px; gap: 12px; }
.error { color: var(--err); font-size: .88rem; min-height: 1.2em; margin: 4px 0 10px; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(800px 400px at 85% 0%, rgba(224,48,30,.16), transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 30px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.auth-brand svg { width: 34px; height: 34px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 8px; padding: 4px; margin: 22px 0; }
.auth-tabs button { border: 0; background: transparent; color: var(--muted); padding: 9px; border-radius: 6px; font: 600 .88rem var(--body); cursor: pointer; }
.auth-tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); }
.auth-foot { text-align: center; margin-top: 18px; font-size: .85rem; }

/* Shell */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; height: 58px; padding: 0 20px; background: rgba(13,15,16,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font: 700 1.1rem/1 var(--display); letter-spacing: .08em; }
.brand svg { width: 26px; height: 26px; }
.brand small { color: var(--muted); font-weight: 500; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; padding: 7px 12px; border-radius: 6px; font-weight: 500; font-size: .9rem; }
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); background: var(--surface-2); }
.who { display: flex; align-items: center; gap: 12px; font-size: .88rem; color: var(--muted); }
.who strong { color: var(--text); }
.badge { font: 600 .7rem/1 var(--body); text-transform: uppercase; letter-spacing: .08em; padding: 4px 7px; border-radius: 4px; background: rgba(224,48,30,.15); color: var(--accent-2); }
.page { width: min(1240px, 100% - 32px); margin: 28px auto 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 0; }

/* Server grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.srv { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s; }
.srv:hover { border-color: var(--accent); transform: translateY(-2px); }
.srv h3 { font-size: 1.2rem; margin: 0; }
.srv .addr { font: 400 .82rem var(--mono); color: var(--muted); }
.srv-foot { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: var(--muted); margin-top: auto; }
.tag { display: inline-block; font: 600 .7rem/1 var(--body); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); border: 1px solid var(--line); padding: 4px 8px; border-radius: 999px; }
.srv-add { align-items: center; justify-content: center; text-align: center; border-style: dashed; background: transparent; min-height: 150px; cursor: pointer; font: inherit; }
.srv-add .plus { font: 600 2rem/1 var(--display); color: var(--accent); }
.empty { text-align: center; padding: 60px 20px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* Server detail */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.detail-head .meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: .88rem; }
.back { color: var(--muted); text-decoration: none; font-size: .85rem; display: inline-block; margin-bottom: 8px; }
.back:hover { color: var(--text); }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.state { display: inline-flex; align-items: center; gap: 7px; font: 600 .78rem/1 var(--body); padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.05); color: var(--muted); }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state.connected { color: var(--ok); }
.state.connecting { color: var(--warn); }
.state.error { color: var(--err); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1rem; margin: 0; }
.panel-body { padding: 14px 16px; }

.console { display: flex; flex-direction: column; height: calc(100vh - 230px); min-height: 420px; }
.log { flex: 1; overflow-y: auto; padding: 12px 16px; font: 400 .82rem/1.55 var(--mono); background: var(--bg); white-space: pre-wrap; word-break: break-word; }
.log .l { padding: 1px 0; }
.log .t { color: #5d646b; margin-right: 8px; user-select: none; }
.log .cmd { color: var(--info); }
.log .cmd .u { color: var(--muted); }
.log .out { color: var(--text); }
.log .event { color: #c8c3b8; }
.log .event.chat { color: var(--warn); }
.log .event.conn { color: var(--ok); }
.log .sys { color: var(--muted); font-style: italic; }
.log .err { color: var(--err); }
.console-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.console-input input { font-family: var(--mono); }
.filters { display: flex; gap: 6px; }
.filters button { border: 1px solid var(--line); background: transparent; color: var(--muted); font: 600 .72rem var(--body); padding: 4px 8px; border-radius: 4px; cursor: pointer; }
.filters button[aria-pressed="true"] { color: var(--text); background: var(--surface-2); }

.side { display: flex; flex-direction: column; gap: 16px; }
.players { max-height: 420px; overflow-y: auto; }
.player { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 16px; border-bottom: 1px solid var(--line); }
.player:last-child { border-bottom: 0; }
.player .pn { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .ps { font-size: .75rem; color: var(--muted); font-family: var(--mono); }
.player .pa { display: flex; gap: 4px; flex-shrink: 0; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick .btn { white-space: normal; text-align: center; line-height: 1.25; min-height: 40px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
td .actions-row { justify-content: flex-end; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; max-width: 520px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; z-index: 100; animation: fade .12s; }
.modal { width: min(500px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 16px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: .82rem; }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 4px; }
@keyframes fade { from { opacity: 0; } }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); background: var(--surface-2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 6px; opacity: 0; transition: .2s; pointer-events: none; font-size: .88rem; z-index: 200; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: var(--err); }

@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; }
  .console { height: 60vh; }
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .brand small, .who .name { display: none; }
  .nav a { padding: 7px 8px; }
  .row { grid-template-columns: 1fr; }
}
