:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-muted: #f7f8fb;
  --line: #dfe4ec;
  --text: #1f2633;
  --muted: #667085;
  --primary: #3b82f6;
  --primary-strong: #2563eb;
  --success: #23a56d;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #b8c2d2 #eef2f7;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #eef2f7;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid #eef2f7;
  border-radius: 999px;
  background: #b8c2d2;
}

*::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a,
h1,
h2,
h3,
.eyebrow,
.sidebar,
.topbar,
.panel-heading,
.brand-link,
.date-chip,
.metric-card,
.rank-badge,
.data-table th,
.profile-chip,
.modal-card button,
.assignment-card,
.empty-state,
.loading-state {
  user-select: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  font-weight: 800;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 18px;
}

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

.auth-loading {
  display: none;
}

.auth-checking .login-layout {
  visibility: hidden;
}

.auth-checking .auth-loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

.login-layout {
  display: grid;
  width: min(1100px, 100%);
  grid-template-columns: 1.15fr 0.85fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-panel,
.auth-card {
  padding: 48px;
}

.brand-panel {
  display: grid;
  align-content: center;
  gap: 18px;
  background: #eef4ff;
}

.brand-panel h1,
.auth-card h2,
.topbar h1,
.panel-heading h2 {
  margin: 0;
}

.brand-panel h1 {
  font-size: 48px;
}

.hero-copy {
  width: min(520px, 100%);
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

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

.soft-grid span,
.hint-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
  padding: 14px 16px;
}

.auth-card {
  display: grid;
  align-content: center;
  gap: 20px;
}

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

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}

.login-form input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.form-error {
  margin: 0;
  border: 1px solid #f2b8b8;
  border-radius: var(--radius);
  background: #fff1f1;
  color: #b42318;
  padding: 12px;
}

.discord-button,
.primary-button,
.secondary-button,
.icon-button,
.ghost-link,
.segmented-control button,
.date-chip {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.discord-button,
.primary-button,
.secondary-button,
.ghost-link,
.date-chip {
  min-height: 48px;
  padding: 0 16px;
}

.discord-button,
.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.discord-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
}

.discord-pill {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 12px;
}

.hint-box {
  color: var(--muted);
  line-height: 1.5;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 28px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.sidebar-brand,
.sidebar-footer,
.topbar,
.toolbar,
.panel-heading,
.team-row,
.player-row,
.button-row,
.toggle-row {
  display: flex;
  align-items: center;
}

.sidebar-brand {
  gap: 12px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.sidebar-nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.sidebar-nav a {
  padding: 12px 14px;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
  background: #eef4ff;
  color: var(--primary-strong);
}

.sidebar-footer {
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

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

.dashboard-main {
  padding: 22px;
}

.topbar,
.panel-heading {
  justify-content: space-between;
  gap: 18px;
}

.back-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  float: left;
  margin: 5px 12px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.topbar {
  margin-bottom: 16px;
}

.toolbar {
  gap: 10px;
  margin-left: auto;
}

.icon-button {
  width: 42px;
  height: 42px;
  cursor: pointer;
}

.profile-menu-wrap {
  position: relative;
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

.avatar-dot {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
}

.avatar-dot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: 220px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 10px;
}

.profile-menu[hidden] {
  display: none;
}

.profile-menu-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.profile-menu button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text);
  text-align: left;
  padding: 0 10px;
  cursor: pointer;
}

.profile-menu-link {
  min-height: 38px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text);
  text-decoration: none;
  padding: 0 10px;
}

.tournament-strip-panel,
.board-panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.tournament-strip-panel,
.board-panel {
  padding: 14px;
}

.tournament-strip-panel {
  min-height: 80px;
}

.tournament-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.date-chip {
  min-width: 150px;
  display: grid;
  justify-items: start;
  gap: 4px;
  cursor: pointer;
}

.date-chip strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.date-dot {
  display: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

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

.date-chip.selected {
  border-color: var(--primary);
  background: #eef4ff;
}

.date-chip.current .date-dot {
  display: inline-block;
}

.date-chip.current > span {
  color: var(--success);
  font-weight: 700;
}

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

.metric-card {
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px;
}

.metric-card span {
  color: var(--muted);
}

.metric-card strong {
  font-size: 24px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  margin-top: 12px;
  align-items: start;
}

.right-rail {
  display: grid;
  gap: 12px;
}

.is-hidden {
  display: none;
}

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented-control button {
  border: 0;
  border-radius: 0;
  min-height: 38px;
  padding: 0 14px;
}

.segmented-control button.active {
  background: var(--primary);
  color: #fff;
}

.team-table,
.form-preview {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.loading-state {
  min-height: 72px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  color: var(--muted);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.team-group {
  overflow: visible;
  border: 1px solid var(--line);
  border-left: 6px solid var(--team-color);
  border-radius: var(--radius);
}

.team-row,
.player-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 120px 110px;
  gap: 10px;
  padding: 4px 10px;
  min-height: 28px;
  font-size: 13px;
  line-height: 1.2;
}

.team-row {
  background: color-mix(in srgb, var(--team-color) 11%, white);
}

.rank-badge {
  display: inline-grid;
  width: 38px;
  height: 22px;
  place-items: center;
  border-radius: 7px;
  background: var(--surface);
  font-weight: 800;
}

.player-list {
  display: grid;
}

.player-row {
  position: relative;
  grid-template-columns: 72px minmax(0, 1fr) 120px 110px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--team-color) 5%, white);
}

.team-row {
  grid-template-columns: 72px minmax(0, 1fr) 120px 110px;
}

.player-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  grid-column: 2;
}

.inline-player .player-cell {
  grid-column: auto;
}

.player-head {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 4px;
  image-rendering: pixelated;
}

.more-button {
  width: 34px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.player-menu {
  position: fixed;
  z-index: 1000;
  width: 250px;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 8px;
}

.player-menu button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.player-menu button:hover {
  background: var(--surface-muted);
}

.form-preview label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}

.form-preview input,
.form-preview select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.toggle-row {
  grid-template-columns: auto 1fr;
  gap: 10px;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
}

.button-row {
  gap: 10px;
}

.secondary-button,
.primary-button {
  cursor: pointer;
}

.compact-button {
  min-height: 42px;
}

.compact-action {
  min-height: 40px;
}

.data-panel {
  display: grid;
  gap: 14px;
}

.data-table-wrap {
  max-height: calc(100vh - 230px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

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

.data-table th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td {
  background: #eef4ff;
}

.color-cell {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--swatch);
  vertical-align: -2px;
}

.table-tools {
  display: flex;
  justify-content: flex-end;
}

.table-tools input {
  width: min(360px, 100%);
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.modal {
  width: min(520px, calc(100vw - 32px));
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  padding: 0;
}

.wide-modal {
  width: min(860px, calc(100vw - 32px));
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.32);
}

.modal-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.color-input-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
}

.color-input-row input[type="color"] {
  min-height: 44px;
  padding: 4px;
}

.danger-button {
  border: 1px solid #f2b8b8;
  border-radius: var(--radius);
  background: #fff1f1;
  color: #b42318;
  cursor: pointer;
  padding: 0 16px;
}

.toast-root {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 2000;
  display: grid;
  gap: 8px;
}

.toast {
  border: 1px solid #b7e4ce;
  border-radius: var(--radius);
  background: #ecfdf3;
  color: #067647;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-weight: 700;
}

.game-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.game-chip {
  border: 1px solid var(--line);
  border-left: 5px solid var(--swatch);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 7px 10px;
  font-weight: 700;
}

.table-tools {
  gap: 10px;
}

.table-tools select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.editor-form-inline {
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  align-items: end;
}

.editor-form-inline .form-error {
  grid-column: 1 / -1;
}

.assignment-card {
  display: grid;
  grid-template-columns: auto 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
}

.assignment-card:hover {
  background: #eef4ff;
}

.assignment-main {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.assignment-prefix,
.muted-text {
  color: var(--muted);
  font-size: 12px;
}

.inline-player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inline-player {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
  padding: 3px 6px;
  font-size: 12px;
}

.modal-search-row {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  padding-bottom: 8px;
}

.modal-search-row input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

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

.is-loading {
  opacity: 0.72;
  pointer-events: none;
}

.toolbar-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) minmax(360px, 1fr);
  gap: 18px;
  align-items: start;
}

.editor-teams-panel {
  margin-top: 18px;
}

.assignment-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: min(620px, 70vh);
  overflow-y: auto;
  padding-right: 4px;
}

.assignment-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 90px auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px 10px;
}

@media (max-width: 1180px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr) 230px;
  }
}

@media (max-width: 920px) {
  .dashboard-shell,
  .login-layout,
  .content-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .team-row,
  .player-row {
    grid-template-columns: 1fr;
  }

  .dashboard-main,
  .brand-panel,
  .auth-card {
    padding: 20px;
  }
}
