:root {
  --navy: #12284c;
  --navy-700: #1c3a68;
  --navy-600: #24487d;
  --gold: #e5b53f;
  --gold-dark: #c99a24;
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #16233b;
  --muted: #6b7896;
  --line: #e4e9f2;
  --green: #2f9e6f;
  --red: #d64550;
  --shadow: 0 2px 8px rgba(18, 40, 76, 0.08);
  --shadow-lg: 0 10px 30px rgba(18, 40, 76, 0.16);
  --radius: 14px;
  --radius-sm: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px calc(14px);
  padding-top: calc(14px + env(safe-area-inset-top));
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-600) 100%);
  color: #fff;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  font-weight: 800;
  letter-spacing: 0.5px;
  background: var(--gold);
  color: var(--navy);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 15px;
}
.brand-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.season-picker { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.season-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; opacity: 0.75; }
#season-select {
  appearance: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 6px 30px 6px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
#season-select option { color: #16233b; }

/* ---------- Tabs / nav ---------- */
.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(18, 40, 76, 0.06);
}
.tab {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-top: 3px solid transparent;
  transition: color 0.15s;
}
.tab.active { color: var(--navy); border-top-color: var(--gold); background: rgba(229, 181, 63, 0.08); }

/* ---------- Layout ---------- */
.view { max-width: 920px; margin: 0 auto; padding: 16px; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }

.page-title { font-size: 20px; font-weight: 800; margin: 4px 0 14px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin: 22px 0 10px; font-weight: 700; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.muted { color: var(--muted); font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Goal card ---------- */
.goal-card {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-700) 100%);
  color: #fff;
  border: none;
}
.goal-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.goal-collected { font-size: 30px; font-weight: 800; line-height: 1.1; }
.goal-of { font-size: 14px; opacity: 0.8; }
.goal-sub { display: flex; justify-content: space-between; margin-top: 4px; font-size: 13px; opacity: 0.85; }
.progress {
  height: 12px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0 6px;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold) 0%, #f3cd6b 100%);
  border-radius: 999px;
  transition: width 0.5s ease;
}
.goal-pct { font-weight: 700; }
.goal-edit {
  margin-top: 12px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
}

/* ---------- Stat chips ---------- */
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; text-align: center; box-shadow: var(--shadow); }
.chip .num { font-size: 20px; font-weight: 800; }
.chip .lbl { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }

/* ---------- Member bar chart ---------- */
.barchart { display: flex; flex-direction: column; gap: 14px; padding: 4px 2px; }
.bar-row { display: flex; flex-direction: column; gap: 6px; }
.bar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.bar-name { font-size: 13px; font-weight: 600; color: var(--ink); min-width: 0; }
.bar-val { font-size: 13px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.bar-track { height: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--navy) 0%, var(--gold) 100%);
  transition: width 0.5s ease;
}

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: none; }
.rank {
  width: 26px; height: 26px; flex: 0 0 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--bg);
  font-size: 12px; font-weight: 800; color: var(--muted);
}
.rank.top { background: var(--gold); color: var(--navy); }
.amount { font-weight: 800; font-variant-numeric: tabular-nums; }
.count-pill { font-size: 12px; color: var(--muted); background: var(--bg); padding: 2px 8px; border-radius: 999px; }

.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.4px; }
.badge.board { background: rgba(229,181,63,0.18); color: var(--gold-dark); }
.badge.member { background: rgba(36,72,125,0.1); color: var(--navy-600); }
.badge.inactive { background: #eef0f4; color: var(--muted); }

.linkcard { cursor: pointer; text-decoration: none; color: inherit; display: block; }
.linkcard:hover { border-color: var(--gold); }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: var(--bg);
  color: var(--ink);
  transition: transform 0.05s, filter 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.gold { background: var(--gold); color: var(--navy); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.danger { background: transparent; color: var(--red); border-color: rgba(214,69,80,0.3); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.icon { padding: 6px 10px; background: transparent; color: var(--muted); }
.btn.icon:hover { color: var(--navy); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--navy-600);
  box-shadow: 0 0 0 3px rgba(36,72,125,0.12);
}
.field textarea { min-height: 64px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.inline-form { display: grid; gap: 10px; }

/* ---------- Meeting detail ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.back:hover { color: var(--navy); }
.fine-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.fine-row:last-child { border-bottom: none; }
.fine-comment { font-size: 13px; color: var(--muted); font-style: italic; margin-top: 2px; }
.member-tag { font-weight: 700; }
.meeting-total { font-size: 22px; font-weight: 800; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty h3 { margin: 0 0 4px; color: var(--ink); }

/* ---------- Modal ---------- */
.modal {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(440px, 92vw);
  box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: rgba(18,40,76,0.4); backdrop-filter: blur(2px); }
.modal form { padding: 20px; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--navy);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }

/* ---------- Desktop ---------- */
@media (min-width: 760px) {
  body { padding-bottom: 24px; }
  .app-header { padding: 16px 24px; padding-top: calc(16px + env(safe-area-inset-top)); }
  .brand-name { font-size: 17px; }
  .tabs {
    position: sticky;
    top: 0;
    bottom: auto;
    border-top: none;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    max-width: 920px;
    margin: 0 auto;
    border-radius: 0 0 var(--radius) var(--radius);
  }
  .tab { border-top: none; border-bottom: 3px solid transparent; padding: 14px 4px; font-size: 14px; }
  .tab.active { border-top: none; border-bottom-color: var(--gold); }
  .view { padding: 22px 24px 40px; }
  .page-title { font-size: 24px; }
}

/* ---------- Header user / logout ---------- */
.header-right { display: flex; align-items: center; gap: 12px; }
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header .btn.ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
}
.app-header .btn.ghost:hover { background: rgba(255, 255, 255, 0.16); }
@media (max-width: 480px) {
  .user-name { display: none; }
}

/* ---------- Login page ---------- */
.login-body {
  min-height: 100dvh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-700) 55%, #0d1d38 100%);
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
  background: var(--card, #fff);
  border-radius: 18px;
  padding: 28px 24px 26px;
  box-shadow: var(--shadow-lg, 0 20px 50px rgba(0, 0, 0, 0.35));
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .brand-mark { font-size: 18px; padding: 6px 10px; }
.login-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.login-brand-text strong { font-size: 16px; color: var(--ink); }
.login-brand-text span { font-size: 12px; color: var(--muted); }
.login-title { margin: 0 0 4px; font-size: 22px; color: var(--ink); }
.login-sub { margin: 0 0 20px; font-size: 14px; color: var(--muted); }
.login-card .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.login-card .field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.login-card .field input {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
}
.login-card .field input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(229, 181, 63, 0.25);
}
.login-error {
  min-height: 18px;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
}
.btn.block { width: 100%; }
.btn.block[disabled] { opacity: 0.7; cursor: default; }
.login-foot {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

