:root {
  --bg: #0a0a0c;
  --card: #161618;
  --card2: #1e1e22;
  --text: #f5f5f7;
  --muted: #8e8e93;
  --accent: #d4a017;
  --accent-dim: rgba(212, 160, 23, 0.15);
  --border: rgba(255,255,255,0.06);
  --green: #4ade80;
  --radius: 16px;
  --nav-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + 12px);
}

.header {
  padding: 12px 16px 8px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg) 80%, transparent);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.logo {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.balance {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.balance.negative { color: #f87171; }

.pocket-bar {
  display: flex;
  gap: 8px;
}

.pocket {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.pocket span { color: var(--muted); }
.pocket strong { font-size: 14px; }

main { padding: 0 16px 16px; }

.page { display: none; animation: fade .2s ease; }
.page.active { display: block; }

@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.tabs, .period-row {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.tab, .period {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
}

.type-tabs { border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.tab.active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }

.period { background: var(--card); font-size: 13px; }
.period.active { background: var(--accent-dim); color: var(--accent); }

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  margin-bottom: 12px;
}

.chart-wrap {
  position: relative;
  width: min(260px, 80vw);
  height: min(260px, 80vw);
  margin: 0 auto;
}

.chart-wrap.small { width: 200px; height: 200px; }

.chart-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.chart-total {
  font-size: 22px;
  font-weight: 700;
}

.chart-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  padding: 14px 16px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.badge {
  background: var(--card2);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  color: var(--text);
}

.cat-list, .record-list {
  list-style: none;
}

.cat-list li, .record-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-name { flex: 1; font-size: 15px; }
.cat-amt { font-weight: 600; font-size: 15px; }

.record-list li { flex-direction: column; align-items: flex-start; gap: 4px; }
.rec-title { font-weight: 500; font-size: 15px; }
.rec-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; width: 100%; justify-content: space-between; }
.rec-amt { font-weight: 600; color: var(--accent); }

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.stat label { font-size: 11px; color: var(--muted); display: block; }
.stat strong { font-size: 16px; display: block; margin-top: 4px; }

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  height: var(--nav-h);
  background: rgba(16,16,18,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
}

.nav {
  flex: 1;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px;
}

.nav span { font-size: 18px; }
.nav.active { color: var(--accent); }

.admin-only { display: none; }
body.is-admin .admin-only { display: flex; }

.profile-card { text-align: center; padding: 24px 16px; }
.avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 28px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}
.profile-card h2 { font-size: 18px; margin-bottom: 4px; }
.profile-card p { color: var(--muted); font-size: 14px; }

.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  margin-bottom: 12px;
}

.hint {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 16px;
  line-height: 1.5;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.detail-row span:last-child { font-weight: 600; }

.loader {
  position: fixed; inset: 0;
  background: rgba(10,10,12,0.7);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
.loader.show { display: flex; }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
