:root {
  --radius: 16px;
  --radius-sm: 11px;
}

body.theme-dark {
  --bg: #111317;
  --surface: #1b1f26;
  --surface-2: #242933;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f3f5f8;
  --muted: #8e98a8;
  --accent: #3b82f6;
  --accent-text: #ffffff;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, 0.12);
}

body.theme-light {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: rgba(15, 23, 42, 0.09);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --green: #059669;
  --red: #dc2626;
  --amber: #b45309;
  --amber-bg: rgba(245, 158, 11, 0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.app-shell {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.scope-switch {
  display: inline-flex;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 12px;
  gap: 2px;
}

.scope-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 9px;
  cursor: pointer;
}

.scope-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}

.top-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn.small { width: 28px; height: 28px; font-size: 13px; }

.screen-body {
  flex: 1;
  padding: 14px;
  padding-bottom: 84px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.subcard {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.hero-amount {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.muted { color: var(--muted); }
.green { color: var(--green); }
.red { color: var(--red); }
.amber { color: var(--amber); }
.small-text { font-size: 12px; }
.xs-text { font-size: 11px; }
.num { font-variant-numeric: tabular-nums; }
.bold { font-weight: 600; }
.center { text-align: center; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

.alert-card {
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
}

.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-green { background: var(--green); color: #091318; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 9px; }
.btn-full { width: 100%; }

.seg-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 7px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn.active { background: var(--accent); color: var(--accent-text); }

.pill-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 11px;
  color: var(--muted);
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.2s; }
.progress-fill.full { background: var(--green); }

.input, .select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 460px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 20;
}

.nav-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  cursor: pointer;
  position: relative;
}

.nav-btn.active { color: var(--accent); font-weight: 600; }
.nav-ico { font-size: 18px; }

.badge {
  position: absolute;
  top: 0;
  right: 18px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--amber);
  color: #111;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hidden { display: none !important; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-weight: 600; font-size: 15px; }
.modal-body { display: flex; flex-direction: column; gap: 10px; }
