/*
  Crest, the web app.

  No framework and no build step. The whole thing is three files the browser
  reads directly, which is deliberate: a club system that outlives its author
  should be editable by whoever holds it next without a toolchain that has to
  be resurrected first.

  Colours are tokens so a club accent can override one of them at runtime.
*/

:root {
  --ink: #0d1b2a;
  --ink-2: #33415c;
  --muted: #5c6b84;
  --line: #d9e0ea;
  --bg: #f6f8fb;
  --card: #ffffff;
  --accent: #1b6b4a;
  --accent-ink: #ffffff;
  --warn: #8a5a00;
  --bad: #9b2226;
  --good: #1b6b4a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(13, 27, 42, .06), 0 8px 24px rgba(13, 27, 42, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8edf4;
    --ink-2: #b9c4d4;
    --muted: #8a99b0;
    --line: #26303f;
    --bg: #0b1220;
    --card: #121b2b;
    --accent: #2f9e6e;
    --accent-ink: #06130d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.sr, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip:focus {
  position: fixed; inset: 8px auto auto 8px; z-index: 50;
  background: var(--card); padding: 8px 12px; border-radius: 8px;
}

/* ---------- the crest mark ---------- */

.mark { width: 56px; height: 63px; display: block; }
.mark path { fill: var(--accent); }
.mark .mark-inner { fill: var(--card); }
.mark.sm { width: 22px; height: 25px; }

/* ---------- sign in ---------- */

.signin {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 50% -10%, color-mix(in oklab, var(--accent) 18%, transparent), transparent 70%),
    var(--bg);
}

.signin-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 24px 24px;
  text-align: center;
}

.signin-card h1 {
  margin: 14px 0 2px;
  font-size: 26px;
  letter-spacing: .2px;
}

.signin-card .mark { margin: 0 auto; }

.lede { margin: 0 0 22px; color: var(--muted); }

.buttons { display: grid; gap: 10px; justify-items: center; }
.gbutton { display: flex; justify-content: center; min-height: 44px; }
/* Apple's own button carries its own dimensions. This only keeps it from
   jumping the layout before the SDK has filled it in. */
.applebutton { min-height: 44px; width: 240px; }
.applebutton[hidden] { display: none; }

.note { margin: 16px 0 0; color: var(--muted); font-size: 13.5px; min-height: 1.2em; }
.note.bad { color: var(--bad); }

.fineprint { margin-top: 22px; text-align: left; }
.fineprint summary { cursor: pointer; color: var(--muted); font-size: 13.5px; }
.fineprint p { color: var(--muted); font-size: 13.5px; }

/* ---------- chrome ---------- */

.top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 650; color: var(--ink); text-decoration: none;
  letter-spacing: .2px;
}

.orgpick { margin-left: auto; }

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

select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
  max-width: 60vw;
}

.who { display: inline-flex; align-items: center; gap: 10px; }
#whoami { color: var(--muted); font-size: 13.5px; }

button {
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 7px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.ghost { background: transparent; }
button.primary {
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
  font-weight: 600;
}
button[disabled] { opacity: .5; cursor: default; }

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tabs a {
  padding: 10px 12px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

main { padding: 20px 16px 48px; max-width: 1000px; margin: 0 auto; }

.foot {
  padding: 0 16px 28px;
  max-width: 1000px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- content ---------- */

h2 { font-size: 19px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 18px; }

.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
a.card { text-decoration: none; color: inherit; display: block; }
a.card:hover { border-color: var(--accent); }

.stat { font-size: 30px; font-weight: 640; letter-spacing: -.5px; }
.stat-label { color: var(--muted); font-size: 13px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

table { width: 100%; border-collapse: collapse; background: var(--card); }
.tablewrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: color-mix(in oklab, var(--accent) 14%, transparent);
  color: var(--accent); font-size: 12px; font-weight: 600;
}
.pill.grey { background: var(--bg); color: var(--muted); }
.pill.warn { background: color-mix(in oklab, var(--warn) 16%, transparent); color: var(--warn); }

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
}

.err {
  border: 1px solid color-mix(in oklab, var(--bad) 40%, var(--line));
  background: color-mix(in oklab, var(--bad) 8%, var(--card));
  border-radius: var(--radius);
  padding: 14px 16px;
}
.err code { color: var(--bad); }

/* access grants */

.grants { display: grid; gap: 8px; }
.grant {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px;
}
.grant .g-name { font-weight: 600; }
.grant .g-desc { color: var(--muted); font-size: 13px; }
.grant .g-body { flex: 1; min-width: 0; }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--line); transition: background .15s;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--card); transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:disabled + span { opacity: .5; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow);
  z-index: 40; font-size: 14px;
}

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .7s linear infinite; display: inline-block; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .orgpick { order: 3; margin-left: 0; width: 100%; }
  select { max-width: 100%; width: 100%; }
  .who { margin-left: auto; }
}
