:root, [data-theme="light"] {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --page-bg: #f1f5f9;
  --card: #ffffff;
  --card-bg: #ffffff;
  --card-alt: #f8fafc;
  --text: #0f172a;
  --fg: #0f172a;
  --text-inv: #f8fafc;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --success: #16a34a;
  --success-hover: #15803d;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --warning: #d97706;
  --warning-hover: #b45309;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --running: #22c55e;
  --stopped: #94a3b8;
  --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 45px rgba(15, 23, 42, 0.15);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --loading-shade: rgba(255,255,255,.55);
  --radius: 14px;
  --topbar-bg: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  --topbar-logo-bg: linear-gradient(135deg, #6366f1, #8b5cf6);
  --topbar-fg: #f8fafc;

  --term-bg: #0b1020;
  --term-fg: #e2e8f0;
  --term-border: #1e293b;
  --term-header-bg: linear-gradient(180deg, #111827, #0b1020);
  --term-btn-red: #ff5f56;
  --term-btn-yellow: #ffbd2e;
  --term-btn-green: #27c93f;
  --term-prompt: #22c55e;
  --term-path: #60a5fa;
  --term-time: #a78bfa;
  --term-info: #38bdf8;
  --term-warn: #fbbf24;
  --term-err: #f87171;
  --term-ok: #4ade80;
  --term-container: #f472b6;
  --term-keyword: #f59e0b;
}

[data-theme="dark"] {
  --page-bg: #0a0f1e;
  --card: #111827;
  --card-bg: #111827;
  --card-alt: #1e293b;
  --text: #e5e7eb;
  --fg: #e5e7eb;
  --text-inv: #0f172a;
  --muted: #94a3b8;
  --border: #1f2937;
  --border-strong: #334155;
  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-soft: #312e81;
  --success: #4ade80;
  --success-hover: #86efac;
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --running: #4ade80;
  --stopped: #64748b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --loading-shade: rgba(0,0,0,.45);
  --radius: 14px;
  --topbar-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --topbar-logo-bg: linear-gradient(135deg, #6366f1, #8b5cf6);
  --topbar-fg: #f8fafc;
}

/* Light-theme overrides for topbar container & ghost-btn visibility when docs-topbar switches to light gradient */
[data-theme="light"] .docs-page .topbar,
[data-theme="light"] .topbar {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  --topbar-fg: var(--text);
  --topbar-logo-bg: linear-gradient(135deg, #4f46e5, #7c3aed);
}
[data-theme="light"] .docs-page .theme-toggle,
[data-theme="light"] .topbar .theme-toggle {
  background: rgba(15, 23, 42, 0.05);
  color: var(--text);
  border-color: var(--border);
}
[data-theme="light"] .docs-page .theme-toggle:hover,
[data-theme="light"] .topbar .theme-toggle:hover {
  background: rgba(15, 23, 42, 0.1);
}
[data-theme="light"] .docs-page .btn-ghost,
[data-theme="light"] .topbar .btn-ghost {
  background: rgba(15, 23, 42, 0.05);
  color: var(--text);
  border-color: var(--border);
}
[data-theme="light"] .docs-page .btn-ghost:hover,
[data-theme="light"] .topbar .btn-ghost:hover {
  background: rgba(15, 23, 42, 0.1);
}
[data-theme="light"] .docs-page .user-chip,
[data-theme="light"] .topbar .user-chip {
  background: rgba(15, 23, 42, 0.05);
  color: var(--text);
}
[data-theme="light"] .docs-page .topbar-title h1,
[data-theme="light"] .docs-page .page-title,
[data-theme="light"] .topbar h1,
[data-theme="light"] .topbar .page-title {
  color: var(--text);
}
[data-theme="light"] .docs-page .page-subtitle,
[data-theme="light"] .topbar .page-subtitle {
  color: var(--muted);
}

/* Override docs .topbar so it also inherits sticky positioning + theme-safe colors */
.docs-page .topbar {
  color: var(--topbar-fg);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Sukhumvit Set", "Noto Sans Thai", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  background: var(--page-bg);
  transition: background-color .2s ease, color .2s ease;
}

/* ========== Login ========== */
.login-body {
  background: #05060f;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #e2e8f0;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

/* ===== Animated Space Scene Layers ===== */
.login-scene {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.login-nebula {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(65% 55% at 12% 18%, rgba(139,92,246,0.55) 0%, rgba(59,7,100,0.22) 45%, transparent 72%),
    radial-gradient(60% 50% at 88% 22%, rgba(6,182,212,0.48) 0%, rgba(8,47,73,0.22) 48%, transparent 75%),
    radial-gradient(70% 60% at 50% 110%, rgba(236,72,153,0.38) 0%, rgba(88,28,135,0.18) 52%, transparent 78%),
    linear-gradient(180deg, #050817 0%, #0a0b1f 55%, #07081a 100%);
  filter: blur(2px) saturate(115%);
  animation: nebulaDrift 28s ease-in-out infinite alternate;
}
@keyframes nebulaDrift {
  0%   { transform: translate(0,0) scale(1); }
  50%  { transform: translate(-2%, -1.5%) scale(1.05); }
  100% { transform: translate(1.5%, 2%) scale(1.02); }
}

/* ---- Perspective tunnel grid (abstract lines / sci-fi style) ---- */
.login-grid {
  position: absolute;
  left: 50%;
  top: 62%;
  width: 280vmax;
  height: 160vmax;
  transform-origin: 50% 0%;
  transform: translateX(-50%) perspective(550px) rotateX(62deg);
  background-image:
    linear-gradient(to right,  rgba(103,232,249,0.35) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(167,139,250,0.35) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 15%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 15%, transparent 75%);
  animation: gridMove 5.2s linear infinite;
  opacity: 0.75;
}
.login-grid::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right,  rgba(244,114,182,0.22) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(244,114,182,0.22) 1px, transparent 1px);
  background-size: 16px 16px;
  animation: gridMove 1.3s linear infinite;
  opacity: 0.7;
}
@keyframes gridMove {
  from { background-position: 0 0; }
  to   { background-position: 0 64px; }
}

/* Horizontal neon horizon glow line */
.login-horizon {
  position: absolute;
  left: 0; right: 0;
  top: 62%;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(103,232,249,0.9) 18%,
    rgba(236,72,153,0.9) 50%,
    rgba(167,139,250,0.9) 82%,
    transparent 100%);
  box-shadow:
    0 0 10px rgba(103,232,249,0.6),
    0 0 30px rgba(236,72,153,0.55),
    0 0 60px rgba(167,139,250,0.45);
  animation: horizonPulse 3.6s ease-in-out infinite alternate;
}
@keyframes horizonPulse {
  from { opacity: 0.6; filter: brightness(0.9); }
  to   { opacity: 1;   filter: brightness(1.25); }
}

/* ---- Starfield (2 layers, parallax drift) using pure CSS box-shadow stars ---- */
.login-stars, .login-stars::before,
.login-stars2, .login-stars2::before {
  position: absolute;
  width: 2px; height: 2px;
  background: transparent;
  border-radius: 50%;
}
.login-stars {
  top: 0; left: 0;
  box-shadow:
    422px 82px #fff, 108px 250px #c7d2fe, 560px 110px #fff, 820px 180px #67e8f9,
    250px 420px #fff, 960px 320px #f9a8d4, 132px 560px #fff, 700px 620px #a5b4fc,
    1180px 90px #fff, 340px 180px #fcd34d, 880px 480px #fff, 1040px 260px #22d3ee,
    660px 720px #fff, 120px 360px #fff, 1300px 520px #f0abfc, 480px 80px #fff,
    200px 680px #67e8f9, 920px 560px #fff, 1100px 420px #fff, 780px 360px #c4b5fd,
    60px 150px #fff, 1420px 180px #fff, 360px 760px #fef08a, 1260px 620px #fff,
    520px 340px #fff, 20px 500px #67e8f9, 1000px 80px #fff, 1380px 340px #fbcfe8,
    720px 200px #fff, 160px 320px #fff, 900px 700px #c4b5fd, 440px 600px #fff,
    1140px 560px #fff, 260px 90px #f9a8d4, 620px 460px #fff, 860px 120px #fff,
    1500px 260px #67e8f9, 80px 600px #fff, 580px 260px #fff, 1200px 380px #fff,
    320px 540px #fff, 1460px 700px #f0abfc, 700px 40px #fff, 980px 180px #fff;
  animation: starDriftA 120s linear infinite;
  opacity: 0.9;
}
.login-stars::before {
  content: ''; top: 100vh; left: 0;
  box-shadow: inherit;
}
@keyframes starDriftA {
  from { transform: translateY(0); }
  to   { transform: translateY(-100vh); }
}
.login-stars2 {
  top: 0; left: 0;
  box-shadow:
    360px 120px #e0e7ff, 680px 220px #fff, 160px 300px #a5f3fc, 1020px 140px #fff,
    520px 500px #fff, 820px 360px #fbcfe8, 280px 640px #fff, 1140px 440px #ddd6fe,
    900px 80px #fff, 40px 220px #fde68a, 760px 560px #fff, 1260px 300px #67e8f9,
    600px 760px #fff, 220px 420px #fff, 1380px 600px #f9a8d4, 440px 60px #fff,
    100px 720px #c4b5fd, 980px 620px #fff, 1180px 480px #fff, 840px 400px #bae6fd,
    140px 200px #fff, 1480px 240px #fff, 380px 800px #fef3c7, 1320px 680px #fff,
    560px 380px #fff, 80px 540px #7dd3fc, 1060px 60px #fff, 1420px 380px #f0abfc,
    760px 240px #fff, 200px 360px #fff, 940px 740px #ddd6fe, 480px 640px #fff,
    1200px 600px #fff, 300px 110px #f9a8d4, 640px 500px #fff, 900px 160px #fff,
    1540px 300px #a5f3fc, 120px 640px #fff, 520px 300px #fff, 1240px 420px #fff,
    340px 580px #fff, 1480px 760px #e9d5ff, 720px 80px #fff, 1020px 220px #fff;
  animation: starDriftB 200s linear infinite;
  opacity: 0.6;
  filter: blur(0.3px);
}
.login-stars2::before {
  content: ''; top: 100vh; left: 0;
  box-shadow: inherit;
}
@keyframes starDriftB {
  from { transform: translateY(0); }
  to   { transform: translateY(-100vh); }
}

/* Shooting stars (meteors) */
.login-meteor {
  position: absolute;
  top: -10%;
  width: 140px;
  height: 1px;
  background: linear-gradient(90deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.95) 50%,
    rgba(167,139,250,0.8) 100%);
  transform: rotate(18deg);
  filter: drop-shadow(0 0 6px rgba(167,139,250,0.9));
  opacity: 0;
  animation: meteor 8s linear infinite;
}
.login-meteor.m2 {
  left: 30%;
  animation-delay: 2.8s;
  animation-duration: 9.5s;
  background: linear-gradient(90deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.95) 50%,
    rgba(103,232,249,0.8) 100%);
  filter: drop-shadow(0 0 6px rgba(103,232,249,0.9));
}
.login-meteor.m3 {
  left: 75%;
  animation-delay: 5.2s;
  animation-duration: 7s;
  transform: rotate(22deg);
}
@keyframes meteor {
  0%   { transform: translate(0,0) rotate(20deg);    opacity: 0; }
  8%   { opacity: 1; }
  50%  { opacity: 0.9; }
  90%  { opacity: 0.2; }
  100% { transform: translate(55vw, 110vh) rotate(20deg); opacity: 0; }
}

.login-container { position: relative; width: 100%; max-width: 420px; text-align: center; z-index: 2; }
.login-card {
  background: rgba(15, 23, 42, 0.55);
  color: var(--text);
  border-radius: 20px;
  padding: 40px 32px;
  box-shadow:
    0 18px 60px rgba(0,0,0,0.55),
    0 0 0 1px rgba(255,255,255,0.06),
    0 0 30px rgba(139,92,246,0.18),
    inset 0 1px 0 rgba(255,255,255,0.06);
  border: 1px solid rgba(148, 163, 184, 0.18);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg,
    rgba(167,139,250,0.7) 0%,
    rgba(103,232,249,0.5) 35%,
    rgba(236,72,153,0.6) 70%,
    rgba(167,139,250,0.7) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  opacity: 0.7;
  animation: cardBorderGlow 6s ease-in-out infinite alternate;
}
@keyframes cardBorderGlow {
  from { opacity: 0.45; filter: hue-rotate(0deg); }
  to   { opacity: 0.9;  filter: hue-rotate(25deg); }
}
.login-logo {
  font-size: 60px; line-height: 1; margin-bottom: 8px;
  filter: drop-shadow(0 0 12px rgba(139,92,246,0.55));
  animation: logoFloat 5s ease-in-out infinite alternate;
}
@keyframes logoFloat {
  from { transform: translateY(0) rotate(-2deg); }
  to   { transform: translateY(-4px) rotate(2deg); }
}
.login-title {
  margin: 6px 0 4px; font-size: 26px; font-weight: 800;
  background: linear-gradient(90deg, #c4b5fd 0%, #67e8f9 50%, #f9a8d4 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.2px;
}
.login-sub { color: #94a3b8; margin: 0 0 24px; font-size: 14px; }
.login-footer { color: rgba(148, 163, 184, 0.75); margin-top: 20px; font-size: 12px; text-shadow: 0 1px 2px rgba(0,0,0,0.6); }

.login-form { text-align: left; }
.form-label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text);
}
.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  margin-bottom: 16px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
  background: var(--card);
  color: var(--text);
}
[data-theme="dark"] .form-input { background: #0f172a; }
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform .05s ease, background-color .15s, border-color .15s, color .15s, filter .15s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--success-hover); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-warning {
  background: linear-gradient(180deg, #f59e0b, var(--warning));
  color: #fff;
  border-color: transparent;
}
.btn-warning:hover:not(:disabled) { filter: brightness(0.94); }

.btn-outline {
  background: var(--card);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-outline:hover:not(:disabled) { background: var(--card-alt); }

.btn-ghost {
  background: rgba(255,255,255,.08);
  color: #fff;
  border-color: rgba(255,255,255,.18);
}
.btn-ghost:hover { background: rgba(255,255,255,.14); }

.btn-block { width: 100%; padding: 12px 14px; font-size: 15px; }
.btn-sm { padding: 7px 10px; font-size: 13px; border-radius: 8px; }

/* Card-level ghost button (light style) */
.server-card .btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.server-card .btn-ghost:hover:not(:disabled) { background: var(--card-alt); }

/* ========== Topbar ========== */
.dashboard-body { background: var(--page-bg); min-height: 100vh; }
.topbar {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(15,23,42,.15);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.topbar-title { display: flex; align-items: center; gap: 12px; }
.topbar-logo { font-size: 28px; }
.topbar-title h1 { margin: 0; font-size: 18px; font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-chip {
  background: rgba(255,255,255,.08);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: #e2e8f0;
}

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  border-radius: 10px;
  background: rgba(255,255,255,.10);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
  font-size: 16px;
  cursor: pointer;
  transition: background-color .15s, transform .05s;
}
.theme-toggle:hover { background: rgba(255,255,255,.16); transform: translateY(-1px); }

/* ========== Container / layout ========== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}
.page-info h2 { margin: 0 0 6px; font-size: 22px; font-weight: 700; }
.page-info p { margin: 4px 0; }
.page-info-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.page-info-actions { display: flex; gap: 8px; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ========== Flash messages ========== */
.flash-area { margin: 18px 0 6px; }
.flash {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  animation: flashIn .18s ease-out;
}
@keyframes flashIn { from { transform: translateY(-4px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.flash-info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.flash-success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.flash-error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
[data-theme="dark"] .flash-info { background: #172554; color: #93c5fd; border-color: #1e3a8a; }
[data-theme="dark"] .flash-success { background: #052e16; color: #86efac; border-color: #14532d; }
[data-theme="dark"] .flash-error { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }

/* ========== Server grid ========== */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 20px;
}
.server-card {
  background: var(--card);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform .15s ease, box-shadow .15s ease, opacity .3s, background-color .2s;
  position: relative;
}
.server-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.server-card.loading::after {
  content: "";
  position: absolute; inset: 0;
  background: var(--loading-shade);
  border-radius: 14px;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(79,70,229,.08) 0 10px,
    rgba(79,70,229,.02) 10px 20px
  );
  animation: slide 1.2s linear infinite;
}
@keyframes slide {
  from { background-position: 0 0; }
  to   { background-position: 40px 0; }
}

.server-banner-link {
  display: block; position: relative; overflow: hidden;
  border-radius: calc(var(--radius) + 2px) calc(var(--radius) + 2px) 0 0;
  margin: -12px -12px 0;
  background: var(--bg-dim);
  min-height: 100px;
  text-decoration: none;
}
.server-banner {
  display: block; width: 100%; height: 140px; object-fit: cover;
  background: var(--bg-dim);
}
@media (max-width: 640px) {
  .server-banner { height: 110px; }
}
.server-banner-overlay {
  position: absolute; inset: auto 0 0 0;
  padding: 14px 14px 10px;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.78) 100%);
  color: #fff;
}
.server-banner-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 15px; letter-spacing: 0.2px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}
.server-banner-doclink {
  position: absolute; right: 10px; bottom: 8px;
  width: 30px; height: 30px; display: inline-flex;
  align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.35);
  backdrop-filter: blur(4px);
  text-decoration: none; font-size: 16px;
  color: #fff;
}
.server-banner-doclink:hover { background: rgba(255,255,255,0.22); }
.server-banner-icon { font-size: 17px; }

.server-card-head {
  display: flex; align-items: flex-start; gap: 14px;
  margin-bottom: 14px;
  padding-top: 12px;
}
.server-icon {
  font-size: 36px; line-height: 1;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card-alt);
  border-radius: 12px;
  flex-shrink: 0;
}
.server-head-info { min-width: 0; flex: 1; }
.server-name { margin: 2px 0 4px; font-size: 18px; font-weight: 700; }
.server-desc { margin: 0; color: var(--muted); font-size: 13px; }

/* Worldline (replaced old red-boxed head — only server description / world name) */
.server-worldline {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 0 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--card-alt);
  border: 1px dashed var(--border);
}
.server-worldline-label { opacity: 0.75; font-size: 14px; }
.server-worldline-name {
  flex: 1; min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.15px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
[data-theme="dark"] .server-worldline-name { color: #94a3b8; }
[data-theme="light"] .server-worldline-name { color: #475569; }

/* ===== htop/bashtop-style Server Stats panel ===== */
.server-stats {
  margin-top: 14px;
  padding: 12px 12px 10px;
  border-radius: 12px;
  background: #020617;
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 0 0 1px rgba(56, 189, 248, 0.06),
    0 4px 20px rgba(2, 6, 23, 0.45);
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  position: relative;
  overflow: hidden;
}
[data-theme="light"] .server-stats {
  background: #0f172a;
  color: #e2e8f0;
}
.server-stats::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(125, 211, 252, 0.035) 0 1px, transparent 1px 3px);
  mix-blend-mode: screen;
  opacity: 0.7;
}
.ss-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 9px;
  padding-bottom: 7px;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.18);
  letter-spacing: 0.3px;
}
.ss-title {
  font-size: 12px;
  font-weight: 700;
  color: #7dd3fc;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.35);
}
.ss-meta { color: #64748b; }
.ss-grid {
  display: grid; grid-template-columns: 1fr;
  gap: 7px;
}
.ss-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}
.ss-label {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  min-width: 0;
}
.ss-tag {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.8px;
  color: #020617;
}
.ss-tag-cpu { background: linear-gradient(180deg, #86efac, #22c55e); box-shadow: 0 0 0 1px rgba(34,197,94,0.4); }
.ss-tag-mem { background: linear-gradient(180deg, #93c5fd, #3b82f6); box-shadow: 0 0 0 1px rgba(59,130,246,0.4); }
.ss-tag-net { background: linear-gradient(180deg, #c4b5fd, #8b5cf6); box-shadow: 0 0 0 1px rgba(139,92,246,0.4); }
.ss-tag-disk { background: linear-gradient(180deg, #fcd34d, #f59e0b); color:#431407; box-shadow: 0 0 0 1px rgba(245,158,11,0.45); }
.ss-val {
  font-size: 11.5px;
  font-weight: 700;
  color: #e2e8f0;
  text-align: right;
  white-space: nowrap;
  min-width: 0;
}
.ss-val-net { display: inline-flex; align-items: center; gap: 4px; }
.ss-sep { opacity: 0.4; }
.ss-bar {
  position: relative;
  height: 9px;
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.2);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.6);
}
.ss-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 1%;
  border-radius: 5px;
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255,255,255,0.08) 0 5px,
    transparent 5px 10px
  );
  transition: width .5s cubic-bezier(.4,.0,.2,1), background-color .2s ease;
}
.ss-fill-cpu { background-color: #22c55e; box-shadow: 0 0 10px rgba(34,197,94,0.55); }
.ss-fill-mem { background-color: #3b82f6; box-shadow: 0 0 10px rgba(59,130,246,0.55); }
.ss-fill-disk { background-color: #f59e0b; box-shadow: 0 0 10px rgba(245,158,11,0.55); }
.ss-fill-cpu.color-warn { background-color: #eab308; box-shadow: 0 0 10px rgba(234,179,8,0.55); }
.ss-fill-mem.color-warn { background-color: #06b6d4; box-shadow: 0 0 10px rgba(6,182,212,0.55); }
.ss-fill-disk.color-warn { background-color: #ef4444; box-shadow: 0 0 10px rgba(239,68,68,0.55); }
.ss-fill-cpu.color-crit { background-color: #ef4444; box-shadow: 0 0 12px rgba(239,68,68,0.7); animation: blinkCrit 0.9s ease-in-out infinite alternate; }
.ss-fill-mem.color-crit { background-color: #ec4899; box-shadow: 0 0 12px rgba(236,72,153,0.7); animation: blinkCrit 0.9s ease-in-out infinite alternate; }
.ss-fill-disk.color-crit { background-color: #dc2626; box-shadow: 0 0 12px rgba(220,38,38,0.7); animation: blinkCrit 0.9s ease-in-out infinite alternate; }
@keyframes blinkCrit {
  from { filter: brightness(0.85); }
  to   { filter: brightness(1.4);  }
}
.ss-mini {
  display: flex; flex-wrap: wrap; gap: 10px 14px;
  color: #94a3b8; font-size: 11px;
  padding-top: 2px;
}
.ss-mini-item { display: inline-flex; align-items: center; gap: 5px; }
.ss-mini-item b { color: #e2e8f0; font-weight: 700; }
.ss-dot {
  width: 8px; height: 8px; border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}
.ss-dot-rx { color: #22d3ee; background: #22d3ee; }
.ss-dot-tx { color: #a78bfa; background: #a78bfa; }
.ss-dot-r  { color: #34d399; background: #34d399; }
.ss-dot-w  { color: #fbbf24; background: #fbbf24; }
.ss-dot-u  { color: #f87171; background: #f87171; }

.server-status-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 10px; flex-wrap: wrap;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  background: var(--card-alt);
  color: var(--text);
}
.status-pill .status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(0,0,0,.04);
}
.status-running { background: #dcfce7; color: var(--success); }
.status-stopped { background: #f1f5f9; color: #64748b; }
[data-theme="dark"] .status-running { background: #052e16; color: var(--success); }
[data-theme="dark"] .status-stopped { background: #1e293b; color: #94a3b8; }
.status-running .status-dot { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%     { transform: scale(1.25); opacity: .75; }
}

.server-actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px;
}
.server-actions .btn { flex: 1 1 auto; min-width: 86px; text-align: center; padding: 9px 10px; }
.guest-actions {
  background: linear-gradient(90deg, #0ea5e911, #8b5cf611);
  border: 1px solid rgba(14, 165, 233, 0.15);
  border-radius: 10px;
  padding: 10px 12px;
  align-items: center;
}
.guest-actions .btn { flex: 0 0 auto; }
.guest-readonly-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: linear-gradient(90deg, #0ea5e9, #8b5cf6);
  color: #fff;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.2px;
}

.modal-select {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
}
[data-theme="dark"] .modal-select { background: #0f172a; }

.server-detail {
  min-height: 16px;
  word-break: break-word;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

.admin-chat-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.admin-chat-head { display: flex; align-items: center; justify-content: space-between; }
.admin-chat-title { font-size: 13px; }
.admin-chat-row {
  display: flex; gap: 8px; align-items: stretch;
}
.admin-chat-row .form-input { margin-bottom: 0; flex: 1 1 auto; min-width: 0; }
.admin-chat-send { flex: 0 0 auto; padding: 0 16px; }
.admin-chat-status { min-height: 16px; word-break: break-word; }
.admin-chat-status.text-err { color: var(--danger); }

/* ========== Patch notes (dashboard inline) ========== */
.server-patchbox {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.server-patchbox-head {
  display: flex; align-items: center; justify-content: space-between;
}
.server-patchbox-title { font-size: 13px; }
.server-patchbox-latest {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow-sm);
}
.server-patchbox-latest-top {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.server-patch-version {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px; font-weight: 700;
  padding: 2px 8px; border-radius: 6px;
  background: linear-gradient(90deg, #1e293b, #0f172a);
  color: #fbbf24;
  border: 1px solid #fbbf2433;
}
.server-patch-tag,
.patch-tag {
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.server-patch-tag-hotfix,
.patch-tag-hotfix { background: #ef444422; color: #f87171; border: 1px solid #ef444444; }
.server-patch-tag-patch,
.patch-tag-patch { background: #3b82f622; color: #60a5fa; border: 1px solid #3b82f644; }
.server-patch-tag-major,
.patch-tag-major { background: #a855f722; color: #c084fc; border: 1px solid #a855f744; }
.server-patch-tag-update,
.patch-tag-update { background: #10b98122; color: #34d399; border: 1px solid #10b98144; }
.server-patch-tag-launch,
.patch-tag-launch { background: #f59e0b22; color: #fbbf24; border: 1px solid #f59e0b44; }
.server-patch-latest {
  margin-left: auto;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  color: #1c1917;
}
.server-patchbox-title-text {
  font-size: 13px; font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.server-patchbox-highlights {
  margin: 0; padding-left: 18px;
  font-size: 12px;
  color: var(--text);
  opacity: 0.92;
}
.server-patchbox-highlights li { margin: 2px 0; line-height: 1.45; }
.server-patchbox-link {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  box-shadow: 0 8px 18px rgba(99, 102, 241, 0.30);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.server-patchbox-link:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 10px 22px rgba(99, 102, 241, 0.42);
}
.server-patchbox-empty {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--card);
  border: 1px dashed var(--border);
}
.server-patchbox-empty a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  margin-left: 6px;
}

/* ========== Patch notes page (patches.html) ========== */
.patch-game-section { scroll-margin-top: 84px; }
.patch-game-head {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: stretch;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}
.patch-game-banner {
  background-size: cover;
  background-position: center center;
  min-height: 140px;
}
.patch-game-info {
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px; justify-content: center;
}
.patch-game-title {
  margin: 0;
  font-size: 22px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.patch-game-icon { font-size: 28px; }
.patch-count {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  color: #fff;
  font-weight: 700;
  margin-left: auto;
}
.patch-links-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

.patch-note {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 5px solid #6366f1;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 84px;
}
.patch-note-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}
.patch-note-title {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.patch-version {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px; font-weight: 700;
  padding: 3px 10px; border-radius: 8px;
  background: linear-gradient(90deg, #1e293b, #0f172a);
  color: #fbbf24;
  border: 1px solid #fbbf2433;
}
.patch-title-text { font-weight: 600; font-size: 14px; }
.patch-note-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.patch-latest {
  font-size: 11px; font-weight: 700;
  padding: 2px 10px; border-radius: 999px;
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  color: #1c1917;
}

.patch-group { margin: 10px 0; }
.patch-group h4 {
  margin: 0 0 6px 0;
  font-size: 13px;
  display: inline-flex; gap: 6px; align-items: center;
  padding: 4px 10px;
  border-radius: 8px;
}
.patch-group-highlights h4 { background: #fbbf2418; color: #fbbf24; }
.patch-group-fixes h4 { background: #10b98118; color: #34d399; }
.patch-group-changes h4 { background: #3b82f618; color: #60a5fa; }
.patch-group ul {
  margin: 4px 0 0 0;
  padding-left: 22px;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
}
.patch-group ul li { margin: 3px 0; }

.patch-group-known { margin-top: 10px; }
.patch-group-known ul { margin-top: 8px; }

.patch-bottom-links {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.patch-bottom-links a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.patch-bottom-links a:hover { text-decoration: underline; }

.game-picker { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-right: 8px; }

@media (max-width: 720px) {
  .patch-game-head { grid-template-columns: 1fr; }
  .patch-game-banner { min-height: 100px; }
}

.dash-footer {
  margin-top: 40px; text-align: center;
  padding-top: 20px; border-top: 1px solid var(--border);
}

/* ========== Modal ========== */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn .15s ease-out;
}
.modal-dialog {
  position: relative;
  width: 100%;
  max-width: min(1100px, calc(100vw - 40px));
  max-height: min(860px, calc(100vh - 40px));
  background: var(--card);
  color: var(--text);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
  display: flex; flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  animation: slideUp .18s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
body.modal-open { overflow: hidden; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--card-alt);
  gap: 10px; flex-wrap: wrap;
}
.modal-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
.modal-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 18px;
  background: var(--card);
  display: flex;
  flex-direction: column;
}

/* ========== Terminal-style Log Viewer ========== */
.terminal {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--term-bg);
  border-radius: 12px;
  box-shadow:
    0 10px 30px rgba(0,0,0,.45),
    inset 0 0 0 1px rgba(255,255,255,.04);
  overflow: hidden;
  border: 1px solid var(--term-border);
}
.terminal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--term-header-bg);
  border-bottom: 1px solid var(--term-border);
  flex-shrink: 0;
  gap: 12px;
}
.terminal-buttons { display: flex; align-items: center; gap: 8px; }
.term-btn {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
}
.term-btn.red    { background: var(--term-btn-red); }
.term-btn.yellow { background: var(--term-btn-yellow); }
.term-btn.green  { background: var(--term-btn-green); }

.terminal-title {
  color: #cbd5e1;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .3px;
  opacity: .9;
}
.terminal-spacer { flex: 1; }
.terminal-status {
  color: #94a3b8;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.terminal-status .dot-online {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--term-ok);
  margin-right: 6px;
  box-shadow: 0 0 8px rgba(74,222,128,.6);
}

.terminal-body {
  margin: 0;
  flex: 1 1 auto;
  min-height: 320px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding: 16px 18px;
  background:
    radial-gradient(1200px 300px at 0% 0%, rgba(37,99,235,.08), transparent 60%),
    linear-gradient(180deg, #0b1020 0%, #0a0f1d 100%);
  color: var(--term-fg);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.terminal-body::-webkit-scrollbar { width: 12px; height: 12px; }
.terminal-body::-webkit-scrollbar-track { background: #0a0f1d; }
.terminal-body::-webkit-scrollbar-thumb {
  background: #1f2a44;
  border-radius: 999px;
  border: 2px solid #0a0f1d;
}
.terminal-body::-webkit-scrollbar-thumb:hover { background: #2e3d66; }

/* Log line wrapper (for padding between entries) */
.terminal-body > .log-line {
  display: block;
  padding: 1px 0;
  border-radius: 4px;
}
.terminal-body > .log-line:hover { background: rgba(148,163,184,.06); }

/* Terminal prompt prefix (first line in viewer) */
.term-prompt-line {
  display: block;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(148,163,184,.18);
  color: #cbd5e1;
}
.term-prompt-line .arrow  { color: var(--term-prompt); font-weight: 700; }
.term-prompt-line .host   { color: var(--term-path); }
.term-prompt-line .path   { color: #f0abfc; }
.term-prompt-line .dollar { color: var(--term-ok); margin: 0 4px; }
.term-prompt-line .cmd    { color: #e2e8f0; }

/* Log parts (colors) */
.term-time      { color: var(--term-time); }
.term-date      { color: #a78bfa; opacity: .95; }
.term-host      { color: var(--term-path); }
.term-user      { color: #f0abfc; }
.term-container { color: var(--term-container); font-weight: 600; }
.term-sep       { color: #475569; }
.term-info      { color: var(--term-info); font-weight: 500; }
.term-warn      { color: var(--term-warn); font-weight: 600; }
.term-err       { color: var(--term-err);  font-weight: 700; }
.term-ok        { color: var(--term-ok);   font-weight: 600; }
.term-keyword   { color: var(--term-keyword); }
.term-syslog-unit { color: #fbbf24; }
.term-pid       { color: #94a3b8; }
.term-tag       {
  display: inline-block;
  padding: 0 6px; margin-right: 6px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(99,102,241,.18);
  color: #a5b4fc;
  border: 1px solid rgba(99,102,241,.3);
}
.term-tag.INFO { background: rgba(56,189,248,.15); color: #7dd3fc; border-color: rgba(56,189,248,.35); }
.term-tag.WARN,
.term-tag.WARNING { background: rgba(251,191,36,.16); color: #fcd34d; border-color: rgba(251,191,36,.35); }
.term-tag.ERR,
.term-tag.ERROR { background: rgba(248,113,113,.16); color: #fca5a5; border-color: rgba(248,113,113,.35); }
.term-tag.SUCCESS,
.term-tag.OK { background: rgba(74,222,128,.16); color: #86efac; border-color: rgba(74,222,128,.35); }
.term-plain    { color: var(--term-fg); }
.term-empty    { color: #64748b; font-style: italic; opacity: .8; }

/* Responsive */
@media (max-width: 560px) {
  .topbar-inner { padding: 12px 16px; }
  .container { padding: 20px 16px 32px; }
  .login-card { padding: 30px 20px; }
  .topbar-title h1 { font-size: 16px; }
  .user-chip { display: none; }
  .modal-dialog { margin: 0; max-width: 100%; max-height: 100%; border-radius: 0; min-height: 100dvh; }
  .modal-body { padding: 12px; }
  .terminal { border-radius: 10px; }
  .terminal-body { font-size: 12px; padding: 12px; }
}

.docs-page { min-height: 100vh; background: var(--bg); color: var(--fg); }
.docs-page .topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; }
.page-title { margin: 0; font-size: 18px; font-weight: 800; }
.page-subtitle { margin: 0; color: var(--muted); font-size: 12px; }
.logo {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px; border-radius: 12px; background: var(--card-alt);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.role-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10px; letter-spacing: 0.6px; font-weight: 700; margin-right: 6px;
}
.role-admin { background: linear-gradient(90deg, #ef4444, #f97316); color: #fff; }

.docs-container {
  max-width: 1280px; margin: 0 auto;
  padding: 28px 24px 64px;
  display: grid; grid-template-columns: 280px 1fr; gap: 28px;
  align-items: flex-start;
}
@media (max-width: 900px) {
  .docs-container { grid-template-columns: 1fr; }
  .docs-page .topbar { padding: 12px 16px; }
}
.toc {
  position: sticky; top: 96px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.toc h2 {
  margin: 0 0 10px; font-size: 14px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc ul ul { padding-left: 16px; margin-top: 4px; }
.toc li { margin: 3px 0; }
.toc a {
  color: var(--muted); text-decoration: none; font-size: 13px;
  padding: 4px 8px; display: block; border-radius: 6px;
}
.toc a:hover { background: var(--card-alt); color: var(--fg); }
.toc-version { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--border); }

.doc-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.doc-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 96px;
}
.doc-section h2 {
  margin: 0 0 12px; font-size: 18px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.doc-section h3 {
  margin: 16px 0 8px; font-size: 15px;
  color: var(--text);
}
.doc-section p, .doc-section li, .doc-section td, .doc-section th,
.doc-section label { color: var(--text); }
.doc-section p, .doc-section li { line-height: 1.65; }
.doc-section ul, .doc-section ol { padding-left: 22px; }
.doc-section li { margin: 4px 0; }

.callout {
  margin: 12px 0; padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
}
[data-theme="light"] .callout-info { background: #eff6ff; border-color: #bfdbfe; }
[data-theme="dark"]  .callout-info { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.4); }
[data-theme="light"] .callout-warn { background: #fffbeb; border-color: #fde68a; }
[data-theme="dark"]  .callout-warn { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.4); }
[data-theme="light"] .callout-ok   { background: #ecfdf5; border-color: #a7f3d0; }
[data-theme="dark"]  .callout-ok   { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.4); }
.callout b { margin-right: 4px; }
.callout ul { margin: 6px 0 0; padding-left: 20px; }

.perm-table, .game-facts {
  width: 100%; border-collapse: collapse; margin: 10px 0;
  font-size: 13px;
  background: var(--card-alt);
  border-radius: 8px; overflow: hidden;
}
.perm-table th, .perm-table td,
.game-facts th, .game-facts td {
  text-align: left; padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.perm-table thead, .game-facts th {
  background: var(--topbar-bg);
  font-size: 12px; letter-spacing: 0.3px;
}
.perm-table th:last-child, .perm-table td:last-child { text-align: center; }
.perm-table tr:last-child td { border-bottom: none; }
.game-facts th { width: 28%; white-space: nowrap; }
.mode-ok { color: #10b981; font-weight: 700; }
.mode-warn { color: #f59e0b; font-weight: 700; }
.doc-section pre, .doc-section code {
  background: var(--card-alt);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-x: auto;
}
.doc-section pre {
  padding: 10px 12px; margin: 10px 0;
  border: 1px solid var(--border);
  line-height: 1.5;
}
.doc-section code { white-space: nowrap; }
.game-doc-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0;
  background: var(--card-alt);
  scroll-margin-top: 96px;
}
.game-doc-card h3 { margin: 0 0 8px; }
.term-time { color: var(--term-time, #a78bfa); }
.term-host { color: var(--term-host, #60a5fa); }
.term-container { color: var(--term-container, #f472b6); }
.term-tag.INFO { background: #1e293b; color: #93c5fd; }
.term-tag.WARN { background: #422006; color: #fbbf24; }
.term-tag.ERROR { background: #450a0a; color: #fca5a5; }
.term-tag.OK { background: #052e16; color: #86efac; }
.term-ok { color: #10b981; }
.term-err { color: #ef4444; }

/* ====== Patch Monitor Admin UI ====== */
.section-title {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--fg, var(--text));
}
.section-divider {
  border: 0;
  border-top: 1px dashed var(--border, #cbd5e1);
  margin: 24px 0;
}
.admin-patch-monitor { scroll-margin-top: 80px; }
.monitor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
}
@media (max-width: 720px) {
  .monitor-grid { grid-template-columns: 1fr; }
}
.monitor-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius, 14px);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.monitor-card.full { grid-column: 1 / -1; }
.monitor-card-head {
  padding: 10px 14px;
  background: var(--topbar-bg, linear-gradient(135deg,#1e293b,#334155));
  color: var(--topbar-fg, #f8fafc);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.2px;
}
.monitor-card-body { padding: 14px; font-size: 13.5px; line-height: 1.55; }
.pm-row { margin: 4px 0; display: flex; gap: 8px; flex-wrap: wrap; }
.pm-label { font-weight: 600; color: var(--muted, #64748b); min-width: 120px; }
.pm-subhead { margin: 12px 0 4px; font-weight: 700; color: var(--fg); font-size: 13px; }
.pm-pg-row { margin: 3px 0; padding: 3px 8px; background: var(--card-alt, #f8fafc); border-radius: 6px; border: 1px solid var(--border); font-size: 12.5px; }
.pm-err { color: var(--danger, #dc2626); font-weight: 600; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0.3px; }
.badge-ok { background: rgba(22,163,74,0.15); color: var(--success, #16a34a); border: 1px solid rgba(22,163,74,0.3); }
.badge-warn { background: rgba(217,119,6,0.15); color: var(--warning, #d97706); border: 1px solid rgba(217,119,6,0.3); }
.badge-err { background: rgba(220,38,38,0.15); color: var(--danger, #dc2626); border: 1px solid rgba(220,38,38,0.3); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-xs { padding: 3px 10px; font-size: 11.5px; }
.pm-toast {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  font-weight: 600;
  font-size: 13px;
  animation: pmFade 0.25s ease-out;
}
@keyframes pmFade { from { opacity: 0; transform: translateY(-4px);} to { opacity:1; transform: translateY(0);} }
.pm-toast-info { background: rgba(79,70,229,0.1); color: var(--primary, #4f46e5); border-color: rgba(79,70,229,0.3); }
.pm-toast-ok { background: rgba(22,163,74,0.1); color: var(--success, #16a34a); border-color: rgba(22,163,74,0.3); }
.pm-toast-err { background: rgba(220,38,38,0.1); color: var(--danger, #dc2626); border-color: rgba(220,38,38,0.3); }
.pm-history-box {
  max-height: 240px;
  overflow-y: auto;
  padding: 10px 12px;
  background: var(--term-bg, #0b1020);
  color: var(--term-fg, #e2e8f0);
  border: 1px solid var(--term-border, #1e293b);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
}
.pm-hist-line { padding: 1px 0; border-bottom: 1px dashed rgba(255,255,255,0.05); }
.pm-hist-line:last-child { border-bottom: none; }
.pm-hist-t { color: var(--term-time, #a78bfa); margin-right: 8px; }
.pm-hist-g { color: var(--term-container, #f472b6); margin-right: 6px; }
.pm-hist-info { color: var(--term-info, #38bdf8); }
.pm-hist-ok { color: var(--term-ok, #4ade80); }
.pm-hist-warn { color: var(--term-warn, #fbbf24); }
.pm-hist-error, .pm-hist-err { color: var(--term-err, #f87171); }
[data-theme="dark"] .monitor-card { background: var(--card-bg, #1e293b); }
[data-theme="dark"] .pm-pg-row { background: rgba(30,41,59,0.6); }
[data-theme="dark"] .section-divider { border-top-color: rgba(148,163,184,0.25); }

/* ========== Mods Management UI (Project Zomboid Build42) ========== */
.modal-lg .modal-dialog {
  max-width: min(1380px, calc(100vw - 40px));
  max-height: min(920px, calc(100vh - 40px));
}
.mods-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px 14px;
  min-height: 0;
}
.mods-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.mods-categories {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1 1 auto;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--card-alt, #f8fafc);
  color: var(--muted, #64748b);
  cursor: pointer;
  user-select: none;
  transition: all .15s ease-out;
}
.chip:hover { filter: brightness(0.96); }
.chip-sm { padding: 2px 9px; font-size: 11.5px; cursor: default; }
.chip-active {
  background: linear-gradient(135deg, #4f46e5, #8b5cf6);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(79,70,229,0.28);
}
.chip-qol      { background: rgba(14,165,233,0.14);  color: #0ea5e9; border-color: rgba(14,165,233,0.35); }
.chip-server   { background: rgba(22,163,74,0.14);   color: #16a34a; border-color: rgba(22,163,74,0.35); }
.chip-char     { background: rgba(236,72,153,0.14);  color: #ec4899; border-color: rgba(236,72,153,0.35); }
.chip-veh      { background: rgba(249,115,22,0.14);  color: #f97316; border-color: rgba(249,115,22,0.35); }
.chip-atmo     { background: rgba(168,85,247,0.14);  color: #a855f7; border-color: rgba(168,85,247,0.35); }
.chip-game     { background: rgba(220,38,38,0.14);   color: #dc2626; border-color: rgba(220,38,38,0.35); }
.chip-weap     { background: rgba(120,53,15,0.16);   color: #b45309; border-color: rgba(180,83,9,0.45); }
.chip-food     { background: rgba(5,150,105,0.14);   color: #059669; border-color: rgba(5,150,105,0.35); }
.chip-map      { background: rgba(100,116,139,0.18); color: #475569; border-color: rgba(71,85,105,0.4); }
.chip-base     { background: rgba(100,116,139,0.18); color: #0f766e; border-color: rgba(15,118,110,0.4); }
.chip-imm      { background: rgba(67,56,202,0.14);   color: #4338ca; border-color: rgba(67,56,202,0.35); }
.chip-admin    { background: rgba(245,158,11,0.16);  color: #d97706; border-color: rgba(217,119,6,0.4); }
.chip-fw       { background: rgba(55,65,81,0.18);    color: #374151; border-color: rgba(55,65,81,0.45); }
.chip-custom   { background: rgba(190,24,93,0.14);   color: #be185d; border-color: rgba(190,24,93,0.35); }

.mods-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
  padding: 4px 0;
}
.mods-count { font-size: 13px; }
.mods-count b { color: var(--primary, #4f46e5); font-size: 15px; }
.mods-dept-hint {
  padding: 2px 10px;
  border-radius: 6px;
  background: rgba(16,185,129,0.1);
  color: #059669;
  border: 1px solid rgba(16,185,129,0.25);
}
.mods-search { flex: 0 0 auto; }
.mods-search .form-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13.5px;
  border-radius: 10px;
}
.mods-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg, #fff);
}
[data-theme="dark"] .mods-table-wrap { background: var(--card-bg, #1e293b); }
.mods-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.mods-table thead { position: sticky; top: 0; z-index: 2; }
.mods-table thead th {
  background: linear-gradient(135deg, #1e293b, #334155);
  color: #e2e8f0;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.2px;
  border-bottom: 1px solid #0f172a;
  white-space: nowrap;
}
.mods-table thead th:first-child { border-top-left-radius: 12px; text-align: center; }
.mods-table thead th:last-child  { border-top-right-radius: 12px; }
.mods-table tbody tr {
  transition: background-color .12s ease;
  border-bottom: 1px solid var(--border);
}
.mods-table tbody tr:last-child { border-bottom: none; }
.mods-table tbody tr:nth-child(even) { background: var(--card-alt, #f8fafc); }
[data-theme="dark"] .mods-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.mods-table tbody tr:hover { background: rgba(79,70,229,0.06); }
.mods-table tbody tr.mod-enabled {
  background: rgba(16,185,129,0.06) !important;
  box-shadow: inset 3px 0 0 #10b981;
}
.mods-table td {
  padding: 9px 12px;
  vertical-align: top;
}
.mods-table td:first-child { text-align: center; vertical-align: middle; }
.mods-table .mod-chk {
  width: 18px; height: 18px;
  cursor: pointer;
  accent-color: var(--primary, #4f46e5);
}
#mods-toggle-all {
  width: 16px; height: 16px;
  cursor: pointer;
  accent-color: #e2e8f0;
}
.mod-name-cell { min-width: 220px; }
.mod-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.mod-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 2px;
  line-height: 1.5;
}
.mod-tags { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.mod-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.15px;
}
.mod-tag-dep    { background: rgba(16,185,129,0.15); color: #059669; }
.mod-tag-cust   { background: rgba(190,24,93,0.15); color: #be185d; }
.mod-tag-client { background: rgba(79,70,229,0.15); color: #4338ca; }
.mod-tag-server { background: rgba(22,163,74,0.15); color: #15803d; }
.mod-tag-warn   { background: rgba(220,38,38,0.12); color: #b91c1c; }

.mod-desc {
  line-height: 1.55;
  max-width: 300px;
  word-wrap: break-word;
}
.mod-ids { line-height: 1.7; }
.mod-ids code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #0f172a;
  color: #38bdf8;
  border: 1px solid #1e293b;
}
[data-theme="light"] .mod-ids code {
  background: #f1f5f9;
  color: #0369a1;
  border-color: #cbd5e1;
}
.mod-order {
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.mods-loading {
  padding: 24px 14px;
  text-align: center;
  font-size: 13.5px;
}
.mods-inline-err {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  background: rgba(220,38,38,0.08);
  border: 1px solid rgba(220,38,38,0.3);
  font-size: 13px;
}
.text-err { color: var(--danger, #dc2626); }

.mods-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2.5px solid rgba(79,70,229,0.2);
  border-top-color: #4f46e5;
  animation: modsSpin .7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes modsSpin { to { transform: rotate(360deg); } }

.mods-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 2px 2px;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}
.mods-footer-hint {
  flex: 1 1 300px;
  line-height: 1.55;
  max-width: 640px;
}
.mods-footer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 760px) {
  .mods-toolbar { flex-direction: column; align-items: stretch; }
  .mods-table thead th:nth-child(5),
  .mods-table tbody td:nth-child(5),
  .mods-table thead th:nth-child(6),
  .mods-table tbody td:nth-child(6) { display: none; }
  .mods-footer { flex-direction: column; align-items: stretch; }
  .mods-footer-actions { justify-content: flex-end; }
}
