:root {
  --bg: #0a0d14;
  --bg2: #0e131d;
  --panel: #131a28;
  --panel2: #18213a;
  --line: #24304a;
  --line2: #2f3d5c;
  --text: #e8edf7;
  --muted: #8e9ab3;
  --dim: #5f6b85;
  --gold: #f4b740;
  --gold2: #ffd47e;
  --gold-bg: rgba(244, 183, 64, .12);
  --green: #39d18a;
  --green-bg: rgba(57, 209, 138, .13);
  --red: #ff5f6d;
  --red-bg: rgba(255, 95, 109, .13);
  --blue: #5aaaff;
  --blue-bg: rgba(90, 170, 255, .13);
  --purple: #a98bff;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, rgba(244, 183, 64, .07), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, rgba(90, 170, 255, .06), transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(244, 183, 64, .35); }

/* ---------- layout */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, #0f1522, #0b1019); border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand .crest {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--gold2), #c9861a); color: #1b1203; font-weight: 900; font-size: 18px;
  box-shadow: 0 6px 18px rgba(244, 183, 64, .35);
}
.brand b { display: block; font-size: 15px; letter-spacing: .3px; }
.brand small { color: var(--muted); font-size: 12px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--muted);
  font-weight: 550; transition: background .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.nav a.on { background: var(--gold-bg); color: var(--gold2); box-shadow: inset 2px 0 0 var(--gold); }
.nav .sep { margin: 14px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--dim); }
.side .me { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.side .me b { color: var(--text); }
.main { min-width: 0; padding: 22px 28px 60px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.top h1 { font-size: 22px; margin: 0; letter-spacing: .2px; }
.top .sub { color: var(--muted); }
.top .grow { flex: 1; }
.btn.burger { display: none; }
.scrim { display: none; }

/* ---------- cards & grid */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.card {
  background: linear-gradient(180deg, var(--panel), #111725); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; min-width: 0; box-shadow: 0 1px 0 rgba(255, 255, 255, .03) inset;
}
.card h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 650;
  display: flex; align-items: center; gap: 8px; }
.card h3 .grow { flex: 1; }
.kpi .v { font-size: 28px; font-weight: 750; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi .v small { font-size: 14px; color: var(--muted); font-weight: 600; }
.kpi.gold .v { color: var(--gold2); }
.kpi.green .v { color: var(--green); }
.kpi.red .v { color: var(--red); }
.kpi.blue .v { color: var(--blue); }

/* ---------- tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--dim);
  font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th.sort { cursor: pointer; user-select: none; }
.tbl th.sort:hover { color: var(--text); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid rgba(36, 48, 74, .6); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: rgba(255, 255, 255, .025); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }

/* ---------- bits */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px;
  font-weight: 650; background: rgba(255, 255, 255, .06); color: var(--muted); white-space: nowrap; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.gold { background: var(--gold-bg); color: var(--gold2); }
.pill.blue { background: var(--blue-bg); color: var(--blue); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(57, 209, 138, .18); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; }
.hr { height: 1px; background: var(--line); margin: 14px 0; }
.empty { color: var(--dim); text-align: center; padding: 26px 10px; }
.bar { height: 7px; border-radius: 99px; background: rgba(255, 255, 255, .06); overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold), var(--gold2)); }
.bar.red > i { background: linear-gradient(90deg, #d8424f, var(--red)); }
.bar.green > i { background: linear-gradient(90deg, #22a56b, var(--green)); }

/* ---------- forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line2);
  background: var(--panel2); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600;
  transition: transform .06s, background .15s, border-color .15s; white-space: nowrap; color: var(--text);
}
.btn:hover { border-color: #43547a; background: #1d2742; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #1d1404; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--red-bg); color: var(--red); border-color: rgba(255, 95, 109, .35); }
.btn.danger:hover { background: rgba(255, 95, 109, .22); }
.btn.green { background: var(--green-bg); color: var(--green); border-color: rgba(57, 209, 138, .35); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.input, select.input, textarea.input {
  width: 100%; background: #0d1320; border: 1px solid var(--line2); border-radius: 10px; padding: 9px 12px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(244, 183, 64, .15); }
textarea.input { min-height: 90px; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 12px; min-height: 420px; white-space: pre; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.search { position: relative; }
.search .input { padding-left: 36px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--dim); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line2); background: transparent; color: var(--muted); padding: 5px 12px; border-radius: 99px;
  cursor: pointer; font-weight: 600; font-size: 12.5px; }
.chip.on { background: var(--gold-bg); color: var(--gold2); border-color: rgba(244, 183, 64, .45); }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #2a3550; cursor: pointer; transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #cfd6e6; transition: transform .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); background: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; color: var(--muted); font-weight: 650; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--gold2); border-bottom-color: var(--gold); }

/* ---------- player header */
.hero { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.avatar { width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center; font-weight: 800; font-size: 22px;
  background: linear-gradient(140deg, #2b3a62, #1a2440); color: var(--gold2); border: 1px solid var(--line2); flex: none; }
.hero h2 { margin: 0; font-size: 21px; }
.stat { background: rgba(255, 255, 255, .025); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat .l { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .7px; font-weight: 650; }
.stat .v { font-size: 17px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.kv .k { color: var(--muted); }
.erow .lbl { width: 150px; flex: none; }
.erow .fld { flex: 1; min-width: 120px; }
select.auto { width: auto; min-width: 150px; }
label.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
label.check input { margin-top: 3px; flex: none; }

/* ---------- feed & chat */
.feed { display: flex; flex-direction: column; max-height: 430px; overflow-y: auto; }
.feed .e { display: grid; grid-template-columns: 70px 14px 1fr; gap: 8px; padding: 7px 2px; border-bottom: 1px solid rgba(36, 48, 74, .55);
  font-size: 13px; align-items: start; }
.feed .e .t { color: var(--dim); font-variant-numeric: tabular-nums; font-size: 12px; padding-top: 1px; }
.feed .e .ic { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--dim); }
.feed .e.login .ic { background: var(--green); }
.feed .e.logout .ic { background: var(--dim); }
.feed .e.chat .ic { background: var(--blue); }
.feed .e.error .ic, .feed .e.refused .ic { background: var(--red); }
.feed .e.warn .ic { background: var(--gold); }
.feed .e.panel .ic { background: var(--purple); }
.feed .who { color: var(--gold2); cursor: pointer; font-weight: 600; }
.msgs { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; padding-right: 4px; }
.msg { background: rgba(255, 255, 255, .03); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.msg.sys { background: var(--gold-bg); border-color: rgba(244, 183, 64, .35); }
.msg .h { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); }
.msg .h b { color: var(--text); }
.msg .b { margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.log { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.log .ln { padding: 5px 2px; border-bottom: 1px solid rgba(36, 48, 74, .5); }
.log .k { color: var(--gold2); }

/* ---------- chart */
.chart { width: 100%; height: 170px; display: block; }
.chart .grid line { stroke: rgba(255, 255, 255, .06); }
.chart text { fill: var(--dim); font-size: 10px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

/* ---------- modal & toast */
.modal-wrap { position: fixed; inset: 0; background: rgba(4, 7, 12, .66); backdrop-filter: blur(4px); display: grid;
  place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { width: min(560px, 100%); max-height: 90vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line2);
  border-radius: 18px; box-shadow: var(--shadow); animation: pop .18s; }
.modal.wide { width: min(980px, 100%); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal header h3 { margin: 0; font-size: 16px; flex: 1; }
.modal .body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #1a2338; border: 1px solid var(--line2); border-left: 3px solid var(--green); padding: 11px 14px;
  border-radius: 12px; box-shadow: var(--shadow); max-width: 360px; animation: pop .2s; }
.toast.err { border-left-color: var(--red); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.pick { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.pick div { padding: 8px 12px; cursor: pointer; display: flex; gap: 8px; border-bottom: 1px solid rgba(36, 48, 74, .5); }
.pick div:hover { background: rgba(255, 255, 255, .04); }
.pick div.on { background: var(--gold-bg); color: var(--gold2); }

/* ---------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .box { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line2); border-radius: 20px; padding: 30px 28px;
  box-shadow: var(--shadow); }
.login .crest { width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; font-weight: 900;
  font-size: 26px; background: linear-gradient(140deg, var(--gold2), #c9861a); color: #1b1203; box-shadow: 0 10px 30px rgba(244, 183, 64, .35); }
.login h1 { text-align: center; margin: 0 0 4px; font-size: 22px; }
.login p { text-align: center; color: var(--muted); margin: 0 0 22px; }
.err-text { color: var(--red); font-size: 13px; min-height: 18px; }

/* ---------- responsive */
@media (max-width: 1200px) { .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-102%); transition: transform .22s; }
  .side.open { transform: none; box-shadow: var(--shadow); }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 39; }
  .btn.burger { display: inline-flex; }
  .main { padding: 14px 16px 60px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span2 { grid-column: auto; }
  .top h1 { font-size: 19px; }
  .kpi .v { font-size: 23px; }
  .hide-sm { display: none !important; }
  .erow .lbl { width: 100%; }
  .toasts { left: 16px; right: 16px; }
  .toast { max-width: none; }
}
