:root {
  --ink: #183126;
  --muted: #64736b;
  --line: #d7e1d8;
  --panel: #ffffff;
  --page: #f3f7f1;
  --green: #176a3b;
  --green-dark: #0b4b2f;
  --green-soft: #e9f3ea;
  --gold: #e0b737;
  --gold-soft: #fff7d8;
  --red: #b33a2c;
  --blue: #23684b;
  --shadow: 0 12px 28px rgba(24, 49, 38, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(11, 75, 47, 0.08), transparent 240px),
    radial-gradient(circle at top right, rgba(224, 183, 55, 0.16), transparent 360px);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 48px);
  background: var(--green-dark);
  border-bottom: 5px solid var(--gold);
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(11, 75, 47, 0.25);
}

.app-header h1,
.panel-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  color: #ffffff;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 850;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.header-actions,
.auth-form,
.tabs,
.panel-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-panel {
  display: grid;
  gap: 8px;
  min-width: min(100%, 430px);
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.auth-status {
  color: #edf6ef;
  font-size: 13px;
  font-weight: 800;
}

.auth-form {
  align-items: stretch;
}

.auth-form input {
  min-width: 120px;
  min-height: 40px;
}

.hidden {
  display: none !important;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 26px clamp(14px, 3vw, 34px) 44px;
}

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

.summary-grid article,
.side-panel,
.main-panel,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.summary-grid article {
  padding: 16px;
  border-radius: 8px;
  border-top: 4px solid var(--green);
}

.summary-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.summary-grid strong {
  font-size: 20px;
  color: var(--green-dark);
}

.tabs {
  margin-bottom: 16px;
}

.tab,
.ghost-button,
.danger-button,
.primary-button,
.small-button {
  min-height: 40px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 750;
}

.tab {
  background: #ffffff;
  border-color: var(--line);
  color: var(--green-dark);
}

.tab.active {
  background: var(--green-dark);
  color: #ffffff;
}

.primary-button {
  background: var(--green-dark);
  color: #ffffff;
  border-color: var(--green-dark);
}

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

.ghost-button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-color: rgba(11, 75, 47, 0.18);
  color: var(--green-dark);
}

.danger-button {
  background: #fff0ed;
  border-color: #f1c5bd;
  color: var(--red);
}

.file-button input {
  display: none;
}

.discipline-panel {
  display: none;
}

.discipline-panel.active {
  display: block;
}

.panel-heading {
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--gold);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(260px, 330px) 1fr;
  gap: 16px;
  align-items: start;
}

.side-panel,
.main-panel {
  border-radius: 8px;
  padding: 16px;
}

.side-panel {
  border-top: 4px solid var(--green);
}

.side-panel {
  position: sticky;
  top: 12px;
}

h3 {
  margin: 0 0 12px;
  color: var(--green-dark);
}

.entry-form {
  display: grid;
  gap: 12px;
}

.settings-box {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
}

.settings-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--ink);
  background: #ffffff;
}

input:focus,
select:focus {
  border-color: var(--green);
  outline: 3px solid rgba(23, 106, 59, 0.18);
}

.entrant-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 16px 0 0;
  list-style: none;
}

.entrant-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  grid-template-areas:
    "main remove"
    "controls controls";
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.entrant-main {
  grid-area: main;
  display: grid;
  gap: 3px;
  min-width: 0;
}

.entrant-main small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.entrant-controls {
  grid-area: controls;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.strength-control,
.gender-control {
  gap: 4px;
  font-size: 11px;
}

.strength-control select,
.gender-control select {
  min-height: 34px;
  padding: 4px 7px;
}

@media (max-width: 560px) {
  .entrant-list li {
    grid-template-columns: 1fr 34px;
  }

  .entrant-controls {
    grid-template-columns: 1fr;
  }
}

.remove-button,
.score-button {
  border: 0;
  border-radius: 6px;
  min-height: 30px;
  padding: 0 9px;
  font-weight: 800;
}

.remove-button {
  grid-area: remove;
  background: #f8ddd8;
  color: var(--red);
}

.score-button {
  background: var(--green-dark);
  color: #ffffff;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.group-card,
.round-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.group-card header,
.round-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  background: var(--green-dark);
  color: #ffffff;
  border-bottom: 1px solid var(--line);
}

.group-card h4,
.round-card h4 {
  margin: 0;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--green-dark);
  font-size: 12px;
  text-transform: uppercase;
  background: #f7faf5;
}

.match-section,
.knockout-section {
  margin-top: 18px;
}

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

.match-row {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.match-row.match-done {
  background: #edf7ef;
  border-color: #a9d6b5;
}

.match-row.match-open {
  background: #fff2ef;
  border-color: #efc3bc;
}

.match-name {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid #bfd7c4;
  border-radius: 7px;
  padding: 7px 10px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 750;
  text-align: center;
  box-shadow: 0 2px 0 rgba(23, 33, 43, 0.04);
}

.match-pairing {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(23, 33, 43, 0.1);
}

.versus {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.match-controls {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(130px, 1fr) minmax(150px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.match-actions {
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
  white-space: nowrap;
}

.score-input {
  min-height: 36px;
}

.winner {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 850;
}

.score-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--gold-soft);
  color: #6a4c00;
  font-size: 12px;
  font-weight: 850;
}

.empty-state {
  display: grid;
  gap: 5px;
  justify-items: center;
  padding: 36px 16px;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.auth-gate {
  display: grid;
  gap: 6px;
  justify-items: center;
  min-height: 220px;
  align-content: center;
  padding: 28px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  text-align: center;
}

.auth-gate strong {
  color: var(--ink);
  font-size: 18px;
}

.empty-state strong {
  color: var(--ink);
}

.notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-weight: 700;
}

@media (max-width: 980px) {
  .app-header,
  .workspace-grid,
  .match-row {
    grid-template-columns: 1fr;
  }

  .app-header {
    display: grid;
  }

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

  .side-panel {
    position: static;
  }

  .match-row {
    justify-items: stretch;
  }

  .match-pairing,
  .match-controls {
    grid-template-columns: 1fr;
  }

  .match-actions {
    justify-content: flex-start;
  }

  .versus {
    justify-self: start;
  }
}
