@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg: #0b0b12;
  --bg-alt: #12121b;
  --surface: #141421;
  --surface-2: #181827;
  --accent: #6000c7;
  --accent-dark: #43008f;
  --text: #f2eefb;
  --muted: #a3a1ba;
  --stroke: #26263d;
  --chip-red: #d45a7b;
  --chip-blue: #5f7dff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  background: linear-gradient(180deg, #0b0b12 0%, #0d0d16 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-orb {
  display: none;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  display: grid;
  gap: 16px;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 20px 16px 28px;
  letter-spacing: 0.03em;
  display: grid;
  gap: 6px;
  justify-items: center;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.footer-link:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.hero {
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: 20px;
  background: linear-gradient(135deg, #1b1626 0%, #12121b 100%);
  border: 1px solid var(--stroke);
  animation: rise 0.6s ease;
  position: relative;
  overflow: hidden;
}

.info-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: rgba(18, 18, 27, 0.85);
  border: 1px solid var(--stroke);
}

.info-button svg {
  width: 16px;
  height: 16px;
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='140' viewBox='0 0 220 140'%3E%3Ctext x='18' y='46' fill='%236000c7' fill-opacity='0.22' font-size='30'%3E%E2%99%A0%3C/text%3E%3Ctext x='98' y='88' fill='%238a2be2' fill-opacity='0.18' font-size='28'%3E%E2%99%A5%3C/text%3E%3Ctext x='158' y='48' fill='%23c070ff' fill-opacity='0.16' font-size='26'%3E%E2%99%A6%3C/text%3E%3Ctext x='36' y='118' fill='%236000c7' fill-opacity='0.14' font-size='24'%3E%E2%99%A3%3C/text%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 220px 140px;
  opacity: 0.3;
  pointer-events: none;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 10px;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 40px);
}

.sub {
  margin: 0;
  color: var(--muted);
  max-width: 420px;
}

.subtle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.club-switch {
  display: grid;
  gap: 8px;
  min-width: 200px;
}

label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
}

select,
input {
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  min-height: 40px;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%23a3a1ba' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 12px;
  padding-right: 36px;
}

select:focus,
input:focus,
button:focus {
  outline: 2px solid rgba(96, 0, 199, 0.45);
  outline-offset: 1px;
}

input[type='date'] {
  color-scheme: dark;
}

input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 4px 4px 8px;
  scroll-padding: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tab-icon {
  display: inline-flex;
}

.tab-icon svg {
  width: 16px;
  height: 16px;
}

.tab.active {
  background: var(--accent);
  color: #f9f5ff;
  border-color: transparent;
}

.tab:focus-visible {
  outline: 2px solid rgba(96, 0, 199, 0.5);
  outline-offset: 2px;
}

.panel {
  background: var(--surface);
  border-radius: 20px;
  padding: 18px;
  border: 1px solid var(--stroke);
  animation: rise 0.5s ease;
  position: relative;
  overflow: hidden;
}

.panel.hidden {
  display: none;
}

.hidden {
  display: none;
}

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

.report-header {
  align-items: flex-start;
}

.panel-footer {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-divider {
  height: 1px;
  background: var(--stroke);
  margin: 16px 0;
}

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

.field {
  display: grid;
  gap: 6px;
  flex: 1 1 160px;
  min-width: 0;
}

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button-row button {
  flex: 1 1 160px;
}

.filters {
  display: grid;
  gap: 10px;
  width: 100%;
}

.filters select,
.filters input {
  width: 100%;
}

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

.stats-filters button {
  grid-column: 1 / -1;
}

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

.history-filters button {
  grid-column: 1 / -1;
}

.history-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.report-controls {
  display: grid;
  gap: 10px;
  width: 100%;
}

.report-controls .field {
  flex: initial;
}

.report-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.summary-card {
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
}

.summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.summary-value {
  font-size: 18px;
  font-weight: 600;
}

.primary,
.ghost {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  min-height: 40px;
  transition: transform 0.2s ease, background 0.2s ease;
}

.primary {
  background: var(--accent);
  color: #f9f5ff;
}

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

.ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--stroke);
}

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

.icon-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: var(--surface-2);
  color: var(--text);
  padding: 0;
  flex: 0 0 auto;
}

.icon-button svg {
  width: 14px;
  height: 14px;
}

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

.table-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--surface-2);
}

.report-row {
  grid-template-columns: 1fr;
}

.report-row select,
.report-row input {
  width: 100%;
}

.table-row .icon-button {
  justify-self: end;
}

.table-row.stats {
  grid-template-columns: 1fr;
}

.table-row.header {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: transparent;
  border: none;
  padding: 0;
  display: none;
}

.cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

.cell::before {
  content: attr(data-label);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.list-item {
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 12px;
  border: 1px solid var(--stroke);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-item.rule {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.list-item.rule .icon-button {
  justify-self: end;
}

.list-item.request {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.history-item {
  display: grid;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--surface-2);
}

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

.history-meta {
  display: grid;
  gap: 4px;
}

.history-date {
  font-weight: 600;
}

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

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

.history-lines {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
  font-size: 14px;
}

.history-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
}

.history-line span:first-child {
  font-weight: 500;
}

.history-line-values {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.score {
  min-width: 64px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--surface);
}

.score.plus {
  color: #61f2a2;
  border-color: rgba(97, 242, 162, 0.4);
  background: rgba(97, 242, 162, 0.12);
}

.score.minus {
  color: #ff8d8d;
  border-color: rgba(255, 141, 141, 0.4);
  background: rgba(255, 141, 141, 0.12);
}

.score.zero {
  color: var(--muted);
}

.points-badge {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--stroke);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.history-footer {
  display: flex;
  justify-content: flex-end;
  font-size: 12px;
  color: var(--muted);
}


.request-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}

.request-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.request-actions select {
  flex: 1 1 140px;
}

.list-item.stack {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.list-meta {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
  font-size: 14px;
}

.line-items {
  display: grid;
  gap: 6px;
  width: 100%;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(96, 0, 199, 0.18);
  border: 1px solid rgba(96, 0, 199, 0.4);
  font-size: 12px;
}

.stats-kpis {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 6px 0 16px;
}

.kpi-card {
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.kpi-value {
  font-size: 20px;
  font-weight: 600;
}

.stats-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
  grid-template-columns: 1fr;
}

.info-grid {
  display: grid;
  gap: 12px;
}

.info-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.info-list strong {
  color: var(--text);
}

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

.chart {
  display: grid;
  place-items: center;
  min-height: 200px;
  gap: 12px;
}

.chart svg {
  max-width: 260px;
  width: 100%;
  height: auto;
}

.chart-legend {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.stats-table {
  margin-top: 8px;
}

.top-podium {
  display: grid;
  gap: 10px;
}

.top-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
}

.top-item.top-1 {
  background: linear-gradient(135deg, rgba(246, 197, 111, 0.18), rgba(24, 24, 39, 0.9));
  border-color: rgba(246, 197, 111, 0.35);
}

.top-item.top-2 {
  background: linear-gradient(135deg, rgba(199, 209, 223, 0.16), rgba(24, 24, 39, 0.9));
  border-color: rgba(199, 209, 223, 0.3);
}

.top-item.top-3 {
  background: linear-gradient(135deg, rgba(210, 138, 92, 0.18), rgba(24, 24, 39, 0.9));
  border-color: rgba(210, 138, 92, 0.32);
}

.top-rank {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.rank-number {
  font-size: 13px;
  color: var(--muted);
}

.top-info {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.top-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
}

.top-secondary {
  color: var(--muted);
  flex-basis: 100%;
}

.top-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 64px;
}

.crown {
  width: 18px;
  height: 18px;
  display: inline-flex;
  color: #f6c56f;
}

.crown svg {
  width: 100%;
  height: 100%;
}

.crown-gold {
  color: #f6c56f;
}

.crown-silver {
  color: #c7d1df;
}

.crown-bronze {
  color: #d28a5c;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.rank-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--surface-2);
}

.rank-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

.rank-pill {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(96, 0, 199, 0.4);
  background: rgba(96, 0, 199, 0.16);
  font-size: 12px;
  font-weight: 600;
  color: #cbb5ff;
}

.rank-name {
  flex: 1;
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.rank-metric {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.rank-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat-chip {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--stroke);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat-chip.plus {
  color: #61f2a2;
  border-color: rgba(97, 242, 162, 0.4);
  background: rgba(97, 242, 162, 0.12);
}

.stat-chip.minus {
  color: #ff8d8d;
  border-color: rgba(255, 141, 141, 0.4);
  background: rgba(255, 141, 141, 0.12);
}

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

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

.card {
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--stroke);
}

#section-admin .inline input,
#section-admin .inline select {
  flex: 1 1 160px;
  min-width: 0;
}

#section-admin .inline button {
  flex: 1 1 120px;
}

#section-admin .list-item {
  flex-wrap: wrap;
  gap: 8px;
}

#section-admin .list-item input {
  flex: 1 1 110px;
  min-width: 0;
}

.user-card {
  display: grid;
  gap: 10px;
  align-items: stretch;
}

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

.user-card-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-name {
  font-weight: 600;
}

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

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

.user-role {
  min-width: 140px;
}

.user-card-footer {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--stroke);
  padding-top: 6px;
}

.icon-button.danger {
  border-color: rgba(255, 141, 141, 0.4);
  color: #ff8d8d;
  background: rgba(255, 141, 141, 0.12);
}

#masterControls {
  margin-bottom: 16px;
}

#section-admin .panel-header {
  margin-bottom: 16px;
}

#section-admin .inline {
  gap: 12px;
  margin-bottom: 12px;
  align-items: flex-end;
}

#section-admin .grid {
  gap: 12px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 720px) {
  .shell {
    padding: 28px 20px 56px;
    gap: 20px;
  }

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

  .stats-filters {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
  }

  .stats-filters button {
    grid-column: auto;
  }

  .history-filters {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

  .history-filters button {
    grid-column: auto;
  }

  .report-controls {
    grid-template-columns: auto auto;
    justify-content: end;
    align-items: end;
  }

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

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

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

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

  .history-meta {
    grid-auto-flow: column;
    align-items: center;
    gap: 12px;
  }

  .table-row {
    grid-template-columns: 1fr 140px 40px;
    background: transparent;
    border: none;
    padding: 0;
  }

  .table-row.stats {
    grid-template-columns: 0.6fr 1.6fr 1fr 0.8fr;
    padding: 0;
  }

  .table-row.header {
    display: grid;
  }

  .cell {
    flex-direction: row;
    gap: 8px;
  }

  .cell::before {
    content: none;
  }

  .list-item.rule {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  }
}

@media (min-width: 1024px) {
  .hero {
    grid-template-columns: 1.6fr 0.4fr;
  }

  .stats-filters {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
  }
}
