/* ============================================
   PetEarn — Design System + Theme
   ============================================ */

:root {
  --bg:        #F4F4F5;
  --surface:   #FFFFFF;
  --surface2:  #FAFAFA;
  --border:    #E4E4E7;
  --border2:   #F0F0F0;
  --text:      #09090B;
  --text2:     #52525B;
  --text3:     #A1A1AA;
  --accent:    #6C5CE7;
  --accent-bg: #EEF0FD;
  --green:     #16A34A;
  --green-bg:  #F0FDF4;
  --red:       #DC2626;
  --red-bg:    #FEF2F2;
  --amber:     #D97706;
  --amber-bg:  #FFFBEB;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --bg:        #09090B;
  --surface:   #111113;
  --surface2:  #18181B;
  --border:    #27272A;
  --border2:   #1F1F22;
  --text:      #FAFAFA;
  --text2:     #A1A1AA;
  --text3:     #52525B;
  --accent:    #7C6FF7;
  --accent-bg: #1C1A3A;
  --green:     #22C55E;
  --green-bg:  #052E16;
  --red:       #EF4444;
  --red-bg:    #450A0A;
  --amber:     #F59E0B;
  --amber-bg:  #1C1400;
  --shadow:    0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }

/* THEME TOGGLE */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  transition: all 0.15s;
}
.theme-toggle:hover { background: var(--surface2); }

/* TYPOGRAPHY */
.t-display { font-size: 2rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1.1; }
.t-title   { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
.t-body    { font-size: 0.9rem; color: var(--text2); }
.t-caption { font-size: 0.75rem; color: var(--text3); font-weight: 500; }
.t-label   { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); }
.t-mono    { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.t-accent  { color: var(--accent); }
.t-green   { color: var(--green); }
.t-red     { color: var(--red); }

/* LAYOUT */
.container { max-width: 480px; margin: 0 auto; padding: 0 16px; }
.page-wrap { padding-bottom: 88px; }

/* CARD */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-body { padding: 16px; }
.card-section { padding: 16px; border-bottom: 1px solid var(--border2); }
.card-section:last-child { border-bottom: none; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 600;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border2); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-full { width: 100%; }
.btn-lg { padding: 14px 20px; font-size: 0.95rem; border-radius: 10px; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* STATUS DOTS */
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-green  { background: var(--green); }
.dot-accent { background: var(--accent); }
.dot-red    { background: var(--red); }
.dot-muted  { background: var(--border); }

/* BADGE */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; font-size: 0.72rem; font-weight: 700; }
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }
.badge-accent { background: var(--accent-bg); color: var(--accent); }
.badge-muted  { background: var(--surface2);  color: var(--text3); border: 1px solid var(--border); }

/* PROGRESS */
.progress { height: 5px; background: var(--border); border-radius: 20px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 20px; transition: width 0.4s ease; }
.progress-green  { background: var(--green); }
.progress-amber  { background: var(--amber); }
.progress-red    { background: var(--red); }
.progress-accent { background: var(--accent); }

/* BOTTOM NAV */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 10px 4px 8px;
  color: var(--text3);
  font-size: 0.6rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
  gap: 4px;
  transition: color 0.15s;
}
.nav-item svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.active { color: var(--accent); }

/* TOP BAR */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-logo { font-size: 1rem; font-weight: 800; letter-spacing: -0.03em; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-balance {
  font-size: 0.875rem; font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
}

/* FORMS */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.75rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 11px 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem; color: var(--text);
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.form-input:focus { outline: none; border-color: var(--accent); }
.form-input::placeholder { color: var(--text3); }

/* DIVIDER */
.divider { height: 1px; background: var(--border2); margin: 0; }

/* ALERT */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 0.85rem; margin-bottom: 14px; }
.alert-red   { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red); }
.alert-green { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.alert-amber { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber); }
.alert-accent{ background: var(--accent-bg);color: var(--accent);border: 1px solid var(--accent); }

/* TOAST */
#toast-wrap { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; min-width: 240px; }
.toast {
  background: var(--text); color: var(--surface);
  padding: 11px 16px; border-radius: 10px;
  font-size: 0.85rem; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease;
  pointer-events: all;
}
@keyframes toastIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--border);
  width: 100%; max-width: 480px;
  padding: 24px 20px 40px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-title { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.modal-sub { font-size: 0.85rem; color: var(--text2); margin-bottom: 20px; }

/* THEME SCRIPT SNIPPET (inline in head) */
