:root {
  --bg: #070b12;
  --bg2: #0d1420;
  --card: #121a28;
  --card2: #182232;
  --border: rgba(148, 163, 184, 0.12);
  --text: #eef2f7;
  --muted: #8b9cb3;
  --accent: #38bdf8;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --games: #22d3ee;
  --game-services: #2dd4bf;
  --sites: #a78bfa;
  --edge: #38bdf8;
  --databases: #4ade80;
  --monitoring: #f472b6;
  --system: #fb923c;
  --control: #fb923c;
  --radius: 16px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

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

body {
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(56, 189, 248, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(167, 139, 250, 0.08), transparent),
    linear-gradient(180deg, var(--bg2), var(--bg));
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.wrap:has(.home-view) {
  min-height: 100vh;
  max-width: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.main.home-view {
  width: 100%;
  max-width: 1080px;
}

.home-head {
  text-align: center;
  margin-bottom: 28px;
}

.home-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.home-sub {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.home-grid--hub {
  gap: 16px;
}

.home-grid--hub .section-card {
  min-height: 188px;
  padding: 22px 20px;
}

.home-grid.games-grid .game-card {
  min-height: 220px;
}

.home-grid.games-grid .section-card {
  min-height: 188px;
}

.wrap:has(.section-view) {
  min-height: 100vh;
  max-width: none;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 24px;
}

.main.section-view {
  width: 100%;
  max-width: 1080px;
}

.main.section-view.games-section {
  max-width: 1080px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
}

.home-grid--cols3,
.home-grid--hub {
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.home-grid--hub .card-logout {
  grid-column: auto;
}

@media (max-width: 900px) {
  .home-grid,
  .home-grid--cols3,
  .home-grid--hub { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .home-grid,
  .home-grid--cols3,
  .home-grid--hub { grid-template-columns: 1fr; max-width: 400px; margin: 0 auto; }
}

/* ── Game cards with background image ── */

.game-card {
  position: relative;
  display: block;
  min-height: 240px;
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  transition: transform 0.22s, box-shadow 0.22s, border-color 0.22s;
}

.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.accent-games.game-card:hover { border-color: rgba(34, 211, 238, 0.45); }

.game-card-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: transform 0.4s ease;
}

.game-card:hover .game-card-bg {
  transform: scale(1.06);
}

.game-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(7, 11, 18, 0.94) 0%,
    rgba(7, 11, 18, 0.45) 45%,
    rgba(7, 11, 18, 0.12) 100%
  );
  pointer-events: none;
}

.game-card-body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-card h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.9);
}

.game-card .section-arrow {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 2;
  color: rgba(255, 255, 255, 0.75);
  opacity: 1;
  font-size: 1.3rem;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}

.game-card .status-pill {
  flex-shrink: 0;
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: lowercase;
  backdrop-filter: blur(6px);
}

.wrap:has(.detail-view) {
  max-width: 720px;
  padding-top: 28px;
}

.main.detail-view .breadcrumb {
  margin-bottom: 24px;
}

/* ── Login ── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

h1 { font-size: 1.5rem; margin-bottom: 8px; }
.sub { color: var(--muted); font-size: 0.92rem; }

.err {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  display: none;
}
.err.show { display: block; }

.tg-box { min-height: 60px; display: flex; justify-content: center; margin: 20px 0; }

/* ── Header ── */

header.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.bar-brand { display: flex; flex-direction: column; gap: 4px; }

.logo {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s;
}
.logo:hover { color: var(--accent); }

.btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

/* ── Page intro ── */

.page-intro { margin-bottom: 20px; }

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.page-desc {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

/* ── Home section blocks ── */

@media (max-width: 600px) {
  .home-grid .section-card { min-height: 170px; }
}

.home-grid .section-card,
.home-grid--cols3 .section-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  padding: 28px 26px;
  min-height: 210px;
  border-radius: 18px;
}

.home-grid .section-card-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
}

.home-grid .section-card-icon svg {
  width: 28px;
  height: 28px;
}

.home-grid .section-card h2 {
  font-size: 1.3rem;
  margin-bottom: 6px;
}

.home-grid .section-card p {
  font-size: 0.9rem;
  line-height: 1.45;
  margin-bottom: 0;
  -webkit-line-clamp: 3;
  flex: 1;
}

.home-grid .section-card-foot {
  margin-top: auto;
  padding-top: 12px;
  width: 100%;
}

.home-grid .section-badge {
  font-size: 0.72rem;
  padding: 3px 9px;
}

.home-grid .section-stat {
  font-size: 0.82rem;
}

.home-grid .section-arrow {
  position: absolute;
  top: 28px;
  right: 24px;
  font-size: 1.4rem;
}

/* compact row layout for inner pages if needed later */
.section-card {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr 20px;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.section-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.accent-games:hover { border-color: rgba(34, 211, 238, 0.5); }
.accent-game-services:hover { border-color: rgba(45, 212, 191, 0.5); }
.accent-sites:hover { border-color: rgba(167, 139, 250, 0.5); }
.accent-edge:hover { border-color: rgba(56, 189, 248, 0.5); }
.accent-databases:hover { border-color: rgba(74, 222, 128, 0.5); }
.accent-monitoring:hover { border-color: rgba(244, 114, 182, 0.5); }
.accent-system:hover { border-color: rgba(251, 146, 60, 0.5); }
.accent-control:hover { border-color: rgba(251, 146, 60, 0.5); }

.section-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.accent-games .section-card-icon { color: var(--games); background: rgba(34, 211, 238, 0.1); }
.accent-game-services .section-card-icon { color: var(--game-services); background: rgba(45, 212, 191, 0.1); }
.accent-sites .section-card-icon { color: var(--sites); background: rgba(167, 139, 250, 0.1); }
.accent-edge .section-card-icon { color: var(--edge); background: rgba(56, 189, 248, 0.1); }
.accent-databases .section-card-icon { color: var(--databases); background: rgba(74, 222, 128, 0.1); }
.accent-monitoring .section-card-icon { color: var(--monitoring); background: rgba(244, 114, 182, 0.1); }
.accent-system .section-card-icon { color: var(--system); background: rgba(251, 146, 60, 0.1); }
.accent-control .section-card-icon { color: var(--control); background: rgba(251, 146, 60, 0.1); }

.section-card-icon svg,
.ico {
  width: 22px;
  height: 22px;
  display: block;
  flex-shrink: 0;
}

.section-card-body { min-width: 0; }

.section-card h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 3px;
  line-height: 1.3;
}

.section-card p {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.section-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.section-badge {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 7px;
  border-radius: 6px;
}

.section-stat {
  font-size: 0.75rem;
  font-weight: 600;
}

.sec-active .section-stat { color: var(--ok); }
.sec-partial .section-stat { color: var(--warn); }
.sec-inactive .section-stat { color: var(--bad); }
.sec-empty .section-stat { color: var(--muted); }

.section-arrow {
  font-size: 1.25rem;
  line-height: 1;
  color: var(--muted);
  opacity: 0.45;
  transition: transform 0.2s, opacity 0.2s;
}

.section-card:hover .section-arrow {
  transform: translateX(2px);
  opacity: 0.9;
}

/* logout card — same shell, muted accent */
.card-logout {
  font: inherit;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.accent-logout .section-card-icon {
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
}

.accent-logout:hover {
  border-color: rgba(148, 163, 184, 0.35);
}

.accent-logout .section-card-body p {
  margin-bottom: 0;
}

.section-card.retire {
  opacity: 0.55;
}

.section-badge.status-pill {
  text-transform: lowercase;
  letter-spacing: 0;
  font-size: 0.72rem;
  padding: 4px 11px;
  border-radius: 999px;
}

.grid-legacy {
  margin-top: 0;
}

/* ── Module detail page ── */

.module-detail {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.module-detail-head {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.module-detail-head .section-card-icon {
  width: 56px;
  height: 56px;
}

.module-detail-head .section-card-icon svg {
  width: 28px;
  height: 28px;
}

.accent-games.module-detail-head .section-card-icon { color: var(--games); background: rgba(34, 211, 238, 0.1); }
.accent-game-services.module-detail-head .section-card-icon { color: var(--game-services); background: rgba(45, 212, 191, 0.1); }
.accent-sites.module-detail-head .section-card-icon { color: var(--sites); background: rgba(167, 139, 250, 0.1); }
.accent-edge.module-detail-head .section-card-icon { color: var(--edge); background: rgba(56, 189, 248, 0.1); }
.accent-databases.module-detail-head .section-card-icon { color: var(--databases); background: rgba(74, 222, 128, 0.1); }
.accent-monitoring.module-detail-head .section-card-icon { color: var(--monitoring); background: rgba(244, 114, 182, 0.1); }
.accent-system.module-detail-head .section-card-icon { color: var(--system); background: rgba(251, 146, 60, 0.1); }
.accent-control.module-detail-head .section-card-icon { color: var(--control); background: rgba(251, 146, 60, 0.1); }

.module-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.module-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.module-note {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 0 4px;
}

.module-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(56, 189, 248, 0.06);
  transition: background 0.15s, border-color 0.15s;
}

.detail-link:hover {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.35);
}

.module-panel {
  padding: 22px 24px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--card);
}

.panel-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 16px;
}

.module-panel .actions {
  margin-top: 0;
  gap: 10px;
}

.module-panel .btn-act {
  font-size: 0.85rem;
  padding: 10px 18px;
}

.section-page-head {
  margin-bottom: 22px;
  padding: 4px 2px 0;
}

.section-page-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.section-page-desc {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* ── Section detail view ── */

.breadcrumb {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 6px 0;
  transition: color 0.2s;
}

.back-link .ico { width: 18px; height: 18px; }
.back-link:hover { color: var(--accent); }

.link-logout {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 6px 0;
}

.link-logout:hover { color: var(--bad); }

.section-header {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 22px 24px;
  margin-bottom: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--card2), var(--card));
}

.section-header-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
}

.accent-games .section-header-icon { color: var(--games); }
.accent-game-services .section-header-icon { color: var(--game-services); }
.accent-sites .section-header-icon { color: var(--sites); }
.accent-edge .section-header-icon { color: var(--edge); }
.accent-databases .section-header-icon { color: var(--databases); }
.accent-monitoring .section-header-icon { color: var(--monitoring); }
.accent-system .section-header-icon { color: var(--system); }
.accent-control .section-header-icon { color: var(--control); }

.section-summary {
  margin-top: 8px;
  font-size: 0.82rem;
  font-weight: 600;
}

.section-summary.sec-active { color: var(--ok); }
.section-summary.sec-partial { color: var(--warn); }
.section-summary.sec-inactive { color: var(--bad); }

.legacy-title {
  margin: 28px 0 12px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.empty-note {
  color: var(--muted);
  padding: 32px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ── Module cards ── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.mod {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  transition: border-color 0.2s;
}

.mod:hover { border-color: rgba(56, 189, 248, 0.25); }
.mod.retire { opacity: 0.55; }

.mod-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 4px;
}

.mod h3 {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
}

.mod .st {
  flex-shrink: 0;
  font-size: 0.7rem;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: lowercase;
}

/* статусы: зелёный = онлайн, красный = ошибка, жёлтый = рестарт/переходные */
.st-active, .st-running, .st-ok, .st-OL, .st-online {
  background: rgba(52, 211, 153, 0.22);
  color: #34d399;
}

.st-error {
  background: rgba(248, 113, 113, 0.22);
  color: #f87171;
}

.st-planned, .st-tech, .st-starting, .st-partial {
  background: rgba(251, 191, 36, 0.22);
  color: #fbbf24;
}

.st-starting {
  animation: pulse-st 1.8s ease-in-out infinite;
}

.st-offline, .st-inactive, .st-exited, .st-failed, .st-unknown, .st-na {
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
}

@keyframes pulse-st {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.module-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.status-detail {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.note {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 8px;
  line-height: 1.45;
}

.note.links a {
  color: var(--accent);
  text-decoration: none;
  margin-right: 10px;
}
.note.links a:hover { text-decoration: underline; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.btn-act {
  font-size: 0.72rem;
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(56, 189, 248, 0.08);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-act:hover { background: rgba(56, 189, 248, 0.2); }
.btn-act.danger {
  color: var(--bad);
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}
.btn-act.danger:hover { background: rgba(248, 113, 113, 0.18); }

/* ── Toast ── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  opacity: 0;
  transform: translateY(10px);
  transition: 0.25s;
  pointer-events: none;
  z-index: 99;
  max-width: 360px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }
.toast.ok { border-color: rgba(52, 211, 153, 0.4); }
