:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #18202a;
  --muted: #687282;
  --line: #d9dee7;
  --blue: #1261a6;
  --green: #13785f;
  --amber: #9b6615;
  --shadow: 0 8px 24px rgba(24, 32, 42, 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;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  min-height: 38px;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  border-color: #9fabba;
}

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

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  max-width: 1480px;
  margin: 0 auto;
}

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

.controls {
  padding: 16px;
  align-self: start;
  position: sticky;
  top: 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.mark {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--blue);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 15px;
}

.brand p,
.hint,
.status {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.compare-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--blue);
  background: #fff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.compare-link:hover {
  border-color: #9fabba;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  background: #fff;
}

.segmented button.active {
  background: var(--text);
  color: #fff;
}

.section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

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

.icon-btn {
  width: 38px;
  font-size: 18px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 9px;
}

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

.primary {
  width: 100%;
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  margin-top: 16px;
  font-weight: 700;
}

.results {
  display: grid;
  gap: 18px;
}

.scoreboard {
  min-height: 118px;
  background: #17202b;
  color: #fff;
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr 180px;
  align-items: center;
  padding: 22px;
}

.scoreboard strong {
  display: block;
  font-size: 30px;
  line-height: 1.2;
  margin-top: 6px;
}

.eyebrow {
  color: #aeb9c8;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 700;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

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

.metrics span {
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  font-size: 26px;
  margin-top: 8px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.results .panel {
  padding: 16px;
}

dl {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 1.2fr;
  gap: 8px 14px;
  margin: 12px 0 0;
  font-size: 14px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 700;
}

.takeaways {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.takeaway-card {
  border: 1px solid #edf0f4;
  border-radius: 6px;
  padding: 12px;
  min-height: 104px;
  display: grid;
  align-content: start;
  gap: 5px;
}

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

.takeaway-card strong {
  font-size: 18px;
  line-height: 1.2;
}

.takeaway-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.list,
.bars,
.table {
  margin-top: 12px;
}

.row,
.bar-row,
.table-row {
  display: grid;
  grid-template-columns: 130px 1fr 70px;
  gap: 10px;
  align-items: center;
  min-height: 32px;
  border-bottom: 1px solid #edf0f4;
  font-size: 13px;
}

.table-row {
  grid-template-columns: 50px 1fr 1fr 88px 120px;
}

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

.period-header,
.period-row {
  display: grid;
  grid-template-columns: 90px repeat(6, 110px);
  gap: 10px;
  align-items: center;
  min-width: 780px;
  min-height: 34px;
  border-bottom: 1px solid #edf0f4;
  font-size: 13px;
}

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

.period-header {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
  margin-top: 12px;
}

.period-header span:not(:first-child),
.period-row span {
  text-align: right;
}

.first-basket-header,
.first-basket-row {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) 150px repeat(4, 86px);
  gap: 10px;
  align-items: center;
  min-width: 760px;
  min-height: 34px;
  border-bottom: 1px solid #edf0f4;
  font-size: 13px;
}

.first-basket-table {
  overflow-x: auto;
  margin-top: 12px;
}

.first-basket-header {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
}

.first-basket-header span:nth-child(n + 3),
.first-basket-row span:nth-child(n + 3) {
  text-align: right;
}

.analysis-table {
  overflow-x: auto;
  margin-top: 12px;
}

.analysis-header,
.analysis-row {
  display: grid;
  gap: 10px;
  align-items: center;
  min-height: 34px;
  min-width: 720px;
  border-bottom: 1px solid #edf0f4;
  font-size: 13px;
}

.analysis-header {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
}

.analysis-row span:nth-last-child(-n + 3),
.analysis-header span:nth-last-child(-n + 3) {
  text-align: right;
}

.ranges-grid {
  grid-template-columns: minmax(190px, 1fr) 150px repeat(4, 90px);
}

.team-box {
  margin-top: 14px;
  overflow-x: auto;
}

.team-box h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.box-header,
.box-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) repeat(7, 58px);
  gap: 8px;
  align-items: center;
  min-width: 620px;
  min-height: 34px;
  border-bottom: 1px solid #edf0f4;
  font-size: 13px;
}

.box-header {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
}

.box-header span:not(:first-child),
.box-row span {
  text-align: right;
}

.box-row > strong {
  display: grid;
  gap: 2px;
}

.stat-cell {
  display: grid;
  gap: 2px;
}

.stat-cell strong {
  font-size: 13px;
}

.stat-cell small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
}

.stat-cell.over-hit strong {
  color: var(--green);
}

.stat-cell.under-hit strong {
  color: #b42318;
}

.pbp-header,
.pbp-row {
  display: grid;
  grid-template-columns: 80px 150px minmax(260px, 1fr) 150px 90px;
  gap: 10px;
  align-items: center;
  min-width: 820px;
  min-height: 34px;
  border-bottom: 1px solid #edf0f4;
  font-size: 13px;
}

.pbp-table {
  overflow-x: auto;
  max-height: 560px;
  margin-top: 12px;
}

.pbp-header {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
  position: sticky;
  top: 0;
  background: #fff;
}

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

.bar-fill {
  height: 100%;
  background: var(--blue);
}

@media (max-width: 980px) {
  .workspace,
  .grid,
  .metrics,
  .scoreboard,
  .takeaways {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
  }
}
