html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

:root {
  --app-bg: #f5f7fa;
  --app-panel: #ffffff;
  --app-panel-soft: #fbfcfd;
  --app-border: #d9e1ea;
  --app-border-strong: #c8d2de;
  --app-text: #0f172a;
  --app-text-muted: #5b6472;
  --app-accent: #1d4ed8;
  --app-accent-soft: rgba(29, 78, 216, 0.08);
  --app-success: #15803d;
  --app-warning: #a16207;
  --app-danger: #b42318;
}

html {
  position: relative;
  min-height: 100%;
}

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

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--app-text);
  letter-spacing: -0.015em;
}

p,
label,
span,
div,
li,
td,
th {
  color: inherit;
}

small,
.text-muted,
.text-secondary {
  color: var(--app-text-muted) !important;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus,
.form-select:focus {
  border-color: var(--app-accent);
  box-shadow: 0 0 0 0.18rem rgba(29, 78, 216, 0.14);
}

.btn {
  border-radius: 0.45rem;
  font-weight: 600;
  box-shadow: none !important;
}

.btn-primary {
  background-color: var(--app-accent);
  border-color: var(--app-accent);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: #1843bc;
  border-color: #1843bc;
}

.btn-outline-secondary {
  border-color: var(--app-border-strong);
  color: var(--app-text);
}

.btn-outline-secondary:hover {
  background-color: #eef2f7;
  border-color: var(--app-border-strong);
  color: var(--app-text);
}

.form-control,
.form-select {
  min-height: 2.65rem;
  border-color: var(--app-border-strong);
  border-radius: 0.45rem;
  color: var(--app-text);
}

.form-label {
  margin-bottom: 0.4rem;
  color: var(--app-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.table td,
.table th {
  vertical-align: middle;
}

code {
  color: #7b2cbf;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: rgba(245, 247, 250, 0.92);
  backdrop-filter: blur(8px);
}

.app-navbar {
  min-height: 4rem;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: none;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--app-text);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.app-brand:hover {
  color: var(--app-text);
}

.app-brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--app-border-strong);
  border-radius: 0.4rem;
  background: var(--app-panel-soft);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: lowercase;
}

.app-nav-links .nav-link,
.navbar-nav .nav-link,
.navbar-nav .btn-link.nav-link {
  color: var(--app-text-muted);
  font-weight: 500;
}

.app-nav-links .nav-link:hover,
.navbar-nav .nav-link:hover,
.navbar-nav .btn-link.nav-link:hover {
  color: var(--app-text);
}

.app-shell {
  padding-top: 1.25rem;
}

.app-footer {
  margin-top: 2rem;
  padding: 0.95rem 0;
  color: var(--app-text-muted);
  background: transparent;
}

.page-heading {
  padding: 0.15rem 0 0.25rem;
}

.page-heading__eyebrow {
  display: inline-block;
  margin-bottom: 0.65rem;
  color: var(--app-accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-heading__title {
  font-size: clamp(1.7rem, 2vw, 2.1rem);
  font-weight: 700;
  line-height: 1.12;
}

.page-heading__description {
  max-width: 62rem;
  color: var(--app-text-muted);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--app-border);
  border-radius: 0.55rem;
  background: var(--app-panel);
  overflow: hidden;
}

.status-strip__item {
  padding: 0.95rem 1rem;
  border-right: 1px solid var(--app-border);
}

.status-strip__item:last-child {
  border-right: none;
}

.status-strip__label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--app-text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-strip__value {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
}

.data-card {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 0.55rem;
  padding: 1rem;
}

.data-card--flush {
  padding: 0;
  overflow: hidden;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.section-head--bordered {
  align-items: center;
  border-bottom: 1px solid var(--app-border);
}

.section-head__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.section-head__meta {
  color: var(--app-text-muted);
  font-size: 0.88rem;
}

.filter-toolbar {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: end;
}

.filter-toolbar--compact {
  grid-template-columns: minmax(0, 2fr) repeat(4, minmax(0, 1fr)) auto;
}

.filter-toolbar__wide {
  grid-column: span 2;
}

.filter-toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-self: end;
}

.empty-state {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.4rem 0;
  color: var(--app-text-muted);
}

.analysis-grid th a,
.table-grid th a {
  color: inherit;
  text-decoration: none;
}

.analysis-grid th a:hover,
.table-grid th a:hover {
  color: var(--app-text);
}

.table-grid {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: transparent;
  --bs-table-hover-bg: #f8fafc;
  margin-bottom: 0;
}

.table-grid thead th {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--app-border-strong);
  background: var(--app-panel-soft);
  color: var(--app-text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table-grid tbody td {
  padding: 0.9rem;
  border-bottom: 1px solid var(--app-border);
  font-size: 0.92rem;
}

.table-grid tbody tr:last-child td {
  border-bottom: none;
}

.table-grid--dense tbody td {
  padding: 0.8rem 0.85rem;
}

.table-compact tbody td,
.table-compact thead th {
  white-space: nowrap;
}

.match-cell {
  min-width: 14rem;
  white-space: normal;
  line-height: 1.3;
}

.metric-positive {
  color: var(--app-success);
  font-weight: 700;
}

.metric-warning {
  color: var(--app-warning);
  font-weight: 700;
}

.metric-negative {
  color: var(--app-danger);
  font-weight: 700;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.6rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--app-border-strong);
  border-radius: 999px;
  background: var(--app-panel-soft);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.status-badge--ok {
  border-color: rgba(21, 128, 61, 0.2);
  background: rgba(21, 128, 61, 0.08);
  color: var(--app-success);
}

.status-badge--muted {
  color: var(--app-text-muted);
}

.table-link {
  color: var(--app-accent);
  font-weight: 600;
  text-decoration: none;
}

.table-link:hover {
  color: #1843bc;
  text-decoration: underline;
}

.table-footer {
  border-top: 1px solid var(--app-border);
  background: var(--app-panel);
}

.pagination {
  gap: 0.25rem;
}

.page-link {
  border-color: var(--app-border-strong);
  color: var(--app-text);
  border-radius: 0.4rem !important;
}

.page-item.active .page-link {
  background-color: var(--app-accent);
  border-color: var(--app-accent);
}

.detail-box {
  background-color: var(--app-panel-soft);
  border: 1px solid var(--app-border);
  padding: 0.85rem 1rem;
  height: 100%;
  border-radius: 0.55rem;
}

.detail-label,
.stat-label {
  display: block;
  color: var(--app-text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-small {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
}

.card,
.stage-card,
.admin-stat-card {
  border-radius: 0.55rem;
}

.analysis-page-heading,
.analysis-filter-card,
.analysis-table-card {
  max-width: 100%;
}

.analysis-table-shell {
  width: 100%;
  overflow-x: auto;
}

.analysis-grid--wide {
  width: 100%;
  min-width: 78rem;
  table-layout: fixed;
}

.analysis-grid--wide thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%);
}

.analysis-grid--wide tbody tr:nth-child(odd) {
  background: rgba(248, 250, 252, 0.72);
}

.analysis-grid--wide tbody tr:hover {
  background: rgba(219, 234, 254, 0.34);
}

.analysis-grid--wide tbody td {
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
}

.analysis-grid__col--tournament {
  width: 8.5rem;
}

.analysis-grid__col--round {
  width: 6.5rem;
}

.analysis-grid__col--match {
  width: 19rem;
}

.analysis-grid__col--pick {
  width: 10rem;
}

.analysis-grid__col--metric {
  width: 5.1rem;
}

.analysis-grid__col--odds {
  width: 4.8rem;
}

.analysis-grid__col--value {
  width: 6rem;
}

.match-cell__title {
  font-weight: 600;
  line-height: 1.28;
}

.match-cell__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin-top: 0.35rem;
  color: var(--app-text-muted);
  font-size: 0.76rem;
}

.pick-cell__name {
  font-weight: 500;
  line-height: 1.3;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 4.15rem;
  padding: 0.34rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 0.48rem;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
}

.metric-chip--positive {
  border-color: rgba(21, 128, 61, 0.14);
  background: rgba(34, 197, 94, 0.16);
  color: #166534;
}

.metric-chip--warning {
  border-color: rgba(180, 83, 9, 0.16);
  background: rgba(251, 191, 36, 0.18);
  color: #b45309;
}

.metric-chip--negative {
  border-color: rgba(185, 28, 28, 0.14);
  background: rgba(248, 113, 113, 0.16);
  color: #b91c1c;
}

.metric-chip--neutral {
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(226, 232, 240, 0.6);
  color: var(--app-text);
}

.status-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.status-inline::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: currentColor;
}

.status-inline--ok {
  color: var(--app-success);
}

.status-inline--muted {
  color: var(--app-text-muted);
}

.table-link--inline {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

@media (max-width: 991.98px) {
  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-strip__item:nth-child(2n) {
    border-right: none;
  }

  .status-strip__item:nth-child(n + 3) {
    border-top: 1px solid var(--app-border);
  }

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

  .filter-toolbar__wide {
    grid-column: span 2;
  }

  .analysis-grid--wide {
    min-width: 72rem;
  }

  .metric-chip {
    min-width: 3.8rem;
    padding-inline: 0.4rem;
  }
}

@media (max-width: 767.98px) {
  .app-shell {
    padding-top: 1rem;
  }

  .page-heading__title {
    font-size: 1.6rem;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .status-strip__item {
    border-right: none;
    border-top: 1px solid var(--app-border);
  }

  .status-strip__item:first-child {
    border-top: none;
  }

  .filter-toolbar,
  .filter-toolbar--compact {
    grid-template-columns: 1fr;
  }

  .filter-toolbar__wide {
    grid-column: auto;
  }

  .filter-toolbar__actions,
  .quick-actions,
  .section-head {
    width: 100%;
  }

  .section-head {
    flex-direction: column;
  }

  .match-cell {
    min-width: 11rem;
  }

  .analysis-grid--wide {
    min-width: 66rem;
  }

  .match-cell__meta {
    gap: 0.35rem 0.5rem;
  }

  .metric-chip {
    min-width: 3.5rem;
    font-size: 0.78rem;
  }
}

.analysis-reference {
  width: 100%;
}

.analysis-reference__toolbar {
  display: grid;
  grid-template-columns: minmax(12rem, 14rem) 1fr;
  gap: 1.5rem;
  align-items: end;
}

.analysis-reference__date-form {
  margin: 0;
}

.analysis-reference__date-field {
  max-width: 14rem;
}

.analysis-reference__selected-date {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.65rem;
  padding-bottom: 0.25rem;
  color: #1f2937;
  font-size: 0.98rem;
}

.analysis-reference__summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.65rem;
}

.analysis-reference__summary-card {
  border: 1px solid #b9bec7;
  background: #f3f3f3;
}

.analysis-reference__summary-label {
  padding: 0.32rem 0.58rem;
  border-bottom: 1px solid #b9bec7;
  color: #20242c;
  font-size: 0.92rem;
  line-height: 1.2;
}

.analysis-reference__summary-value {
  padding: 0.34rem 0.58rem 0.42rem;
  color: #10151d;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.15;
}

.analysis-reference__table-shell {
  width: 100%;
  overflow-x: auto;
}

.analysis-reference-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}

.analysis-reference-table th,
.analysis-reference-table td {
  border-right: 1px solid #8e9399;
  border-bottom: 1px solid #8e9399;
  padding: 0.42rem 0.56rem;
  font-size: 0.95rem;
  line-height: 1.2;
}

.analysis-reference-table th:first-child,
.analysis-reference-table td:first-child {
  border-left: 1px solid #8e9399;
}

.analysis-reference-table thead th {
  border-top: 1px solid #8e9399;
  background: #ffffff;
  color: #111827;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.analysis-reference-table thead th:first-child {
  background: #b8d1e6;
}

.analysis-reference-table thead th a {
  color: inherit;
  text-decoration: none;
}

.analysis-reference-table thead th a:hover {
  color: #0f172a;
}

.analysis-reference-table__identity {
  background: #e7f0e0;
}

.analysis-reference-table__identity--round {
  background: #ece7d5;
}

.analysis-reference-table__number {
  background: #ffffff;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.analysis-reference-table__cell--positive {
  background: #e5f1e1;
}

.analysis-reference-table__cell--warning {
  background: #f4ece2;
}

.analysis-reference-table__cell--negative {
  background: #f5e2df;
}

.analysis-reference-table__match-link {
  color: #1f2937;
  text-decoration: none;
}

.analysis-reference-table__match-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

.analysis-reference__value--positive {
  color: #1f8a58;
  font-weight: 700;
}

.analysis-reference__value--warning {
  color: #c07b2b;
  font-weight: 700;
}

.analysis-reference__value--negative {
  color: #d15f58;
  font-weight: 700;
}

.analysis-reference__pagination {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 1199.98px) {
  .analysis-reference__summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 767.98px) {
  .analysis-reference__toolbar {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .analysis-reference__selected-date {
    justify-content: flex-start;
    padding-bottom: 0;
  }

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

  .analysis-reference-table th,
  .analysis-reference-table td {
    font-size: 0.88rem;
    padding: 0.36rem 0.45rem;
  }
}
