:root {
  --paper: #f2ede3;
  --panel: rgba(255, 251, 244, 0.78);
  --ink: #182126;
  --muted: #5a666f;
  --line: rgba(24, 33, 38, 0.14);
  --green: #1f8f68;
  --amber: #b46a1c;
  --rust: #b4432f;
  --shadow: 0 24px 60px rgba(24, 33, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(180, 106, 28, 0.12), transparent 35%),
    radial-gradient(circle at bottom right, rgba(31, 143, 104, 0.1), transparent 30%),
    linear-gradient(180deg, #f8f4ec 0%, var(--paper) 100%);
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
}

body[data-view="dashboard"] .login-panel {
  display: none !important;
}

body[data-view="login"] .dashboard {
  display: none !important;
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(24, 33, 38, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 33, 38, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at center, black, transparent 85%);
}

.app-shell {
  position: relative;
  padding: 32px;
}

.login-panel {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
}

.login-card,
.panel,
.metric-card {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(520px, 100%);
  padding: 32px;
  border-radius: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.75rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--amber);
}

h1,
h2,
.metric-value {
  font-family: "Syne", sans-serif;
  margin: 0;
}

h1 {
  font-size: clamp(2.4rem, 4vw, 4rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.35rem;
}

.muted {
  color: var(--muted);
  max-width: 48rem;
}

.login-form,
.controls {
  display: grid;
  gap: 14px;
}

.login-form {
  margin-top: 24px;
}

label,
.control span {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--ink);
  color: #f8f4ec;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.ghost-button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.error-text {
  margin-top: 16px;
  color: var(--rust);
  min-height: 1.25rem;
}

.dashboard {
  display: grid;
  gap: 24px;
  animation: fade-in 280ms ease;
}

.hero,
.panel-header,
.summary-strip,
.leaderboard-grid,
.metric-grid {
  display: grid;
  gap: 18px;
}

.hero {
  grid-template-columns: 1.4fr 0.8fr;
  align-items: end;
}

.controls {
  justify-self: end;
  width: min(320px, 100%);
}

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

.metric-card {
  padding: 20px;
  border-radius: 24px;
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: auto -30% -55% auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(180, 106, 28, 0.08);
}

.metric-label {
  margin: 0 0 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
}

.metric-value {
  font-size: clamp(1.6rem, 2vw, 2.5rem);
}

.metric-subtext {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.panel {
  border-radius: 28px;
  padding: 22px;
}

.panel-header {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.panel-header.compact {
  grid-template-columns: 1fr;
}

.range-switcher {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(24, 33, 38, 0.06);
}

.range-switcher button {
  background: transparent;
  color: var(--muted);
}

.range-switcher button.active {
  background: var(--ink);
  color: #f8f4ec;
}

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

.summary-item {
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
}

.summary-item strong {
  display: block;
  margin-top: 8px;
  font-family: "Syne", sans-serif;
  font-size: 1.3rem;
}

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

.chart-grid {
  gap: 18px;
}

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

.chart-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  margin-top: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.52);
}

.chart-card .chart-canvas {
  width: 100%;
  min-height: 240px;
}

.chart-card footer {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.75rem;
}

.table {
  display: grid;
  gap: 10px;
}

.table-row {
  display: grid;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.table-row:last-child {
  border-bottom: 0;
}

.table-row strong {
  word-break: break-word;
}

.table-row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.empty {
  color: var(--muted);
  padding: 8px 0;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .metric-grid,
  .summary-strip,
  .leaderboard-grid,
  .chart-grid,
  .hero {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 18px;
  }

  .metric-grid,
  .summary-strip,
  .leaderboard-grid,
  .chart-grid,
  .hero {
    grid-template-columns: 1fr;
  }

  .controls {
    justify-self: stretch;
  }
}
