:root {
  --bg: #09100e;
  --bg-raised: #101916;
  --panel: rgba(18, 29, 25, 0.86);
  --panel-strong: #15231e;
  --line: rgba(194, 230, 211, 0.12);
  --line-strong: rgba(194, 230, 211, 0.2);
  --text: #edf8f1;
  --muted: #91a79d;
  --faint: #61766d;
  --green: #66e19b;
  --green-strong: #2fc979;
  --green-dark: #153f2d;
  --amber: #f7c96b;
  --red: #ff817a;
  --blue: #70b8ff;
  --radius: 18px;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.24);
  color-scheme: dark;
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }

.dashboard-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 88% -10%, rgba(57, 182, 113, 0.13), transparent 33rem),
    linear-gradient(rgba(103, 152, 128, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(103, 152, 128, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 36px 36px, 36px 36px, auto;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: 248px;
  padding: 30px 22px 22px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(9, 16, 14, 0.92);
  backdrop-filter: blur(20px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand strong { display: block; font-size: 16px; letter-spacing: -0.01em; }
.brand small { display: block; margin-top: 3px; color: var(--faint); font-size: 9px; font-weight: 800; letter-spacing: 0.17em; }
.brand-mark {
  position: relative;
  width: 35px;
  height: 35px;
  flex: 0 0 35px;
  display: block;
  border: 1px solid rgba(102, 225, 155, 0.48);
  background: linear-gradient(145deg, rgba(102, 225, 155, 0.24), rgba(20, 89, 55, 0.12));
  box-shadow: inset 0 0 15px rgba(102, 225, 155, 0.08), 0 0 24px rgba(102, 225, 155, 0.08);
  transform: rotate(30deg) skewY(-5deg);
  border-radius: 7px;
}
.brand-mark::before, .brand-mark::after, .brand-mark span::before, .brand-mark span::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  background: var(--green);
  border-radius: 1px;
}
.brand-mark::before { left: 7px; top: 8px; }
.brand-mark::after { right: 7px; top: 8px; }
.brand-mark span::before { left: 7px; bottom: 8px; }
.brand-mark span::after { right: 7px; bottom: 8px; }

.side-nav { display: grid; gap: 7px; margin-top: 44px; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: 160ms ease;
}
.side-nav a span { width: 18px; color: var(--faint); font-size: 16px; text-align: center; }
.side-nav a:hover { color: var(--text); background: rgba(255,255,255,0.025); }
.side-nav a.active { color: var(--green); background: rgba(102, 225, 155, 0.08); border-color: rgba(102, 225, 155, 0.12); }
.side-nav a.active span { color: var(--green); }

.sidebar-meta { margin-top: auto; }
.secure-indicator { display: block; margin: 0 8px 16px; color: var(--faint); font-size: 11px; }
.secure-indicator i { display: inline-block; width: 6px; height: 6px; margin-right: 6px; background: var(--green); border-radius: 50%; box-shadow: 0 0 10px var(--green); }
.account-row { display: flex; align-items: center; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 34px; color: #07110c; background: var(--green); border-radius: 10px; font-size: 13px; font-weight: 900; }
.account-name { min-width: 0; flex: 1; }
.account-name strong, .account-name small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.account-name strong { font-size: 12px; }
.account-name small { margin-top: 3px; color: var(--faint); font-size: 10px; }
.icon-button { width: 32px; height: 32px; cursor: pointer; color: var(--muted); background: transparent; border: 0; border-radius: 8px; }
.icon-button:hover { color: var(--text); background: rgba(255,255,255,0.05); }

.dashboard-main { width: min(1240px, calc(100% - 248px)); margin-left: 248px; padding: 38px clamp(28px, 4vw, 64px) 30px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 42px; }
.eyebrow { margin: 0 0 9px; color: var(--green); font-size: 10px; font-weight: 850; letter-spacing: 0.19em; }
h1, h2, p { margin-top: 0; }
.topbar h1 { margin-bottom: 0; font-size: clamp(27px, 3vw, 38px); line-height: 1.1; letter-spacing: -0.045em; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.updated-at { color: var(--faint); font-size: 11px; white-space: nowrap; }

.button {
  min-height: 40px;
  padding: 0 16px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 750;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: 0.58; }
.button-primary { color: #06130c; background: var(--green); box-shadow: 0 8px 24px rgba(47, 201, 121, 0.13); }
.button-primary:hover:not(:disabled) { background: #7ae8aa; }
.button-secondary { color: var(--text); background: rgba(255,255,255,0.035); border-color: var(--line-strong); }
.button-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.065); border-color: rgba(194,230,211,0.3); }
.button-wide { width: 100%; min-height: 46px; }
.refresh-icon { display: inline-block; margin-right: 4px; font-size: 15px; }
.is-spinning .refresh-icon { animation: spin 0.75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.section-block { margin-bottom: 28px; scroll-margin-top: 28px; }
.section-heading, .panel-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.section-heading { margin-bottom: 18px; }
.section-heading h2, .panel-header h2 { margin-bottom: 5px; font-size: 17px; letter-spacing: -0.02em; }
.section-heading p, .panel-header p { margin-bottom: 0; color: var(--muted); font-size: 11px; }

.status-pill, .count-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,0.02);
  font-size: 10px;
  font-weight: 750;
}
.status-pill i { width: 7px; height: 7px; background: var(--faint); border-radius: 50%; }
.status-online { color: var(--green); border-color: rgba(102,225,155,0.2); background: rgba(102,225,155,0.065); }
.status-online i { background: var(--green); box-shadow: 0 0 10px rgba(102,225,155,0.75); }
.status-offline { color: var(--red); border-color: rgba(255,129,122,0.18); background: rgba(255,129,122,0.06); }
.status-offline i { background: var(--red); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.metric-card {
  position: relative;
  min-height: 145px;
  padding: 21px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(22, 35, 30, 0.96), rgba(14, 23, 20, 0.92));
  box-shadow: var(--shadow);
}
.metric-card::after { content: ""; position: absolute; inset: auto -35px -55px auto; width: 110px; height: 110px; border: 1px solid rgba(255,255,255,0.035); transform: rotate(45deg); }
.metric-primary { border-color: rgba(102,225,155,0.22); background: linear-gradient(145deg, rgba(25, 58, 43, 0.96), rgba(13, 29, 23, 0.95)); }
.metric-primary::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 90% 0, rgba(102,225,155,0.16), transparent 52%); pointer-events: none; }
.metric-label { position: relative; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: 0.05em; }
.metric-value { position: relative; display: flex; align-items: baseline; gap: 7px; margin-top: 14px; }
.metric-value strong { font-size: 35px; line-height: 1; letter-spacing: -0.05em; }
.metric-value span { color: var(--muted); font-size: 14px; }
.metric-value.metric-text strong { font-size: 24px; line-height: 1.25; }
.metric-card p { position: relative; margin: 14px 0 0; color: var(--faint); font-size: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.motd-value { position: relative; min-height: 38px; margin-top: 14px; font-size: 15px; font-weight: 760; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.panel { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.panel-header { margin-bottom: 21px; padding-bottom: 19px; border-bottom: 1px solid var(--line); }
.diagnostic-list { display: grid; gap: 9px; }
.diagnostic-item { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 14px; align-items: center; min-height: 48px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,0.018); }
.severity { width: max-content; padding: 4px 7px; border-radius: 6px; font-size: 9px; font-weight: 850; letter-spacing: 0.06em; }
.severity-high { color: #ffaaa5; background: rgba(255,129,122,0.1); }
.severity-medium { color: var(--amber); background: rgba(247,201,107,0.1); }
.severity-low { color: var(--blue); background: rgba(112,184,255,0.1); }
.severity-info { color: var(--green); background: rgba(102,225,155,0.08); }
.diagnostic-copy strong { display: block; margin-bottom: 3px; font-size: 11px; }
.diagnostic-copy span { display: block; color: var(--muted); font-size: 11px; line-height: 1.45; }

.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-bottom: 17px; }
input {
  width: 100%;
  min-height: 43px;
  padding: 0 14px;
  color: var(--text);
  outline: none;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(4, 10, 8, 0.48);
  font-size: 12px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
input::placeholder { color: var(--faint); }
input:focus { border-color: rgba(102,225,155,0.55); box-shadow: 0 0 0 3px rgba(102,225,155,0.08); }
.player-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.player-item { display: flex; align-items: center; gap: 10px; min-height: 49px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,0.018); }
.player-face { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 31px; color: #07110c; background: linear-gradient(145deg, #79e4a7, #36a96d); border-radius: 7px; font-size: 11px; font-weight: 900; }
.player-name { min-width: 0; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; font-weight: 700; }
.remove-player { width: 29px; height: 29px; cursor: pointer; color: var(--faint); border: 0; border-radius: 7px; background: transparent; font-size: 15px; }
.remove-player:hover { color: var(--red); background: rgba(255,129,122,0.07); }
.empty-state { padding: 24px; color: var(--faint); font-size: 11px; text-align: center; }
.player-list > .empty-state { grid-column: 1 / -1; border: 1px dashed var(--line); border-radius: 11px; }
.raw-response { margin: 13px 0 0; color: var(--faint); font-family: ui-monospace, "Cascadia Code", monospace; font-size: 10px; }

.table-wrap { overflow-x: auto; }
.audit-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.audit-table th { padding: 0 12px 11px; color: var(--faint); font-size: 9px; font-weight: 800; letter-spacing: 0.06em; text-align: left; }
.audit-table td { padding: 12px; border-top: 1px solid var(--line); color: var(--muted); vertical-align: middle; }
.audit-table td:first-child { white-space: nowrap; }
.audit-table td:nth-child(2), .audit-table td:nth-child(4) { color: var(--text); font-weight: 650; }
.result-badge { display: inline-flex; padding: 4px 7px; border-radius: 6px; font-size: 9px; font-weight: 850; }
.result-success { color: var(--green); background: rgba(102,225,155,0.08); }
.result-failure { color: var(--red); background: rgba(255,129,122,0.08); }

.alert { margin-bottom: 17px; padding: 11px 13px; border: 1px solid; border-radius: 10px; font-size: 11px; line-height: 1.5; }
.alert-danger { color: #ffb2ad; border-color: rgba(255,129,122,0.22); background: rgba(255,129,122,0.07); }
.alert-warning { color: #f8d995; border-color: rgba(247,201,107,0.2); background: rgba(247,201,107,0.065); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.page-footer { padding: 8px 0 4px; color: var(--faint); font-size: 9px; text-align: center; }

.toast-region { position: fixed; z-index: 50; right: 24px; bottom: 24px; display: grid; gap: 9px; pointer-events: none; }
.toast { min-width: 260px; max-width: 380px; padding: 12px 14px; color: var(--text); border: 1px solid var(--line-strong); border-left: 3px solid var(--green); border-radius: 10px; background: #17231f; box-shadow: 0 16px 44px rgba(0,0,0,0.42); font-size: 11px; animation: toast-in 180ms ease-out; }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.noscript { position: fixed; inset: auto 0 0; z-index: 100; padding: 12px; color: #111; background: var(--amber); text-align: center; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 5%, rgba(76, 196, 129, 0.16), transparent 32rem),
    linear-gradient(rgba(103, 152, 128, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(103, 152, 128, 0.035) 1px, transparent 1px),
    #08100d;
  background-size: auto, 38px 38px, 38px 38px, auto;
}
.login-shell { width: min(100%, 420px); }
.login-card { padding: 32px; border: 1px solid var(--line-strong); border-radius: 22px; background: rgba(16,25,22,0.94); box-shadow: 0 30px 90px rgba(0,0,0,0.44); backdrop-filter: blur(20px); }
.brand-login { padding-bottom: 25px; border-bottom: 1px solid var(--line); }
.login-copy { padding: 28px 0 20px; }
.login-copy h1 { margin-bottom: 9px; font-size: 29px; letter-spacing: -0.04em; }
.login-copy > p:last-child { margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 750; }
.login-form .button { margin-top: 9px; }
.login-note { margin: 20px 0 0; color: var(--faint); font-size: 9px; text-align: center; }
.login-note span { margin-right: 5px; color: var(--green); font-size: 7px; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .sidebar { position: static; width: 100%; height: auto; padding: 18px 20px; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-nav { display: none; }
  .sidebar-meta { margin: 0 0 0 auto; }
  .secure-indicator, .account-name { display: none; }
  .account-row { padding: 0; border: 0; }
  .dashboard-main { width: 100%; margin-left: 0; padding: 28px 18px; }
  .topbar { align-items: flex-start; margin-bottom: 31px; }
  .topbar-actions { align-items: flex-end; flex-direction: column-reverse; gap: 7px; }
  .updated-at { font-size: 9px; }
  .player-list { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 132px; }
  .panel { padding: 18px; }
  .panel-header, .section-heading { align-items: flex-start; }
  .whitelist-header { flex-direction: column; }
  .inline-form { grid-template-columns: 1fr; }
  .inline-form .button { width: 100%; }
  .audit-table th:nth-child(2), .audit-table td:nth-child(2) { display: none; }
  .toast-region { right: 14px; bottom: 14px; left: 14px; }
  .toast { min-width: 0; max-width: none; }
  .login-card { padding: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
