:root {
  color-scheme: dark;
  --bg: #0b2434;
  --topbar: #153348;
  --panel: #153348;
  --panel-2: #102c3f;
  --ink: #e7f4fb;
  --strong: #ffffff;
  --muted: #83abc1;
  --line: rgba(115, 220, 200, 0.16);
  --line-strong: rgba(115, 220, 200, 0.38);
  --mint: #73dcc8;
  --sky: #91bdff;
  --pink: #ff8fbe;
  --track: rgba(255, 255, 255, 0.08);
  --input: rgba(2, 20, 31, 0.34);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Roboto", "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 40px;
}

body.is-auth .header-actions {
  display: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--topbar) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.app-header::before {
  content: "";
  display: block;
  height: 10px;
  background: var(--mint);
  box-shadow: 0 0 10px rgba(115, 220, 200, 0.2);
}

.header-main {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto minmax(430px, 0.9fr);
  align-items: center;
  gap: 24px;
  padding: 14px clamp(16px, 4vw, 60px);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}

.eyebrow,
.field span,
th {
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--mint);
  font-size: 0.72rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--strong);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  color: var(--strong);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-actions,
.summary-grid,
.layout,
.table-tools {
  display: grid;
  gap: 12px;
}

.header-actions {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  width: min(430px, 100%);
}

.header-user {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 14px;
  min-width: 260px;
}

.header-user[hidden] {
  display: none;
}

.header-user div {
  display: grid;
  gap: 3px;
  text-align: right;
}

.header-user span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.header-user strong {
  color: var(--strong);
  font-size: 0.95rem;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  padding: 0 12px;
  text-decoration: none;
  white-space: nowrap;
}

.topbar-link:hover,
.topbar-link.is-active {
  border-color: var(--mint);
  background: rgba(115, 220, 200, 0.1);
  color: var(--strong);
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

select,
input,
.toggle-button {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--input);
  color: var(--ink);
  font: inherit;
  padding: 0 12px;
  outline: none;
}

select:focus,
input:focus,
.toggle-button:focus-visible {
  border-color: var(--mint);
  box-shadow: 0 0 0 3px rgba(115, 220, 200, 0.14);
}

.metric-toggle {
  display: grid;
  grid-template-columns: 1fr 0.72fr;
  gap: 8px;
}

.toggle-button {
  cursor: pointer;
  font-weight: 800;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.toggle-button:hover,
.toggle-button.is-active {
  border-color: var(--mint);
  background: rgba(115, 220, 200, 0.12);
  color: var(--strong);
}

.dashboard,
.auth-view {
  width: min(1820px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 86px) 0;
}

.auth-view {
  display: grid;
  min-height: calc(100vh - 130px);
  place-items: center;
}

.auth-view[hidden],
.dashboard[hidden] {
  display: none;
}

.auth-card {
  width: min(460px, 100%);
}

.auth-card h2 {
  margin-bottom: 8px;
  font-size: 24px;
  letter-spacing: 0;
  text-transform: none;
}

.auth-card p {
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
  width: 100%;
}

.auth-form input,
.auth-form button {
  width: 100%;
}

.auth-form label,
.invite-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-form button,
.invite-form button {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(115, 220, 200, 0.14);
  color: var(--strong);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  padding: 0 14px;
}

.auth-link {
  margin: 18px 0 0;
}

.auth-link a {
  color: var(--mint);
  font-weight: 900;
}

.profile-view {
  display: grid;
  gap: 22px;
}

.admin-view {
  display: grid;
  gap: 22px;
}

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

.profile-heading {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.profile-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.profile-avatar {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(115, 220, 200, 0.12);
  color: var(--strong);
  font-size: 20px;
  font-weight: 900;
}

.profile-form {
  display: grid;
  gap: 14px;
}

.profile-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.profile-form button {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(115, 220, 200, 0.14);
  color: var(--strong);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  padding: 0 14px;
}

.pagination-controls {
  display: flex;
  gap: 10px;
  justify-content: end;
}

.summary-grid {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 22px;
}

.account-panel {
  display: block;
  margin-bottom: 22px;
}

.account-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.8fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

#registerForm {
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto;
}

#statForm {
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.8fr) minmax(180px, 1fr) auto;
}

.account-form[hidden],
.clear-selection[hidden] {
  display: none;
}

.account-form button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(115, 220, 200, 0.12);
  color: var(--strong);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0 12px;
}

.account-form label {
  display: grid;
  gap: 6px;
}

.account-form label span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.account-form label em {
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.invite-panel {
  margin-bottom: 22px;
}

.invite-form {
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(140px, 180px) auto;
  gap: 12px;
  align-items: end;
}

.new-invite {
  display: grid;
  gap: 5px;
  margin-top: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(115, 220, 200, 0.08);
  padding: 14px;
}

.new-invite[hidden] {
  display: none;
}

.new-invite span,
.new-invite em,
.invite-row span,
.invite-row em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.new-invite strong,
.invite-row strong {
  color: var(--strong);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.invite-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.invite-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 10px;
}

.invite-row div {
  display: grid;
  gap: 4px;
}

.stat,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.stat {
  display: grid;
  min-height: 152px;
  padding: 22px 24px 18px;
  text-align: center;
}

.stat::after {
  content: "";
  align-self: start;
  height: 1px;
  margin: 16px -24px 0;
  background: rgba(255, 255, 255, 0.06);
  order: 3;
}

.stat-label {
  display: block;
  color: var(--mint);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  color: var(--strong);
  font-size: clamp(34px, 4vw, 58px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

.stat-compare {
  display: block;
  order: 4;
  min-height: 18px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.layout {
  grid-template-columns: 1fr;
  margin-bottom: 22px;
}

.panel {
  padding: 24px;
}

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

.panel-heading p,
.import-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.chart-panel {
  min-height: 330px;
}

canvas {
  display: block;
  width: 100%;
}

.clear-selection {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(115, 220, 200, 0.1);
  color: var(--strong);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0 12px;
  white-space: nowrap;
}

.clear-selection:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.power {
  color: var(--strong);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.table-tools {
  grid-template-columns: 1fr minmax(220px, 320px);
  align-items: end;
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 14px 10px;
  text-align: left;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

th {
  color: var(--muted);
  font-size: 0.72rem;
}

td {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

tbody tr:hover {
  background: rgba(115, 220, 200, 0.04);
}

tbody tr {
  cursor: pointer;
}

tbody tr:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: -2px;
}

tbody tr.is-selected {
  background: rgba(115, 220, 200, 0.1);
}

tbody tr.is-selected td:first-child {
  color: var(--mint);
}

.positive {
  color: var(--mint);
  font-weight: 900;
}

.negative,
.stale {
  color: var(--pink);
  font-weight: 900;
}

.squad-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--mint);
  background: rgba(115, 220, 200, 0.08);
  font-size: 12px;
  font-weight: 900;
  padding: 0 10px;
  text-transform: capitalize;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid rgba(255, 143, 190, 0.44);
  border-radius: 999px;
  color: var(--pink);
  background: rgba(255, 143, 190, 0.08);
  font-size: 12px;
  font-weight: 900;
  padding: 0 10px;
}

.status-pill.is-registered {
  border-color: var(--line-strong);
  color: var(--mint);
  background: rgba(115, 220, 200, 0.08);
}

.import-panel {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-top: 22px;
}

.import-panel a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(115, 220, 200, 0.12);
  color: var(--strong);
  font-weight: 800;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

@media (max-width: 1040px) {
  .header-main {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .header-main,
  .import-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .header-user {
    flex-wrap: wrap;
    justify-content: start;
    min-width: 0;
  }

  .header-user div {
    text-align: left;
  }

  .summary-grid,
  .layout,
  .account-panel,
  .account-form,
  .invite-form,
  .profile-grid,
  #registerForm,
  #statForm {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .dashboard {
    padding-inline: 12px;
  }

  .header-actions,
  .table-tools {
    grid-template-columns: 1fr;
  }

  .header-actions {
    width: 100%;
  }

  .metric-toggle {
    grid-template-columns: 1fr 1fr;
  }

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

  .stat {
    min-height: 124px;
    padding: 18px 14px;
  }

  .stat strong {
    font-size: clamp(26px, 10vw, 34px);
  }

  .panel {
    padding: 20px;
  }

  .panel-heading {
    display: grid;
  }

}
