*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg:      #0c0c14;
  --bg2:     #13131f;
  --bg3:     #1c1c2a;
  --bg4:     #242436;
  --border:  rgba(255,255,255,0.06);
  --border2: rgba(255,255,255,0.1);
  --accent:  #5b7fff;
  --accent2: #9b6bff;
  --green:   #22d47e;
  --red:     #ff5f6d;
  --text:    #f0f0f8;
  --text2:   #7a7a96;
  --text3:   #4a4a66;
  --r:       18px;
  --r-sm:    12px;
}

body.light {
  --bg:      #f2f2f7;
  --bg2:     #ffffff;
  --bg3:     #e8e8f0;
  --bg4:     #dcdcec;
  --border:  rgba(0,0,0,0.07);
  --border2: rgba(0,0,0,0.12);
  --green:   #16a34a;
  --red:     #dc2626;
  --text:    #0d0d1a;
  --text2:   #6b6b85;
  --text3:   #a0a0b8;
}

body.light .hero-amount {
  background: linear-gradient(160deg, #1a1a2e 30%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ─── Sticky header ─────────────────────────── */

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding: 14px 16px 0;
  border-bottom: 1px solid var(--border);
}

.header-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.header-top .tabs {
  flex: 1;
  margin-bottom: 0;
}

.theme-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--bg2);
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  line-height: 1;
}

.theme-btn:active {
  background: var(--bg4);
}

/* ─── Tabs ───────────────────────────────────── */

.tabs {
  display: flex;
  background: var(--bg2);
  border-radius: 14px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 12px;
}

.tab {
  flex: 1;
  padding: 9px 6px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab.active {
  background: var(--bg4);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 6px rgba(0,0,0,0.4);
}

/* ─── Month nav ──────────────────────────────── */

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 12px;
}

.nav-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--bg2);
  color: var(--text2);
  font-size: 22px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}

.nav-btn:active {
  background: var(--bg4);
  color: var(--text);
}

.month-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* ─── State screens ──────────────────────────── */

.state-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 40px 24px;
  gap: 16px;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--bg3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 95, 109, 0.15);
  color: var(--red);
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.error-text {
  color: var(--text2);
  font-size: 15px;
  text-align: center;
}

.retry-btn {
  padding: 12px 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: -0.01em;
}

/* ─── Content ────────────────────────────────── */

#content {
  padding: 0 16px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Hero ───────────────────────────────────── */

.hero {
  padding: 28px 0 20px;
  text-align: center;
}

.hero-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

.hero-amount {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -2.5px;
  background: linear-gradient(160deg, #ffffff 30%, rgba(155,107,255,0.9) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.05;
  margin-bottom: 10px;
}

.hero-trend {
  font-size: 13px;
  min-height: 18px;
  font-weight: 500;
}

.trend-up   { color: var(--red);   }
.trend-down { color: var(--green); }
.trend-same { color: var(--text2); }

/* ─── Stats row ──────────────────────────────── */

.stats-row {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 0;
  margin-bottom: 12px;
}

.stat-item {
  flex: 1;
  text-align: center;
}

.stat-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  margin-bottom: 3px;
}

.stat-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-divider {
  width: 1px;
  height: 36px;
  background: var(--border2);
}

/* ─── Cards ──────────────────────────────────── */

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 18px;
}

/* ─── Donut chart ────────────────────────────── */

.donut-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 22px;
}

.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  width: 110px;
}

.donut-amount {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.donut-cat {
  font-size: 11px;
  color: var(--text2);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Category list ──────────────────────────── */

.cat-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.15s;
}

.cat-item:last-child { border-bottom: none; padding-bottom: 0; }
.cat-item:first-child { padding-top: 0; }
.cat-item:active { opacity: 0.7; }

.cat-icon {
  font-size: 19px;
  width: 40px;
  height: 40px;
  background: var(--bg3);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cat-info {
  flex: 1;
  min-width: 0;
}

.cat-name-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.cat-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.cat-amount {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  flex-shrink: 0;
  margin-left: 8px;
}

.cat-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-bar-track {
  flex: 1;
  height: 3px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.cat-pct {
  font-size: 11px;
  color: var(--text2);
  font-weight: 500;
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}

/* ─── Tabs (4 items) ─────────────────────────── */

.tab {
  font-size: clamp(11px, 3.5vw, 14px);
}

/* ─── Bar chart ──────────────────────────────── */

.bar-wrap {
  height: 156px;
}

/* ─── Category trends ────────────────────────── */

.trend-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 16px;
}

.trend-pill {
  padding: 5px 13px;
  border-radius: 20px;
  border: 1.5px solid var(--pill-color, #5b7fff);
  background: transparent;
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}

.trend-pill.active {
  background: var(--pill-color, #5b7fff);
  color: #fff;
}

.trends-wrap {
  height: 200px;
}

/* ─── Transaction list ───────────────────────── */

.tx-date-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 14px 0 8px;
}

.tx-date-label:first-child {
  padding-top: 0;
}

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

.tx-item:last-child {
  border-bottom: none;
}

.tx-icon {
  font-size: 17px;
  width: 40px;
  height: 40px;
  background: var(--bg3);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tx-info {
  flex: 1;
  min-width: 0;
}

.tx-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-sub {
  font-size: 12px;
  color: var(--text2);
  margin-top: 1px;
}

.tx-amount {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.03em;
  flex-shrink: 0;
}

/* ─── Empty state ────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 36px 0;
  color: var(--text2);
  font-size: 14px;
}

/* ─── Bottom padding ─────────────────────────── */

.bottom-pad { height: 40px; }
