/* Royal Stock — base styles. Own look, taken from the Royal Bikes logo:
   deep brown #4a2c1b on cream #f9f4ee (docs/brand/royal-bikes-logo.jpeg). */
:root {
  --bg: #f9f4ee;          /* logo cream */
  --surface: #fffdfa;
  --ink: #2b1d14;
  --muted: #74604f;
  --line: #e9ddd0;
  --accent: #4a2c1b;      /* logo brown */
  --accent-ink: #f9f4ee;
  --ok: #2e7d4a;
  --warn: #a8691a;
  --bad: #b83227;
  --off: #a8998c;
  --radius: 12px;
  --mono: ui-monospace, "Cascadia Mono", "Consolas", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Slab/serif for the brand name and page titles — echoes the logo lettering. */
  --display: "Rockwell", "Roboto Slab", "Georgia", "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17110d;
    --surface: #211914;
    --ink: #f3e9df;
    --muted: #b8a493;
    --line: #3a2c22;
    --accent: #d9ab80;    /* lighter tan of the logo brown, readable on dark */
    --accent-ink: #1d140e;
    --ok: #5bbf7d;
    --warn: #e0a54a;
    --bad: #ef7a6c;
    --off: #7d6e62;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: var(--surface);
  border-bottom: 3px solid var(--accent);
}
.brand {
  display: flex; align-items: center; gap: 12px;
  font: 700 19px/1.1 var(--display); letter-spacing: .03em; color: var(--accent);
}
.mark {
  display: block; width: 40px; height: 40px; border-radius: 50%; flex: none;
  filter: drop-shadow(0 1px 1.5px rgba(43, 29, 20, .35));
}

/* ---- 3D logo coin (sign-in pages) ----
   Front + back faces of the 3D logo, with 10 stacked rings between them as the
   coin's thick edge. It sways slowly; a light streak follows the tilt. */
.logo-hero { display: flex; flex-direction: column; align-items: center; margin: 10px 0 -6px; }
.coin { width: 128px; height: 128px; perspective: 700px; }
.coin-spin {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transform: rotateY(-20deg) rotateX(6deg);
  animation: coin-sway 7s ease-in-out infinite alternate;
}
.coin-face, .coin-edge, .coin-shine { position: absolute; inset: 0; border-radius: 50%; }
.coin-face { width: 100%; height: 100%; backface-visibility: hidden; }
.coin-front { transform: translateZ(5px); }
.coin-back { transform: translateZ(-5px) rotateY(180deg); }
.coin-edge {
  transform: translateZ(calc(var(--z) * 1px));
  background: radial-gradient(circle at 35% 30%, #f1e8dc, #bfa98f 55%, #7a6350);
}
.coin-shine {
  transform: translateZ(5.5px); pointer-events: none;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 251, 243, .38) 48%, transparent 58%);
  background-size: 260% 100%;
  animation: coin-shine 7s ease-in-out infinite alternate;
}
.coin-shadow {
  width: 92px; height: 12px; margin-top: 12px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(43, 29, 20, .30), transparent);
  animation: coin-shadow 7s ease-in-out infinite alternate;
}
@keyframes coin-sway {
  from { transform: rotateY(-32deg) rotateX(8deg); }
  to   { transform: rotateY(32deg) rotateX(4deg); }
}
@keyframes coin-shine { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes coin-shadow {
  from { transform: translateX(5px) scaleX(.86); }
  to   { transform: translateX(-5px) scaleX(.86); }
}
@media (prefers-color-scheme: dark) {
  .coin-shadow { background: radial-gradient(closest-side, rgba(0, 0, 0, .55), transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .coin-spin, .coin-shine, .coin-shadow { animation: none; }
}
.hero h1, .form h1, .card > h1 { font-family: var(--display); color: var(--accent); letter-spacing: .01em; }
.env {
  font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted);
}
.env-dev { color: var(--warn); border-color: var(--warn); }
main { width: 100%; max-width: 880px; margin: 0 auto; padding: 24px 16px 40px; flex: 1; }
.hero h1 { margin: 8px 0 4px; font-size: 26px; }
.muted { color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-top: 18px;
}
.card h2 { margin: 0 0 12px; font-size: 17px; }
.status { margin: 0; display: grid; gap: 8px; }
.status div { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center; }
.status dt { color: var(--muted); }
.status dd { margin: 0; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--off); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); } .dot.off { background: var(--off); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.steps li {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
}
.steps li.done { border-color: var(--ok); }
.stepno { font: 700 13px var(--mono); color: var(--muted); }
.tag { font-size: 12px; color: var(--muted); }
.steps li.done .tag { color: var(--ok); font-weight: 700; }
.foot { text-align: center; padding: 12px; color: var(--muted); font: 12px var(--mono); }
@media (max-width: 560px) {
  .status div { grid-template-columns: 1fr; gap: 2px; }
}

/* ---- top bar: signed-in person ---- */
a.brand { text-decoration: none; }
.right { display: flex; align-items: center; gap: 14px; }
.who { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.who a { color: var(--ink); text-decoration: none; }
.who a:hover { text-decoration: underline; }
.who .name { font-weight: 600; }
.who form { margin: 0; }
.who, .brand-name { white-space: nowrap; }
.who .name { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) {
  .top { padding: 8px 14px; }
  .mark { width: 36px; height: 36px; }
  /* Phones: the round logo is the brand; the name stays for screen readers. */
  .brand-name {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%);
  }
}
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
button.link:hover { text-decoration: underline; }

/* ---- layout ---- */
main.narrow { max-width: 440px; }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.count { font: 600 13px var(--mono); color: var(--muted); margin-left: 6px; }
a { color: var(--accent); }

/* ---- forms ---- */
.form h1 { margin: 0 0 6px; font-size: 22px; }
.form form { display: grid; gap: 12px; margin-top: 12px; }
.form label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 44px;
}
input:focus, select:focus, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 1px; border-color: var(--accent); }
button {
  font: 600 15px var(--sans); background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 8px; padding: 10px 16px; min-height: 44px; cursor: pointer;
}
button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
button.secondary:hover { border-color: var(--muted); }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 2px 4px 2px 0; }
form.inline select, form.inline button { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.alert { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); border: 1px solid var(--bad); color: var(--ink); padding: 10px 12px; border-radius: 8px; margin: 10px 0 0; }
.notice { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); border: 1px solid var(--ok); color: var(--ink); padding: 10px 12px; border-radius: 8px; margin: 10px 0 0; }

/* ---- tables ---- */
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 8px; }
table.grid td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: middle; }
tr.inactive td { color: var(--muted); }
.tag-off { font: 600 11px var(--mono); text-transform: uppercase; color: var(--bad); border: 1px solid var(--bad); border-radius: 4px; padding: 0 4px; }

/* ---- phone tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.tile { border: 1px solid var(--line); border-radius: 10px; padding: 14px 10px; display: grid; gap: 4px; text-align: center; }
.tile.off { color: var(--muted); }
.tile span { font-size: 12px; }

@media (max-width: 640px) {
  .form .row { grid-template-columns: 1fr; }
  .who a { display: none; }
  table.grid thead { display: none; }
  table.grid, table.grid tbody, table.grid tr, table.grid td { display: block; width: 100%; }
  table.grid tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  table.grid td { border: 0; padding: 3px 0; }
}

/* ---- Tally page ---- */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.actions form { margin: 0; }
a.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px;
  border-radius: 8px; font: 600 15px var(--sans); text-decoration: none;
  background: var(--accent); color: var(--accent-ink);
}
a.button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
a.button.secondary:hover { border-color: var(--muted); }
button.big { min-height: 52px; padding: 12px 26px; font-size: 17px; }
button.danger { background: var(--bad); color: #fff; }
.howto { margin: 4px 0 0; padding-left: 22px; display: grid; gap: 6px; }
.alt-way { margin-top: 12px; }
.alt-way button.link { font-size: 14px; }
.status dd.wrap, td.wrap { flex-wrap: wrap; }
.status dd .inline { margin: 2px 0; }
.waiting { border-color: var(--warn); }
.waiting h2 { display: flex; align-items: center; gap: 10px; }
.dot.pulse { animation: dot-pulse 1.4s ease-in-out infinite; }
@keyframes dot-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .dot.pulse { animation: none; } }
.copybox {
  display: flex; align-items: stretch; gap: 8px; margin: 14px 0;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--bg);
}
.copybox code { flex: 1; font: 13px/1.45 var(--mono); word-break: break-all; align-self: center; }
.copybox button { flex: none; }
details.help summary { cursor: pointer; font-weight: 600; }
details.help[open] summary { margin-bottom: 10px; }
td .dot { display: inline-block; margin-right: 6px; vertical-align: middle; }
td.nowrap { white-space: nowrap; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 6px 0 16px; }
.choice { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: grid; gap: 8px; align-content: start; }
.choice h3 { margin: 0; font-size: 16px; }
.choice p { margin: 0; }
.choice form { margin: 4px 0 0; }
.warnbox { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border: 1px solid var(--warn); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
@media (max-width: 640px) { .choices { grid-template-columns: 1fr; } }
.actions + .howto, .copybox + .actions { margin-top: 14px; } details.help { margin-top: 14px; }
