:root {
  color: #17212f;
  background: #eef2f7;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(214, 231, 248, 0.95) 0, rgba(242, 246, 250, 0.86) 270px),
    #f4f7fb;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  flex: 0 0 auto;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 96px;
  margin-bottom: 18px;
  border: 1px solid rgba(185, 204, 224, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 18px 50px rgba(25, 45, 72, 0.1);
  padding: 18px 20px;
  backdrop-filter: blur(12px);
}

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

.team-switcher {
  min-width: 260px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #3b74a8;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

h1 {
  color: #111827;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1;
}

h2 {
  color: #172033;
  font-size: 1.22rem;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  font-weight: 700;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary-button {
  color: #ffffff;
  background: #2563eb;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
  padding: 0 16px;
}

.secondary-button {
  color: #1d4f7a;
  background: #dbeafe;
  padding: 0 16px;
}

.ghost-button {
  color: #334155;
  background: #eef2f7;
  padding: 0 14px;
}

.icon-button {
  width: 38px;
  height: 38px;
  color: #8d2f2f;
  background: #fee2e2;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-grid article {
  min-height: 106px;
  border: 1px solid #d9e3ee;
  border-radius: 8px;
  background: #ffffff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.summary-grid span {
  color: #64748b;
  font-size: 0.92rem;
  font-weight: 700;
}

.summary-grid strong {
  color: #172033;
  font-size: 2rem;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.single-panel {
  grid-template-columns: minmax(320px, 520px);
  margin-bottom: 18px;
}

.muted {
  margin: 7px 0 0;
  color: #64748b;
  font-size: 0.92rem;
  line-height: 1.4;
}

.match-panel {
  margin-bottom: 18px;
  overflow: hidden;
}

.aggregate-panel {
  margin-bottom: 18px;
  overflow: hidden;
}

.dashboard-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.dashboard-strip article {
  min-height: 84px;
  border: 1px solid #d9e3ee;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(25, 45, 72, 0.06);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.dashboard-strip span {
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.dashboard-strip strong {
  color: #172033;
  font-size: 1.8rem;
  line-height: 1;
}

.aggregate-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
  gap: 10px;
  padding: 8px 20px 14px;
  align-items: end;
}

.aggregate-band {
  min-height: 180px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  align-items: end;
}

.bar-pair {
  height: 146px;
  border-bottom: 1px solid #cbd5e1;
  background: linear-gradient(180deg, transparent 0, transparent 24%, rgba(203, 213, 225, 0.5) 25%, transparent 26%, transparent 49%, rgba(203, 213, 225, 0.5) 50%, transparent 51%, transparent 74%, rgba(203, 213, 225, 0.5) 75%, transparent 76%);
  padding: 0 3px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  align-items: end;
}

.bar {
  min-height: 7px;
  border-radius: 5px 5px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 900;
  padding-top: 4px;
}

.bar.for,
.legend-dot.for {
  background: #2563eb;
}

.bar.against,
.legend-dot.against {
  background: #b84242;
}

.aggregate-band strong {
  color: #64748b;
  font-size: 0.75rem;
  text-align: center;
}

.chart-legend {
  display: flex;
  gap: 16px;
  padding: 0 20px 20px;
  color: #475569;
  font-size: 0.9rem;
  font-weight: 800;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.team-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 480px);
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
  padding: 20px;
  border-left: 5px solid #2563eb;
}

.team-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.quick-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.matches-panel {
  margin-bottom: 18px;
  overflow: hidden;
}

.match-actions,
.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.save-match {
  width: auto;
  min-width: 150px;
}

.match-meta {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) 160px repeat(4, minmax(84px, 1fr)) 140px;
  gap: 10px;
  padding: 0 20px 18px;
  align-items: end;
}

.duration-card {
  min-height: 42px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  padding: 8px 12px;
  display: grid;
  gap: 1px;
}

.duration-card span,
.mini-heading span {
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 800;
}

.duration-card strong {
  color: #1d4ed8;
  font-size: 1.25rem;
  line-height: 1;
}

.lineup-grid,
.derived-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 0 20px 20px;
}

.lineup-grid > section,
.derived-grid > section,
.event-block {
  border-top: 1px solid #e2e8f0;
  padding-top: 16px;
}

.lineup-grid > section,
.derived-grid > section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
}

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

.mini-heading h3 {
  margin: 0;
  color: #172033;
  font-size: 1rem;
}

.lineup-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.events-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 0 20px 20px;
}

.event-block:first-child {
  grid-column: 1 / -1;
}

.event-list {
  display: grid;
  gap: 10px;
}

.event-row {
  display: grid;
  grid-template-columns: 92px repeat(3, minmax(160px, 1fr)) 42px;
  gap: 10px;
  align-items: end;
}

.event-block:not(:first-child) .event-row {
  grid-template-columns: 92px minmax(180px, 1fr) 42px;
}

.compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.inline-remove {
  align-self: end;
}

.empty-note {
  margin: 0;
  color: #64748b;
  font-size: 0.9rem;
}

.editing-row {
  background: #eff6ff;
}

.compact-table {
  max-height: 360px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

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

.compact-table th,
.compact-table td {
  padding: 9px 10px;
}

.bands-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
}

.bands-grid article {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
}

.bands-grid span {
  display: block;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 5px;
}

.bands-grid strong {
  color: #1d4ed8;
  font-size: 1.1rem;
}

.panel {
  border: 1px solid #d9e3ee;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 42px rgba(25, 45, 72, 0.07);
}

.add-player {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.add-player .primary-button {
  width: 100%;
}

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

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #ffffff;
  color: #17212f;
  padding: 0 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.stat-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.table-panel {
  min-width: 0;
  overflow: hidden;
}

.primary-stats-panel {
  margin-bottom: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 14px;
}

.compact-heading {
  padding: 0;
}

.section-heading span {
  color: #627269;
  font-size: 0.92rem;
  font-weight: 700;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 190px auto;
  gap: 10px;
  padding: 0 20px 18px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

tbody tr:nth-child(even) {
  background: #f8fafc;
}

tbody tr:hover {
  background: #eff6ff;
}

th,
td {
  border-top: 1px solid #e2e8f0;
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: #475569;
  background: #eef4fb;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0;
  position: sticky;
  top: 0;
  z-index: 1;
}

.sort-button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0;
  font: inherit;
  font-weight: 900;
  text-transform: uppercase;
}

.sort-button:hover {
  color: #2563eb;
}

td {
  color: #263244;
}

td input {
  width: 88px;
}

.player-name {
  color: #111827;
  font-weight: 800;
}

.empty-state {
  color: #64748b;
  text-align: center;
  padding: 32px 16px;
}

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

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

  .topbar-actions,
  .secondary-button {
    width: 100%;
  }

  .topbar-actions,
  .team-panel,
  .team-create,
  .quick-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .team-switcher {
    min-width: 0;
  }

  .summary-grid,
  .dashboard-strip,
  .workspace,
  .lineup-grid,
  .derived-grid,
  .events-grid,
  .match-meta {
    grid-template-columns: 1fr;
  }

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

  .filters {
    grid-template-columns: 1fr;
  }

  .event-block:first-child {
    grid-column: auto;
  }

  .event-row,
  .event-block:not(:first-child) .event-row {
    grid-template-columns: 1fr;
  }

  .inline-remove {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .summary-grid,
  .dashboard-strip,
  .stat-inputs,
  .lineup-list {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 11px 10px;
  }
}
