:root {
  color-scheme: light;
  --bg: #f8faf7;
  --panel: #ffffff;
  --panel-strong: #eef5f1;
  --text: #182523;
  --muted: #65736f;
  --line: #dce7e2;
  --brand: #135d54;
  --brand-strong: #0e463f;
  --accent: #f4d35e;
  --danger: #b83232;
  --danger-bg: #fff0f0;
  --ok-bg: #e8f6ef;
  --wait-bg: #fff7d8;
  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;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 20px;
}

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

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

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #16883a;
  display: grid;
  place-items: center;
  padding: 0;
  flex: 0 0 auto;
  overflow: hidden;
}

button.brand-mark:hover {
  background: #16883a;
  filter: brightness(1.05);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

button.brand-mark:focus-visible {
  outline: 3px solid rgba(19, 93, 84, 0.24);
  outline-offset: 3px;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.1;
}

.brand p,
.muted {
  margin: 0;
  color: var(--muted);
}

.login {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 28px 0;
}

.login-panel,
.admin-panel,
.profile-panel,
.session,
.empty-state,
.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-panel {
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.login-panel h1,
.section-title,
.admin-panel h2,
.profile-panel h2 {
  margin: 0 0 10px;
  font-size: 1.35rem;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  min-height: 44px;
}

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

input:focus,
textarea:focus,
select:focus {
  outline: 3px solid rgba(19, 93, 84, 0.18);
  border-color: var(--brand);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  min-height: 42px;
  border-radius: 6px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 750;
  background: var(--panel-strong);
  color: var(--text);
  text-decoration: none;
}

.btn.primary {
  background: var(--brand);
  color: white;
}

.btn.primary:hover {
  background: var(--brand-strong);
}

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

.btn.ghost {
  background: transparent;
  color: var(--brand);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel-strong);
  border-radius: 8px;
}

.view-tabs {
  flex: 0 1 auto;
}

.tab {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.tab.active {
  background: white;
  color: var(--brand);
  box-shadow: 0 1px 2px rgba(18, 37, 33, 0.08);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.side-stack {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 16px;
}

.admin-panel,
.profile-panel {
  padding: 18px;
}

.calendar-sync {
  margin: 0 0 18px;
}

.calendar-sync details {
  background: transparent;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.calendar-sync summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 750;
}

.calendar-sync-body {
  display: grid;
  gap: 10px;
  padding-top: 12px;
}

.calendar-link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.calendar-link-row input {
  color: var(--muted);
  font-size: 0.88rem;
}

.calendar-steps {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.calendar-steps li + li {
  margin-top: 4px;
}

.session-list {
  display: grid;
  gap: 12px;
}

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

.session {
  padding: 18px;
}

.session.cancelled {
  background: #f7f1f1;
}

.session-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.session h3 {
  margin: 0 0 8px;
  font-size: 1.12rem;
}

.session-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 0.94rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.84rem;
  font-weight: 800;
  background: var(--panel-strong);
  color: var(--text);
  white-space: nowrap;
}

.badge.attending {
  background: var(--ok-bg);
  color: #12603f;
}

.badge.waitlisted {
  background: var(--wait-bg);
  color: #705600;
}

.badge.cancelled {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.declined {
  background: #eef0f3;
  color: #515b68;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--panel-strong);
  overflow: hidden;
  margin: 14px 0 10px;
}

.progress > span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  max-width: 100%;
  background: var(--brand);
}

.people {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.people-group {
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.people-group h4 {
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.people-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.people-list small {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.match-list,
.match-editor {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.match-list h4,
.match-editor h4 {
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.match-card,
.match-draft {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  padding: 10px;
}

.match-card + .match-card,
.match-draft + .match-draft {
  margin-top: 8px;
}

.match-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.match-score {
  font-weight: 850;
  white-space: nowrap;
}

.match-teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.match-teams em {
  color: var(--text);
  font-style: normal;
  font-weight: 800;
}

.match-reporter {
  font-size: 0.82rem;
  margin: 8px 0 0;
}

.result-form {
  display: grid;
  grid-template-columns: minmax(0, 96px) minmax(0, 96px) auto;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
}

.result-form label {
  display: grid;
  gap: 4px;
}

.result-form input {
  min-height: 38px;
  padding: 8px 10px;
}

.ranking-list {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  padding: 10px;
}

.ranking-list h4 {
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.ranking-list ol {
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.ranking-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.ranking-list small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.match-editor-head,
.match-draft-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.match-draft-head {
  align-items: center;
  margin-bottom: 10px;
}

.match-draft-head > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

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

.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.substitute-session-controls {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.substitute-session-controls h4 {
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.substitute-session-list {
  display: grid;
  gap: 8px;
}

.substitute-session-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--text);
}

.substitute-session-row strong,
.substitute-session-row small {
  display: block;
}

.substitute-session-row small {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.notice,
.empty-state {
  padding: 14px;
}

.notice {
  margin: 0 0 12px;
  border-color: #cde8df;
  background: #eef8f4;
}

.notice.error {
  border-color: #f0c5c5;
  background: var(--danger-bg);
  color: var(--danger);
}

.member-admin {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.choice-block {
  margin-top: 16px;
}

.choice-block h3 {
  margin: 0 0 8px;
  font-size: 0.96rem;
}

.check-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding-right: 2px;
}

.check-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--text);
  font-size: 0.92rem;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  margin: 2px 0 0;
  padding: 0;
}

.check-row span,
.admin-list span {
  min-width: 0;
}

.check-row strong,
.admin-list strong {
  display: block;
}

.check-row small,
.admin-list small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

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

.admin-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fbfcfb;
}

.btn.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.84rem;
}

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

  .side-stack {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .session-head,
  .list-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
    justify-content: stretch;
  }

  .form-grid,
  .people,
  .match-slot-grid,
  .match-teams,
  .result-form {
    grid-template-columns: 1fr;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

  .btn {
    width: 100%;
  }

  .admin-list li,
  .substitute-session-row,
  .calendar-link-row {
    grid-template-columns: 1fr;
  }
}
