/* =========================================================
   Sift — Side Hustle Profit Tracker
   Main Styles (Light Mode Base)
   ========================================================= */

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-900: #0d3b1a;
  --green-800: #166534;
  --green-700: #1a7a3e;
  --green-600: #22a34e;
  --green-500: #2ec46a;
  --green-400: #5cd68a;
  --green-100: #d6f5e2;

  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;

  --red-500: #ef4444;
  --red-100: #fee2e2;
  --amber-500: #f59e0b;
  --amber-100: #fef3c7;

  --bg:        #ffffff;
  --bg-alt:    var(--slate-50);
  --bg-card:   #ffffff;
  --text:      var(--slate-900);
  --text-dim:  var(--slate-500);
  --border:    var(--slate-200);
  --accent:    var(--green-700);
  --accent-hover: var(--green-800);
  --danger:    var(--red-500);
  --warning:   var(--amber-500);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", "JetBrains Mono", "Consolas", monospace;

  --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,0.08);
  --shadow-lg:  0 10px 25px -3px rgba(0,0,0,0.1);
  --radius:     10px;
  --radius-sm:  6px;
  --nav-h:      60px;
  --max-w:      800px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  padding-top: var(--nav-h);
  padding-bottom: 80px;
}

/* ── Typography ──────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
p  { color: var(--text-dim); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-green { color: var(--accent); }
.text-red   { color: var(--danger); }
.text-dim   { color: var(--text-dim); }
.text-sm    { font-size: 0.875rem; }
.text-xs    { font-size: 0.75rem; }
.font-bold  { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ── Layout ──────────────────────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
}

.page { display: none; }
.page.active { display: block; }

/* ── Top Nav Bar ─────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}
.navbar-brand {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.navbar-brand svg { width: 28px; height: 28px; }
.navbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── Bottom Tab Bar ──────────────────────────────────── */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabbar-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.65rem;
  font-family: var(--font-sans);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
  padding: 4px 0;
}
.tabbar-btn svg { width: 22px; height: 22px; }
.tabbar-btn.active { color: var(--accent); }
.tabbar-btn:active { opacity: 0.6; }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.stat-card .stat-value {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--slate-100);
  color: var(--text);
}
.btn-secondary:hover { background: var(--slate-200); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--slate-100); color: var(--text); }
.btn-block { width: 100%; }

/* ── Forms ───────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.12);
}
.form-input.mono { font-family: var(--font-mono); }
.form-textarea { resize: vertical; min-height: 60px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
.form-check input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
}

/* ── Tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
td:last-child { text-align: right; }
td .mono { font-family: var(--font-mono); }

/* ── Lists (entries list) ────────────────────────────── */
.entry-list { list-style: none; }
.entry-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.entry-item:last-child { border-bottom: none; }
.entry-info { min-width: 0; }
.entry-info .entry-desc {
  font-weight: 600;
  font-size: 0.9rem;
}
.entry-info .entry-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.entry-amount {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}
.entry-actions { display: flex; gap: 6px; align-items: center; }

/* ── Badge / Tags ────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-green  { background: var(--green-100); color: var(--green-800); }
.badge-red    { background: var(--red-100);   color: var(--red-500); }
.badge-amber  { background: var(--amber-100); color: var(--amber-500); }
.badge-slate  { background: var(--slate-200); color: var(--slate-600); }

/* ── Toggle Switch ───────────────────────────────────── */
.toggle {
  position: relative;
  width: 44px; height: 24px;
  cursor: pointer;
  display: inline-block;
}
.toggle input { display: none; }
.toggle .slider {
  position: absolute;
  inset: 0;
  background: var(--slate-300);
  border-radius: 999px;
  transition: background 0.2s;
}
.toggle .slider::before {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  left: 2px; bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* ── Modal / Overlay ─────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: var(--max-w);
  max-height: 85dvh;
  overflow-y: auto;
  padding: 20px 16px;
  padding-bottom: 32px;
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h2 { margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

/* ── Chart / Bars ──────────────────────────────────── */
.chart-bar-group { margin-bottom: 8px; }
.chart-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 3px;
}
.chart-bar-track {
  height: 24px;
  background: var(--slate-100);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}
.chart-bar-income {
  height: 100%;
  background: var(--green-500);
  transition: width 0.3s;
  min-width: 2px;
}
.chart-bar-expense {
  height: 100%;
  background: var(--red-500);
  transition: width 0.3s;
  min-width: 2px;
}
.chart-bar-profit {
  height: 100%;
  background: var(--green-800);
  transition: width 0.3s;
  min-width: 2px;
}

/* ── Empty State ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}
.empty-state svg {
  width: 48px; height: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.empty-state h3 { color: var(--text-dim); margin-bottom: 8px; }
.empty-state p { font-size: 0.85rem; }
.empty-state .btn { margin-top: 16px; }

/* ── Toast ────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(var(--nav-h) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  background: var(--slate-900);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  animation: toastIn 0.2s ease-out;
  pointer-events: auto;
  white-space: nowrap;
}
.toast.toast-error { background: var(--danger); }
.toast.toast-success { background: var(--accent); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive: Tablet+ ─────────────────────────────── */
@media (min-width: 640px) {
  body { padding-top: var(--nav-h); }
  .container { padding: 0 24px; }
  .modal { border-radius: var(--radius); margin-bottom: auto; }
  .modal-overlay { align-items: center; }
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
  .tabbar {
    flex-direction: column;
    top: var(--nav-h);
    bottom: 0; left: 0;
    width: 72px;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 8px 0;
  }
  .tabbar-btn { padding: 12px 0; }
  body { margin-left: 72px; }
}

/* ── Focus Visible (Keyboard Accessibility) ────────── */
.navbar-brand:focus-visible,
.tabbar-btn:focus-visible,
.btn:focus-visible,
.btn-icon:focus-visible,
.modal-close:focus-visible,
.sift-support-link:focus-visible,
.sift-support-link-accent:focus-visible,
.sift-ecolink:focus-visible,
.upgrade-badge:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.toggle:focus-visible .slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Utility ─────────────────────────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.mt-2 { margin-top: 8px; }
/* ─── Upgrade / Monetization ─── */
.upgrade-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--warning);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.ml-2 { margin-left: 8px; }
.card-grid-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card-sm { padding: 10px; }
.text-base { font-size: 1rem; }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }
.divider-hr { border: none; border-top: 1px solid var(--border); }
.upgrade-content {
  padding: 8px 0;
}
.upgrade-pricing {
  display: flex;
  justify-content: center;
}
.pricing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}
.pricing-card.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.pricing-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.pricing-price {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}
.pricing-features {
  list-style: none;
  padding: 0;
  margin: 0 0 20px 0;
  text-align: left;
}
.pricing-features li {
  padding: 6px 0;
  font-size: 14px;
  color: var(--text-secondary);
}
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.pb-2 { padding-bottom: 8px; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Support / Monetization Footer ─────────────────────── */
.sift-support {
  margin-top: 32px;
  padding: 24px 20px 32px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}

.sift-support-inner {
  max-width: 480px;
  margin: 0 auto;
}

.sift-support-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}
.sift-support-icon {
  font-size: 28px;
  flex-shrink: 0;
  line-height: 1;
}
.sift-support-text {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
}

.sift-support-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.sift-support-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.sift-support-link:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.sift-support-link .link-icon { font-size: 20px; flex-shrink: 0; }
.sift-support-link .link-label { flex: 1; }
.sift-support-link .link-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--green-100);
  color: var(--green-800);
}
.sift-support-link-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.sift-support-link-accent:hover {
  filter: brightness(1.1);
}

.sift-affiliate {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.sift-affiliate-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.sift-affiliate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.sift-affiliate-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.sift-affiliate-link:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.sift-affiliate-link .link-icon { font-size: 16px; flex-shrink: 0; }
.sift-affiliate-link .link-label { flex: 1; }
.sift-affiliate-link .link-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 12px;
  background: var(--green-100);
  color: var(--green-800);
  white-space: nowrap;
}
.sift-affiliate-link-store:hover .link-badge {
  background: rgba(255,255,255,0.25);
  color: #fff;
}
.sift-affiliate-disclosure {
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0.55;
  text-align: center;
  line-height: 1.4;
  font-style: italic;
}

.sift-ecosystem {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.sift-ecosystem-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}
.sift-ecosystem-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.sift-ecolink {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s ease;
}
.sift-ecolink:hover {
  background: var(--bg-card);
  color: var(--text);
}

.sift-support-disclosure {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.6;
  margin-top: 12px;
  text-align: center;
  line-height: 1.4;
}

@media (max-width: 420px) {
  .sift-ecosystem-grid { grid-template-columns: 1fr; }
}
