/* Phive: the day as a calm list. White or near-black (system), hairlines, Phive yellow for actions.
   Yellow on white fails text contrast: in light mode it only fills, with dark ink on top. */

:root {
  --bg: #ffffff;
  --bg-2: #f4f4f5;
  --bg-elev: #ffffff;
  --line: rgba(9, 9, 11, 0.08);
  --line-2: rgba(9, 9, 11, 0.14);
  --ring: #8a8a93;
  --text: #0a0a0b;
  --text-2: #5c5c66;
  --text-3: #75757f;
  --accent: #ffbb02;
  --accent-text: #0a0a0b;
  --accent-ink: #1a1400;
  --accent-soft: rgba(255, 187, 2, 0.24);
  --focus: #0a0a0b;
  --warn: #c2410c;
  --warn-soft: rgba(194, 65, 12, 0.1);
  --dot: #0a0a0b;
  --accent-edge: rgba(138, 93, 0, 0.45);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.1);
  --scrim: rgba(9, 9, 11, 0.32);
  --lift: 0 1px 2px rgba(9, 9, 11, 0.04), 0 8px 24px rgba(9, 9, 11, 0.06);
  --sheet-shadow: 0 -8px 40px rgba(9, 9, 11, 0.12);
  --tabbar: calc(58px + env(safe-area-inset-bottom));
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0e;
    --bg-2: #1c1c20;
    --bg-elev: #18181b;
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.16);
    --ring: #6e6e78;
    --text: #f4f4f5;
    --text-2: #a6a6b0;
    --text-3: #8a8a94;
    --accent: #ffbb02;
    --accent-text: #ffbb02;
    --accent-ink: #1a1400;
    --accent-soft: rgba(255, 187, 2, 0.18);
    --focus: #ffbb02;
    --dot: #ffbb02;
    --accent-edge: transparent;
    --warn: #fb923c;
    --warn-soft: rgba(251, 146, 60, 0.14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, 0.12);
    --scrim: rgba(0, 0, 0, 0.55);
    --lift: none;
    --sheet-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  caret-color: var(--focus);
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
img { display: block; }

#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; }
.view { padding: max(env(safe-area-inset-top), 12px) 20px calc(var(--tabbar) + 32px); }

/* Titles */
.page-title { margin: 24px 0 2px; font-size: 34px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; text-wrap: balance; }
.page-sub { margin: 0 0 16px; color: var(--text-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.section-title { margin: 36px 0 4px; font-size: 20px; font-weight: 700; letter-spacing: -0.015em; }
.section-title:first-child { margin-top: 8px; }
.section-note { margin: 0 0 8px; font-size: 15px; color: var(--text-2); }

/* Week strip: numbered circles, a dot under days with a booking */
.sticky {
  position: sticky; top: 0; z-index: 5; margin: 4px -20px 0; padding: 8px 20px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.days { display: grid; grid-template-columns: repeat(7, 1fr); }
.day { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 2px 0 8px; position: relative; color: var(--text-3); }
.day small { font-size: 12px; font-weight: 600; }
.day b {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  font-size: 17px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.day:active b { transform: scale(0.9); }
.day.is-today small { color: var(--text); font-weight: 700; }
.day.is-selected b { background: var(--text); color: var(--bg); }
.day.is-selected.is-today b { background: var(--accent); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent-edge); }
.day.has-booking::after { content: ""; position: absolute; bottom: 1px; width: 5px; height: 5px; border-radius: 50%; background: var(--dot); }

.day-caption { margin: 18px 0 2px; color: var(--text-2); font-size: 15px; display: flex; justify-content: space-between; align-items: baseline; }
.day-caption b { color: var(--text); font-weight: 600; }
.link { color: var(--accent-text); font-weight: 600; font-size: 15px; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }

/* Lists: no cards, hairlines between items */
.list { display: flex; flex-direction: column; }

.row {
  position: relative; display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center;
  width: 100%; min-height: 64px; padding: 12px 0; text-align: left;
  transition: opacity 0.2s var(--ease);
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 66px; right: 0; height: 1px; background: var(--line); }
.row[role="button"] { cursor: pointer; }
.row:active .main { opacity: 0.6; }
.row.is-past { opacity: 0.4; }
.row .time { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.row .time b { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.row .time span { font-size: 13px; color: var(--text-3); }
.row .main { min-width: 0; transition: opacity 0.15s var(--ease); }
.row .name { display: block; font-size: 17px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { display: block; margin-top: 2px; font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.row .meta .dot { color: var(--text-3); padding: 0 5px; }
.row .side { display: flex; align-items: center; justify-content: flex-end; min-width: 44px; }

.spots { font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.spots.is-low { color: var(--warn); font-weight: 600; }
.spots.is-full { color: var(--danger); font-weight: 600; }
.spots.is-closed, .spots.is-past { color: var(--text-3); }
.opens { font-size: 13px; font-weight: 600; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* The booking circle. Tapping an open one books in place. */
.tick { display: grid; place-items: center; width: 44px; height: 44px; margin: -10px -9px -10px 0; flex: none; }
.tick-c {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--ring); color: var(--accent-ink);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.tick-c svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 20; stroke-dashoffset: 20; }
button.tick:active .tick-c { transform: scale(0.86); border-color: var(--accent); }
.tick.is-on .tick-c { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-edge); }
.tick.is-closed .tick-c { border-style: dashed; border-color: var(--line-2); }
.tick.is-off .tick-c { border-color: var(--line-2); background: var(--bg-2); }
.tick.is-on .tick-c svg { stroke-dashoffset: 0; }
.tick.is-busy .tick-c { border-color: var(--focus); border-right-color: transparent; animation: spin 0.8s linear infinite; }
.tick.is-pop .tick-c { animation: tick-fill 0.36s var(--ease); }
.tick.is-pop .tick-c svg { animation: tick-draw 0.32s 0.12s var(--ease) both; }
@keyframes tick-fill { from { transform: scale(0.72); background: transparent; } to { transform: scale(1); } }
@keyframes tick-draw { from { stroke-dashoffset: 20; } to { stroke-dashoffset: 0; } }

/* Bookings */
.booking { position: relative; display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; padding: 14px 0; }
.booking + .booking::before { content: ""; position: absolute; top: 0; left: 66px; right: 0; height: 1px; background: var(--line); }
.booking .time { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.booking .time b { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.booking .time span { font-size: 13px; color: var(--text-2); }
.booking .main { min-width: 0; }
.booking .name { display: block; font-size: 17px; font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.booking .meta { display: block; margin-top: 2px; color: var(--text-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.booking .countdown { display: block; margin-top: 3px; color: var(--accent-text); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.btn-ghost { padding: 8px 12px; border-radius: 10px; background: var(--bg-2); font-weight: 600; font-size: 15px; transition: transform 0.18s var(--ease); }
.btn-ghost:active { transform: scale(0.95); }
.btn-ghost.is-danger { color: var(--danger); }

/* Big numbers: session balance, money due */
.hero-stat { display: flex; flex-direction: column; margin: 12px 0 8px; }
.hero-stat b { font-size: 56px; font-weight: 700; letter-spacing: -0.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.hero-stat .label { margin-top: 6px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.hero-stat .meta { margin-top: 2px; font-size: 14px; color: var(--text-2); }
.hero-stat.is-zero b { color: var(--text-3); }
.hero-stat.is-money { margin: 4px 0 12px; }
.hero-stat.is-money b { font-size: 40px; letter-spacing: -0.03em; }

/* Plain list items (packs, payments, invoices, coach history) */
.card-row {
  position: relative; display: flex; gap: 12px; align-items: center;
  min-height: 60px; padding: 12px 0; color: inherit; text-decoration: none;
}
.card-row .main { flex: 1; }
.card-row + .card-row::before, .list > .row-more::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px; background: var(--line); }
.card-row .main { min-width: 0; }
.card-row .name { display: block; font-size: 16px; font-weight: 500; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-row .meta { display: block; margin-top: 2px; font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-row .value { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; }
.card-row.is-link:active .main { opacity: 0.6; }
.chev { width: 16px; height: 16px; fill: none; stroke: var(--text-3); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--ok-soft); color: var(--ok); white-space: nowrap; }
.pill.is-warn { background: var(--warn-soft); color: var(--warn); }
.row-more { position: relative; padding: 14px 0; text-align: left; color: var(--accent-text); font-weight: 600; font-size: 15px; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }

/* Empty, loading, error */
.empty { padding: 48px 16px; text-align: center; color: var(--text-2); font-size: 15px; }
.empty b { display: block; color: var(--text); font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.skeleton {
  height: 44px; margin: 10px 0; border-radius: 10px;
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--line) 50%, var(--bg-2) 100%); background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin: 12px 0; padding: 12px 14px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-size: 15px; }
.banner button { padding: 6px 12px; border-radius: 8px; background: var(--bg); color: var(--text); font-weight: 600; font-size: 15px; }
.note { margin: 12px 0 14px; color: var(--text-2); font-size: 14px; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: var(--tabbar);
  padding: 6px 0 env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr); max-width: 640px; margin: 0 auto;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 2px; color: var(--text-3); font-size: 11px; font-weight: 600; transition: color 0.2s var(--ease); }
.tab svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.is-active { color: var(--accent-text); }
.tab.is-active svg { stroke-width: 2.3; }
.tab.is-active::before { content: ""; position: absolute; top: -7px; width: 22px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.tab-badge {
  position: absolute; top: -2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; font-style: normal; font-variant-numeric: tabular-nums;
  display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg), inset 0 0 0 1px var(--accent-edge);
}

/* Bottom sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: var(--scrim); opacity: 0; transition: opacity 0.25s var(--ease); }
.sheet-backdrop.is-open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 640px; margin: 0 auto;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 20px); border-radius: 20px 20px 0 0;
  background: var(--bg-elev); box-shadow: var(--sheet-shadow);
  transform: translateY(100%); transition: transform 0.32s var(--ease);
}
.sheet.is-open { transform: translateY(0); }
.sheet::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 0 auto 18px; }
.sheet-head { display: flex; gap: 14px; align-items: center; }
.avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: var(--bg-2); flex: none; }
.avatar.is-text { display: grid; place-items: center; font-weight: 600; font-size: 17px; color: var(--text-2); }
.sheet h2 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.sheet .sub { margin: 2px 0 0; color: var(--text-2); font-size: 15px; }
.facts { display: grid; grid-template-columns: 1.4fr 1fr 1fr; margin: 18px 0 4px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fact { padding: 0 12px; min-width: 0; }
.fact:first-child { padding-left: 0; }
.fact + .fact { border-left: 1px solid var(--line); }
.fact small { display: block; color: var(--text-3); font-size: 12px; font-weight: 600; }
.fact b { display: block; margin-top: 2px; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.fact.is-full b { color: var(--danger); }
.fact.is-low b { color: var(--warn); }
.fact.is-booked b { color: var(--accent-text); }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 50px;
  border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-size: 17px; font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent-edge);
  transition: transform 0.18s var(--ease), opacity 0.18s var(--ease), background 0.18s var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn[disabled], .btn.is-danger, .btn.is-secondary { box-shadow: none; }
.btn[disabled] { background: var(--bg-2); color: var(--text-3); cursor: default; }
.btn.is-danger { background: var(--danger-soft); color: var(--danger); }
.btn.is-secondary { background: var(--bg-2); color: var(--text); }
.btn + .btn { margin-top: 10px; }
.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 16px); z-index: 30; transform: translateX(-50%) translateY(8px);
  max-width: calc(100% - 40px); padding: 11px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 15px; text-align: center;
  box-shadow: 0 8px 24px rgba(9, 9, 11, 0.18); opacity: 0; transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.toast.is-open { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { background: var(--danger); color: #fff; }

/* Conta: entry QR stays on white in both themes so the gate reader catches it */
.qr-card {
  display: flex; align-items: center; gap: 16px; width: 100%; margin: 8px 0 4px; padding: 14px 16px; text-align: left;
  border-radius: 16px; background: #fff; color: #0a0a0b; border: 1px solid var(--line); box-shadow: var(--lift);
  transition: transform 0.18s var(--ease);
}
.qr-card:active { transform: scale(0.985); }
.qr-card img { width: 88px; height: 88px; border-radius: 6px; image-rendering: pixelated; }
.qr-card.is-loading { height: 118px; background: var(--bg-2); border-color: transparent; box-shadow: none; }
.qr-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.qr-code { font-size: 20px; font-weight: 700; letter-spacing: 0.14em; font-variant-numeric: tabular-nums; }
.qr-hint { font-size: 13px; color: #5c5c66; }
.qr-card .chev { stroke: #8a8a93; }

.qr-overlay {
  position: fixed; inset: 0; z-index: 40; background: #fff; color: #0a0a0b; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  opacity: 0; transition: opacity 0.25s var(--ease);
}
.qr-overlay.is-open { opacity: 1; }
.qr-overlay img { width: min(78vw, 420px); height: auto; border-radius: 6px; image-rendering: pixelated; }
.qr-overlay .qr-code { font-size: 24px; }
.qr-overlay .qr-hint { margin-top: 6px; }

/* Conta: profile and settings-style groups */
.profile-card { display: flex; align-items: center; gap: 14px; padding: 4px 0 14px; }
.profile-card .main { flex: 1; min-width: 0; }
.profile-card .name { display: block; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.profile-card .meta { display: block; margin-top: 2px; font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group { margin-bottom: 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.group-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 13px 0; }
.group-row + .group-row { border-top: 1px solid var(--line); }
.group-row span { flex: none; font-size: 15px; color: var(--text); }
.group-row b { min-width: 0; font-size: 15px; font-weight: 400; color: var(--text-2); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-row.is-logout { width: 100%; justify-content: flex-start; color: var(--danger); font-size: 15px; font-weight: 600; transition: transform 0.18s var(--ease); }
.group-row.is-logout:active { transform: scale(0.97); }

/* Login */
.login-overlay {
  position: fixed; inset: 0; z-index: 50; overflow-y: auto; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: max(env(safe-area-inset-top), 20px) max(env(safe-area-inset-right), 20px) max(env(safe-area-inset-bottom), 20px) max(env(safe-area-inset-left), 20px);
}
.login-wrap { width: min(100%, 360px); }
.login-title { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; }
.login-sub { margin: 4px 0 24px; color: var(--text-2); font-size: 17px; }
.login-card { width: 100%; }
.login-input {
  display: block; width: 100%; height: 50px; padding: 0 16px; border: 1px solid transparent; border-radius: 12px;
  background: var(--bg-2); color: var(--text); font: inherit; font-size: 17px;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.login-input::placeholder { color: var(--text-3); }
.login-input:focus { outline: none; border-color: var(--focus); background: var(--bg); }
.login-error { min-height: 18px; margin: 8px 0 10px; color: var(--danger); font-size: 14px; }
.login-offer-title { margin: 0 0 6px; font-size: 24px; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }

@media (min-width: 640px) {
  .view { padding-top: 32px; }
  .page-title { font-size: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
