*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Hide page content until pwa.js signals ready — prevents flash before login check */
body:not(.pwa-ready) .page,
body:not(.pwa-ready) nav { visibility: hidden; }

:root {
  --bg:        #0f0f0f;
  --surface:   #1a1a1a;
  --border:    #2a2a2a;
  --text:      #e8e8e8;
  --muted:     #888;
  --accent:    #4f8ef7;
  --income:    #34c474;
  --expense:   #f05a5a;
  --radius:    12px;
  --nav-h:     56px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

/* ── Nav ── */
nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  padding-top: 6px;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}

nav a, nav span.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: var(--muted);
  font-size: 10px;
  padding: 4px 0;
  transition: color 0.15s;
}

nav a.active, nav a:hover { color: var(--accent); }

nav a svg, nav span.nav-item svg { width: 22px; height: 22px; }

nav span.nav-item { opacity: 0.35; cursor: default; }

/* ── Page layout ── */
.page {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px 12px;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
}

h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 24px 0 10px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.card-value { font-size: 22px; font-weight: 700; }
.card-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Summary row ── */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

/* ── Amount colors ── */
.income  { color: var(--income); }
.expense { color: var(--expense); }

/* ── Transaction list ── */
.tx-list { list-style: none; }

.tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.tx-item:last-child { border-bottom: none; }

.tx-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.tx-body { flex: 1; min-width: 0; }
.tx-merchant { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta     { font-size: 12px; color: var(--muted); margin-top: 2px; }

.tx-amount {
  font-size: 15px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

/* ── Filter bar ── */
.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.filter-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Transaction item – updated layout ── */
a.tx-icon { display: flex; align-items: center; justify-content: center; }
a.tx-icon:hover { opacity: 0.75; }

.tx-account {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}

a.tx-category {
  display: block;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  margin-top: 3px;
}
a.tx-category:hover { text-decoration: underline; }

.tx-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  gap: 3px;
}

.tx-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Transaction groups ── */
.tx-group { margin-bottom: 20px; }

.tx-group-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  padding: 0 2px;
}

.tx-group-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 16px;
}

.tx-group-total {
  padding: 8px 4px 0;
  font-size: 13px;
  color: var(--muted);
}

/* ── Misc ── */
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }

.synced-at {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 12px 0 4px;
}
