:root {
  --bg: #f4f7f5;
  --paper: #fffefa;
  --ink: #17231f;
  --muted: #6a756f;
  --line: #d8ded8;
  --line-strong: #b9c3bb;
  --jade: #13715c;
  --jade-dark: #0a4d41;
  --coral: #d95842;
  --gold: #bd8c2f;
  --mint: #dceee5;
  --wash: #edf3ef;
  --shadow: 0 18px 50px rgba(22, 35, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background:
    linear-gradient(90deg, rgba(19, 113, 92, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(19, 113, 92, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
}

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

button {
  cursor: pointer;
}

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

.topbar,
.panel-heading,
.participant-toolbar,
.form-actions,
.split-actions,
.member-form,
.nav-tabs {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar h1,
.panel-heading h2 {
  margin: 0;
  line-height: 1.1;
}

.topbar h1 {
  font-size: clamp(30px, 4.2vw, 56px);
  font-weight: 900;
}

.panel-heading h2 {
  font-size: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--jade);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

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

.nav-tabs {
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.82);
  box-shadow: var(--shadow);
}

.nav-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.nav-button.is-active {
  color: #ffffff;
  background: var(--jade);
  box-shadow: 0 10px 22px rgba(19, 113, 92, 0.2);
}

.page {
  display: none;
}

.page.is-active {
  display: block;
}

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

.summary-tile {
  min-height: 96px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.88);
  box-shadow: var(--shadow);
}

.summary-tile span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-tile strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1;
}

.leader-tile strong {
  color: var(--jade-dark);
  font-size: clamp(22px, 3vw, 32px);
}

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

.board-grid {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.58fr);
  align-items: start;
}

.entry-panel,
.rank-panel,
.ledger-panel,
.member-panel,
.recent-panel {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.95);
  box-shadow: var(--shadow);
}

.entry-panel,
.rank-panel,
.ledger-panel,
.member-panel,
.recent-panel {
  padding: 18px;
}

.panel-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.activity-form,
.member-form {
  width: 100%;
}

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

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

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--jade);
  box-shadow: 0 0 0 4px rgba(19, 113, 92, 0.12);
}

.participant-toolbar {
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.participant-toolbar strong {
  font-size: 16px;
}

.participant-toolbar div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.participant-card {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 220px;
  gap: 10px;
  align-items: center;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.participant-card.is-selected {
  border-color: rgba(19, 113, 92, 0.52);
  background: linear-gradient(180deg, #ffffff 0%, #eef8f3 100%);
  box-shadow: 0 10px 24px rgba(19, 113, 92, 0.12);
}

.participant-card:hover {
  transform: translateY(-1px);
}

.participant-card input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--jade);
}

.participant-card input[type="number"],
.participant-card select {
  min-height: 36px;
  padding: 0 8px;
  text-align: center;
}

.contribution-inputs {
  display: grid;
  grid-template-columns: 82px repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.contribution-inputs span {
  display: grid;
  gap: 3px;
}

.contribution-inputs small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.person-name {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-role,
.small-note {
  color: var(--muted);
  font-size: 12px;
}

.form-actions {
  justify-content: flex-end;
  padding-top: 4px;
}

.primary-button,
.ghost-button,
.text-button,
.chip-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 900;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.primary-button {
  min-width: 128px;
  padding: 0 18px;
  color: #ffffff;
  background: var(--jade);
  box-shadow: 0 12px 28px rgba(19, 113, 92, 0.24);
}

.primary-button:hover,
.ghost-button:hover,
.text-button:hover,
.chip-button:hover {
  transform: translateY(-1px);
}

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

.primary-button.compact {
  min-width: 72px;
}

.ghost-button,
.chip-button,
.text-button {
  color: var(--ink);
  background: #ffffff;
  border-color: var(--line);
}

.ghost-button,
.text-button {
  padding: 0 14px;
}

.ghost-button.danger {
  color: var(--coral);
}

.chip-button {
  min-height: 34px;
  padding: 0 11px;
  color: var(--jade-dark);
  background: var(--mint);
  border-color: rgba(19, 113, 92, 0.18);
  font-size: 13px;
}

.text-button {
  min-width: 68px;
}

.rank-panel {
  position: sticky;
  top: 16px;
}

.rank-panel select {
  max-width: 150px;
}

.ranking-list,
.activity-list,
.member-list,
.recent-list {
  display: grid;
  gap: 10px;
}

.share-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.share-box[hidden] {
  display: none;
}

.rank-row {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 78px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.rank-row::before {
  position: absolute;
  inset: auto auto 0 0;
  width: var(--bar, 0%);
  height: 4px;
  content: "";
  background: linear-gradient(90deg, var(--jade), var(--gold));
}

.rank-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 900;
  background: var(--ink);
}

.rank-row.top-1 .rank-number {
  background: var(--gold);
}

.rank-row.top-2 .rank-number {
  background: var(--jade);
}

.rank-row.top-3 .rank-number {
  background: var(--coral);
}

.rank-meta {
  min-width: 0;
}

.rank-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 5px;
}

.rank-name strong {
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-badge,
.inactive-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.role-badge {
  color: var(--jade-dark);
  background: var(--mint);
}

.inactive-badge {
  color: var(--coral);
  background: #fde7e2;
}

.rank-sub {
  color: var(--muted);
  font-size: 12px;
}

.rank-score {
  min-width: 66px;
  text-align: right;
}

.rank-score strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.rank-score span {
  color: var(--muted);
  font-size: 12px;
}

.activity-item,
.recent-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.recent-item {
  grid-template-columns: 1fr;
}

.activity-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.activity-title strong {
  font-size: 17px;
}

.date-pill,
.location-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.location-pill {
  color: var(--jade-dark);
  background: var(--mint);
}

.score-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.score-chip {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--jade-dark);
  background: var(--wash);
  font-size: 12px;
  font-weight: 800;
}

.activity-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.item-actions {
  display: grid;
  gap: 8px;
  align-content: start;
}

.mini-button {
  min-width: 58px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.mini-button.danger {
  color: var(--coral);
}

.member-form {
  gap: 8px;
  margin-bottom: 12px;
}

.member-form input {
  min-width: 0;
}

.member-form select {
  width: 116px;
}

.member-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 116px 74px 54px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.member-row input,
.member-row select {
  min-height: 36px;
}

.toggle-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--mint);
  color: var(--jade-dark);
  font-weight: 900;
}

.toggle-button.is-off {
  color: var(--muted);
  background: #f3f3f0;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.54);
  text-align: center;
}

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

  .rank-panel {
    position: static;
  }
}

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

  .topbar,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .split-actions {
    justify-content: flex-start;
  }

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

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

  .participant-card {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .contribution-inputs {
    grid-column: 2;
  }

  .activity-item,
  .recent-item,
  .member-row,
  .share-box {
    grid-template-columns: 1fr;
  }

  .item-actions {
    display: flex;
    flex-wrap: wrap;
  }

  .member-form {
    align-items: stretch;
    flex-direction: column;
  }

  .member-form select {
    width: 100%;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .top-actions,
  .nav-tabs,
  .entry-panel,
  .ledger-panel,
  .member-panel,
  .recent-panel {
    display: none;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

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

  .rank-panel,
  .summary-tile {
    box-shadow: none;
  }
}
