:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef2f6;
  color: #16202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

.shell {
  min-height: 100vh;
  padding: 32px;
}

.workspace {
  width: min(1380px, 100%);
  margin: 0 auto;
}

.login-shell {
  display: grid;
  place-items: center;
}

.login-workspace {
  display: grid;
  gap: 24px;
  width: min(460px, 100%);
}

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

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #356154;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p,
dl {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.02;
}

h2 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}

p {
  color: #4d5b68;
  line-height: 1.55;
}

.status {
  flex: 0 0 auto;
  border: 1px solid #b9c4ce;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  background: #ffffff;
}

.status--ok {
  border-color: #78b18f;
  color: #1f6b43;
  background: #edf8f1;
}

.status--error {
  border-color: #d88d8d;
  color: #a83333;
  background: #fff1f1;
}

.dashboard {
  display: grid;
  gap: 24px;
}

.panel,
.core-nav-panel,
.management-panel {
  display: grid;
  gap: 28px;
  border: 1px solid #d6dde4;
  border-radius: 8px;
  padding: 24px;
  background: #ffffff;
  box-shadow: 0 16px 42px rgba(34, 50, 66, 0.08);
}

.panel {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
}

.core-nav-panel {
  gap: 20px;
}

.account-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.management-panel {
  gap: 20px;
}

.core-links {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.core-links a,
.back-link {
  min-height: 44px;
  border: 1px solid #c9d4dc;
  border-radius: 6px;
  padding: 11px 12px;
  color: #1c302b;
  font-weight: 800;
  text-decoration: none;
  background: #f9fbfc;
}

.core-links a:hover,
.back-link:hover {
  border-color: #356154;
  background: #edf8f1;
}

.table-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.simple-page {
  display: grid;
  gap: 20px;
  min-height: 360px;
  border-top: 1px solid #d6dde4;
  padding-top: 24px;
}

.reference-page {
  display: grid;
  gap: 24px;
  border-top: 1px solid #d6dde4;
  padding-top: 24px;
}

.reference-section {
  display: grid;
  gap: 16px;
  min-width: 0;
  border: 1px solid #e1e7ed;
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
}

.reference-list-header h3 {
  margin: 0;
  font-size: 1rem;
}

.empty-state {
  color: #667382;
  font-weight: 750;
}

.auth-panel {
  width: min(420px, 100%);
  border: 1px solid #d6dde4;
  border-radius: 8px;
  padding: 24px;
  background: #ffffff;
  box-shadow: 0 16px 42px rgba(34, 50, 66, 0.08);
}

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

label {
  display: grid;
  gap: 7px;
  color: #334150;
  font-size: 0.9rem;
  font-weight: 750;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c7d0d9;
  border-radius: 6px;
  padding: 10px 12px;
  color: #16202a;
  font: inherit;
  background: #ffffff;
}

select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c7d0d9;
  border-radius: 6px;
  padding: 10px 12px;
  color: #16202a;
  font: inherit;
  background: #ffffff;
}

input:focus {
  border-color: #356154;
  outline: 3px solid rgba(53, 97, 84, 0.16);
}

select:focus {
  border-color: #356154;
  outline: 3px solid rgba(53, 97, 84, 0.16);
}

button {
  min-height: 44px;
  border: 1px solid #244a40;
  border-radius: 6px;
  padding: 10px 14px;
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  background: #2f5a4e;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.secondary-button {
  color: #244a40;
  border-color: #b8c8c2;
  background: #f7faf9;
}

.danger-button {
  color: #9b2f2f;
  border-color: #e1b4b4;
  background: #fff5f5;
}

button.is-dirty {
  color: #ffffff;
  border-color: #9a6112;
  background: #7a4d0f;
  box-shadow: 0 0 0 3px rgba(154, 97, 18, 0.18);
}

button.is-dirty::after {
  content: " *";
}

.panel-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  border: 1px solid #e1e7ed;
  border-radius: 8px;
  padding: 16px;
  background: #f9fbfc;
}

.core-crud-panel {
  display: grid;
  gap: 16px;
}

.core-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  border: 1px solid #e1e7ed;
  border-radius: 8px;
  padding: 16px;
  background: #f9fbfc;
}

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

.checkbox-label {
  align-content: end;
  grid-template-columns: 22px minmax(0, 1fr);
  min-height: 70px;
}

.checkbox-label input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: end;
}

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

.form-error {
  min-height: 22px;
  color: #a83333;
  font-size: 0.92rem;
  font-weight: 700;
}

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

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

th,
td {
  border-bottom: 1px solid #e4e9ee;
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #627181;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

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

.row-actions button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.84rem;
}

.players-page {
  display: grid;
  grid-template-columns: minmax(340px, 500px) minmax(520px, 1fr);
  gap: 20px;
  border-top: 1px solid #d6dde4;
  padding-top: 24px;
}

.player-editor-panel,
.player-search-panel,
.player-stats-panel,
.player-owners-panel {
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}

.player-form {
  display: grid;
  gap: 14px;
  border: 1px solid #e1e7ed;
  border-radius: 8px;
  padding: 16px;
  background: #f9fbfc;
}

.player-filter-checkbox {
  min-height: 0;
  align-items: center;
  border: 1px solid #d8e1e8;
  border-radius: 6px;
  padding: 10px 12px;
  background: #ffffff;
}

.elite-link-field {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  align-items: center;
  min-height: 44px;
  border: 1px solid #d8e1e8;
  border-radius: 6px;
  padding: 10px 12px;
  background: #ffffff;
}

.elite-link-field > span {
  color: #627181;
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: uppercase;
}

.elite-link-field a {
  overflow: hidden;
  color: #275b7a;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.elite-link-field a.is-empty {
  color: #667382;
  font-weight: 700;
  text-decoration: none;
  pointer-events: none;
}

.wide-field {
  grid-column: 1 / -1;
}

.transaction-panel {
  display: grid;
  gap: 12px;
  border: 1px solid #d8e1e8;
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.transaction-panel[hidden] {
  display: none;
}

.transaction-panel h3 {
  margin: 0;
  font-size: 1rem;
}

.transaction-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(140px, 180px);
  gap: 12px;
}

.transaction-history-panel {
  display: grid;
  gap: 14px;
  border: 1px solid #e1e7ed;
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
}

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

.transaction-history-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid #e4e9ee;
  padding-bottom: 8px;
}

.transaction-history-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.transaction-history-date {
  color: #627181;
  font-size: 0.84rem;
  font-weight: 800;
}

.transaction-history-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.transaction-history-type {
  color: #16202a;
  font-weight: 800;
}

.transaction-history-team {
  color: #4d5b68;
  font-size: 0.88rem;
}

.player-id,
.stats-meta,
.record-count {
  color: #667382;
  font-size: 0.9rem;
  font-weight: 750;
}

.player-search-toolbar {
  display: grid;
  grid-template-columns: 44px 44px 96px auto 44px 44px minmax(220px, 1fr);
  gap: 8px;
  align-items: end;
  min-width: 0;
}

.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
}

.record-jump {
  gap: 4px;
  font-size: 0.78rem;
}

.record-jump input {
  min-height: 44px;
  text-align: center;
}

.player-results-panel {
  display: grid;
  gap: 8px;
}

.player-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #627181;
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: uppercase;
}

.player-results-header button {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 0.82rem;
  text-transform: none;
}

.player-nhl-action-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.player-nhl-action-group span {
  color: #667382;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: none;
  white-space: nowrap;
}

.player-results-panel select {
  min-height: 218px;
}

.player-stats-panel,
.player-owners-panel {
  border: 1px solid #e1e7ed;
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
}

.import-page {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(520px, 1fr);
  gap: 20px;
  border-top: 1px solid #d6dde4;
  padding-top: 24px;
}

.import-panel,
.import-report-panel {
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
  border: 1px solid #e1e7ed;
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
}

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

.import-progress {
  display: grid;
  gap: 8px;
}

.import-progress-track {
  height: 14px;
  overflow: hidden;
  border: 1px solid #c7d0d9;
  border-radius: 999px;
  background: #f2f5f7;
}

.import-progress-bar {
  width: 0;
  height: 100%;
  background: #2f5a4e;
  transition: width 180ms ease;
}

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

.import-sample,
.import-result {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.import-sample h3,
.import-result h3 {
  margin: 0;
  font-size: 1rem;
}

.import-sample-table {
  min-width: 520px;
}

.import-review-list {
  display: grid;
  gap: 12px;
}

.import-review-item,
.import-create-item {
  display: grid;
  gap: 10px;
  border: 1px solid #e1e7ed;
  border-radius: 8px;
  padding: 12px;
  background: #f9fbfc;
}

.import-review-item > div,
.import-create-item span {
  display: grid;
  gap: 3px;
}

.import-review-item span,
.import-create-item span span {
  color: #667382;
  font-size: 0.88rem;
  font-weight: 700;
}

.import-create-item {
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: start;
}

.import-create-item input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.stats-table {
  min-width: 680px;
}

.transaction-table {
  min-width: 420px;
}

.owner-table {
  min-width: 360px;
}

.stats-table th,
.stats-table td,
.transaction-table th,
.transaction-table td,
.owner-table th,
.owner-table td {
  padding: 8px 10px;
}

.stats-table th,
.stats-table td {
  text-align: right;
}

.transaction-table th,
.transaction-table td,
.owner-table th,
.owner-table td {
  text-align: left;
}

.stats-table th:first-child,
.stats-table td:first-child,
.stats-table th:nth-child(2),
.stats-table td:nth-child(2) {
  text-align: left;
}

.stats-row,
.transaction-row {
  cursor: pointer;
}

.stats-row:hover,
.stats-row.is-selected,
.transaction-row:hover,
.transaction-row.is-selected {
  background: #edf8f1;
}

.stat-editor,
.transaction-editor {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  border: 1px solid #d8e1e8;
  border-radius: 8px;
  padding: 14px;
  background: #f9fbfc;
}

.stat-editor h3,
.transaction-editor h3 {
  margin: 0;
  font-size: 1rem;
}

.stat-editor-grid,
.transaction-editor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

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

.stat-editor .form-actions,
.transaction-editor .form-actions {
  align-items: center;
}

.stat-editor .form-error,
.transaction-editor .form-error {
  min-height: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.8rem;
  font-weight: 800;
  background: #edf8f1;
  color: #1f6b43;
}

.status-pill--inactive {
  background: #f2f4f6;
  color: #667382;
}

.status-pill--error {
  background: #fff1f1;
  color: #a83333;
}

.audit-page {
  display: grid;
  gap: 10px;
  border-top: 1px solid #d6dde4;
  padding-top: 24px;
}

.audit-panel {
  display: grid;
  gap: 10px;
  border: 1px solid #e1e7ed;
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
}

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

.audit-actions span {
  min-width: 70px;
  color: #667382;
  font-weight: 800;
  text-align: center;
}

.audit-loading {
  display: none;
  color: #667382;
  font-weight: 800;
}

.audit-loading.show {
  display: inline;
}

.audit-alert {
  display: none;
  border-radius: 8px;
  padding: 8px;
  white-space: pre-wrap;
}

.audit-alert.show {
  display: block;
}

.audit-alert.ok {
  color: #1f6b43;
  background: #edf8f1;
}

.audit-alert.error {
  color: #a83333;
  background: #fff1f1;
}

.audit-meta {
  color: #667382;
  font-size: 0.8rem;
  font-weight: 750;
}

.audit-table {
  min-width: 1100px;
}

.audit-table .audit-target {
  min-width: 120px;
}

.audit-target-table,
.audit-target-pk {
  display: block;
}

.audit-target-table {
  color: #16202a;
  font-weight: 800;
}

.audit-target-pk {
  color: #667382;
  font-size: 0.78rem;
  font-weight: 750;
  margin-top: 3px;
}

.audit-table .audit-json {
  min-width: 360px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
}

.facts {
  display: grid;
  gap: 12px;
}

.facts div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 16px;
  align-items: baseline;
  padding-bottom: 12px;
  border-bottom: 1px solid #e4e9ee;
}

.facts div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

dt {
  color: #627181;
  font-size: 0.84rem;
  font-weight: 700;
}

dd {
  margin: 0;
  color: #16202a;
  font-weight: 750;
}

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

  .topbar,
  .table-page-header,
  .account-row,
  .panel {
    display: grid;
  }

  .panel,
  .core-links {
    grid-template-columns: 1fr;
  }

  .section-header,
  .admin-form,
  .core-form,
  .players-page,
  .player-search-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .status {
    width: fit-content;
  }
}

@media (max-width: 1100px) {
  .players-page {
    grid-template-columns: 1fr;
  }

  .player-search-toolbar,
  .stat-editor-grid,
  .transaction-editor-grid,
  .import-page,
  .transaction-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .player-search-toolbar,
  .stat-editor-grid,
  .transaction-editor-grid,
  .import-page,
  .transaction-grid {
    grid-template-columns: 1fr;
  }
}
