:root {
  --bg: #f4f7f8;
  --panel: #ffffff;
  --ink: #172124;
  --muted: #66777c;
  --line: #dce5e8;
  --brand: #0f8b8d;
  --brand-dark: #0a6668;
  --accent: #f25f5c;
  --warn: #f4a261;
  --ok: #2a9d8f;
  --shadow: 0 16px 40px rgba(23, 33, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(120deg, rgba(15, 139, 141, 0.16), transparent 44%),
    linear-gradient(300deg, rgba(242, 95, 92, 0.13), transparent 42%),
    var(--bg);
}

.login-panel {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-copy {
  padding: 48px;
  background: #173438;
  color: #f8fbfb;
}

.login-copy h1 {
  margin: 0 0 18px;
  font-size: 34px;
  line-height: 1.18;
  letter-spacing: 0;
}

.login-copy p {
  margin: 0;
  color: #c4d6d8;
  line-height: 1.8;
}

.login-form {
  padding: 42px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 5px;
  margin-bottom: 24px;
  background: #eef4f5;
  border-radius: 8px;
}

.segmented button {
  height: 40px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.segmented .active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 3px 10px rgba(23, 33, 36, 0.08);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: 0;
}

.field input,
.field select {
  height: 42px;
}

.field textarea {
  min-height: 132px;
  padding-top: 10px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.12);
}

.primary,
.secondary,
.danger,
.ghost {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.primary {
  color: #fff;
  background: var(--brand);
}

.primary:hover {
  background: var(--brand-dark);
}

.secondary {
  color: var(--brand-dark);
  background: #e6f3f3;
}

.danger {
  color: #fff;
  background: var(--accent);
}

.ghost {
  color: var(--muted);
  background: transparent;
}

.login-form .primary {
  width: 100%;
  margin-top: 6px;
}

.error {
  min-height: 20px;
  color: var(--accent);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  padding: 22px 16px;
  color: #e9f2f3;
  background: #173438;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 22px;
  font-weight: 700;
  font-size: 18px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #c4d6d8;
  background: transparent;
  border-radius: 6px;
  text-align: left;
}

.nav .active,
.nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat,
.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(23, 33, 36, 0.04);
}

.stat {
  padding: 16px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.filters-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px 28px;
  margin-bottom: 16px;
}

.filters-panel label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--ink);
  white-space: nowrap;
}

.filters-panel select {
  min-width: 180px;
  height: 38px;
  padding: 0 12px;
  color: var(--ink);
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.chip {
  min-height: 32px;
  padding: 0 14px;
  color: var(--ink);
  background: #eef4f5;
  border-radius: 6px;
}

.chip.active {
  color: #165dff;
  background: #fff;
  box-shadow: 0 2px 8px rgba(23, 33, 36, 0.08);
}

.ad-stats {
  margin-bottom: 0;
}

.avatar {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  object-fit: cover;
}

.avatar-fallback {
  color: #fff;
  background: var(--brand);
  font-weight: 700;
}

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

.panel {
  padding: 16px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 14px;
}

th {
  color: var(--muted);
  background: #f7fafb;
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

.actions {
  display: flex;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  color: var(--brand-dark);
  background: #e6f3f3;
  border-radius: 999px;
  font-size: 12px;
}

.badge.warn {
  color: #8a5600;
  background: #fff0d8;
}

.badge.ok {
  color: #0e625a;
  background: #daf4ee;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 920px) {
  .login-panel,
  .app-shell,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .login-shell,
  .main {
    padding: 14px;
  }

  .login-copy,
  .login-form {
    padding: 24px;
  }

  .login-copy h1 {
    font-size: 26px;
  }

  .stats,
  .nav {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

.login-form .segmented,
.login-form [data-cookie-fields] {
  display: none !important;
}

form[onsubmit="syncDeveloperGames(event)"] select[name="loginMode"],
form[onsubmit="syncDeveloperGames(event)"] input[name="cookie"] {
  display: none !important;
}

form[onsubmit="syncDeveloperGames(event)"] label:has(select[name="loginMode"]),
form[onsubmit="syncDeveloperGames(event)"] label:has(input[name="cookie"]) {
  display: none !important;
}

form[onsubmit="addUser(event)"] input[name="cookie"],
form[onsubmit="addUser(event)"] label:has(input[name="cookie"]) {
  display: none !important;
}
