/* Bank of Dad — styles following the Stitch "Card Balance & Transactions (Light)" mockup.
   Light theme, Hanken Grotesk / Inter (system fallback; CSP forbids external fonts),
   phone-frame layout centred on larger screens. */

:root {
  --bg: #f1f5f9;
  --frame: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #f8fafc;
  --text: #0f172a;
  --text-2: #334155;
  --text-3: #475569;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --border: #e2e8f0;
  --border-soft: #f1f5f9;
  --primary: #2563eb;
  --primary-deep: #004ac6;
  --primary-dark: #1d4ed8;
  --blue-100: #dbeafe;
  --credit: #059669;
  --credit-bg: #ecfdf5;
  --credit-border: #a7f3d0;
  --mint-400: #34d399;
  --mint-500: #10b981;
  --danger: #f43f5e;
  --danger-hover: #e11d48;
  --danger-bg: #fff1f2;
  --danger-border: #fecdd3;
  --warn: #f59e0b;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --radius: 16px;
  --radius-lg: 26px;
  --radius-frame: 40px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px -1px rgba(15, 23, 42, .06);
  --font: "Hanken Grotesk", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overscroll-behavior-y: contain;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100dvh; }

button, a.button {
  font: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

/* Phone frame: full-bleed on small screens, a rounded device card on larger ones. */
.app {
  width: 100%;
  max-width: 420px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--frame);
  position: relative;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 640px) {
  body { padding: 24px 16px; }
  .app {
    min-height: 880px;
    border-radius: var(--radius-frame);
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, .25);
    overflow: hidden;
  }
}

.screen-center {
  flex: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 20px;
}
@media (min-width: 640px) { .screen-center { min-height: 880px; } }

/* ---- Sign in --------------------------------------------------------- */

.signin {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 36px 26px 26px;
  text-align: center;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: #65d5fd;
  object-fit: cover;
  display: block;
  box-shadow: var(--shadow-xs);
}

.signin h1 {
  margin: 18px 0 6px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}

.signin p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.button-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: transform .08s ease, background .15s ease;
}
.button-google:hover { background: #1e293b; }
.button-google:active { transform: scale(.97); }
.button-google svg { width: 18px; height: 18px; flex: none; }

.signin .notice { margin-top: 18px; text-align: left; }
.signin .fineprint { margin: 18px 0 0; font-size: 12px; color: var(--muted-2); }

/* ---- Top bar --------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(226, 232, 240, .8);
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-xs);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}
.brand .brand-mark { width: 36px; height: 36px; border-radius: 12px; }

.user {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}
.avatar-button {
  display: grid;
  place-items: center;
  padding: 2px;
  border-radius: 50%;
  transition: box-shadow .15s ease, transform .1s ease;
}
.avatar-button:hover { box-shadow: 0 0 0 3px var(--surface-2); }
.avatar-button:active { transform: scale(.95); }
.avatar-button[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--blue-100); }
.avatar-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  object-fit: cover;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.avatar.large { width: 40px; height: 40px; font-size: 14px; }

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  min-width: 220px;
  max-width: calc(100vw - 32px);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px -10px rgba(15, 23, 42, .25), var(--shadow-sm);
  animation: menu-in .12s ease-out;
  transform-origin: top right;
}
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.account-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 10px;
  min-width: 0;
}
.account-text { min-width: 0; }
.account-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-email {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-divider { height: 1px; margin: 0 4px 6px; background: var(--border-soft); }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-align: left;
  transition: background .15s ease, color .15s ease;
}
.menu-item svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.menu-item:hover, .menu-item:focus-visible { background: var(--danger-bg); color: var(--danger-hover); outline: none; }
.menu-item:hover svg, .menu-item:focus-visible svg { color: var(--danger-hover); }

/* ---- Main ------------------------------------------------------------ */

main { flex: 1; }

/* ---- Balance cards --------------------------------------------------- */

.balances {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  margin-top: 16px;
  padding: 0 20px 6px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.balances::-webkit-scrollbar { display: none; }

.balance-card {
  flex: 0 0 86%;
  min-width: 300px;
  scroll-snap-align: center;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 20px;
  color: #fff;
  background: linear-gradient(to bottom right, var(--primary-dark), var(--primary), var(--primary-deep));
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, .2), 0 4px 6px -4px rgba(37, 99, 235, .2);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.balances:has(.balance-card:only-child) .balance-card { flex-basis: 100%; }
.balance-card:nth-child(2n) {
  background: linear-gradient(to bottom right, #334155, #1e293b, #0f172a);
  box-shadow: 0 10px 15px -3px rgba(15, 23, 42, .15), 0 4px 6px -4px rgba(15, 23, 42, .15);
}
.balance-card::before {
  content: "";
  position: absolute;
  right: -20%;
  top: -15%;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .22) 0%, rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}
.balance-card::after {
  content: "";
  position: absolute;
  right: 15px;
  bottom: -60px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 35px solid rgba(255, 255, 255, .1);
  pointer-events: none;
}
.balance-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--blue-100);
}
.balance-card:nth-child(2n) .balance-label { color: #cbd5e1; }
.balance-label .currency-badge {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .2);
  border: 1px solid rgba(255, 255, 255, .25);
  backdrop-filter: blur(12px);
  color: #fff;
}
.balance-amount {
  margin: 10px 0 24px;
  font-size: clamp(36px, 10vw, 42px);
  font-weight: 800;
  letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .08);
}
.balance-reserved {
  margin: -16px 0 16px;
  font-size: 12px;
  color: var(--blue-100);
}
.balance-card:nth-child(2n) .balance-reserved { color: #cbd5e1; }
.balance-stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat {
  background: rgba(0, 0, 0, .15);
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 16px;
  padding: 10px;
  backdrop-filter: blur(4px);
}
.balance-card:nth-child(2n) .stat {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .1);
}
.stat .stat-label { font-size: 10px; line-height: 1.25; font-weight: 500; color: var(--blue-100); }
.balance-card:nth-child(2n) .stat-label { color: #cbd5e1; }
.stat .stat-value { margin-top: 4px; font-size: 14px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }

/* ---- Sync row ------------------------------------------------------- */

.sync-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 0 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.sync-status { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint-500);
  flex: none;
}
.dot::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--mint-400);
  opacity: .75;
  animation: ping 1.4s cubic-bezier(0, 0, .2, 1) infinite;
}
.dot.stale { background: var(--warn); }
.dot.stale::before { animation: none; opacity: 0; }
.dot.failed { background: var(--danger); }
.dot.failed::before { animation: none; opacity: 0; }
.dot.running { background: var(--primary); }
.dot.running::before { background: var(--primary); animation-duration: .8s; }
@keyframes ping { 75%, 100% { transform: scale(2.4); opacity: 0; } }

.button-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, transform .08s ease;
}
.button-refresh:hover:not([disabled]) { background: var(--surface-3); }
/* Touch-only devices refresh by pulling down (app.js); the button is desktop-only. */
@media (hover: none) and (pointer: coarse) { .button-refresh { display: none; } }
.button-refresh:active:not([disabled]) { transform: scale(.95); }
.button-refresh[disabled] { opacity: .6; cursor: progress; }
.button-refresh svg { width: 14px; height: 14px; color: var(--muted); stroke-width: 2.2; }
.button-refresh.spinning svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Filter chips --------------------------------------------------- */

.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding: 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background .15s ease, color .15s ease;
}
.chip:hover { background: var(--surface-3); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

/* ---- Notices --------------------------------------------------------- */

.notice {
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-2);
  background: var(--info-bg);
  border: 1px solid var(--info-border);
}
.notice.error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-hover);
}
.notice.error code { font-family: var(--mono); font-size: 12px; }
main > .notice { margin: 16px 20px 0; }

/* ---- Transactions ---------------------------------------------------- */

.transactions {
  margin-top: 24px;
  padding: 0 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.transactions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 4px;
}
.transactions h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}
.transactions .period { font-size: 11px; font-weight: 500; color: var(--muted); }

.day-group { display: flex; flex-direction: column; gap: 8px; }
.day-heading {
  margin: 0;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.day-heading .day-total {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: 0;
}
.day-heading .day-total.credit { color: var(--credit); font-weight: 600; }

.tx-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.tx {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  transition: background .15s ease;
}
.tx:hover { background: rgba(248, 250, 252, .8); }
.tx + .tx { border-top: 1px solid var(--border-soft); }

.tx-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.tx-avatar.two { font-size: 12px; }
.tx-avatar svg { width: 20px; height: 20px; stroke-width: 2.5; }
.tx-avatar.credit {
  background: var(--credit-bg);
  border-color: var(--credit-border);
  color: var(--credit);
}
.tx-avatar.transfer { color: #0284c7; background: #f0f9ff; border-color: #bae6fd; }
.tx-avatar.other { color: #b45309; background: #fffbeb; border-color: #fde68a; }

.tx-body { min-width: 0; }
.tx-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-sub {
  margin-top: 1px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-amount {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}
.tx-amount.credit { color: var(--credit); }
.tx.declined .tx-title { color: var(--text-2); }
.tx.declined .tx-avatar { color: var(--text-3); }
.tx.declined .tx-sub { color: var(--danger); font-weight: 500; }
.tx-amount.declined { color: var(--muted-2); text-decoration: line-through; font-weight: 600; }

.button-more {
  display: block;
  width: 100%;
  padding: 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: background .15s ease;
}
.button-more:hover:not([disabled]) { background: var(--surface-3); }
.button-more[disabled] { opacity: .6; }

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 36px 16px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.footer {
  text-align: center;
  color: var(--muted-2);
  font-size: 11px;
  margin: 0;
  padding: 8px 20px 24px;
}

/* ---- Bits ------------------------------------------------------------ */

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}

/* Pull-to-refresh pill (touch only, driven from app.js). Sits under the
   status bar; hidden above the viewport until a drag reveals it. */
.pull-indicator {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 50%;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -56px);
  transition: transform .18s ease-out, opacity .18s ease-out;
  pointer-events: none;
}
.pull-indicator.dragging { transition: none; }
.pull-indicator svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
  stroke-width: 2.2;
  transition: transform .12s linear;
}
.pull-indicator.busy svg { animation: spin .9s linear infinite; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .dot::before, .button-refresh.spinning svg, .pull-indicator.busy svg, .account-menu { animation: none; }
}
