:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f5f7f8;
  --text: #192026;
  --muted: #66727e;
  --line: #dfe5e8;
  --line-strong: #c6d0d6;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --amber: #b45309;
  --red: #b42318;
  --shadow: 0 16px 40px rgba(31, 42, 55, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.9)),
    url("logo.png") center 120px / min(70vw, 760px) auto no-repeat fixed,
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.header-logo {
  width: clamp(120px, 16vw, 210px);
  height: auto;
  flex: 0 0 auto;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1;
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1rem;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(118px, 1fr));
  gap: 10px;
  width: min(520px, 100%);
}

.summary-strip > div,
.schedule-section,
.penalty-editor-section,
.toolbar,
.table-section,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 9px 13px;
  background: #ffffff;
  color: #33404a;
  font-weight: 800;
  text-decoration: none;
}

.nav-button {
  margin-left: auto;
}

.nav-link.active {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

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

.login-panel {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-logo {
  display: block;
  width: min(190px, 60vw);
  height: auto;
  margin: 0 auto 18px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.login-form input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 11px;
  background: #ffffff;
  color: var(--text);
}

.schedule-section {
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 14px;
}

.schedule-note,
.status-line {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
}

.schedule-item {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfc;
}

.schedule-item.next {
  border-color: #99d4cc;
  background: #eef8f6;
}

.schedule-item span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.schedule-item strong {
  display: block;
  margin-top: 7px;
  font-size: 1rem;
}

.status-line {
  min-height: 22px;
  margin: -6px 0 12px;
}

.penalty-editor-section {
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 14px;
}

.penalty-editor {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
}

.penalty-editor-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 110px;
  align-items: end;
  gap: 8px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfc;
}

.penalty-editor-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.penalty-editor-row input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 9px;
  background: white;
  color: var(--text);
  font-weight: 700;
}

.penalty-amount-input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.penalty-editor-row .delete-penalty {
  grid-column: 1 / -1;
  width: 100%;
}

.summary-strip > div {
  min-height: 76px;
  border-radius: 8px;
  padding: 13px 14px;
}

.summary-strip span,
.toolbar label,
th .price {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.summary-strip strong {
  display: block;
  margin-top: 5px;
  font-size: 1.35rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 14px;
}

.toolbar label {
  display: grid;
  gap: 7px;
  min-width: 180px;
}

.toolbar input,
.toolbar select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 11px;
  color: var(--text);
  background: #fbfcfc;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
}

.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.primary-button {
  background: var(--teal);
  color: white;
}

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

.secondary-button {
  background: #eef8f6;
  color: var(--teal-dark);
  border-color: #b9ded8;
}

.ghost-button {
  background: #fff7ed;
  color: var(--amber);
  border-color: #fed7aa;
}

.table-section {
  overflow: hidden;
  border-radius: 8px;
}

.table-scroll {
  overflow: auto;
}

.table-scroll.small {
  max-height: 470px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: var(--panel);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  min-width: 124px;
  padding: 11px 10px;
  background: #eef3f4;
  color: #26323b;
  font-size: 0.83rem;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 220px;
  border-left: 1px solid var(--line);
}

th:first-child {
  z-index: 4;
  background: #e4ecee;
}

td:first-child {
  background: #fbfcfc;
}

td {
  padding: 8px;
}

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

tr.absent-player td,
tr.absent-player td:first-child {
  background: #edf0f2;
  color: #7a838b;
}

tr.absent-player .name-input,
tr.absent-player .amount-input,
tr.absent-player .counter {
  background: #e4e8eb;
  border-color: #c9d0d5;
}

tr.absent-player .row-total {
  color: #5e6870;
}

th .label {
  display: block;
  min-height: 38px;
  line-height: 1.15;
}

th .price {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 7px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #dbeafe;
  color: #1d4ed8;
}

th .price.round {
  background: #fef3c7;
  color: #92400e;
}

.name-input,
.amount-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
  background: white;
  color: var(--text);
  font-weight: 700;
}

.amount-input {
  min-width: 120px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.counter {
  display: grid;
  grid-template-columns: 36px minmax(38px, 1fr) 36px;
  align-items: center;
  width: 116px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow: hidden;
  background: #fbfcfc;
}

.counter button {
  width: 36px;
  height: 40px;
  border: 0;
  background: #edf2f4;
  color: #33404a;
  font-size: 1.2rem;
  font-weight: 900;
}

.counter button:hover {
  background: #dce6e9;
}

.counter button.minus {
  color: var(--red);
}

.counter button.plus {
  color: var(--teal-dark);
}

.counter output {
  display: grid;
  place-items: center;
  min-width: 38px;
  height: 40px;
  font-weight: 900;
}

.row-total {
  min-width: 112px;
  color: var(--teal-dark);
  font-weight: 900;
  text-align: right;
}

.results-section {
  margin-top: 18px;
}

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

.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.result-panel {
  border-radius: 8px;
  overflow: hidden;
}

.result-panel h3 {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.result-panel table th,
.result-panel table td {
  min-width: auto;
  padding: 10px 12px;
}

.result-panel table th:first-child,
.result-panel table td:first-child {
  position: static;
  min-width: auto;
}

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

.category-list {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fbfcfc;
}

.category-row strong {
  overflow-wrap: anywhere;
}

.category-row span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 24px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 20px, 1720px);
    padding-top: 18px;
  }

  .app-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .header-logo {
    align-self: center;
  }

  .summary-strip {
    width: 100%;
  }

  .toolbar-actions {
    width: 100%;
    margin-left: 0;
  }

  .nav-button {
    width: 100%;
    margin-left: 0;
    justify-content: center;
  }

  .toolbar-actions button {
    flex: 1;
  }

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

  .schedule-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .penalty-editor-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    flex-direction: column;
  }

  th:first-child,
  td:first-child {
    min-width: 170px;
  }

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