/* GH-Cash components, modelled on GH Store's client styles (tab bar, sheets, toasts, success mark,
   countdown ring, admin layout). Loaded after app.css; uses its colour tokens. */

/* ---------- motion ---------- */
@keyframes gh-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes gh-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes gh-down { from { transform: none; } to { transform: translateY(100%); } }
@keyframes gh-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes gh-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes gh-pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes gh-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes gh-dialog { from { opacity: 0; transform: translateY(calc(-50% + 14px)) scale(.98); } to { opacity: 1; transform: translateY(-50%); } }
@keyframes gh-dialog-out { from { opacity: 1; transform: translateY(-50%); } to { opacity: 0; transform: translateY(calc(-50% + 12px)); } }
@keyframes gh-pulse { 0%, 100% { transform: scale(.7); opacity: .5; } 50% { transform: scale(1.2); opacity: 1; } }
.screen { animation: gh-in .35s cubic-bezier(.2, .8, .2, 1) both; }
.stagger > * { animation: gh-in .4s cubic-bezier(.2, .8, .2, 1) both; }
.stagger > *:nth-child(2) { animation-delay: .04s; } .stagger > *:nth-child(3) { animation-delay: .08s; }
.stagger > *:nth-child(4) { animation-delay: .12s; } .stagger > *:nth-child(5) { animation-delay: .16s; }
.stagger > *:nth-child(6) { animation-delay: .2s; } .stagger > *:nth-child(n+7) { animation-delay: .24s; }
.pop { animation: gh-pop .45s cubic-bezier(.2, .8, .2, 1); }
.btn, .icon-btn, .tabbar a, .row--tap { -webkit-tap-highlight-color: transparent; }
.btn:active:not(:disabled), .icon-btn:active, .row--tap:active { transform: scale(.96); }

/* ---------- button sizes and helpers used by the app pages ---------- */
.btn { gap: 8px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-xs { padding: 6px 13px; font-size: .8rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn:disabled { opacity: .5; pointer-events: none; }
@media (max-width: 440px) { .hide-xs { display: none !important; } }
.dot { position: relative; }
.dot.live::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: inherit; animation: ping 2.2s cubic-bezier(0, 0, .2, 1) infinite; }
@keyframes ping { 0% { transform: scale(1); opacity: .6; } 80%, 100% { transform: scale(2.7); opacity: 0; } }
.wallet .acts .btn { flex: 0 0 auto; }
a.row { text-decoration: none; }
@media (hover: hover) { a.row:hover { background: var(--surface-2); } }

/* small inline badges (API / test on transfers) */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; white-space: nowrap; flex: none;
  font: 700 .7rem var(--font); letter-spacing: .02em; background: var(--surface-2); color: var(--muted); }
.badge.acc { background: var(--tile); color: var(--accent-text); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---------- floating pill tab bar (phones) ---------- */
.tabbar {
  position: fixed; z-index: 30; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  inset-inline: 16px; max-width: 560px; margin: 0 auto; height: 68px; border-radius: 34px;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 6px;
  background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--border);
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .55);
}
.tabbar a {
  min-width: 0; overflow: hidden;
  border-radius: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; transition: background .25s, color .25s, transform .12s;
}
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a[aria-current="page"] { background: var(--tile); color: var(--accent-text); }
.tabbar__badge {
  position: absolute; top: -5px; inset-inline-end: -10px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font: 700 10.5px/17px var(--font); text-align: center; box-shadow: 0 0 0 2px var(--surface);
}
.tabbar__icon { position: relative; display: inline-flex; }
@media (min-width: 900px) { .tabbar { display: none; } }

/* ---------- sheets: bottom sheet on phones, dialog on desktop ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .45); animation: gh-fade .22s ease;
  backdrop-filter: blur(6px) saturate(.9); -webkit-backdrop-filter: blur(6px) saturate(.9);
}
.sheet {
  position: fixed; z-index: 51; inset-inline: 0; bottom: 0; max-height: 90dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 28px 28px 0 0; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px); animation: gh-up .34s cubic-bezier(.2, .8, .2, 1);
}
.sheet__handle { display: flex; justify-content: center; padding-top: 10px; }
.sheet__handle span { width: 40px; height: 5px; border-radius: 3px; background: var(--border-2, var(--border)); }
.sheet__head { padding: 10px 20px 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sheet__head h3 { font-size: 1.15rem; }
.sheet__body { overflow-y: auto; padding: 14px 20px 22px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.sheet-layer--closing { pointer-events: none; }
.sheet-layer--closing .backdrop { animation: gh-fade-out .22s ease forwards; }
.sheet-layer--closing .sheet { animation: gh-down .22s cubic-bezier(.4, 0, 1, 1) forwards; }
@media (min-width: 700px) {
  .sheet {
    margin: 0 auto; bottom: auto; top: 50%; transform: translateY(-50%); width: min(var(--sheet-w, 520px), calc(100vw - 32px));
    max-height: 86dvh; border-radius: 28px; border: 1px solid var(--border); animation: gh-dialog .26s cubic-bezier(.2, .8, .2, 1);
    box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .6);
  }
  .sheet-layer--closing .sheet { animation: gh-dialog-out .2s ease forwards; }
  .sheet__handle { display: none; }
  .sheet__head { padding-top: 20px; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 70; inset-inline: 16px; bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  width: fit-content; max-width: min(440px, calc(100vw - 32px)); margin: 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 10px; padding-inline: 10px 16px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: .92rem; box-shadow: 0 12px 32px -6px rgba(0, 0, 0, .35); animation: toast-in .32s cubic-bezier(.2, .9, .3, 1.2);
}
.toast__icon { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.toast__icon svg { width: 15px; height: 15px; }
.toast--bad .toast__icon { background: var(--danger); color: #fff; }
.toast--leaving { animation: toast-out .18s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* ---------- drawn success / failure mark ---------- */
.sx { position: relative; display: inline-flex; color: var(--ok); animation: sx-pulse .62s cubic-bezier(.3, .7, .3, 1) both; }
.sx svg { display: block; overflow: visible; }
.sx__fill { fill: color-mix(in srgb, currentColor 14%, transparent); animation: gh-fade .3s ease .3s both; }
.sx__ring, .sx__tick { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1 1; }
.sx__ring { transform: rotate(-90deg); transform-origin: 48px 48px; stroke-width: 4; animation: sx-draw .36s ease-out .04s both; }
.sx__tick { stroke-width: 5.5; animation: sx-draw .26s cubic-bezier(.3, .7, .3, 1) .34s both; }
.sx::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid currentColor; opacity: 0; animation: sx-burst .5s ease-out .5s forwards; }
.sx--fail { color: var(--danger); animation: sx-shake .42s cubic-bezier(.36, .07, .19, .97) .62s both; }
.sx--fail .sx__tick--2 { animation-delay: .5s; }
@keyframes sx-draw { from { stroke-dashoffset: 1; opacity: 0; } 1% { opacity: 1; } to { stroke-dashoffset: 0; opacity: 1; } }
@keyframes sx-pulse { 0% { transform: scale(.86); } 55% { transform: scale(1); } 80% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes sx-burst { 0% { opacity: .5; transform: scale(1); } 100% { opacity: 0; transform: scale(1.35); } }
@keyframes sx-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.done { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 10px 4px; }
.done__hint { color: var(--muted); font-size: .9rem; animation: gh-fade .4s ease .9s both; }

/* ---------- countdown ring ---------- */
.ring { position: relative; flex: none; width: 104px; height: 104px; display: grid; place-items: center; text-align: center; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring__track, .ring__bar { fill: none; stroke-width: 7; }
.ring__track { stroke: var(--surface-2); }
.ring__bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke .3s; }
.ring--warn .ring__bar { stroke: var(--warn); }
.ring__time { position: relative; display: block; font: 800 1.3rem var(--mono); color: var(--accent-text); direction: ltr; }
.ring--warn .ring__time { color: var(--warn); }
.ring__label { position: relative; display: block; font-size: .7rem; color: var(--muted); }

/* ---------- small building blocks ---------- */
.copy-box { min-height: 48px; border-radius: 14px; background: var(--surface-2); display: flex; align-items: center; gap: 8px; padding-block: 6px; padding-inline: 14px 6px; }
.copy-box > span { flex: 1; min-width: 0; font: 600 .86rem var(--mono); direction: ltr; text-align: start; word-break: break-all; }
.copy-box small { display: block; color: var(--muted); font: 500 .74rem var(--font); }
.waiting { display: inline-flex; align-items: center; gap: 10px; }
.waiting::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: gh-pulse 1.2s ease-in-out infinite; }
.skel { border-radius: 12px; min-height: 18px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3, var(--border)) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: gh-shimmer 1.3s linear infinite; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); gap: 2px; }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: 700 .84rem var(--font); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .14); }
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.ph h2 { font-size: clamp(1.45rem, 3vw, 1.9rem); }
.ph p { color: var(--muted); margin-top: 4px; font-size: .92rem; }
.list { border-radius: 22px; background: var(--surface); border: 1px solid var(--border); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--border); }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row__meta { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.row__end { flex: none; display: flex; align-items: center; gap: 8px; }
/* Phones: the top bar keeps the balance; the profile chip shows its icon only. */
@media (max-width: 460px) { .topbar #whoName { display: none; } .topbar .chip { padding-inline: 10px; } }
/* Dashboard activation offer: icon, text, action; the action drops below the text on phones. */
.act-card__in { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.act-card__in .row__main { min-width: 200px; gap: 4px; }
@media (max-width: 520px) { .act-card__in > .btn, .act-card__in > a.btn { width: 100%; justify-content: center; } }
/* Notifications (admin) */
.note-row.unread .row__title::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-inline-end: 8px; vertical-align: middle; }
.note-row .row__meta { white-space: pre-line; }
.round { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text); }
.round svg { width: 19px; height: 19px; }
.round--in { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.round--out { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.amt { font: 700 1rem var(--mono); direction: ltr; white-space: nowrap; flex: none; }
.amt--in { color: var(--ok); } .amt--out { color: var(--danger); }
.statgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .statgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { border-radius: 22px; background: var(--surface); border: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.stat__top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat__top svg { width: 18px; height: 18px; color: var(--accent-text); }
.stat__v { font: 700 1.7rem var(--font-head); direction: ltr; text-align: right; line-height: 1.1; }
.stat__hint { font-size: .76rem; color: var(--faint, var(--muted)); }
.table-wrap { overflow-x: auto; border-radius: 22px; border: 1px solid var(--border); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.table th { font-size: .76rem; font-weight: 600; color: var(--muted); background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }

/* ---------- app shell: sidebar on desktop, tab bar on phones ---------- */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100dvh; }
.shell__side { display: none; }
.shell__main { width: min(1080px, 100%); margin: 0 auto; padding: 22px 16px 120px; min-width: 0; }
@media (min-width: 900px) {
  .shell { grid-template-columns: 250px 1fr; }
  .shell__side {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh; padding: 22px 14px;
    border-inline-end: 1px solid var(--border); background: var(--surface);
  }
  .shell__side .logo { padding: 4px 10px 22px; }
  .shell__side a.nav-i {
    height: 44px; padding: 0 14px; border-radius: 14px; display: flex; align-items: center; gap: 11px;
    color: var(--muted); font-weight: 600; font-size: .93rem; transition: background .2s, color .2s;
  }
  .shell__side a.nav-i svg { width: 19px; height: 19px; }
  .shell__side a.nav-i:hover { background: var(--surface-2); color: var(--text); }
  .shell__side a.nav-i[aria-current="page"] { background: var(--tile); color: var(--accent-text); }
  .shell__side .sp { flex: 1; }
  .shell__main { padding: 34px 36px 60px; }
}
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.topbar .sp { flex: 1; }
@media (min-width: 900px) { .topbar .logo { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .screen, .stagger > *, .pop, .sheet, .backdrop, .toast, .sx, .sx *, .sx::after, .waiting::before, .skel { animation: none !important; }
  .sx__ring, .sx__tick { stroke-dashoffset: 0; }
}
