:root {
  --bg: #0d0f12;
  --panel: #14171c;
  --panel-2: #1a1e24;
  --line: #262b33;
  --text: #dfe3ea;
  --muted: #8b93a1;
  --gold: #d8b45a;
  --gold-dim: #8d7434;
  --green: #46c46a;
  --red: #e0574f;
  --amber: #e0a94f;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: "Cascadia Mono", Consolas, "SF Mono", monospace; font-size: 12.5px; }
.error { color: var(--red); min-height: 1.2em; margin: 8px 0 0; }

/* --- login ---------------------------------------------------------------- */

.login {
  display: grid;
  place-items: center;
  height: 100%;
}
.login-card {
  width: 320px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.login-card h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.5px;
  font-weight: 700;
}
.login-card h1 span { color: var(--gold); }
.login-card p { margin: 4px 0 20px; }
.login-card label {
  display: block;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--muted);
}
.login-card input {
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
}
.login-card button {
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  background: var(--gold);
  color: #17130a;
  border: 0;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}

/* --- layout --------------------------------------------------------------- */

.app { display: flex; height: 100%; }

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
}
.brand {
  padding: 0 18px 16px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.brand span { color: var(--gold); }

.sidebar nav { display: flex; flex-direction: column; }
.sidebar nav a {
  padding: 9px 18px;
  color: var(--muted);
  text-decoration: none;
  border-left: 2px solid transparent;
}
.sidebar nav a:hover { color: var(--text); background: var(--panel-2); }
.sidebar nav a.active {
  color: var(--gold);
  border-left-color: var(--gold);
  background: var(--panel-2);
}

.servers {
  flex: 1;
  overflow-y: auto;
  margin-top: 18px;
  padding: 0 10px;
  border-top: 1px solid var(--line);
}
.srv {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  font-size: 12px;
  border-radius: var(--radius);
}
.srv:hover { background: var(--panel-2); }
.srv .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.srv .dot.on { background: var(--green); }
.srv .dot.off { background: var(--red); }
.srv .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv .ct { color: var(--muted); font-variant-numeric: tabular-nums; }

.me { padding: 12px 18px 0; border-top: 1px solid var(--line); }
.me-name { font-weight: 600; }
.me-role { font-size: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.6px; }
.link {
  margin-top: 8px;
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  text-decoration: underline;
}

main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
#view-title { font-size: 16px; font-weight: 600; }
.head-right { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.pill {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 11px;
}
.pill.ok { color: var(--green); border-color: var(--gold-dim); }
.pill.bad { color: var(--red); }

.view { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 14px 20px 18px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input, .toolbar select, .cmdbar input, .cmdbar select {
  padding: 7px 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
}
.toolbar input { min-width: 220px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

button.ghost {
  padding: 7px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
}
button.ghost:hover { border-color: var(--gold-dim); }
button.danger { background: #3a1c1a; border-color: #5c2a26; color: #ffb9b4; }
button.gold { background: var(--gold); color: #17130a; border: 0; font-weight: 600; }

/* --- streams -------------------------------------------------------------- */

.stream {
  flex: 1;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.line { display: flex; gap: 8px; padding: 1px 0; white-space: pre-wrap; word-break: break-word; }
.line .t { color: var(--muted); flex: 0 0 62px; }
.line .s { color: var(--gold-dim); flex: 0 0 110px; overflow: hidden; text-overflow: ellipsis; }
.line .m { flex: 1; }
.line.chat .m b { color: var(--gold); font-weight: 600; }
.line.join .m { color: var(--green); }
.line.leave .m { color: var(--muted); }
.line.err .m { color: var(--red); }

.cmdbar { display: flex; gap: 8px; margin-top: 10px; }
.cmdbar input { flex: 1; font-family: "Cascadia Mono", Consolas, monospace; }
.cmdbar button {
  padding: 7px 16px;
  background: var(--gold);
  color: #17130a;
  border: 0;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}
.cmdbar button:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }

/* --- tables --------------------------------------------------------------- */

.tablewrap {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  text-align: left;
  padding: 9px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
}
tbody td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: var(--panel-2); }
td.num { font-variant-numeric: tabular-nums; }
.sid { color: var(--muted); font-size: 11px; font-family: Consolas, monospace; }
.warn { color: var(--amber); }
.bad { color: var(--red); }

/* --- modal ---------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  z-index: 50;
}
.modal-card {
  width: min(560px, 92vw);
  max-height: 86vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.modal-card h2 { margin: 0 0 4px; font-size: 17px; }
.modal-card label { display: block; margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.modal-card input, .modal-card select, .modal-card textarea {
  width: 100%;
  margin-top: 5px;
  padding: 8px 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal-actions button { padding: 8px 16px; border-radius: var(--radius); cursor: pointer; }
