:root {
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #14201d;
  --muted: #61706a;
  --line: #dfe6e1;
  --accent: #0f7b5c;
  --accent-ink: #ffffff;
  --warn: #a45b12;
  --danger: #a62d35;
  --shadow: 0 14px 40px rgba(28, 40, 36, .09);
}

* { 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;
}

a { color: inherit; text-decoration: none; }

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

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

.auth-panel, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  width: min(440px, 100%);
  padding: 24px;
}

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

.brand small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

.compact .brand-mark {
  width: 32px;
  height: 32px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 24px 0 18px;
  padding: 4px;
  background: #edf2ee;
  border-radius: 8px;
}

.tab, .ghost {
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
  padding: 0;
}

.tab {
  border-radius: 6px;
  min-height: 40px;
  font-weight: 700;
}

.tab.active {
  background: #fff;
  box-shadow: 0 2px 10px rgba(20, 32, 29, .08);
}

.form-stack {
  display: grid;
  gap: 14px;
}

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

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

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

.primary, .pick {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  cursor: pointer;
}

.inline-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  text-decoration: none;
}

.message {
  min-height: 22px;
  color: var(--muted);
  margin: 14px 0 0;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--accent);
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 244, .92);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(10px);
}

.nav-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.ghost {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 12px;
  background: #fff;
  font-weight: 700;
}

.layout {
  width: min(1220px, calc(100% - 32px));
  margin: 24px auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.admin-layout {
  grid-template-columns: minmax(0, 1fr) 380px;
}

.panel {
  padding: 18px;
}

.side {
  display: grid;
  gap: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 16px;
}

.section-head.tight {
  align-items: center;
}

h1, h2, p {
  margin-top: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
  margin-bottom: 6px;
}

h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

p {
  color: var(--muted);
  line-height: 1.45;
}

.matches, .admin-list {
  display: grid;
  gap: 10px;
}

.phase-section {
  display: grid;
  gap: 10px;
}

.phase-section + .phase-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.phase-section h2 {
  margin-bottom: 0;
}

.match-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.match-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  font-weight: 850;
  margin-bottom: 12px;
}

.teams span:last-child {
  text-align: right;
}

.vs {
  color: var(--muted);
  font-weight: 700;
}

.picks {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.pick {
  background: #f0f5f2;
  color: var(--ink);
  border: 1px solid var(--line);
}

.pick.selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pick:disabled {
  cursor: not-allowed;
  opacity: .62;
}

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

.rank-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.score {
  font-weight: 900;
  color: var(--accent);
}

.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 30px;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(130px, 1fr) minmax(130px, 1fr) 140px 100px;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

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

.history-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
}

.history-row span {
  color: var(--muted);
}

.history-row b {
  color: var(--accent);
}

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

.hidden {
  display: none !important;
}

@media (max-width: 880px) {
  .layout, .admin-layout {
    grid-template-columns: 1fr;
  }

  .section-head {
    display: grid;
  }

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

  .admin-row button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 0 12px;
  }

  .brand.compact strong {
    display: none;
  }

  .layout {
    width: calc(100% - 20px);
    margin-top: 10px;
  }

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