:root {
  --ink: #202124;
  --muted: #646a73;
  --line: #d9ded7;
  --surface: #f7f8f5;
  --panel: #ffffff;
  --nav: #262a2b;
  --nav-active: #e7b94a;
  --accent: #2f7d5c;
  --accent-dark: #256548;
  --danger: #b6423c;
  --warn: #b87333;
  --shadow-card: 0 10px 24px rgb(32 33 36 / 8%);
  --shadow-button: 0 7px 15px rgb(47 125 92 / 18%);
  --shadow-button-soft: 0 5px 12px rgb(32 33 36 / 10%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 108px 1fr;
}

.sidebar {
  background: var(--nav);
  color: #fff;
  padding: 14px 10px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 2px solid var(--nav-active);
  color: var(--nav-active);
  font-weight: 700;
}

.brand > span:not(.brand-mark) {
  display: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #bfc6bf;
  margin-top: 2px;
}

.main-nav {
  display: grid;
  gap: 4px;
}

.main-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  padding: 8px 6px;
  border-radius: 6px;
  color: #eef2ee;
  min-height: 62px;
  text-align: center;
  font-size: 11px;
  line-height: 1.15;
}

.main-nav a:hover,
.main-nav a.active {
  background: #3a3f40;
  color: #fff;
}

.main-nav a.active {
  border-left: 0;
  box-shadow: inset 0 -3px 0 var(--nav-active);
  padding-left: 6px;
}

.nav-icon {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  color: #c8d2cc;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.main-nav a:hover .nav-icon,
.main-nav a.active .nav-icon {
  color: var(--nav-active);
}

.content {
  min-width: 0;
  padding: 20px;
}

.topbar {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.section-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  padding: 2px 1px 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.section-tabs::-webkit-scrollbar {
  display: none;
}

.section-tabs a {
  width: 38px;
  min-width: 38px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex: 0 0 auto;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #3c463f;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-button-soft);
}

.section-tabs a:hover,
.section-tabs a.active {
  border-color: var(--nav);
  background: var(--nav);
  color: #fff;
}

.section-tabs a.active .nav-icon,
.section-tabs a:hover .nav-icon {
  color: var(--nav-active);
}

.status-pill,
.tag,
.result {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill {
  background: #e9eee8;
  color: #3c473d;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.panel.warning {
  border-color: #e4b160;
  background: #fff8eb;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title h2 {
  margin: 0;
}

.section-title span {
  color: var(--muted);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  box-shadow: var(--shadow-card);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  font-size: 24px;
  line-height: 1.05;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  align-items: end;
  gap: 12px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cdd3cc;
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-button);
}

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

.button.ghost {
  color: var(--accent);
  background: #fff;
  box-shadow: var(--shadow-button-soft);
}

.button.disabled {
  opacity: .45;
  pointer-events: none;
}

.notice.success {
  border-color: #b8d9c5;
  background: #f3fbf6;
}

.saved-match {
  display: grid;
  gap: 5px;
}

.saved-match strong {
  font-size: 18px;
}

.saved-match span {
  color: var(--muted);
}

.match-form {
  display: grid;
  gap: 16px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid.two {
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
}

.form-grid.four {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.combo-field {
  position: relative;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.combo-box {
  position: relative;
}

.combo-options {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-card);
}

.combo-option {
  width: 100%;
  min-height: 36px;
  display: block;
  border: 0;
  border-bottom: 1px solid #edf1eb;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.combo-option:last-child {
  border-bottom: 0;
}

.combo-option:hover,
.combo-option.is-active {
  background: #e6f3ed;
  color: var(--accent-dark);
}

.score-entry {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 86px minmax(220px, 1fr) 86px;
  align-items: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  box-shadow: var(--shadow-card);
}

.team-column {
  display: grid;
  gap: 10px;
}

.goals-field input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

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

.check-row {
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 9px;
  align-self: end;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  box-shadow: var(--shadow-card);
}

.check-row input {
  width: auto;
  min-height: 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.error-list {
  margin: 0;
  padding-left: 18px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid #e7ebe5;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  background: #eef2ea;
  color: #3b443c;
  font-size: 12px;
  text-transform: uppercase;
}

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

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.muted-row {
  color: var(--muted);
  background: #fafafa;
}

.tag.warning {
  background: #fff0dd;
  color: var(--warn);
}

.tag.error {
  background: #ffe7e5;
  color: var(--danger);
}

.tag.info {
  background: #e6f3ed;
  color: var(--accent-dark);
}

.result.w {
  background: #e2f4ea;
  color: #22623e;
}

.result.d {
  background: #fff1d4;
  color: #8a5c14;
}

.result.l {
  background: #ffe5e2;
  color: #96362e;
}

.pager {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.scoreboard div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  background: #fff;
  box-shadow: var(--shadow-card);
}

.stat-bars,
.timeline-bars {
  display: grid;
  gap: 9px;
}

.stat-bar-row {
  display: grid;
  grid-template-columns: minmax(150px, 260px) minmax(130px, 1fr) 64px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.stat-bar-label {
  min-width: 0;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-bar-track,
.timeline-track {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2ea;
}

.stat-bar-track span,
.timeline-track span {
  display: block;
  width: var(--bar-size);
  min-width: 4px;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--nav-active));
}

.stat-bar-value {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timeline-row {
  display: grid;
  grid-template-columns: 58px minmax(130px, 1fr) minmax(190px, 260px);
  align-items: center;
  gap: 10px;
}

.timeline-year,
.timeline-detail {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timeline-detail {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.timeline-detail small {
  color: var(--muted);
  font-weight: 700;
}

.matrix-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
}

.matrix-table {
  min-width: 760px;
}

.matrix-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
}

.matrix-table tbody th {
  background: #f8faf5;
}

.matrix-table td,
.matrix-table th {
  text-align: center;
}

.matrix-table tbody th:first-child {
  text-align: left;
}

.heat-cell,
.heat-empty {
  min-width: 70px;
  text-align: center;
}

.heat-cell strong,
.heat-cell span {
  display: block;
}

.heat-cell span {
  color: var(--muted);
  font-size: 11px;
}

.heat-pos {
  background: #e3f3e9;
}

.heat-neg {
  background: #fde7e4;
}

.heat-zero,
.heat-empty {
  background: #f5f6f2;
}

.scoreboard span,
.scoreboard small {
  display: block;
  color: var(--muted);
}

.scoreboard strong {
  display: block;
  font-size: 32px;
  margin: 6px 0;
}

.champion-bars {
  display: grid;
  gap: 9px;
}

.champion-bar-row {
  display: grid;
  grid-template-columns: 34px minmax(150px, 240px) minmax(120px, 1fr) 48px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.champion-rank,
.champion-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.champion-rank {
  color: var(--muted);
  text-align: right;
}

.champion-team {
  min-width: 0;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.champion-track {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2ea;
}

.champion-fill {
  display: block;
  width: var(--bar-size);
  min-width: 4px;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--nav-active));
}

.champion-count {
  text-align: right;
}

pre {
  max-width: 100%;
  overflow-x: auto;
  margin: 10px 0 0;
  padding: 12px;
  border-radius: 6px;
  background: #232829;
  color: #f5f8f2;
}

.empty {
  color: var(--muted);
}

.welcome-panel p {
  margin: 0;
  color: var(--muted);
}

.app-footer {
  margin-top: 24px;
  padding: 14px 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.login-body {
  min-height: 100vh;
  background: #eef2ea;
}

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

.login-panel {
  width: min(100%, 420px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 18px 45px rgb(32 33 36 / 10%);
}

.login-brand {
  color: var(--ink);
  margin-bottom: 18px;
}

.login-brand small {
  color: var(--muted);
}

.login-copy h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.login-copy p {
  margin: 8px 0 0;
  color: var(--muted);
}

.login-copy .credits {
  color: var(--accent-dark);
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.login-footer {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.chart-box {
  width: 100%;
  overflow-x: auto;
  margin-bottom: 14px;
}

.chart-box svg {
  min-width: 760px;
  width: 100%;
  height: auto;
}

.chart-bg {
  fill: #fff;
  stroke: var(--line);
}

.grid-line {
  stroke: #dfe5dc;
  stroke-width: 1;
}

.grid-line.vertical {
  stroke-dasharray: 4 4;
}

.axis-label {
  fill: #667064;
  font-size: 12px;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
}

.chart-dot {
  fill: var(--nav-active);
  stroke: #5b4311;
  stroke-width: 1.5;
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 10px 12px;
    overflow: hidden;
  }

  .brand {
    display: none;
  }

  .main-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .main-nav::-webkit-scrollbar {
    display: none;
  }

  .main-nav a {
    flex: 0 0 auto;
    flex-direction: row;
    width: max-content;
    min-height: 38px;
    padding: 8px 10px;
    white-space: nowrap;
    font-size: 12px;
  }

  .main-nav a.active {
    box-shadow: inset 0 -3px 0 var(--nav-active);
  }

  .metrics-grid,
  .filters,
  .form-grid.two,
  .form-grid.four,
  .score-entry,
  .scoreboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .goals-field {
    max-width: 120px;
  }
}

@media (max-width: 620px) {
  .content {
    padding: 12px;
  }

  .topbar-row {
    display: grid;
  }

  .topbar-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .metrics-grid,
  .filters,
  .form-grid.two,
  .form-grid.four,
  .score-entry,
  .scoreboard {
    grid-template-columns: 1fr;
  }

  .section-tabs a {
    width: 36px;
    min-width: 36px;
    min-height: 34px;
    padding: 7px;
  }

  .stat-bar-row,
  .timeline-row {
    grid-template-columns: 1fr 58px;
    gap: 7px 9px;
  }

  .stat-bar-track,
  .timeline-track {
    grid-column: 1 / 3;
    grid-row: 2;
  }

  .stat-bar-value {
    grid-column: 2;
    grid-row: 1;
  }

  .timeline-detail {
    grid-column: 1 / 3;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .goals-field {
    max-width: none;
  }

  .form-actions {
    justify-content: stretch;
  }

  .form-actions .button {
    width: 100%;
  }

  .champion-bar-row {
    grid-template-columns: 28px minmax(0, 1fr) 44px;
    gap: 7px 9px;
  }

  .champion-track {
    grid-column: 2 / 4;
  }
}
