:root {
  --bg: #f6f7f3;
  --surface: #ffffff;
  --ink: #17211d;
  --muted: #64706a;
  --line: #dce2dd;
  --primary: #176b57;
  --primary-dark: #10513f;
  --accent: #c44635;
  --profit: #147a4f;
  --loss: #b83227;
  --warn-bg: #fff4d7;
  --ok-bg: #e8f6ef;
  --shadow: 0 18px 45px rgba(29, 48, 41, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

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

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

button.ghost:hover {
  background: #eef3ef;
}

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

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 87, 0.14);
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

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

.topbar,
.toolbar,
.add-player,
.table-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.78rem;
}

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

h1 {
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1.05;
}

h2 {
  font-size: 1.25rem;
}

.session-controls {
  display: grid;
  grid-template-columns: minmax(180px, 280px) auto;
  align-items: end;
  gap: 10px;
  min-width: min(100%, 440px);
}

.session-controls label {
  grid-column: 1 / -1;
  margin-bottom: -4px;
}

.toolbar,
.add-player {
  display: grid;
  grid-template-columns: 1.4fr 220px 170px;
  gap: 14px;
  margin-top: 16px;
  padding: 18px;
  align-items: end;
}

.add-player {
  grid-template-columns: 1fr 140px auto;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.metric {
  min-height: 112px;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  min-height: 38px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  line-height: 1.1;
}

.metric.diff.ok {
  background: var(--ok-bg);
  border-color: #bce2cc;
}

.metric.diff.warn {
  background: var(--warn-bg);
  border-color: #efd37a;
}

.table-section {
  margin-top: 16px;
  overflow: hidden;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

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

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

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

th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-weight: 650;
}

.number-input {
  max-width: 150px;
}

.money-cell,
.result-cell {
  white-space: nowrap;
}

.result-cell.profit {
  color: var(--profit);
}

.result-cell.loss {
  color: var(--loss);
}

.actions-cell {
  width: 88px;
  text-align: right;
}

.delete-player {
  min-height: 36px;
  padding: 0 12px;
}

.empty-state {
  margin: 0;
  padding: 28px 18px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 860px) {
  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .session-controls,
  .toolbar,
  .add-player,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    gap: 10px;
  }

  .metric {
    min-height: 92px;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
  }

  td {
    display: grid;
    grid-template-columns: 118px 1fr;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  .actions-cell {
    display: flex;
    justify-content: flex-end;
    width: 100%;
  }

  .actions-cell::before {
    content: "";
  }

  .number-input {
    max-width: none;
  }
}
