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

:root {
  /* Light mode (default) */
  --bg:       #f9fafb;
  --surface:  #ffffff;
  --card:     #ffffff;
  --border:   #e5e7eb;
  --accent:   #10b981;
  --accent2:  #059669;
  --green:    #10b981;
  --text:     #111827;
  --muted:    #6b7280;
  --red:      #ef4444;
  --amber:    #f59e0b;
  --hover:    rgba(16,185,129,0.06);
  --radius:   12px;
  --nav-h:    56px;
}

[data-theme="dark"] {
  --bg:       #111111;
  --surface:  #1a1a1a;
  --card:     #222222;
  --border:   #2e2e2e;
  --accent:   #10b981;
  --accent2:  #059669;
  --green:    #10b981;
  --text:     #f9fafb;
  --muted:    #9ca3af;
  --red:      #f87171;
  --amber:    #fbbf24;
  --hover:    rgba(255,255,255,0.05);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}

.hidden { display: none !important; }
.view   { min-height: 100vh; }

/* ── Toast ─────────────────────────────────────────────────── */
#appToast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  font-size: 0.82rem; font-weight: 500;
  padding: 9px 18px; border-radius: 20px;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.18s;
  z-index: 9999;
}
#appToast.toast-visible { opacity: 1; }

/* ── Loading ───────────────────────────────────────────────── */
#loadingScreen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}

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

/* ── Button loading state ──────────────────────────────────── */
.btn-loading {
  position: relative !important;
  color: transparent !important;
  pointer-events: none !important;
  cursor: default !important;
}
.btn-loading::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: rgba(255,255,255,0.9);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  top: 50%; left: 50%;
  margin-top: -7px; margin-left: -7px;
}
.btn-ghost.btn-loading::after,
.btn-danger.btn-loading::after {
  border-color: rgba(16,185,129,0.25);
  border-top-color: var(--accent);
}

/* ── Landing Page ──────────────────────────────────────────── */
#viewAuth { display: block; min-height: 100vh; }

/* Nav */
.land-nav {
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.land-nav-logo {
  font-size: 1.1rem; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.land-nav-cta {
  font-size: 0.85rem; font-weight: 600; color: var(--accent);
  text-decoration: none; padding: 7px 16px;
  border: 1.5px solid var(--accent); border-radius: 8px;
  transition: background 0.15s;
}
.land-nav-cta:hover { background: rgba(16,185,129,0.08); }

/* Hero */
.land-hero {
  padding: 88px 28px 72px;
  text-align: center;
  background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(16,185,129,0.08), transparent);
}
.land-hero-inner { max-width: 620px; margin: 0 auto; }
.land-eyebrow {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--accent); margin-bottom: 18px;
}
.land-h1 {
  font-size: 3rem; font-weight: 800; line-height: 1.12;
  letter-spacing: -0.025em;
  background: linear-gradient(140deg, var(--text) 40%, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 22px;
}
.land-hero-desc {
  font-size: 1.05rem; color: var(--muted); line-height: 1.7;
  max-width: 500px; margin: 0 auto 36px;
}
.land-hero-btn {
  display: inline-block; text-decoration: none;
  padding: 14px 32px; font-size: 1rem; border-radius: 10px;
  font-weight: 600;
}

/* Features */
.land-features {
  padding: 72px 28px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.land-features-inner { max-width: 960px; margin: 0 auto; }
.land-sec-title {
  font-size: 1.5rem; font-weight: 800;
  text-align: center; margin-bottom: 44px;
}
.land-feat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px;
}
.land-feat {
  padding: 28px 24px;
  background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.land-feat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  background: rgba(16,185,129,0.1);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.land-feat h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 8px; }
.land-feat p  { font-size: 0.85rem; color: var(--muted); line-height: 1.65; }

/* How it works */
.land-steps { padding: 72px 28px; }
.land-steps-inner { max-width: 560px; margin: 0 auto; }
.land-step-list { list-style: none; display: flex; flex-direction: column; gap: 32px; }
.land-step { display: flex; gap: 20px; align-items: flex-start; }
.land-step-num {
  flex-shrink: 0;
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-weight: 800; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
}
.land-step strong { display: block; font-size: 0.97rem; margin-bottom: 5px; }
.land-step p { font-size: 0.84rem; color: var(--muted); line-height: 1.65; margin: 0; }

/* Auth section */
.land-auth {
  padding: 72px 28px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.land-auth-inner {
  max-width: 860px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 56px;
  align-items: center;
}
.land-auth-copy h2 {
  font-size: 1.9rem; font-weight: 800; line-height: 1.2; margin-bottom: 12px;
}
.land-auth-copy p { color: var(--muted); font-size: 0.95rem; }

/* Landing footer */
.land-page-footer {
  text-align: center; padding: 22px 24px;
  font-size: 0.72rem; color: var(--muted); opacity: 0.65;
  border-top: 1px solid var(--border);
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  display: flex; flex-direction: column; gap: 20px;
}

#emailAuthSection {
  display: flex; flex-direction: column; gap: 16px;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.auth-tab {
  flex: 1; padding: 10px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.auth-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 0.75rem;
}
.auth-divider::before,
.auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px 16px;
  background: #fff; color: #3c4043;
  border: 1px solid #dadce0; border-radius: var(--radius);
  font-size: 0.95rem; font-weight: 500;
  cursor: pointer; transition: background 0.15s, box-shadow 0.15s;
}
.btn-google:hover  { background: #f8f9fa; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.btn-google:active { background: #f1f3f4; }
.btn-google:disabled { opacity: 0.6; cursor: default; }

.demo-notice {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: 8px; padding: 9px 12px;
  font-size: 0.8rem; color: var(--amber); text-align: center;
}

.auth-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 8px; padding: 9px 12px;
  font-size: 0.82rem; color: var(--red);
}

/* ── Nav ───────────────────────────────────────────────────── */
#appNav {
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
  transition: background 0.2s, border-color 0.2s;
}
.nav-brand {
  font-size: 1.1rem; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-right: auto;
  text-decoration: none;
  cursor: pointer;
}
.nav-right { display: flex; align-items: center; gap: 10px; }
#navUserEmail { font-size: 0.8rem; color: var(--muted); }

/* Theme toggle button */
.btn-theme {
  background: none; border: 1px solid var(--border);
  color: var(--muted); border-radius: 8px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-theme:hover { border-color: var(--accent); color: var(--accent); }
.btn-theme svg   { pointer-events: none; }

/* Show sun in dark mode (click → go light), moon in light mode (click → go dark) */
.icon-sun  { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ── App Views ─────────────────────────────────────────────── */
.app-view {
  max-width: 1300px;
  margin: 0 auto;
  padding: 32px 24px;
}

.page-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-header h2 { font-size: 1.4rem; font-weight: 700; }

/* ── Goals Grid ────────────────────────────────────────────── */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.goal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
  transition: border-color 0.15s;
  cursor: pointer;
  position: relative;
}
.goal-card:hover { border-color: var(--accent); }

.goal-card-actions {
  position: absolute; top: 10px; right: 10px;
  display: flex; gap: 4px; opacity: 0;
  transition: opacity 0.15s;
}
.goal-card:hover .goal-card-actions { opacity: 1; }

.goal-card-action-btn {
  background: none; border: none;
  color: var(--muted); font-size: 0.8rem;
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.goal-card-action-btn:hover        { background: var(--hover); color: var(--text); }
.goal-card-action-btn.danger:hover { background: rgba(239,68,68,0.1); color: var(--red); }

.goal-card-name-input {
  font-size: 1.05rem; font-weight: 700;
  background: transparent; border: none;
  border-bottom: 1px solid var(--accent);
  color: var(--text); outline: none;
  width: 100%; padding: 0; font-family: inherit;
}

.goal-title-input {
  font-size: 1.3rem; font-weight: 700;
  background: transparent; border: none;
  border-bottom: 2px solid var(--accent);
  color: var(--text); outline: none;
  flex: 1; padding: 2px 0; font-family: inherit;
  min-width: 0;
}

#goalTitle { cursor: pointer; transition: color 0.15s; min-width: 0; }
#goalTitle:hover { color: var(--accent); }

.goal-card-name {
  font-size: 1.05rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.goal-card-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.meta-pill {
  font-size: 0.7rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 2px 8px; color: var(--muted);
}
.goal-card-progress { display: flex; flex-direction: column; gap: 5px; }
.goal-card-progress-bar {
  height: 4px; background: var(--surface);
  border-radius: 99px; overflow: hidden;
}
.goal-card-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
}
.goal-card-progress-label {
  font-size: 0.72rem; color: var(--muted);
  display: flex; justify-content: space-between;
}
.goal-card-footer { display: flex; gap: 8px; margin-top: auto; }

/* ── Empty / Error States ──────────────────────────────────── */
.goals-error {
  grid-column: 1 / -1;
  padding: 16px 20px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius);
  color: var(--red); font-size: 0.85rem; line-height: 1.5;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center; padding: 60px 24px;
  color: var(--muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { margin-bottom: 20px; }

/* ── Goal Not Found ────────────────────────────────────────── */
.goal-not-found {
  text-align: center;
  padding: 80px 24px;
  color: var(--muted);
}
.goal-not-found .empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.goal-not-found p  { margin-bottom: 24px; font-size: 0.9rem; }

/* ── Tags ──────────────────────────────────────────────────── */
.goal-tags-row { padding: 0 0 4px; }

.tags-wrap {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 28px;
}

.tag-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.28);
  color: var(--accent);
  border-radius: 99px; padding: 3px 6px 3px 10px;
  font-size: 0.73rem; font-weight: 500;
  white-space: nowrap;
}

.tag-remove {
  background: none; border: none; padding: 0;
  color: rgba(16,185,129,0.55); font-size: 0.85rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center;
  width: auto; min-width: 14px; height: 14px;
  transition: color 0.15s; position: relative;
}
.tag-remove:hover { color: var(--red); }
.tag-remove.btn-loading { width: 14px; }
.tag-remove.btn-loading::after {
  width: 9px; height: 9px;
  margin-top: -4.5px; margin-left: -4.5px;
  border-color: rgba(16,185,129,0.25);
  border-top-color: var(--accent);
}

.tag-add-input {
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 99px; color: var(--muted);
  padding: 3px 10px; font-size: 0.73rem;
  width: 80px; outline: none;
  transition: border-color 0.15s, color 0.15s;
}
.tag-add-input:focus {
  border-color: rgba(16,185,129,0.4); color: var(--text);
}
.tag-add-input::placeholder { color: var(--muted); opacity: 0.7; }

/* ── Goal Topbar + Tabs ────────────────────────────────────── */
.goal-topbar {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 24px;
}
.goal-topbar h2 { font-size: 1.3rem; font-weight: 700; flex: 1; }
.btn-back { font-size: 0.85rem; }

.tabs-bar {
  display: flex; gap: 4px; margin-bottom: 28px;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.tab-btn {
  padding: 10px 20px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: color 0.15s, border-color 0.15s;
  position: relative;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--green); color: #fff;
  font-size: 0.6rem; font-weight: 800;
  width: 16px; height: 16px; border-radius: 50%;
  margin-left: 5px; vertical-align: middle;
}

/* ── Calculator Layout ─────────────────────────────────────── */
.calc-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) { .calc-layout { grid-template-columns: 1fr; } }

/* ── Inputs ────────────────────────────────────────────────── */
.inputs-panel { position: sticky; top: calc(var(--nav-h) + 16px); }
/* Override sticky AFTER the declaration so the cascade is correct */
@media (max-width: 900px) { .inputs-panel { position: static; } }

.inputs-grid {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; }

label {
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted);
}

.input-row { display: flex; }
.input-row input  { border-radius: var(--radius) 0 0 var(--radius); flex: 1; border-right: none; }
.input-row select { border-radius: 0 var(--radius) var(--radius) 0; width: auto; min-width: 100px; }

input[type="number"], input[type="email"],
input[type="password"], input[type="text"], select {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 10px 13px;
  font-size: 0.92rem; border-radius: var(--radius);
  width: 100%; outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
input:focus, select:focus { border-color: var(--accent); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; border: none; border-radius: var(--radius);
  padding: 10px 22px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap; font-family: inherit;
}
.btn-primary:hover  { opacity: 0.88; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.full   { width: 100%; padding: 12px; }

.btn-ghost {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px;
  padding: 7px 14px; font-size: 0.82rem; font-weight: 500;
  cursor: pointer; transition: border-color 0.15s;
  white-space: nowrap; font-family: inherit;
}
.btn-ghost:hover { border-color: var(--accent); }
.btn-danger, .btn-ghost.btn-danger { color: var(--red); }
.btn-ghost.btn-danger:hover { border-color: var(--red); }

.btn-sm {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px;
  padding: 5px 12px; font-size: 0.76rem; font-weight: 500;
  cursor: pointer; width: auto; font-family: inherit;
}
.btn-sm.danger:hover { border-color: var(--red); color: var(--red); }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin-bottom: 18px;
}

/* ── Summary ───────────────────────────────────────────────── */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.stat-card .label {
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin-bottom: 8px;
}
.stat-card .value { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.5px; }
.value.green  { color: var(--accent); }
.value.blue   { color: var(--accent); }
.value.purple { color: #34d399; }
.value.white  { color: var(--text); }

/* Results panel - must not overflow its grid cell on mobile */
.results-panel { min-width: 0; overflow-x: hidden; }

/* ── Chart ─────────────────────────────────────────────────── */
.chart-wrapper { position: relative; height: 300px; }

/* ── Challenge CTA ─────────────────────────────────────────── */
.challenge-cta {
  background: var(--card); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 20px 22px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.cta-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 3px; }
.cta-sub   { font-size: 0.8rem; color: var(--muted); }

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
thead th {
  text-align: left; padding: 8px 12px;
  font-size: 0.67rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.12s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--hover); }
tbody td { padding: 9px 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.col-muted  { color: var(--muted); }
.col-green  { color: var(--accent); font-weight: 600; }
.col-blue   { color: var(--accent); font-weight: 600; }
.col-purple { color: #34d399; }

.pagination {
  display: flex; align-items: center;
  justify-content: flex-end; gap: 10px; margin-top: 14px;
}
.pagination span { font-size: 0.78rem; color: var(--muted); }

/* ── Challenge layout ──────────────────────────────────────── */
.challenge-hdr {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px;
  margin-bottom: 24px;
}
.challenge-title { font-size: 1rem; font-weight: 700; }
.challenge-sub   { font-size: 0.78rem; color: var(--muted); margin-top: 3px; }

.challenge-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 24px; align-items: start;
}
@media (max-width: 1050px) { .challenge-layout { grid-template-columns: 1fr; } }

.challenge-left, .challenge-right { display: flex; flex-direction: column; gap: 0; }

/* ── Submit card ───────────────────────────────────────────── */
.cp-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px 24px; margin-bottom: 20px;
}
.cp-eyebrow {
  font-size: 0.63rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); margin-bottom: 4px;
}
.cp-period    { font-size: 1.9rem; font-weight: 800; color: var(--accent); line-height: 1; }
.cp-date      { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.cp-right     { text-align: right; }
.cp-projected { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.cp-need      { font-size: 0.74rem; color: var(--muted); margin-top: 3px; }

.cp-drawdown-row {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 0;
  border-top: 1px dashed var(--border);
}
.cp-drawdown-label {
  font-size: 0.63rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin-right: auto;
}
.cp-drawdown-amt { font-size: 0.9rem; font-weight: 700; color: var(--red); }
.cp-drawdown-pct { font-size: 0.78rem; color: var(--muted); }

.cp-progress-wrap  { grid-column: 1 / -1; }
.cp-progress-track { height: 5px; background: var(--surface); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); margin-bottom: 4px; }
.cp-progress-fill  { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 99px; transition: width 0.3s ease; }
.cp-progress-label { display: flex; justify-content: space-between; font-size: 0.68rem; color: var(--muted); }

.cp-input-row { grid-column: 1 / -1; display: flex; gap: 10px; }
.cp-input-row input  { flex: 1; }
.cp-input-row button { width: auto; padding: 10px 22px; }

/* ── All done ──────────────────────────────────────────────── */
.cm-all-done {
  background: rgba(16,185,129,0.07); border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--radius); padding: 22px; text-align: center; margin-bottom: 20px;
}
.cm-all-done-title { font-size: 1.05rem; font-weight: 700; color: var(--accent); margin-bottom: 5px; }
.cm-all-done-sub   { font-size: 0.78rem; color: var(--muted); }

/* ── Trade log ─────────────────────────────────────────────── */
.cm-history-label {
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin-bottom: 8px;
}
.cm-sub-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 420px; overflow-y: auto; padding-right: 2px;
}
.cm-sub-list::-webkit-scrollbar { width: 4px; }
.cm-sub-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.cm-sub-row {
  display: grid;
  grid-template-columns: 36px 1fr 36px 1fr 1fr 1fr 88px;
  align-items: center; gap: 6px; padding: 9px 11px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; font-size: 0.78rem; border-left-width: 3px;
}
.cm-sub-row.cm-sub-header {
  background: transparent; border-color: transparent; padding-bottom: 3px;
}
.cm-sub-row.cm-sub-header span {
  font-size: 0.62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted);
}

.cm-sub-row.tier-s    { border-left-color: var(--amber);  background: rgba(245,158,11,0.07); box-shadow: 0 0 10px rgba(245,158,11,0.1); }
.cm-sub-row.tier-a    { border-left-color: var(--green);  background: rgba(16,185,129,0.06); box-shadow: 0 0 6px rgba(16,185,129,0.08); }
.cm-sub-row.tier-b    { border-left-color: rgba(16,185,129,0.45); background: rgba(16,185,129,0.03); }
.cm-sub-row.tier-c    { border-left-color: var(--border); }
.cm-sub-row.tier-miss { border-left-color: rgba(239,68,68,0.5); background: rgba(239,68,68,0.04); }

.cm-sub-period { color: var(--muted); font-weight: 700; }
.cm-sub-date   { color: var(--muted); font-size: 0.7rem; }
.cm-sub-actual { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.cm-sub-proj   { color: var(--text); font-variant-numeric: tabular-nums; }
.cm-sub-diff   { font-weight: 600; font-variant-numeric: tabular-nums; }
.cm-sub-diff.pos { color: var(--green); }
.cm-sub-diff.neg { color: var(--red); }

.level-badge {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 0.6rem; font-weight: 800; padding: 1px 5px;
  border-radius: 4px; margin-left: 4px; vertical-align: middle;
}
.level-badge.s    { background: rgba(245,158,11,0.18); color: var(--amber); }
.level-badge.a    { background: rgba(16,185,129,0.15); color: var(--green); }
.level-badge.b    { background: rgba(16,185,129,0.1);  color: var(--green); }
.level-badge.miss { background: rgba(239,68,68,0.12);  color: var(--red); }

/* ── Checklist ─────────────────────────────────────────────── */
.progress-wrap { margin-bottom: 16px; }
.progress-top  { display: flex; justify-content: space-between; margin-bottom: 6px; }
.progress-label { font-size: 0.76rem; color: var(--muted); }
.progress-pct   { font-size: 0.9rem; font-weight: 700; color: var(--green); }
.progress-bar   { height: 5px; background: var(--surface); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill  { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 99px; transition: width 0.3s ease; }

.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px; max-height: 300px; overflow-y: auto;
  padding-right: 4px; margin-top: 4px;
}
.checklist-grid::-webkit-scrollbar { width: 4px; }
.checklist-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.check-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: border-color 0.12s, background 0.12s;
  user-select: none;
}
.check-item:hover { border-color: var(--accent); }
.check-item.done  { border-color: rgba(16,185,129,0.4); background: rgba(16,185,129,0.06); }
.check-box {
  width: 16px; height: 16px; border-radius: 4px;
  border: 2px solid var(--border); background: var(--bg);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: border-color 0.12s, background 0.12s;
}
.check-item.done .check-box { border-color: var(--green); background: var(--green); }
.check-box svg { display: none; }
.check-item.done .check-box svg { display: block; }
.check-info { flex: 1; min-width: 0; }
.check-period { font-size: 0.74rem; font-weight: 700; color: var(--text); }
.check-item.done .check-period { color: var(--muted); text-decoration: line-through; }
.check-date    { font-size: 0.64rem; color: var(--muted); margin-top: 1px; }
.check-balance { font-size: 0.67rem; color: var(--accent); font-weight: 600; margin-top: 1px; }
.check-item.done .check-balance { color: var(--muted); }

/* ── Challenge Graph header ────────────────────────────────── */
.cg-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px; margin-bottom: 16px;
}
.btn-icon { padding: 5px 7px; flex-shrink: 0; line-height: 1; }
.cg-subtext { font-size: 0.76rem; color: var(--muted); margin-top: 4px; }
.cg-subtext .ahead  { color: var(--green); font-weight: 600; }
.cg-subtext .behind { color: var(--red); font-weight: 600; }

/* ── Modals ────────────────────────────────────────────────── */
.chart-modal-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  width: 92vw; max-width: 1300px; max-height: 90vh;
  display: flex; flex-direction: column; gap: 16px;
}
.chart-modal-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px; flex-shrink: 0;
}
.chart-modal-body {
  position: relative; flex: 1; min-height: 300px;
  height: clamp(300px, 60vh, 600px);
}
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.modal-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: 18px;
}
.modal-card h3 { font-size: 1.05rem; font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.confirm-card { max-width: 360px; }
.confirm-msg  { font-size: 0.93rem; line-height: 1.55; color: var(--text); }

.btn-danger-solid {
  padding: 9px 18px; border-radius: var(--radius);
  background: var(--red); color: #fff; border: none;
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s;
}
.btn-danger-solid:hover  { opacity: 0.87; }
.btn-danger-solid:active { opacity: 0.75; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Challenge Setup Form ──────────────────────────────────── */
.challenge-setup {
  max-width: 500px;
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 20px;
  padding: 8px 0 32px;
}

.setup-header {
  display: flex; align-items: center; gap: 14px;
}
.setup-icon  { font-size: 2rem; line-height: 1; }
.setup-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 3px; }
.setup-sub   { font-size: 0.8rem; color: var(--muted); }

.setup-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}

.setup-preview {
  background: rgba(16,185,129,0.06);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.setup-rate-label {
  font-size: 0.65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin-bottom: 4px;
}
.setup-rate-value {
  font-size: 2.4rem; font-weight: 800;
  color: var(--accent); line-height: 1;
}

.setup-targets { display: flex; flex-wrap: wrap; gap: 5px; }
.setup-target-chip {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 3px 10px;
  font-size: 0.72rem; color: var(--muted);
}
.setup-target-chip.final {
  border-color: rgba(16,185,129,0.3);
  color: var(--accent); font-weight: 600;
}

.setup-alt {
  text-align: center;
  font-size: 0.78rem; color: var(--muted);
}
.btn-link {
  background: none; border: none; padding: 0;
  color: var(--accent); font-size: inherit;
  cursor: pointer; font-family: inherit;
  text-decoration: underline; text-underline-offset: 2px;
}
.btn-link:hover { opacity: 0.8; }

/* ── Custom Challenge Summary Banner ───────────────────────── */
.custom-summary-card {
  display: flex; flex-wrap: wrap;
  background: var(--card);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--radius); overflow: hidden;
  margin-bottom: 20px;
}
.cs-stat {
  flex: 1; min-width: 110px;
  padding: 13px 16px;
  border-right: 1px solid var(--border);
}
.cs-stat:last-child { border-right: none; }
.cs-label {
  font-size: 0.63rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin-bottom: 4px;
}
.cs-value { font-size: 0.96rem; font-weight: 700; }
.cs-green { color: var(--accent); }

/* ── App Footer ────────────────────────────────────────────── */
.app-footer {
  border-top: 1px solid var(--border);
  padding: 18px 24px;
  margin-top: 40px;
}
.footer-inner {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px;
  font-size: 0.78rem; color: var(--muted);
}
.footer-brand {
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.footer-sep { opacity: 0.4; }
.footer-disclaimer {
  font-size: 0.7rem; color: var(--muted); opacity: 0.65;
  margin-top: 6px;
}
.footer-link {
  color: inherit; text-underline-offset: 2px;
}
.footer-link:hover { color: var(--accent); }

/* ── Auth Footer ───────────────────────────────────────────── */
.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.7;
}

/* ── Responsive ────────────────────────────────────────────── */

/* Touch / no-hover: card actions always visible, bigger tap targets */
@media (hover: none), (pointer: coarse) {
  .goal-card-actions  { opacity: 1; }
  .goal-card-action-btn { width: 32px; height: 32px; font-size: 0.9rem; }
  .btn-ghost  { min-height: 40px; }
  .btn-sm     { min-height: 38px; padding: 8px 14px; }
  .tab-btn    { padding: 12px 18px; }
  .tag-remove { width: 18px; height: 18px; min-width: 18px; }
}

/* Tablet / large phone */
@media (max-width: 768px) {
  .land-h1 { font-size: 2.2rem; }
  .land-feat-grid { grid-template-columns: 1fr; }
  .land-auth-inner { grid-template-columns: 1fr; text-align: center; }
  .land-auth-copy { order: -1; }

  #appNav { padding: 0 16px; }
  #navUserEmail {
    max-width: 150px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .app-view    { padding: 20px 16px; }
  .goal-topbar { flex-wrap: wrap; gap: 10px; }
  .challenge-cta { flex-direction: column; align-items: flex-start; gap: 14px; }
  .challenge-cta .btn-primary { width: 100%; text-align: center; }
  .cp-card  { grid-template-columns: 1fr; }
  .cp-right { text-align: left; }
  .modal-actions { flex-direction: column-reverse; gap: 8px; }
  .modal-actions .btn-ghost,
  .modal-actions .btn-primary { width: 100%; text-align: center; justify-content: center; }
}

/* Small phone */
@media (max-width: 600px) {
  .land-hero  { padding: 52px 18px 44px; }
  .land-h1    { font-size: 1.8rem; }
  .land-hero-desc { font-size: 0.92rem; }
  .land-features, .land-steps, .land-auth { padding: 48px 18px; }
  .land-nav   { padding: 0 18px; }

  .setup-fields { grid-template-columns: 1fr; }
  #navUserEmail { display: none; }

  /* Prevent iOS Safari auto-zoom on input focus (requires font-size >= 16px) */
  input[type="number"], input[type="email"],
  input[type="password"], input[type="text"], select { font-size: 16px; }

  .app-view    { padding: 16px 14px; }
  .page-header { flex-wrap: wrap; gap: 10px; }
  .summary     { grid-template-columns: 1fr 1fr; }
  .stat-card   { padding: 14px 12px; overflow: hidden; }
  .stat-card .value { font-size: 1.1rem; word-break: break-all; }

  .goal-topbar { gap: 8px; }
  .goal-topbar h2 { font-size: 1.15rem; }

  .cp-input-row        { flex-direction: column; }
  .cp-input-row button { width: 100%; }

  /* Trade log: drop target and vs-prev columns */
  .cm-sub-row {
    grid-template-columns: 28px 1fr 28px 1fr 80px;
    font-size: 0.72rem;
  }
  .cm-sub-row > :nth-child(5),
  .cm-sub-row > :nth-child(6) { display: none; }
  .cm-sub-row.cm-sub-header > :nth-child(5),
  .cm-sub-row.cm-sub-header > :nth-child(6) { display: none; }

  /* Periodic breakdown table: hide Opening, Top-Up, per-period Interest */
  .table-wrap table thead th:nth-child(3),
  .table-wrap table thead th:nth-child(4),
  .table-wrap table thead th:nth-child(5),
  .table-wrap table tbody td:nth-child(3),
  .table-wrap table tbody td:nth-child(4),
  .table-wrap table tbody td:nth-child(5) { display: none; }

  .card        { padding: 18px 14px; }
  .inputs-grid { padding: 18px 14px; }
  .cp-card     { padding: 16px 14px; }
  .chart-wrapper { height: 220px; }
  .modal-card  { padding: 22px 16px; }
}

/* Very small phone */
@media (max-width: 400px) {
  .summary          { grid-template-columns: 1fr; }
  .stat-card .value { font-size: 1.15rem; }
  .cp-period        { font-size: 1.5rem; }
}
