:root {
  --bg: #f4f4f4;
  --ink: #1c1c1c;
  --muted: #737373;
  --line: #ececec;
  --card: #ffffff;
  --green: #009a34;
  --green-deep: #007a29;
  --green-soft: #e7f8ee;
  --yellow: #ffcc00;
  --yellow-soft: #fff4c2;
  --amber: #7a5b00;
  --danger: #c43838;
  --shadow: 0 8px 24px rgba(20, 20, 20, 0.04);
  --font: "Plus Jakarta Sans", "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-weight: 800; letter-spacing: -0.03em; margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); margin: 0; }
.boot { padding: 32px; color: var(--muted); }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 0.92rem; font-weight: 500; }

.brand-pills { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-decoration: none;
  line-height: 1.2;
}
.pill.green { background: var(--green); color: white; }
.pill.yellow { background: var(--yellow); color: #1c1c1c; }
.pill.outline {
  background: white;
  color: var(--ink);
  border: 1px solid #e4e4e4;
  font-weight: 700;
  padding: 8px 14px;
  font-size: 0.88rem;
}
.pill.outline:hover, a.pill.yellow:hover { filter: brightness(0.97); }
a.pill.yellow { padding: 8px 14px; font-size: 0.88rem; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.gate-card h1 { font-size: 2.4rem; margin: 14px 0 2px; }
.lede { color: var(--muted); margin: 14px 0 22px; line-height: 1.45; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 0.92rem; font-weight: 600; }
input, select {
  width: 100%;
  border: 1px solid #e6e6e6;
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
}
input:focus, select:focus {
  outline: 2px solid #b7ebc8;
  border-color: var(--green);
}
button[type="submit"], .primary {
  border: 0;
  background: var(--green);
  color: white;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 700;
}
button[type="submit"]:hover { background: var(--green-deep); }
button:disabled { opacity: 0.6; cursor: wait; }
.form-error { min-height: 1.2em; margin: 0; color: var(--danger); font-size: 0.9rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 28px 14px;
  background: rgba(244, 244, 244, 0.92);
  backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 1.8rem; margin-top: 8px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.who { font-size: 0.92rem; color: var(--muted); font-weight: 600; margin-right: 4px; }

.app { padding-bottom: 48px; }
.banner, .stats, .filters, .result-count, .roster {
  width: min(1080px, calc(100% - 32px));
  margin-left: auto;
  margin-right: auto;
}
.banner {
  width: min(1280px, calc(100% - 16px));
  margin-top: 8px;
  background: var(--green-soft);
  color: #0b6b2c;
  border-radius: 18px;
  padding: 14px 28px;
  line-height: 1.45;
  font-weight: 600;
}
.stats {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 12px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  text-align: left;
}
.stat strong {
  display: block;
  font-size: 1.7rem;
  font-weight: 800;
  margin-top: 4px;
  letter-spacing: -0.03em;
}
.stat span { color: var(--muted); font-size: 0.86rem; font-weight: 600; }
.stat.money strong { color: var(--green); }
button.stat {
  cursor: pointer;
  appearance: none;
  margin: 0;
  width: 100%;
  font: inherit;
  line-height: inherit;
}
button.stat.is-on { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.progress {
  margin-top: 10px;
  height: 8px;
  background: #f0f0f0;
  border-radius: 99px;
  overflow: hidden;
}
.progress span { display: block; height: 100%; background: var(--green); }

.filters {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 0.7fr) auto;
  gap: 10px;
  align-items: end;
}
body.is-vocal .admin-only { display: none !important; }
body.is-vocal .filters { grid-template-columns: 1fr auto; }
.admin-nav {
  width: min(1080px, calc(100% - 32px));
  margin: 16px auto 0;
  display: flex;
  gap: 8px;
}
.admin-nav button {
  border: 1px solid #e4e4e4;
  background: white;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
}
.admin-nav button.is-on { background: var(--green); color: white; border-color: transparent; }
.admin-panel { width: min(1080px, calc(100% - 32px)); margin: 16px auto 0; display: grid; gap: 12px; }
.admin-form, .inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}
.admin-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.admin-form label, .inline-form label { display: grid; gap: 4px; font-size: 0.86rem; font-weight: 700; color: var(--muted); }
.admin-form input, .admin-form select, .inline-form input {
  border: 1px solid #e4e4e4;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: white;
}
.admin-form .form-error { flex-basis: 100%; }
.admin-form button, .inline-form button {
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: white;
  font-weight: 800;
  padding: 10px 14px;
}
.admin-search { max-width: 420px; }
.secret {
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.vocal-line { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid #f3f3f3; }
.vocal-line p { margin: 2px 0 0; color: var(--muted); font-size: 0.86rem; }
.segment {
  display: flex;
  background: #efefef;
  border-radius: 999px;
  padding: 4px;
}
.segment button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
}
.segment button.is-on { background: var(--green); color: white; }
.result-count { color: var(--muted); font-size: 0.9rem; font-weight: 600; }

.roster {
  margin-top: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.group-label {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fafafa;
  border: 0;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
}
.group-label:hover { background: #f3f3f3; }
.group-title { display: inline-flex; align-items: center; gap: 8px; }
.group-label strong { font-size: 1.02rem; font-weight: 800; }
.chevron {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.75rem;
  transition: transform 140ms ease;
}
.group-label.is-open .chevron { transform: rotate(90deg); }
.student {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px 16px;
  align-items: center;
  padding: 13px 16px;
  border-top: 1px solid #f3f3f3;
}
.student h3 { font-weight: 700; font-size: 1rem; letter-spacing: -0.02em; }
.student p { margin: 2px 0 0; color: var(--muted); font-size: 0.86rem; }
.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 800;
}
.badge.pending { background: var(--yellow); color: #1c1c1c; }
.badge.paid { background: var(--green-soft); color: var(--green-deep); }
.amount { font-weight: 700; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.row-actions button, .row-actions a, .text-btn {
  border-radius: 999px;
  border: 1px solid #e6e6e6;
  background: white;
  padding: 8px 12px;
  text-decoration: none;
  font-weight: 700;
}
.row-actions a.receipt { color: var(--green-deep); }
.row-actions .mark { background: var(--green); color: white; border-color: transparent; }
.row-actions .mark:hover { background: var(--green-deep); }
.text-btn { color: var(--danger); background: transparent; }
.empty { padding: 28px 16px; color: var(--muted); }

dialog {
  border: 0;
  border-radius: 22px;
  padding: 22px;
  width: min(440px, calc(100% - 24px));
  box-shadow: 0 18px 50px rgba(20, 20, 20, 0.16);
}
dialog::backdrop { background: rgba(20, 20, 20, 0.35); }
.dialog-name { font-size: 1.15rem; font-weight: 800; margin: 8px 0 0; }
.preview {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--green-soft);
  color: var(--green-deep);
  font-weight: 700;
}
.ghost, .dialog-actions .ghost {
  border: 1px solid #e4e4e4;
  background: white;
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.danger { background: var(--danger) !important; color: white !important; border-color: transparent !important; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 160ms ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  .stats, .filters { grid-template-columns: 1fr 1fr; }
  body.is-vocal .filters { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .student { grid-template-columns: 1fr; }
}
