:root {
  --bg: #f6f8f5;
  --ink: #14201b;
  --muted: #5f6d66;
  --line: #dfe7df;
  --panel: #ffffff;
  --green: #0f8a5f;
  --teal: #0b6f7b;
  --red: #bf4b4b;
  --amber: #c9902d;
  --blue: #345ea8;
  --shadow: 0 18px 42px rgba(22, 32, 26, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 42px;
}

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

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

.topbar h1 {
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source-note {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(320px, 2fr) repeat(3, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 14px;
}

.fixture-panel {
  min-width: 0;
}

.side-stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

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

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 0;
}

.fixture-heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mode-toggle {
  display: inline-flex;
  padding: 3px;
  border: 1px solid #cbd8cf;
  border-radius: 8px;
  background: #f7faf8;
}

.mode-button {
  min-height: 30px;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.mode-button.active {
  background: var(--green);
  color: #fff;
}

.panel h2 {
  font-size: 20px;
  line-height: 1.2;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf6ef;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.next-panel {
  min-height: 240px;
  position: relative;
  overflow: hidden;
}

.scoreline {
  padding: 22px 18px 10px;
  font-size: clamp(44px, 7vw, 72px);
  font-weight: 900;
  line-height: 0.95;
}

.prob-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 18px 18px;
}

.prob-item {
  display: grid;
  gap: 4px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdfb;
}

.prob-item span {
  color: var(--muted);
  font-size: 12px;
}

.prob-item b {
  font-size: 18px;
}

.pitch-visual {
  position: absolute;
  right: -28px;
  bottom: -32px;
  width: 210px;
  height: 132px;
  border: 2px solid rgba(15, 138, 95, 0.24);
  border-radius: 8px;
  transform: rotate(-9deg);
  pointer-events: none;
}

.pitch-visual::before,
.pitch-visual::after,
.pitch-visual span {
  content: "";
  position: absolute;
  border: 2px solid rgba(15, 138, 95, 0.18);
}

.pitch-visual::before {
  inset: 18px;
}

.pitch-visual::after {
  left: 50%;
  top: 0;
  bottom: 0;
}

.pitch-visual span {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  left: calc(50% - 21px);
  top: calc(50% - 21px);
}

.metric-panel {
  min-height: 160px;
  padding: 18px;
}

.metric-value {
  margin-top: 16px;
  font-size: 42px;
  font-weight: 900;
}

.metric-caption {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.controls {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr 0.8fr auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px;
  background: #eaf1eb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd8cf;
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.95);
}

.ghost-button {
  border: 1px solid #bcd0c3;
  background: #fff;
  color: var(--ink);
}

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

.sync-control {
  display: grid;
  gap: 6px;
}

.sync-control button {
  background: var(--blue);
}

.sync-control button:disabled {
  cursor: wait;
  filter: grayscale(0.25);
  opacity: 0.72;
}

#scoreSyncStatus {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
}

#scoreSyncStatus[data-state="loading"] {
  color: var(--blue);
}

#scoreSyncStatus[data-state="success"] {
  color: var(--green);
}

#scoreSyncStatus[data-state="error"] {
  color: var(--red);
}

.table-wrap {
  width: 100%;
  min-width: 0;
  max-height: 830px;
  overflow: auto;
  margin-top: 14px;
}

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

th,
td {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

tbody tr.row-score-hit td:first-child {
  border-left: 5px solid var(--green);
}

tbody tr.row-outcome-hit td:first-child {
  border-left: 5px solid var(--blue);
}

tbody tr.row-miss td:first-child {
  border-left: 5px solid var(--red);
}

tbody tr.row-pending td:first-child {
  border-left: 5px solid #c8d1cd;
}

tbody tr.row-score-hit {
  background: linear-gradient(90deg, rgba(15, 138, 95, 0.08), transparent 18%);
}

tbody tr.row-outcome-hit {
  background: linear-gradient(90deg, rgba(52, 94, 168, 0.08), transparent 18%);
}

tbody tr.row-miss {
  background: linear-gradient(90deg, rgba(191, 75, 75, 0.08), transparent 18%);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbf8;
  color: var(--muted);
  font-size: 12px;
}

.match-cell {
  display: grid;
  gap: 4px;
  min-width: 210px;
}

.match-cell strong {
  font-size: 15px;
}

.match-meta,
.real-score {
  color: var(--muted);
  font-size: 12px;
}

.match-state {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-top: 7px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.state-live {
  background: #fff2d6;
  color: #9a6a12;
  border: 1px solid #e6bf69;
}

.state-upcoming {
  background: #eef2f4;
  color: var(--muted);
  border: 1px solid #d4ded9;
}

.state-played {
  background: #e7f6ee;
  color: var(--green);
  border: 1px solid #acdcbc;
}

.state-pending {
  background: #f1eef4;
  color: #65556f;
  border: 1px solid #d8cede;
}

.compare-hit,
.compare-miss,
.compare-pending {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.compare-hit {
  background: #dff4e8;
  color: var(--green);
  border: 1px solid #9bd5b4;
}

.compare-miss {
  background: #fae7e7;
  color: var(--red);
  border: 1px solid #efb8b8;
}

.compare-pending {
  background: #eef2f4;
  color: var(--muted);
  border: 1px solid #d7e0dc;
}

.compare-detail {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.history-list {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.history-match {
  display: grid;
  gap: 2px;
}

.history-match strong {
  color: var(--ink);
}

.history-match span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.history-average {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 10px;
  border-radius: 6px;
  background: #eef4f1;
  color: var(--ink);
  font-weight: 900;
}

.history-note {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.history-note span {
  color: var(--ink);
  font-weight: 800;
}

.history-note {
  padding: 8px 10px;
  border-radius: 6px;
}

.history-note.error-low {
  background: #e8f6ee;
  border: 1px solid #acdcbc;
}

.history-note.error-low span {
  color: var(--green);
}

.history-note.error-mid {
  background: #fff6df;
  border: 1px solid #e8ca7d;
}

.history-note.error-mid span {
  color: #9a6a12;
}

.history-note.error-high {
  background: #faeaea;
  border: 1px solid #efb6b6;
}

.history-note.error-high span {
  color: var(--red);
}

.history-note small {
  color: var(--muted);
}

.predicted-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  min-height: 34px;
  border-radius: 6px;
  background: #10271d;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}

.outcome-bars {
  display: grid;
  gap: 5px;
  min-width: 150px;
}

.bar {
  display: grid;
  grid-template-columns: 28px 1fr 42px;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eee9;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.bar:nth-child(2) .bar-fill {
  background: var(--amber);
}

.bar:nth-child(3) .bar-fill {
  background: var(--red);
}

.factor-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 170px;
}

.factor-tags span {
  padding: 5px 8px;
  border-radius: 999px;
  background: #eef4f1;
  color: #38524a;
  font-size: 12px;
}

.test-panel,
.model-panel,
.standings-panel,
.stars-panel {
  padding-bottom: 18px;
}

textarea {
  display: block;
  min-height: 210px;
  margin: 14px 18px 10px;
  width: calc(100% - 36px);
  resize: vertical;
  line-height: 1.5;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 18px;
}

.button-row button {
  padding: 0 8px;
  font-size: 13px;
}

.test-summary {
  margin: 14px 18px 0;
  color: var(--muted);
  line-height: 1.55;
}

.test-summary strong {
  color: var(--ink);
}

.factor-list {
  display: grid;
  gap: 10px;
  margin: 16px 18px 0;
  padding: 0;
  list-style: none;
}

.factor-list li {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

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

.factor-list span {
  color: var(--muted);
  line-height: 1.45;
}

.player-model-summary {
  display: grid;
  gap: 5px;
  margin: 14px 18px 0;
  padding: 12px;
  border: 1px solid #cfe0d4;
  border-radius: 6px;
  background: #f4faf6;
  line-height: 1.45;
}

.player-model-summary strong {
  color: var(--green);
}

.player-model-summary span {
  color: var(--muted);
}

.team-list {
  display: grid;
  gap: 8px;
  margin: 16px 18px 0;
}

.team-row {
  display: grid;
  grid-template-columns: 92px 1fr 42px;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}

.team-power-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eee9;
}

.team-power-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.star-list {
  display: grid;
  gap: 12px;
  margin: 14px 18px 0;
}

.star-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.star-team {
  display: grid;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.star-team:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.star-team-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.star-team-head span {
  color: var(--muted);
  font-size: 12px;
}

.star-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.star-chips span {
  display: grid;
  gap: 2px;
  min-width: 112px;
  padding: 7px 9px;
  border-radius: 6px;
  background: #f3f6f5;
  color: var(--muted);
  font-size: 12px;
}

.star-chips b {
  color: var(--ink);
  font-size: 12px;
}

.empty-state {
  padding: 28px 18px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .dashboard-grid,
  .content-grid,
  .controls {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-note {
    text-align: left;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 22px, 1500px);
    padding-top: 16px;
  }

  .prob-row,
  .button-row {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 34px;
  }
}
