:root {
  --bg: #f5f1e8;
  --panel: #fffaf0;
  --ink: #251f18;
  --muted: #756b5c;
  --line: #d8cbb9;
  --dark: #17312b;
  --dark-2: #21493f;
  --gold: #c4913b;
  --red: #a33e34;
  --green: #3a745c;
  --shadow: 0 18px 45px rgba(37, 31, 24, 0.12);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 49, 43, 0.05) 25%, transparent 25%) 0 0 / 64px 64px,
    linear-gradient(90deg, transparent 75%, rgba(23, 49, 43, 0.05) 75%) 0 0 / 64px 64px,
    linear-gradient(0deg, rgba(23, 49, 43, 0.05) 25%, transparent 25%) 0 0 / 64px 64px,
    linear-gradient(0deg, transparent 75%, rgba(23, 49, 43, 0.05) 75%) 0 0 / 64px 64px,
    var(--bg);
}

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

button {
  border: 0;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: var(--dark);
  color: #fffaf0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fffaf0;
  color: var(--dark);
  font-size: 28px;
  box-shadow: inset 0 -4px 0 rgba(196, 145, 59, 0.45);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.05;
}

.brand p {
  margin: 4px 0 0;
  color: rgba(255, 250, 240, 0.72);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  background: transparent;
  border-radius: 8px;
  padding: 11px 12px;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 250, 240, 0.12);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  font-size: 13px;
  color: rgba(255, 250, 240, 0.72);
}

.content {
  padding: 30px;
  overflow: auto;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.subtitle {
  color: var(--muted);
  margin: 8px 0 0;
  max-width: 760px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--dark);
  color: #fffaf0;
  font-weight: 750;
}

.btn.secondary {
  background: #eadfce;
  color: var(--ink);
}

.btn.danger {
  background: var(--red);
}

.btn.ghost {
  background: transparent;
  color: inherit;
  border: 1px solid var(--line);
}

.btn.compact {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.panel {
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.panel-title {
  margin: 0;
  font-size: 18px;
}

.panel-body {
  padding: 18px;
}

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

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

.stat b {
  display: block;
  font-size: 26px;
}

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

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

.login {
  width: min(440px, 100%);
  background: rgba(255, 250, 240, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login .brand {
  color: var(--ink);
  margin-bottom: 24px;
}

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

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

textarea {
  resize: vertical;
  min-height: 96px;
}

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

.form-grid.full {
  grid-template-columns: 1fr;
}

.notice {
  border-radius: 8px;
  border: 1px solid rgba(196, 145, 59, 0.45);
  background: rgba(196, 145, 59, 0.12);
  color: #5e421a;
  padding: 12px;
  margin: 12px 0;
}

.error {
  color: var(--red);
  min-height: 20px;
  margin: 8px 0 0;
  font-size: 13px;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eadfce;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.pill.green {
  background: rgba(58, 116, 92, 0.16);
  color: var(--green);
}

.pill.gold {
  background: rgba(196, 145, 59, 0.18);
  color: #7b541c;
}

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

.team-card {
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 8px;
  padding: 12px;
}

.team-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.team-name {
  font-weight: 850;
}

.players {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.date-field {
  width: 180px;
}

.round-pool {
  min-width: 0;
}

.round-pool-title {
  margin-bottom: 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}

.score-pair {
  display: grid;
  grid-template-columns: minmax(46px, 1fr) auto minmax(46px, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 116px;
}

.score-pair input {
  min-height: 32px;
  padding: 6px;
  text-align: center;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  background: #eadfce;
  border-radius: 8px;
}

.tabs button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.tabs button.active {
  background: #fffaf0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(23, 49, 43, 0.55);
  padding: 20px;
  z-index: 20;
}

.modal {
  width: min(760px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

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

.source-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdf8;
}

.output-preview {
  width: min(820px, 100%);
  display: grid;
  gap: 8px;
  padding: 22px 26px;
  border-radius: 8px;
}

.output-preview span {
  font-size: 18px;
  font-weight: 900;
}

.output-preview strong {
  font-size: 42px;
  line-height: 1;
}

.output-preview em {
  font-size: 24px;
  font-style: normal;
  font-weight: 900;
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

  .content {
    padding: 20px;
  }

  .topbar,
  .team-main,
  .source-item {
    display: grid;
  }

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

  .grid.two,
  .stats,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
