:root {
  color-scheme: light;
  --bg: #eceff2;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --panel-muted: #f3f5f7;
  --ink: #1c2529;
  --muted: #667079;
  --line: #dbe0e5;
  --accent: #006d5b;
  --accent-soft: rgba(0, 109, 91, 0.10);
  --warn: #b4471f;
  --warn-soft: rgba(180, 71, 31, 0.10);
  --ok: #2d7a35;
  --ok-soft: rgba(45, 122, 53, 0.10);
  --shadow: 0 1px 2px rgba(24, 34, 38, 0.06), 0 1px 3px rgba(24, 34, 38, 0.04);
  --radius: 10px;
  --radius-small: 6px;
  --mono: "SF Mono", "JetBrains Mono", "Consolas", monospace;
  --sans: "Avenir Next", "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

body.admin-protected-page:not(.admin-ready) .workspace-shell {
  display: none;
}

body.admin-protected-page.admin-ready #auth-splash {
  display: none;
}

.background-grid {
  display: none;
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(24, 34, 38, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 34, 38, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.1));
  pointer-events: none;
}

.login-shell,
.page-shell {
  position: relative;
  z-index: 1;
}

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

.auth-splash[hidden] {
  display: none;
}

.workspace-shell {
  position: relative;
  z-index: 1;
  width: min(1720px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 16px 0 32px;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 16px;
}

.panel,
.nav-shell,
.page-header {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.login-card {
  width: min(560px, 100%);
  display: grid;
  gap: 18px;
}

.eyebrow,
.section-tag,
.label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  color: var(--muted);
}

.page-title .eyebrow {
  display: none;
}

h2 {
  font-size: 1rem;
}

h3 {
  font-size: 0.92rem;
}

h1,
h2,
h3 {
  margin: 0;
}

.login-card h1 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.page-title h1 {
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.hero-copy,
.page-description,
.muted {
  margin: 0;
  line-height: 1.7;
  color: var(--muted);
}

.page-shell {
  display: grid;
  align-content: start;
  gap: 14px;
}

.page-header {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.page-title {
  display: grid;
  gap: 2px;
}

.page-description {
  font-size: 0.82rem;
}

.header-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.identity-card,
.info-card,
.secret-card,
.notice,
.log-item,
.timeline li,
.table-card,
.admin-card {
  border-radius: var(--radius-small);
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.identity-card,
.info-card,
.secret-card,
.notice {
  padding: 12px;
}

.nav-shell {
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 12px;
  position: sticky;
  top: 16px;
  height: fit-content;
}

.brand-block {
  display: grid;
  gap: 8px;
}

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

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-small);
  text-decoration: none;
  color: var(--ink);
  background: transparent;
  font-size: 0.9rem;
}

.nav-link:hover {
  background: var(--panel-muted);
}

.nav-link.active {
  background: var(--accent);
  color: #fff;
}

.nav-link span:last-child {
  font-size: 0.72rem;
  opacity: 0.7;
}

.nav-footer {
  display: grid;
  gap: 12px;
}

.operations-page .nav-link.active {
  background: var(--accent);
  color: #fff;
}

.operations-tabs-shell {
  display: grid;
  gap: 14px;
}

.operations-tabs-copy {
  max-width: 520px;
}

.operations-tab-list {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  flex-wrap: wrap;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.operations-tab-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(24, 34, 38, 0.03);
}

.operations-tab-status strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.operations-tab-list > .operations-tab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 14px;
  border-radius: 0;
  min-width: 0;
  border: 0;
  background: transparent;
  background-image: none;
  color: var(--muted);
  box-shadow: none;
  font-weight: 600;
  opacity: 1;
  transition: color 120ms ease, border-color 120ms ease;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.operations-tab-list > .operations-tab-button:hover,
.operations-tab-list > .operations-tab-button:active {
  color: var(--ink);
  background: transparent;
}

.operations-tab-list > .operations-tab-button.active,
.operations-tab-list > .operations-tab-button[aria-selected="true"],
.operations-tab-list > .operations-tab-button[aria-current="page"],
.operations-tab-list > .operations-tab-button[data-tab-active="true"] {
  background: transparent;
  border-bottom-color: var(--accent);
  color: var(--accent);
  box-shadow: none;
  opacity: 1;
  transform: none;
}

.operations-tab-list > .operations-tab-button.active:hover,
.operations-tab-list > .operations-tab-button[aria-selected="true"]:hover,
.operations-tab-list > .operations-tab-button[aria-current="page"]:hover,
.operations-tab-list > .operations-tab-button[data-tab-active="true"]:hover {
  background: transparent;
  color: var(--accent);
}

.operations-tab-panel[hidden] {
  display: none;
}

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

.operations-tab-grid .panel {
  background: var(--panel-muted);
  box-shadow: none;
}

.operations-page-footer {
  display: grid;
  gap: 8px;
}

.operations-update-meta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.operations-update-meta time {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--ink);
}

.operations-update-copy {
  margin-top: 2px;
}

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

.panel-span-12 {
  grid-column: span 12;
}

.panel-span-8 {
  grid-column: span 8;
}

.panel-span-7 {
  grid-column: span 7;
}

.panel-span-6 {
  grid-column: span 6;
}

.panel-span-5 {
  grid-column: span 5;
}

.panel-span-4 {
  grid-column: span 4;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.stack-form,
.panel-body,
.page-block,
.history-grid {
  display: grid;
  gap: 12px;
}

.plain-list,
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.plain-list li {
  line-height: 1.6;
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

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

input,
textarea,
select {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-small);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

textarea {
  resize: vertical;
}

button {
  border: 0;
  border-radius: var(--radius-small);
  padding: 7px 14px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: opacity 120ms ease, background 120ms ease;
}

button:hover {
  opacity: 0.9;
}

button.secondary {
  background: var(--panel-muted);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

button.danger {
  background: var(--warn);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.form-actions,
.inline-form,
.badge-row,
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.inline-form input,
.inline-form select {
  min-width: 130px;
}

.switch-grid,
.triple-grid,
.double-grid,
.stats-grid,
.history-grid,
.cards-grid {
  display: grid;
  gap: 12px;
}

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

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

.switch-item,
.stat-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-small);
  background: var(--panel-muted);
  color: var(--ink);
}

.stat-card {
  display: grid;
  align-items: start;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
}

.stat-card strong {
  font-size: 1.25rem;
}

.switch-item input {
  width: auto;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

tbody tr:hover {
  background: var(--panel-muted);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}

.history-meta,
.player-meta,
.permission-pill,
.session-meta,
.log-meta,
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge,
.history-meta span,
.player-meta span,
.permission-pill span,
.session-meta span,
.log-meta span {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-muted);
  font-size: 0.76rem;
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.danger {
  background: rgba(196, 57, 57, 0.12);
  color: #b42318;
}

.badge.accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.timeline li,
.log-item,
.admin-card {
  padding: 14px 16px;
}

.message,
pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}

pre {
  padding: 12px;
  background: rgba(24, 34, 38, 0.06);
  border-radius: 12px;
  font-family: var(--mono);
  font-size: 0.86rem;
}

.notice {
  color: var(--ink);
}

.notice.danger {
  background: var(--warn-soft);
  color: var(--warn);
}

.notice.info {
  background: rgba(24, 34, 38, 0.06);
}

.notice.success,
.toast.success {
  background: var(--ok-soft);
  color: var(--ok);
}

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

.secret-card code,
.mono {
  font-family: var(--mono);
  word-break: break-all;
}

.toast {
  position: sticky;
  top: 12px;
  z-index: 20;
  padding: 14px 16px;
  border-radius: var(--radius-small);
  border: 1px solid var(--line);
  background: var(--warn-soft);
  color: var(--warn);
  box-shadow: var(--shadow);
}

.toast.info {
  background: rgba(24, 34, 38, 0.08);
  color: var(--ink);
}

.toast.danger {
  background: var(--warn-soft);
  color: var(--warn);
}

.leaderboard-row-highlight td {
  background: var(--accent-soft);
}

.admin-card {
  display: grid;
  gap: 12px;
}

.admin-card.active {
  border-color: rgba(0, 109, 91, 0.35);
  box-shadow: inset 0 0 0 1px rgba(0, 109, 91, 0.18);
}

.status-stack {
  display: grid;
  gap: 8px;
}

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

.analytics-meta-row {
  margin-top: 16px;
}

.chart-list {
  display: grid;
  gap: 14px;
}

.chart-list-scroll {
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.chart-row {
  display: grid;
  gap: 8px;
}

.chart-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.chart-row-head span {
  color: var(--muted);
  font-size: 0.88rem;
}

.chart-track {
  position: relative;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(24, 34, 38, 0.08);
  overflow: hidden;
}

.chart-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(0, 109, 91, 0.38), rgba(0, 109, 91, 0.9));
}

.sparkline-shell,
.sparkline-points {
  display: grid;
  gap: 14px;
}

.sparkline-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.sparkline-svg {
  width: 100%;
  height: 220px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(0, 109, 91, 0.05), rgba(24, 34, 38, 0.02));
  border: 1px solid rgba(24, 34, 38, 0.08);
}

.sparkline-axis {
  stroke: rgba(24, 34, 38, 0.16);
  stroke-width: 1;
}

.sparkline-area {
  fill: rgba(0, 109, 91, 0.12);
}

.sparkline-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline-dot {
  fill: var(--accent);
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 2;
}

.sparkline-points {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sparkline-point-card {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(24, 34, 38, 0.05);
}

.activity-feed {
  display: grid;
  gap: 12px;
}

.activity-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(24, 34, 38, 0.04);
  border: 1px solid rgba(24, 34, 38, 0.08);
}

.activity-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: baseline;
}

.activity-card-body {
  display: grid;
  gap: 6px;
}

.activity-pill-row {
  align-items: flex-start;
}

.activity-card-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.activity-json {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(24, 34, 38, 0.05);
  color: var(--muted);
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.mobile-only {
  display: none;
}

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

  .panel-span-8,
  .panel-span-7,
  .panel-span-6,
  .panel-span-5,
  .panel-span-4 {
    grid-column: span 12;
  }

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

@media (max-width: 960px) {
  .workspace-shell {
    width: min(100vw, calc(100vw - 16px));
    grid-template-columns: 1fr;
    padding-top: 12px;
  }

  .nav-shell {
    position: static;
    gap: 12px;
  }

  .nav-links {
    grid-auto-flow: column;
    grid-auto-columns: minmax(150px, 1fr);
    overflow: auto;
    padding-bottom: 4px;
  }

  .page-header {
    flex-direction: column;
  }

  .switch-grid,
  .double-grid,
  .triple-grid,
  .stats-grid,
  .analytics-stats-grid,
  .cards-grid,
  .history-grid,
  .sparkline-points {
    grid-template-columns: 1fr;
  }

  .mobile-only {
    display: block;
  }

  .operations-tab-button {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .login-shell,
  .workspace-shell {
    padding-left: 8px;
    padding-right: 8px;
  }

  .operations-tab-list {
    display: flex;
    flex-wrap: wrap;
  }

  .inline-form,
  .form-actions,
  .header-actions,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  th,
  td {
    padding: 12px 8px;
  }
}