:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --text: #15201d;
  --muted: #65736f;
  --line: #d9e0dc;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --soft: #e8f2ef;
  --pitch: #23614f;
  --gold: #a16207;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  padding: 0 12px;
  white-space: nowrap;
}

button:hover {
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

button.secondary {
  background: var(--soft);
}

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 243, 0.94);
  backdrop-filter: blur(10px);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
}

.meta,
.topbar-controls,
.panel-heading,
.filters,
.bid-controls,
.commissioner-controls,
.nomination-controls,
.draft-settings-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.route-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

#routePathHint {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.draft-route-nav {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.draft-route-link {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  line-height: 1;
  padding: 0 10px;
  text-decoration: none;
}

.draft-route-link:hover {
  border-color: var(--accent);
}

.draft-route-link.active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent-strong);
}

.sync-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  border: 1px solid rgba(161, 98, 7, 0.35);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.12);
  color: #7c2d12;
  font-size: 12px;
  padding: 5px 8px;
}

.sync-banner button {
  min-height: 24px;
  padding: 0 8px;
  font-size: 12px;
}

.sync-banner.sync-banner-critical {
  border-color: rgba(185, 28, 28, 0.4);
  background: rgba(254, 226, 226, 0.9);
  color: #991b1b;
}

.sync-banner.sync-banner-recovering {
  border-color: rgba(14, 116, 72, 0.35);
  background: rgba(220, 252, 231, 0.8);
  color: #14532d;
}

.sync-banner.sync-banner-hidden {
  display: none;
}

.contention-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.contention-actions-note {
  color: var(--muted);
  font-size: 11px;
}

.contention-actions button {
  min-height: 28px;
  font-size: 12px;
  padding: 0 10px;
}

.contention-history-text {
  display: inline-block;
  max-width: 420px;
  overflow-wrap: anywhere;
  text-align: right;
  white-space: normal;
}

.meta span:not(:last-child)::after {
  content: "/";
  padding-left: 8px;
  color: #9aa5a1;
}

.draft-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(300px, 0.72fr);
  gap: 12px;
  padding: 12px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}

.auction-panel {
  min-height: 250px;
}

.player-panel,
.league-panel {
  grid-column: 1 / -1;
}

.panel-heading {
  justify-content: space-between;
  margin-bottom: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  padding: 0 9px;
}

.auction-state {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
}

.timer {
  display: grid;
  place-items: center;
  min-height: 128px;
  border-radius: 8px;
  background: var(--pitch);
  color: #fff;
}

.timer-value {
  font-size: 42px;
  line-height: 1;
  font-weight: 800;
}

.timer-label {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.78);
  text-transform: uppercase;
}

.lot-card {
  display: grid;
  align-content: center;
  min-height: 128px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.lot-player {
  font-size: 22px;
  font-weight: 760;
}

.lot-meta,
.muted {
  color: var(--muted);
}

.lot-meta {
  margin-top: 5px;
}

.high-bid {
  margin-top: 12px;
  color: var(--gold);
  font-weight: 760;
}

.field {
  display: grid;
  gap: 4px;
  min-width: 120px;
}

.field.compact {
  min-width: 150px;
}

.field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
}

input,
select {
  min-height: 36px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(15, 118, 110, 0.14);
}

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

.draft-results-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 10px;
  margin-bottom: 12px;
}

.results-link-button {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: #fff;
  color: var(--accent-strong);
  font-size: 12px;
  padding: 0 10px;
  text-decoration: none;
}

.results-link-button:hover {
  border-color: var(--accent-strong);
}

.summary-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
}

.summary-value {
  margin-top: 3px;
  font-size: 18px;
  font-weight: 760;
}

.subheading {
  margin: 12px 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.subheading.with-action {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.subheading.with-action button {
  min-height: 24px;
  padding: 0 8px;
}

.inline-actions {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.audit-filter-select {
  min-height: 24px;
  border-radius: 6px;
  font-size: 12px;
  padding: 0 8px;
}

.audit-start-summary {
  border: 1px solid rgba(239, 68, 68, 0.28);
  border-left: 3px solid rgba(185, 28, 28, 0.8);
  border-radius: 6px;
  background: #fff7f7;
  color: #7f1d1d;
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
  padding: 8px 10px;
}

.audit-start-summary-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.audit-start-summary-title {
  font-size: 12px;
  font-weight: 760;
}

.audit-start-summary-line {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.audit-start-summary-copy {
  min-height: 24px;
  padding: 0 8px;
}

.diag-hint {
  color: var(--muted);
  font-size: 11px;
  margin: -2px 0 7px;
}

.diag-thresholds {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 8px;
}

.tiny-field {
  gap: 4px;
}

.tiny-field span {
  font-size: 11px;
}

.tiny-field input {
  height: 30px;
  min-width: 0;
  padding: 4px 7px;
}

.tiny-field input.threshold-alert {
  border-color: rgba(185, 28, 28, 0.55);
  background: rgba(254, 226, 226, 0.7);
  color: #7f1d1d;
}

.diag-presets {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  margin-bottom: 8px;
}

.diag-presets button.active-preset {
  border-color: rgba(22, 101, 52, 0.4);
  background: rgba(34, 197, 94, 0.15);
  color: #14532d;
}

.diag-preset-state {
  color: var(--muted);
  font-size: 11px;
  margin-left: 4px;
}

.list {
  display: grid;
  gap: 6px;
}

.compact-list {
  max-height: 220px;
  overflow: auto;
}

.chat-list {
  display: grid;
  gap: 8px;
  max-height: 230px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

#healthMetrics {
  max-height: 170px;
}

.health-status {
  min-width: 62px;
  justify-content: center;
}

.health-good {
  border-color: rgba(14, 116, 72, 0.35);
  background: rgba(22, 163, 74, 0.12);
  color: #166534;
}

.health-warn {
  border-color: rgba(161, 98, 7, 0.35);
  background: rgba(245, 158, 11, 0.14);
  color: #92400e;
}

.contention-badge {
  font-size: 11px;
}

.start-health-badge {
  font-size: 11px;
}

.start-health-ready {
  border-color: rgba(14, 116, 72, 0.35);
  background: rgba(22, 163, 74, 0.12);
  color: #166534;
}

.start-health-blocked {
  border-color: rgba(185, 28, 28, 0.35);
  background: rgba(239, 68, 68, 0.14);
  color: #991b1b;
}

.start-health-unknown {
  border-color: var(--line);
  background: var(--soft);
  color: var(--muted);
}

.draft-closed-badge {
  border-color: rgba(185, 28, 28, 0.35);
  background: rgba(239, 68, 68, 0.14);
  color: #991b1b;
  font-size: 11px;
}

.contention-ok {
  border-color: rgba(14, 116, 72, 0.35);
  background: rgba(22, 163, 74, 0.12);
  color: #166534;
}

.contention-warn {
  border-color: rgba(161, 98, 7, 0.35);
  background: rgba(245, 158, 11, 0.14);
  color: #92400e;
}

.contention-critical {
  border-color: rgba(185, 28, 28, 0.35);
  background: rgba(239, 68, 68, 0.14);
  color: #991b1b;
}

.contention-unknown {
  border-color: var(--line);
  background: var(--soft);
  color: var(--muted);
}

.chat-message {
  display: grid;
  gap: 2px;
  border-bottom: 1px solid #edf1ef;
  padding-bottom: 7px;
}

.chat-message:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.chat-author {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.chat-text {
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
  border-bottom: 1px solid #edf1ef;
  padding: 5px 0;
}

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

.audit-entry {
  border-bottom: 1px solid #edf1ef;
  display: grid;
  gap: 4px;
  padding: 7px 0;
}

.audit-entry:last-child {
  border-bottom: 0;
}

.audit-entry-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.audit-entry-head span {
  overflow-wrap: anywhere;
}

.audit-entry-meta {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.audit-entry-age-fresh {
  color: #b45309;
  font-weight: 700;
}

.audit-entry-error {
  color: #b91c1c;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.audit-outcome {
  font-size: 11px;
  font-weight: 760;
  justify-content: center;
  min-width: 84px;
}

.audit-outcome-accepted {
  background: #ecfdf5;
  border-color: rgba(16, 185, 129, 0.32);
  color: #047857;
}

.audit-outcome-rejected {
  background: #fef2f2;
  border-color: rgba(239, 68, 68, 0.32);
  color: #b91c1c;
}

.audit-start-attempt {
  border-left: 2px solid #e2e8f0;
  display: grid;
  gap: 2px;
  margin-left: 2px;
  padding-left: 8px;
}

.audit-start-attempt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  overflow-wrap: anywhere;
}

.audit-start-attempt-row strong {
  font-size: 12px;
}

.roster-row {
  align-items: center;
}

.roster-row-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nomination-row {
  align-items: center;
}

.nomination-row.is-current {
  background: var(--soft);
}

.nomination-row-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nomination-meta {
  padding-top: 6px;
}

.roster-slot {
  min-width: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 4px 7px;
  text-align: center;
}

.roster-move-btn {
  min-height: 28px;
  padding: 0 8px;
}

.filters {
  align-items: end;
  margin-bottom: 10px;
}

.filters .field:first-child {
  flex: 1;
}

.nomination-controls,
.bid-controls,
.commissioner-controls,
.draft-settings-controls {
  flex-wrap: wrap;
  margin-top: 10px;
}

.draft-settings-state {
  margin-top: 6px;
  font-size: 12px;
}

.correction-grid {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(130px, 0.7fr) minmax(200px, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
}

.table {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  overflow: hidden;
  border-bottom: 1px solid #edf1ef;
  padding: 8px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #f8faf9;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

tr.selectable {
  cursor: pointer;
}

tr.selectable:hover,
tr.selected {
  background: var(--soft);
}

.player-table {
  max-height: 430px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.65fr);
  gap: 12px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(16, 24, 40, 0.18);
  color: var(--text);
  opacity: 0;
  padding: 12px;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: rgba(180, 35, 24, 0.45);
  color: var(--danger);
}

@media (max-width: 980px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-controls,
  .draft-grid,
  .split,
  .correction-grid {
    grid-template-columns: 1fr;
  }

  .draft-grid {
    display: grid;
  }

  .auction-state {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar,
  .draft-grid {
    padding: 10px;
  }

  .topbar-controls,
  .filters,
  .bid-controls,
  .commissioner-controls,
  .nomination-controls,
  .draft-settings-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .field,
  .field.compact,
  button {
    width: 100%;
  }

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