:root {
  --bg:       #1e1e2e;
  --surface:  #313244;
  --surface2: #45475a;
  --text:     #cdd6f4;
  --subtle:   #a6adc8;
  --muted:    #6c7086;
  --blue:     #89b4fa;
  --green:    #a6e3a1;
  --red:      #f38ba8;
  --orange:   #fab387;
  --purple:   #cba6f7;
  --teal:     #94e2d5;
  --radius:   10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-title { font-size: 1.1rem; font-weight: 700; }
.nav-back { color: var(--blue); font-size: 0.9rem; cursor: pointer; background: none; border: none; padding: 4px 8px; }

.tab-bar {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  border-top: 1px solid var(--surface);
  padding-bottom: var(--safe-bot);
  z-index: 10;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.65rem;
  gap: 2px;
  border: none;
  background: none;
}
.tab-item.active { color: var(--blue); }
.tab-icon { font-size: 1.3rem; }

.content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(70px + var(--safe-bot));
  overflow-y: auto;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.card-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.75; }
.btn-primary { background: var(--blue); color: #000; }
.btn-success { background: var(--green); color: #000; }
.btn-danger  { background: var(--red); color: #000; }
.btn-ghost   { background: var(--surface); color: var(--text); }
.btn-sm      { padding: 8px 14px; font-size: 0.82rem; }

.input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.95rem;
}
.input:focus { outline: none; border-color: var(--blue); }

.label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px; }
.subtitle { color: var(--subtle); font-size: 0.85rem; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--blue);
  color: #000;
}
.badge-food      { background: var(--green); color: #000; }
.badge-drinks    { background: var(--blue); color: #000; }
.badge-household { background: var(--orange); color: #000; }
.badge-personal  { background: var(--purple); color: #000; }
.badge-work      { background: var(--teal); color: #000; }
.badge-other     { background: var(--muted); color: #000; }

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.bar-label { width: 90px; font-size: 0.75rem; color: var(--subtle); text-align: right; flex-shrink: 0; }
.bar-track { flex: 1; background: var(--surface2); border-radius: 4px; height: 18px; position: relative; overflow: hidden; }
.bar-fill  { height: 18px; border-radius: 4px; display: flex; align-items: center; padding-left: 6px; transition: width 0.4s ease; }
.bar-value { font-size: 0.68rem; font-weight: 700; color: #000; white-space: nowrap; }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.summary-card { background: var(--surface); border-radius: var(--radius); padding: 12px; text-align: center; }
.summary-amount { font-size: 1.4rem; font-weight: 700; margin: 4px 0; }
.summary-label  { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.up   { color: var(--red); }
.down { color: var(--green); }

.store-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--surface2);
  object-fit: cover;
  flex-shrink: 0;
}
.store-logo-placeholder {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.warning { background: var(--red); color: #000; border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; font-size: 0.85rem; font-weight: 600; }

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--surface2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.period-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.period-btn {
  padding: 6px 12px; border-radius: 99px; border: none;
  background: var(--surface); color: var(--subtle);
  font-size: 0.78rem; cursor: pointer;
}
.period-btn.active { background: var(--blue); color: #000; font-weight: 600; }

.divider { border: none; border-top: 1px solid var(--surface); margin: 14px 0; }

.totals-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.totals-row .total-label { color: var(--subtle); font-size: 0.85rem; }
.totals-row .total-value { font-weight: 600; }
.totals-row.grand .total-value { font-size: 1.2rem; color: var(--green); }
