/* Infinity Loops. Brand colours from the Infinity ABA logo (infinityaba.com). */
:root {
  --blue: #349fda;        /* logo infinity blue */
  --green: #9bcc63;       /* logo infinity green */
  --coral: #f05b67;       /* logo wing */
  --yellow: #ede354;      /* logo wing */
  --ink: #1d1d1f;         /* logo black */
  --navy: #112f5b;        /* headings */
  --primary: #1a73b3;     /* darker logo blue: passes contrast for white text and links */
  --primary-press: #145d92;
  --muted: #5d6573;
  --bg: #f4f8fc;
  --card: #fff;
  --line: #e1e8f0;
  --pos: #2f7d32;
  --neg: #c42f3c;
  --warnbg: #fff6e0;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(17, 47, 91, .06), 0 4px 14px rgba(17, 47, 91, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); min-height: 100dvh; }
main { max-width: 960px; margin: 0 auto; padding: 16px; }
a { color: var(--primary); }
h1 { font-size: 1.6rem; margin: 8px 0 12px; color: var(--navy); letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 24px 0 8px; color: var(--navy); }
.small { font-size: .875rem; } .center { text-align: center; }
.devbar { background: var(--neg); color: #fff; text-align: center; font-weight: 600; padding: 4px; font-size: 14px; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; gap: 16px; align-items: center; padding: calc(10px + var(--safe-t)) 16px 10px; background: var(--card); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); font-size: 1.1rem; margin-right: auto; }
.brand img { display: block; height: 33px; width: auto; }
.brand b { color: var(--primary); }
.top nav.desk { display: flex; gap: 4px; }
.top nav.desk a { text-decoration: none; color: var(--muted); font-weight: 600; padding: 8px 12px; border-radius: 999px; }
.top nav.desk a:hover { background: var(--bg); }
.top nav.desk a[aria-current="page"] { color: var(--primary); background: #e8f3fb; }
.signout { font-size: .9rem; color: var(--muted) !important; }
.stripe { height: 4px; background: linear-gradient(90deg, var(--green) 0 25%, var(--blue) 25% 50%, var(--coral) 50% 75%, var(--yellow) 75% 100%); }

/* Install hint */
.install-hint { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: center; background: #e8f3fb; color: var(--navy); padding: 10px 16px; font-size: .9rem; }
.install-hint a { font-weight: 700; }
.install-hint[hidden] { display: none; }

/* Bottom tab bar (phones) */
.tabbar { display: none; }
@media (max-width: 720px) {
  .top nav.desk { display: none; }
  body.has-tabs main { padding-bottom: calc(88px + var(--safe-b)); }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255, 255, 255, .96); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; min-height: 50px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; }
  .tabbar svg { width: 26px; height: 26px; fill: currentColor; }
  .tabbar a[aria-current="page"] { color: var(--primary); }
}

/* Home: points hero */
.hello { margin: 4px 0 10px; color: var(--muted); font-size: 1.05rem; }
.hello { color: var(--navy); font-weight: 600; }
.hero { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 14px; color: #fff; border-radius: 20px; padding: 26px 24px 30px; background: linear-gradient(135deg, var(--primary) 0%, #2a8fd2 65%, #3fa6c9 100%); box-shadow: var(--shadow); }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: linear-gradient(90deg, var(--green) 0 25%, var(--blue) 25% 50%, var(--coral) 50% 75%, var(--yellow) 75% 100%); }
.hero .num { font-size: 3.4rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.hero .label { font-size: 1.1rem; opacity: .9; }
@media (min-width: 721px) { .hero { max-width: 520px; } }
.hero-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hero-sm { padding: 18px 20px 24px; margin: 8px 0 4px; }
.hero-sm .num { font-size: 2.6rem; }

/* Infinity loop: every 20 points draws one full loop of the logo's infinity sign */
.loopwrap { display: flex; align-items: center; gap: 14px; background: #fff; color: var(--navy); border-radius: 16px; padding: 10px 14px; }
.loop { width: 136px; flex: none; height: auto; }
.loop-text { flex: 1; min-width: 0; }
.loop-track, .loop-fill { fill: none; stroke-width: 11; stroke-linecap: round; stroke-linejoin: round; }
.loop-track { stroke: #e6edf4; }
.loop-text p { margin: 0; }
.loop-count { font-size: 1.05rem; } .loop-count b { font-size: 1.6rem; color: var(--primary); }
.loop-next { color: var(--muted); font-size: .85rem; }
@media (max-width: 380px) { .loop { width: 120px; } }

/* Exchange: the supervisor's main action */
.exchange { box-shadow: inset 0 5px 0 var(--coral), var(--shadow); }
.exchange-info { box-shadow: inset 5px 0 0 var(--coral), var(--shadow); padding-left: 20px; }
.exchange-info p { margin: 6px 0; }
button.accent { background: #c8384a; border-color: #c8384a; }
button.accent:active { background: #a92c3c; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
button.chip { min-height: 38px; padding: 6px 14px; border-radius: 999px; background: #fff; color: var(--navy); border: 1px solid var(--line); font-size: .9rem; }
button.chip[aria-pressed="true"] { background: #fdecee; border-color: var(--coral); color: #a92c3c; }
.tag.ex { background: #fdecee; color: #a92c3c; }

/* + / - stepper: big thumb targets instead of the tiny native spinner */
.field { display: flex; flex-direction: column; gap: 6px; }
.flabel { font-weight: 600; }
.stepper { display: flex; align-items: stretch; gap: 8px; max-width: 280px; }
.stepper input { text-align: center; font-size: 1.4rem; font-weight: 700; min-width: 0; flex: 1; -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
button.step { width: 56px; min-height: 52px; padding: 0; font-size: 1.6rem; line-height: 1; border-radius: 12px; background: #e8f3fb; color: var(--primary); border-color: #cfe4f4; flex: none; }
button.step:active { background: #d4e8f7; }

/* Add / Subtract segmented toggle */
.seg { display: flex; background: #eef2f7; border-radius: 12px; padding: 4px; gap: 4px; }
.seg label { flex: 1; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; justify-content: center; align-items: center; min-height: 44px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: #fff; color: var(--pos); box-shadow: var(--shadow); }
.seg label:nth-child(2) input:checked + span { color: var(--neg); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.give.is-subtract button[type="submit"] { background: var(--neg); border-color: var(--neg); }
.give.is-subtract .chips { display: none; }

/* Staff profile: compact header + balance bar + one action card with tabs */
.phead { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.phead .back { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); text-decoration: none; font-size: 1.2rem; flex: none; }
.pwho { min-width: 0; }
.pwho h1 { font-size: 1.3rem; margin: 0; }
.pwho p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.balbar { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, var(--primary), #2a8fd2); color: #fff; border-radius: 16px; padding: 8px 10px 8px 16px; box-shadow: var(--shadow); }
.balnum { display: flex; flex-direction: column; line-height: 1; flex: none; }
.balnum b { font-size: 2rem; font-weight: 800; }
.balnum span { font-size: .8rem; opacity: .9; margin-top: 2px; }
.loopwrap.compact { flex: 1; padding: 6px 10px; gap: 10px; border-radius: 12px; min-width: 0; }
.loopwrap.compact .loop { width: 76px; }
.loopwrap.compact .loop-count { font-size: .9rem; } .loopwrap.compact .loop-count b { font-size: 1.15rem; }
.loopwrap.compact .loop-next { font-size: .78rem; }

.tabs { padding: 6px 12px 14px; }
.tab-r { position: absolute; opacity: 0; pointer-events: none; }
.tablist { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 -12px 12px; padding: 0 8px; }
.tablist label { flex: 1; text-align: center; padding: 10px 4px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; margin: 0 0 -1px; min-height: 44px; }
#pane-points:checked ~ .tablist label[for="pane-points"],
#pane-note:checked ~ .tablist label[for="pane-note"] { color: var(--primary); border-color: var(--primary); }
#pane-exchange:checked ~ .tablist label[for="pane-exchange"] { color: #a92c3c; border-color: var(--coral); }
.tab-r:focus-visible ~ .tablist { outline: 2px solid var(--primary); outline-offset: 2px; }
.tabs .pane { display: none; }
#pane-points:checked ~ .p-points, #pane-exchange:checked ~ .p-exchange, #pane-note:checked ~ .p-note { display: flex; }
.tabs .stack { gap: 10px; }
.tabs .exchange { box-shadow: none; }
.tabs .hint { font-size: .78rem; }
.tabs .stepper { max-width: none; }
.chips.scrollx { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -12px; padding: 0 12px 2px; }
.chips.scrollx::-webkit-scrollbar { display: none; }
.chips.scrollx .chip { flex: none; white-space: nowrap; }

/* Quieter secondary actions */
button.ghost { background: #fff; color: var(--primary); border-color: #cfe4f4; }
details.retract { margin-top: 6px; }
details.retract summary { cursor: pointer; color: var(--muted); font-size: .85rem; min-height: 32px; display: flex; align-items: center; }
tr[hidden] { display: none !important; }

/* Loop draws itself in on load */
.loop-fill { animation: loopdraw 1.1s ease-out both; }
@keyframes loopdraw { from { stroke-dasharray: 0 100; } }
@media (prefers-reduced-motion: reduce) { .loop-fill { animation: none; } }

/* Staff list: name + points first */
@media (max-width: 640px) {
  .table.staff td.c-title:empty { display: none; }
  .table.staff td.c-pts { font-size: 1.25rem; }
}
/* Manager view of someone else's balance */
.balance { display: flex; align-items: baseline; gap: 8px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; width: fit-content; }
.balance .num { font-size: 2.6rem; font-weight: 800; color: var(--primary); } .balance .label { color: var(--muted); }

/* Login / install / offline */
body.centered main { min-height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.login { text-align: center; max-width: 420px; margin: 24px auto 8px; }
.login-mark { display: block; margin: 8px auto 12px; height: auto; }
.login h1 { font-size: 1.8rem; }
.steps ol { padding-left: 1.2em; margin: 0; } .steps li { margin: 6px 0; }

/* Messages */
.muted { color: var(--muted); } .hint { color: var(--neg); font-size: .85rem; margin: 0; }
.ok { background: #eaf6e4; color: #24502a; padding: 10px 14px; border-radius: 10px; }
.warn { background: var(--warnbg); border-left: 4px solid #f0a020; padding: 10px 14px; border-radius: 10px; }

/* Tables */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.scroll .table { box-shadow: none; }
.table th, .table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table.small { font-size: .85rem; } .table code { white-space: pre-wrap; word-break: break-word; }
.pos { color: var(--pos); font-weight: 700; } .neg { color: var(--neg); font-weight: 700; }
tr.reversed td, tr.inactive td, li.retracted .body { color: var(--muted); } li.retracted .body { text-decoration: line-through; }
tr.flag td { background: var(--warnbg); }
/* Phones: table rows become cards */
@media (max-width: 640px) {
  .table.cards, .table.cards tbody { display: block; background: none; box-shadow: none; }
  .table.cards thead { display: none; }
  .table.cards tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 10px; }
  .table.cards td { border: 0; padding: 0; grid-column: 1 / -1; }
  .table.cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  .table.cards td.c-main { grid-column: 1; font-weight: 600; }
  .table.cards td.c-main::before, .table.cards td.c-pts::before, .table.cards td.c-date::before, .table.cards td.c-by::before { content: none; }
  .table.cards td.c-pts { grid-column: 2; grid-row: 1; font-size: 1.25rem; text-align: right; }
  .table.cards td.c-date, .table.cards td.c-by { font-size: .8rem; color: var(--muted); }
  .table.cards td.c-date { order: 3; } .table.cards td.c-by { order: 4; }
  .table.cards td.c-act { order: 5; }
  .table.cards td.c-act:empty { display: none; }
}

/* Lists, cards, forms */
.tag { display: inline-block; font-size: .75rem; padding: 0 8px; border-radius: 10px; background: #eef2f7; color: var(--muted); font-weight: 600; }
.notes, .list { list-style: none; padding: 0; }
.notes li, .list li { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 10px; border-left: 4px solid var(--green); }
.notes .meta { font-size: .8rem; color: var(--muted); } .notes .body { white-space: pre-wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin: 12px 0; }
.card h2 { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; } .stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; } .inline { display: inline; }
/* 16px inputs stop iOS from zooming in on focus */
input, textarea, select { font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); min-height: 44px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
textarea { min-height: 90px; }
button, .button { font: inherit; font-weight: 600; min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button:active, .button:active { background: var(--primary-press); }
button[hidden] { display: none; }
.button.big { padding: 14px 28px; font-size: 1.05rem; border-radius: 12px; }
button.small { min-height: 36px; padding: 4px 12px; font-size: .85rem; }
button.danger { background: var(--neg); border-color: var(--neg); }
button.link { background: none; border: none; color: var(--primary); padding: 0; min-height: 0; text-decoration: underline; font-weight: 500; }
@media (max-width: 640px) { .table.cards td.c-empty { display: none; } }
.push[hidden] { display: none; } .push h2 { margin-bottom: 4px; }
