:root {
  --bg: #0f1218;
  --panel: #181d26;
  --panel2: #222a36;
  --line: #30394a;
  --text: #f5f8fc;
  --muted: #9aa7b8;
  --cyan: #39d6ff;
  --green: #36d887;
  --amber: #ffbd4a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(57, 214, 255, .14), transparent 28rem),
    radial-gradient(circle at 85% 10%, rgba(54, 216, 135, .10), transparent 26rem),
    var(--bg);
  color: var(--text);
}

.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand p { margin: 0 0 3px; color: var(--muted); font-size: 13px; }
h1, h2 { margin: 0; }
h1 { font-size: 32px; }
h2 { margin-bottom: 14px; font-size: 18px; }
.brand-logo { display: block; width: clamp(210px, 30vw, 330px); height: auto; }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; border: 1px solid rgba(57,214,255,.35); border-radius: 8px; background: linear-gradient(145deg, rgba(57,214,255,.18), rgba(54,216,135,.12)); }
.brand-mark span { width: 25px; height: 25px; border: 4px solid var(--cyan); border-bottom-color: transparent; border-radius: 50%; transform: rotate(-35deg); }
.pill { display: inline-flex; align-items: center; gap: 9px; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: rgba(24,29,38,.9); color: var(--muted); }
.pill span { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 18px rgba(54,216,135,.75); }
.auth-panel { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(260px, 1.2fr) auto auto; gap: 10px; align-items: center; margin-bottom: 18px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(24,29,38,.94); }
.auth-panel strong { display: block; margin-top: 5px; }
.auth-form { display: flex; gap: 8px; align-items: center; min-width: 0; }
.auth-form input, .auth-form select { min-width: 0; width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: #121720; color: var(--text); padding: 0 10px; }
.auth-form button, .ghost-btn, .admin-link { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 12px; border: 1px solid rgba(57,214,255,.42); border-radius: 8px; background: #131820; color: var(--text); text-decoration: none; cursor: pointer; white-space: nowrap; }
.auth-form button { background: var(--cyan); color: #06131a; font-weight: 760; }
.primary-link { background: var(--cyan); color: #06131a; font-weight: 760; }
.ghost-btn { color: var(--muted); }
#logoutBtn { justify-self: end; width: auto; min-width: 92px; min-height: 32px; padding: 0 14px; font-size: 13px; }
.narrow-shell { width: min(680px, calc(100% - 32px)); }
.register-card { max-width: 680px; margin: 0 auto; }
.stacked-form { flex-direction: column; align-items: stretch; margin-top: 14px; }
.stacked-form button { width: fit-content; padding: 0 18px; }
.muted-copy { margin-bottom: 12px; color: var(--muted); }
.layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr); gap: 18px; }
.meter-card, .side-card { border: 1px solid var(--line); border-radius: 8px; background: rgba(24,29,38,.94); box-shadow: 0 22px 70px rgba(0,0,0,.28); }
.meter-card { display: flex; flex-direction: column; align-items: center; min-height: 650px; padding: 22px; }
.server-line { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.server-line div, .metrics article, .details { border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); padding: 16px; }
small, dt { color: var(--muted); font-size: 13px; }
.server-line strong { display: block; margin-top: 5px; overflow-wrap: anywhere; }
.gauge { position: relative; display: grid; place-items: center; width: min(430px, 78vw); aspect-ratio: 1; margin: 38px 0 20px; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg, .ring { fill: none; stroke-width: 16; }
.ring-bg { stroke: #283140; }
.ring { stroke: var(--cyan); stroke-linecap: round; stroke-dasharray: 678.58; stroke-dashoffset: 678.58; filter: drop-shadow(0 0 10px rgba(57,214,255,.65)); transition: stroke-dashoffset .18s ease, stroke .18s ease; }
.speed { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.speed span { font-size: clamp(64px, 12vw, 108px); font-weight: 780; line-height: .92; }
.speed small { font-size: 18px; }
.start-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-width: 176px; min-height: 58px; border: 0; border-radius: 8px; background: var(--green); color: #06130c; font-size: 18px; font-weight: 760; cursor: pointer; box-shadow: 0 18px 40px rgba(54,216,135,.22); }
.start-btn:disabled { opacity: .72; cursor: wait; }
.play { width: 0; height: 0; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 13px solid currentColor; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin-top: 3mm; }
.step { display: grid; place-items: center; min-height: 46px; border: 1px solid var(--line); border-radius: 8px; background: #131820; color: var(--muted); }
.step.active { color: var(--text); border-color: rgba(57,214,255,.48); }
.side-card { display: flex; flex-direction: column; gap: 16px; padding: 18px; }
.history-panel { margin-top: 18px; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metrics article { min-height: 116px; }
.metrics strong { display: block; margin-top: 20px; font-size: 18px; }
.metrics span { font-size: 30px; }
dl { display: grid; gap: 13px; margin: 0; }
dl div { display: flex; justify-content: space-between; gap: 12px; }
dd { margin: 0; text-align: right; }
p { margin: 0; color: var(--muted); line-height: 1.45; }
.history-list { overflow-x: auto; }
.history-table { display: grid; min-width: 720px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: rgba(15,18,24,.48); }
.history-row { display: grid; grid-template-columns: minmax(170px, 1.2fr) minmax(150px, 1fr) minmax(90px, .55fr) minmax(120px, .7fr) minmax(120px, .7fr); align-items: center; gap: 14px; min-height: 42px; padding: 0 12px; border-top: 1px solid var(--line); }
.history-row:first-child { border-top: 0; }
.history-head { min-height: 36px; color: var(--muted); font-size: 11px; font-weight: 760; text-transform: uppercase; }
.history-head span:nth-child(n+3) { text-align: right; }
.history-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-row .number { text-align: right; font-variant-numeric: tabular-nums; }
.admin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.admin-grid strong { display: block; margin-top: 10px; font-size: 30px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #131820; color: var(--text); }
.server-form { margin-bottom: 12px; }
.admin-table { min-width: 980px; }

@media (max-width: 860px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .layout { grid-template-columns: 1fr; }
  .auth-panel, .admin-grid { grid-template-columns: 1fr; }
  .auth-form { flex-direction: column; align-items: stretch; }
}
@media (max-width: 520px) {
  .shell { width: min(100% - 20px, 1180px); padding: 14px 0; }
  .server-line, .metrics, .steps { grid-template-columns: 1fr; }
  .meter-card, .side-card { padding: 12px; }
}
:root { color-scheme: dark; }
#serverSelect { background: #202a37; color: #f5f8fc; border: 1px solid #3a4658; border-radius: 8px; padding: 9px 12px; margin: 8px; max-width: 90%; }
#deleteHistory, #revokeSessions { background: #202a37; color: #d8e5f1; border: 1px solid #3a4658; border-radius: 8px; padding: 10px 14px; margin: 8px 8px 8px 0; cursor: pointer; }
.history-panel > a { color: #39d6ff; display: inline-block; margin: 8px; }
.meter-card > p { color: #a8b7c8; line-height: 1.5; margin: 8px 0; }
