:root {
  --brand: #1a2857;
  --accent: #e0b554;
  --brand-dark: #121c40;
  --ok: #1e7b4f;
  --danger: #b3261e;
  --bg: #f4f6f9;
  --card: #fff;
  --text: #1b1f24;
  --muted: #667085;
  --line: #e3e7ed;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1rem; margin-top: 1.4rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: .5rem 0; }
code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }

/* Layout */
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  background: var(--brand); color: #fff; padding: .8rem 1rem; padding-top: calc(.8rem + env(safe-area-inset-top));
}
.top { border-bottom: 3px solid var(--accent); }
.top .brand { font-weight: 700; display: flex; align-items: center; gap: .6rem; }
.top .brand img { height: 36px; width: auto; display: block; }
.top .who { font-size: .85rem; opacity: .9; display: flex; gap: .6rem; align-items: center; }
.top .link { color: #fff; text-decoration: underline; }
.tabs { display: flex; background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; position: sticky; top: 0; z-index: 500; }
.tabs a { padding: .8rem 1rem; color: var(--muted); white-space: nowrap; border-bottom: 3px solid transparent; font-weight: 500; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--accent); }
.subtabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.subtabs a { padding: .4rem .9rem; border-radius: 999px; background: #e7ecf3; color: var(--text); font-size: .9rem; }
.subtabs a.on { background: var(--brand); color: #fff; }
main { max-width: 860px; margin: 0 auto; padding: 1rem; }

.card { background: var(--card); border-radius: var(--radius); padding: 1rem; margin-bottom: .75rem; box-shadow: 0 1px 2px rgba(16,24,40,.06); border: 1px solid var(--line); }
.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }
.right { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.grow { flex: 1; min-width: 0; }

/* Auth */
.auth { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 1.5rem 1rem; }
.brand.big { text-align: center; font-size: 1.6rem; font-weight: 800; color: var(--brand); margin-bottom: 1rem; }
.notice { text-align: center; background: #fff7e0; border: 1px solid #f1d98a; padding: .6rem; border-radius: 8px; max-width: 420px; margin: 0 auto 1rem; }

/* Forms */
label { display: block; font-size: .9rem; font-weight: 500; margin-bottom: .8rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .65rem .75rem; font: inherit;
  border: 1px solid #cfd5dd; border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(26,40,87,.35); border-color: var(--brand); }
label.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
label.check input { width: auto; margin-top: .2rem; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-form .span2 { grid-column: span 2; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
.inline-form { display: flex; gap: .5rem; }
.inline-form select { margin: 0; flex: 1; }
.actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }
.search-row { display: flex; gap: .5rem; margin-bottom: .5rem; }
.search-row input { margin: 0; flex: 1; }
#map { height: 320px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: .4rem; z-index: 1; }
.filter { margin-bottom: .6rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  padding: .6rem 1rem; border-radius: 8px; border: 1px solid #cfd5dd; background: #fff; color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f2f4f7; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #f0c4c0; }
.btn.small { padding: .35rem .7rem; font-size: .85rem; }
.btn.big { padding: 1rem 1.4rem; font-size: 1.1rem; width: 100%; margin-top: .5rem; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.link.danger { color: var(--danger); }

/* Pills */
.pill { display: inline-block; padding: .25rem .6rem; border-radius: 999px; background: #eef1f5; font-size: .85rem; color: var(--muted); }
.pill.ok { background: #e3f4ea; color: var(--ok); font-weight: 600; }
.pill.small { font-size: .7rem; padding: .1rem .45rem; vertical-align: middle; }

/* Home / events */
.hero { display: flex; justify-content: space-between; align-items: center; background: linear-gradient(135deg, var(--brand), #2f4283); color: #fff; border: 0; }
.hero .muted { color: rgba(255,255,255,.8); }
.hero .btn { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.35); }
.big-num { font-size: 2.4rem; font-weight: 800; line-height: 1.1; }
.event { display: flex; gap: 1rem; justify-content: space-between; align-items: center; }
.event-title { font-weight: 700; font-size: 1.05rem; }
.event-main { min-width: 0; }
.event-side { display: flex; flex-direction: column; align-items: flex-end; gap: .5rem; text-align: right; }
.desc { margin-top: .3rem; font-size: .92rem; }
.pts { font-weight: 700; color: var(--brand); white-space: nowrap; }
.pts.neg { color: var(--danger); }

/* Lists */
.list { padding: 0; }
.list .row { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); color: inherit; }
.list .row:last-child { border-bottom: 0; }
.list a.row:hover { background: #f8f9fb; }
.list .row.me { background: #eef4fb; }
.list > p { padding: 1rem; margin: 0; }
.rank { width: 2rem; font-weight: 700; color: var(--muted); text-align: center; }
.list-head { display: flex; justify-content: space-between; align-items: center; margin-top: 1.4rem; margin-bottom: .5rem; }
.list-head h3 { margin: 0; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; padding: .2rem .6rem; border-radius: 6px; font-weight: 700; color: var(--muted); }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] > div { position: absolute; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: .4rem; z-index: 10; display: flex; flex-direction: column; min-width: 150px; }
.menu[open] > div .link { text-align: left; padding: .45rem .6rem; }

/* Admin detail */
.detail-head { display: flex; justify-content: space-between; gap: 1rem; }
.btn-col { display: flex; flex-direction: column; gap: .5rem; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.stat { text-align: center; }

/* Calendar */
.cal-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.cal-head h2 { flex: 1; text-align: center; margin: 0; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.dow { background: #f8f9fb; text-align: center; font-size: .75rem; font-weight: 600; color: var(--muted); padding: .35rem 0; }
.day { background: #fff; min-height: 86px; padding: .25rem; cursor: pointer; overflow: hidden; position: relative; }
.day:hover { background: #f6f9fd; }
.day.other { background: #fafbfc; color: #b0b7c3; }
.day.today .dnum { background: var(--brand); color: #fff; border-radius: 999px; }
.dnum { font-size: .8rem; font-weight: 600; width: 1.6rem; height: 1.6rem; display: flex; align-items: center; justify-content: center; }
.chip { display: block; font-size: .72rem; background: #f6ecd2; color: var(--brand-dark); border-radius: 4px; padding: 1px 4px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { display: none; }

/* QR screen */
.qr-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; padding: 1.5rem; background: #fff; text-align: center; }
.qr-screen > .btn { position: absolute; top: 1rem; left: 1rem; }
.qr-screen h1 { font-size: 2rem; }
.qr-screen .lead { font-size: 1.2rem; color: var(--muted); margin: 0; }
.qr-box { padding: 1rem; background: #fff; border: 1px solid var(--line); border-radius: 16px; min-width: 232px; min-height: 232px; display: flex; align-items: center; justify-content: center; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .1em; color: var(--text); }
.qr-count { font-size: 1.4rem; font-weight: 700; color: var(--ok); }

/* Toasts */
.toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #222; color: #fff; padding: .75rem 1.1rem; border-radius: 10px; max-width: min(92vw, 480px);
  box-shadow: 0 8px 24px rgba(0,0,0,.2); opacity: 0; transition: .25s; z-index: 2000; font-size: .95rem;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--ok); }
.toast.error { background: var(--danger); }

/* Phones */
@media (max-width: 600px) {
  .grid-form { grid-template-columns: 1fr; }
  .grid-form .span2 { grid-column: auto; }
  .event { flex-direction: column; align-items: stretch; }
  .event-side { flex-direction: row; justify-content: space-between; align-items: center; }
  .detail-head { flex-direction: column; }
  .btn-col { flex-direction: row; flex-wrap: wrap; }
  .day { min-height: 52px; }
  .chip { display: none; }
  .dot { display: inline-flex; position: absolute; bottom: 4px; right: 4px; background: var(--brand); color: #fff; font-size: .7rem; width: 1.1rem; height: 1.1rem; border-radius: 999px; align-items: center; justify-content: center; }
  .cal-head .btn.primary { padding: .5rem .7rem; }
  .cal-head h2 { font-size: 1.05rem; }
  .top .who span { display: none; }
  .search-row { flex-wrap: wrap; }
  .search-row input { flex-basis: 100%; }
}

/* Logo on the sign-in screens */
.brand.big img { display: block; width: 130px; height: auto; margin: 0 auto .75rem; }
