:root {
  --bg-1: #060b16;
  --bg-2: #0a1222;
  --text: #e5e9ff;
  --muted: #97a1c7;
  --line: rgba(255, 255, 255, 0.1);
  --panel: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  --active: rgba(110, 95, 230, 0.22);
  --active-line: rgba(110, 95, 230, 0.55);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", "SF Pro Text", -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 8% 5%, rgba(103, 84, 240, 0.22), transparent 55%),
    radial-gradient(900px 500px at 78% 22%, rgba(20, 165, 190, 0.2), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 188px 1fr;
  gap: 12px;
  padding: 10px;
}

.sidebar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 6px 12px;
  border-bottom: 1px solid var(--line);
}

.logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(135deg, #5b6ee7, #3ec6f4);
}

.title strong {
  display: block;
  font-size: 14px;
}

.title span {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav button {
  all: unset;
  cursor: pointer;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
}

.nav button.active {
  background: var(--active);
  border-color: var(--active-line);
  color: var(--text);
}

.nav button.nav-icon-only {
  justify-content: center;
  padding: 14px 0;
}

.nav button.nav-icon-only .icon {
  width: auto;
  font-size: 48px;
  line-height: 1;
}

.nav button.nav-bottom-game {
  margin-top: auto;
}

.icon {
  width: 19px;
  text-align: center;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.topbar,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.topbar {
  padding: 9px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.top-left {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pill {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 5px 9px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #20d36b;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  width: min(410px, 100%);
  background: rgba(0, 0, 0, 0.16);
}

.search input {
  all: unset;
  width: 100%;
  font-size: 13px;
}

.panel {
  padding: 12px;
  overflow: auto;
}

h1 {
  margin: 0 0 4px;
  font-size: 29px;
}

.subtitle {
  margin: 0 0 12px;
  color: var(--muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.14);
  padding: 10px;
}

.label {
  color: var(--muted);
  font-size: 12px;
}

.section-title {
  position: relative;
  color: #eef2ff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
  margin-bottom: 8px;
  text-shadow: 0 0 12px rgba(120, 160, 255, 0.28);
  padding-left: 12px;
}

.section-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  bottom: 3px;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.95), rgba(120, 140, 255, 0.95));
}

.value {
  margin-top: 5px;
  font-size: 24px;
  font-weight: 700;
}

.app-hidden {
  display: none;
}

.login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(6, 12, 28, 0.95), rgba(5, 10, 22, 0.95));
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  padding: 24px;
}

.login-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: linear-gradient(135deg, #5b6ee7, #3ec6f4);
  margin-bottom: 10px;
}

.login-card h1 {
  margin: 0;
  font-size: 28px;
}

.login-subtitle {
  margin: 6px 0 14px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 8px;
}

.login-form label {
  color: var(--muted);
  font-size: 12px;
}

.login-form input {
  width: 100%;
}

.login-error {
  min-height: 18px;
  color: #ff7b7b;
  font-size: 13px;
}

.tablewrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  min-width: 1400px;
  border-collapse: collapse;
}

table.table-compact {
  min-width: 0;
  width: 100%;
}

table.table-compact th,
table.table-compact td {
  white-space: normal;
  word-break: break-word;
}

thead th {
  text-align: left;
  font-size: 12px;
  color: #d4dbfb;
  position: sticky;
  top: 0;
  background: rgba(8, 13, 25, 0.96);
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
}

td {
  padding: 9px 8px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

tr.incident-row {
  cursor: pointer;
}

tr.incident-row:hover td {
  background: rgba(115, 95, 226, 0.1);
}

tr.run-row {
  cursor: pointer;
}

tr.run-row:hover td {
  background: rgba(34, 211, 238, 0.1);
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-block;
  padding: 2px 7px;
  font-size: 12px;
}

.chip.green {
  border-color: rgba(30, 195, 95, 0.6);
  background: rgba(30, 195, 95, 0.18);
}

.chip.cyan {
  border-color: rgba(34, 200, 223, 0.6);
  background: rgba(34, 200, 223, 0.18);
}

.chip.orange {
  border-color: rgba(240, 163, 48, 0.62);
  background: rgba(240, 163, 48, 0.2);
}

.chip.purple {
  border-color: rgba(144, 121, 247, 0.62);
  background: rgba(144, 121, 247, 0.2);
}

select,
input[type="number"] {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  padding: 6px 7px;
  min-width: 120px;
}

.btn {
  all: unset;
  cursor: pointer;
  font-size: 12px;
  border: 1px solid rgba(112, 89, 224, 0.8);
  background: rgba(112, 89, 224, 0.25);
  border-radius: 9px;
  padding: 5px 8px;
}

.btn.save-glow-once {
  position: relative;
  isolation: isolate;
}

.btn.save-glow-once::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 11px;
  padding: 2px;
  pointer-events: none;
  background: conic-gradient(
    from 0deg,
    rgba(16, 185, 129, 0) 0deg,
    rgba(16, 185, 129, 0) 280deg,
    rgba(16, 185, 129, 0.95) 330deg,
    rgba(16, 185, 129, 0) 360deg
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: saveSweepOnce 1s linear 1;
}

@keyframes saveSweepOnce {
  from {
    transform: rotate(0turn);
  }
  to {
    transform: rotate(1turn);
  }
}

.btn.success {
  border-color: rgba(17, 185, 129, 0.8);
  background: rgba(17, 185, 129, 0.22);
}

.build-control-wrap {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.dl-progress-wrap {
  position: relative;
  width: 98px;
  height: 28px;
  border-radius: 9px;
  border: 1px solid rgba(34, 211, 238, 0.55);
  background: rgba(7, 17, 32, 0.85);
  overflow: hidden;
}

.dl-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.85), rgba(34, 211, 238, 0.85));
  transition: width 0.25s ease;
}

.dl-progress-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #eaf2ff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
}

.status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  z-index: 80;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 81;
}

.modal-card {
  width: min(980px, 95vw);
  max-height: 92vh;
  overflow: auto;
  background: linear-gradient(180deg, rgba(12, 19, 35, 0.98), rgba(8, 15, 30, 0.98));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.jetski-wrap {
  display: grid;
  gap: 10px;
}

.jetski-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.jetski-hud {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.jetski-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.jetski-btn {
  all: unset;
  cursor: pointer;
  border: 1px solid rgba(34, 200, 223, 0.55);
  background: rgba(34, 200, 223, 0.18);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
}

.jetski-stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: radial-gradient(900px 320px at 50% -40%, rgba(0, 220, 255, 0.22), transparent 70%),
    linear-gradient(180deg, #031228, #020a1c);
}

.jetski-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

.jetski-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.38);
}

.jetski-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 15, 30, 0.9);
  padding: 14px;
  text-align: center;
  max-width: 420px;
}

.jetski-card h3 {
  margin: 0 0 6px;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.game-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.14);
  padding: 10px;
}

.game-thumb-wrap {
  position: relative;
  width: min(300px, 100%);
  aspect-ratio: 1 / 1;
  max-width: 100%;
  margin-inline: auto;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.game-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.game-thumb-fallback {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.game-card.is-inactive .game-thumb {
  filter: grayscale(1) brightness(0.74);
}

.game-card.is-inactive {
  opacity: 0.92;
}

.game-inactive-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(15, 18, 30, 0.78);
  color: #d1d6ee;
  font-size: 11px;
  padding: 3px 8px;
}

.game-meta {
  margin-top: 8px;
  display: grid;
  justify-items: center;
  gap: 8px;
}

.game-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2px;
  text-align: center;
}

.game-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.game-info-btn {
  all: unset;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(34, 211, 238, 0.5);
  background: rgba(34, 211, 238, 0.16);
  font-weight: 700;
}

.add-game-btn {
  all: unset;
  cursor: pointer;
  width: 100%;
  min-height: 120px;
  border: 1px dashed rgba(34, 211, 238, 0.5);
  border-radius: 12px;
  display: grid;
  place-items: center;
  gap: 6px;
  font-size: 19px;
  font-weight: 700;
  color: #dff6ff;
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.14), rgba(34, 211, 238, 0.06));
}

.add-game-plus {
  font-size: 42px;
  line-height: 1;
}

.game-info-modal {
  width: min(740px, 95vw);
}

.builds-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 10px;
  align-items: start;
}

.build-list-scroll {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
  padding: 8px;
}

.build-list-item {
  height: 34px;
  display: flex;
  align-items: center;
}

.add-table-config-btn {
  all: unset;
  width: 100%;
  min-height: 220px;
  border: 2px dashed rgba(34, 211, 238, 0.45);
  border-radius: 22px;
  display: grid;
  place-items: center;
  gap: 12px;
  cursor: pointer;
  color: #d8f4ff;
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.2), rgba(34, 211, 238, 0.09));
}

.add-table-config-btn:hover {
  border-color: rgba(34, 211, 238, 0.75);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.26), rgba(34, 211, 238, 0.12));
}

.add-table-config-plus {
  font-size: 74px;
  line-height: 1;
  font-weight: 700;
}

.payment-offers-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.payment-offer-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(189, 214, 235, 0.16);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.payment-offer-title {
  text-align: center;
  font-size: 26px;
  font-weight: 800;
}

.payment-offer-card .label {
  text-align: center;
}

.payment-offer-card input {
  text-align: center;
}

.tablecfg-games-scroll {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.14);
}

.hardware-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.run-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 4px;
  min-height: 210px;
}

.run-bar-wrap {
  min-width: 70px;
  display: grid;
  justify-items: center;
  gap: 5px;
}

.run-bar {
  width: 36px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.95), rgba(59, 130, 246, 0.9));
}

.run-bar-label {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  word-break: break-word;
}

.run-bar-value {
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 1420px) {
  .games-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .games-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1000px) {
  .builds-layout {
    grid-template-columns: 1fr;
  }
  .payment-offers-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .payment-offers-grid {
    grid-template-columns: 1fr;
  }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
}

.status-pill.active {
  border-color: rgba(34, 211, 238, 0.65);
  box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.65);
  animation: pulseGlow 1.4s ease-in-out infinite;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  display: inline-block;
}

.status-badge.ok {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.16);
}
.status-badge.ok .status-dot {
  background: #22c55e;
}

.status-badge.progress {
  border-color: rgba(34, 211, 238, 0.55);
  background: rgba(34, 211, 238, 0.16);
}
.status-badge.progress .status-dot {
  background: #22d3ee;
}

.status-badge.error {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.16);
}
.status-badge.error .status-dot {
  background: #ef4444;
}

.status-badge.neutral {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
}
.status-badge.neutral .status-dot {
  background: #b7c1ee;
}

.status-badge.is-active {
  animation: statusPulse 1.4s ease-in-out infinite;
}

.runend-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 122px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}

.runend-badge.runend-green {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.16);
}

.runend-badge.runend-orange {
  border-color: rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.18);
}

.runend-badge.runend-red {
  border-color: rgba(239, 68, 68, 0.62);
  background: rgba(239, 68, 68, 0.2);
}

.runend-badge.runend-gray {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
}

.runend-badge.is-pulse {
  animation: runEndPulse 2.2s ease-in-out infinite;
}

@keyframes statusPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.45);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(34, 211, 238, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 211, 238, 0);
  }
}

@keyframes pulseGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.55);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(34, 211, 238, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 211, 238, 0);
  }
}

@keyframes runEndPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }
  .cards {
    grid-template-columns: 1fr;
  }
}
