:root {
  --primary: #1a5a2a;
  --primary-dark: #0d3315;
  --primary-light: #2d8a42;
  --primary-subtle: #eaf5ee;
  --secondary: #b8862a;
  --secondary-light: #c9a04a;
  --secondary-subtle: #f7f0e0;
  --accent: #7a3b10;
  --accent-light: #9a5a2a;
  --bg: #f4f2ec;
  --bg-card: #fdfcf9;
  --bg-elevated: #fefdfa;
  --bg-dark: #141c16;
  --bg-subtle: #ebe8e0;
  --text: #1a1c19;
  --text-secondary: #4a4f48;
  --text-tertiary: #7a8076;
  --text-inverse: #fdfcf9;
  --border: #d8d4c8;
  --border-light: #e6e2d6;
  --success: #1a7a3a;
  --success-bg: #e6f5ea;
  --warning: #b8862a;
  --warning-bg: #f7f0e0;
  --danger: #b83a2e;
  --danger-bg: #f9e8e6;
  --info: #1a5f78;
  --info-bg: #e6f0f4;
  --radius: 24px 6px 6px 6px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 28px 10px 10px 10px;
  --radius-xl: 1.5rem;
  --radius-2xl: 2rem;
  --radius-pill: 999px;
  --shadow: 0 2px 8px rgba(26, 90, 42, 0.06), 0 1px 2px rgba(26, 28, 25, 0.04);
  --shadow-md: 0 8px 20px rgba(26, 90, 42, 0.08), 0 2px 6px rgba(26, 28, 25, 0.05);
  --shadow-lg: 0 16px 40px rgba(26, 90, 42, 0.1), 0 4px 10px rgba(26, 28, 25, 0.05);
  --shadow-xl: 0 28px 60px rgba(13, 51, 21, 0.14);
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-serif: 'Lora', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --header-h: 0px;
  --nav-w: 0px;
  --max-w: 1180px;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-snap: cubic-bezier(0.32, 0.72, 0, 1);
  --transition: 0.22s var(--ease-out-expo);
  --transition-slow: 0.45s var(--ease-out-expo);
  --z-header: 100;
  --z-nav: 99;
  --z-overlay: 98;
  --z-modal: 1000;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #3d9a52;
    --primary-dark: #1a5a2a;
    --primary-light: #5bb86a;
    --primary-subtle: #15251a;
    --secondary: #d4a84a;
    --secondary-light: #e0bc68;
    --secondary-subtle: #241c0e;
    --accent: #c07a4a;
    --accent-light: #d49468;
    --bg: #0e1210;
    --bg-card: #161b17;
    --bg-elevated: #1c221e;
    --bg-dark: #0a0d0b;
    --bg-subtle: #131814;
    --text: #e8ebe7;
    --text-secondary: #a0a89e;
    --text-tertiary: #6a7268;
    --text-inverse: #0e1210;
    --border: #2a322c;
    --border-light: #222a24;
    --success: #3d9a52;
    --success-bg: #0f2414;
    --warning: #d4a84a;
    --warning-bg: #241c0e;
    --danger: #e05a4c;
    --danger-bg: #2a1210;
    --info: #4ab0c8;
    --info-bg: #102028;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(26, 90, 42, 0.12);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(26, 90, 42, 0.15);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5), 0 4px 10px rgba(26, 90, 42, 0.12);
    --shadow-xl: 0 28px 60px rgba(0, 0, 0, 0.6);
  }
}

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

html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  font-feature-settings: "ss01", "kern";
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 180px 180px;
}

.skip-link {
  position: absolute; top: -100px; left: 1rem; z-index: 10000;
  background: var(--primary); color: var(--text-inverse);
  padding: 0.65rem 1.1rem; border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-weight: 600; font-size: 0.875rem;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 0.75rem; outline: 2px solid var(--secondary); outline-offset: 2px; }

a { color: var(--primary-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary); }
img { max-width: 100%; height: auto; display: block; }

::selection { background: var(--primary); color: var(--text-inverse); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans); font-weight: 600; line-height: 1.2;
  color: var(--text); letter-spacing: -0.02em; text-wrap: balance;
}
h1 { font-size: clamp(1.75rem, 2.5vw, 2.15rem); font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: clamp(1.3rem, 2vw, 1.55rem); letter-spacing: -0.025em; }
h3 { font-size: 1.2rem; font-weight: 600; }
h4 { font-size: 1.05rem; font-weight: 600; }

p { margin-bottom: 0.75rem; color: var(--text-secondary); font-size: 0.95rem; line-height: 1.7; max-width: 65ch; text-wrap: pretty; }
.scripture, .welcome-banner p, blockquote { font-family: var(--font-serif); font-style: italic; }
.money, .stat-value, .cat-planned, .cat-actual, .cat-diff, .debt-percent, .savings-amount {
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
}

button {
  cursor: pointer; font-family: var(--font-sans); border: none;
  background: none; font-size: 0.95rem; font-weight: 500; outline: none;
}
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

input, textarea, select {
  font-family: var(--font-body); font-size: 0.95rem;
  padding: 0.75rem 0.85rem 0.75rem 1.25rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%; outline: none;
}
input:hover, textarea:hover, select:hover { border-color: #c5c3bd; }
input:focus, textarea:focus, select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(45,138,66,0.1);
}
input::placeholder, textarea::placeholder { color: var(--text-tertiary); opacity: 1; }
textarea { resize: vertical; min-height: 90px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23555' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; border-radius: var(--radius-sm); }

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.7rem 1.45rem; border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-weight: 600; font-size: 0.875rem;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  text-align: center; white-space: nowrap; line-height: 1.4; letter-spacing: 0.01em;
}
.btn:active { transform: scale(0.98) translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary {
  background: var(--primary); color: var(--text-inverse); font-weight: 600;
  border-radius: 999px; padding: 0.7rem 1.5rem;
  box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset, var(--shadow);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); transform: translateY(-1px); }

.btn-secondary {
  background: var(--secondary); color: #1a1c19; font-weight: 600; border-radius: 999px;
}
.btn-secondary:hover { background: var(--secondary-light); box-shadow: var(--shadow-md); transform: translateY(-1px); }

.btn-outline {
  background: transparent; border: 1.5px solid var(--border); color: var(--primary);
  font-weight: 500; border-radius: 999px;
}
.btn-outline:hover { background: var(--primary-subtle); border-color: var(--primary-light); color: var(--primary-dark); }

.btn-ghost { background: transparent; color: var(--text-secondary); font-weight: 500; }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }

.btn-danger { background: var(--danger); color: var(--text-inverse); font-weight: 600; border-radius: 999px; }
.btn-danger:hover { background: #962e24; }

.btn-sm { padding: 0.45rem 0.95rem; font-size: 0.8rem; }
.btn-lg { padding: 0.9rem 1.85rem; font-size: 0.95rem; }
.btn-xl { padding: 1.05rem 2.5rem; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ========== BUTTON-IN-BUTTON ========== */
.btn-icon-wrap {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.75rem; height: 1.75rem; border-radius: 50%;
  background: rgba(255,255,255,0.15); flex-shrink: 0;
  transition: transform 0.4s var(--ease-out-expo);
}
.btn-primary:hover .btn-icon-wrap { transform: translateX(2px) scale(1.05); }
.btn-icon { font-size: 0.75rem; line-height: 1; }

.icon-btn {
  width: 36px; height: 36px; display: inline-flex;
  align-items: center; justify-content: center;
  border-radius: 50%; font-size: 1.1rem;
  transition: all var(--transition); color: var(--text-secondary);
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--text); }

/* ========== DOUBLE-BEZEL CARD ========== */
.double-bezel { height: 100%; }
.bezel-outer {
  padding: 0.5rem; border-radius: var(--radius-2xl);
  background: rgba(26, 28, 25, 0.035);
  border: 1px solid rgba(26, 28, 25, 0.06);
  height: 100%; transition: all 0.4s var(--ease-out-expo);
}
.bezel-outer:hover { background: rgba(26, 90, 42, 0.04); border-color: rgba(26, 90, 42, 0.12); }
.bezel-inner {
  border-radius: calc(var(--radius-2xl) - 0.375rem);
  background: var(--bg-card); padding: 1.5rem; height: 100%;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 1px 2px rgba(26, 28, 25, 0.04);
  position: relative;
}
.bezel-inner h3 { font-family: var(--font-sans); font-weight: 600; font-size: 1.1rem; letter-spacing: -0.02em; margin-bottom: 0.6rem; color: var(--text); }
.bezel-inner p { font-family: var(--font-body); font-size: 0.9rem; color: rgba(26, 28, 25, 0.6); line-height: 1.65; }
.bezel-icon {
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  background: rgba(26, 90, 42, 0.08); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; margin-bottom: 1rem; font-family: var(--font-sans); font-weight: 600;
}

/* ========== STANDARD CARD ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-2xl);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 18%, var(--border-light)); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.75rem; padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; padding-bottom: 0.65rem;
  border-bottom: 2px solid var(--border-light); position: relative;
}
.section-header::after {
  content: ''; position: absolute; bottom: -2px; left: 0;
  width: 50px; height: 3px; background: var(--primary); border-radius: 2px;
}
.section-header h1 { margin: 0; font-size: 1.5rem; }
.section-subtitle { color: var(--text-tertiary); font-size: 0.9rem; margin-top: 0.15rem; font-family: var(--font-body); }

.dt-sc-small-separator {
  clear: both; display: inline-block; height: 3px;
  margin: 0.5rem 0 1rem; width: 60px; background: var(--primary); border-radius: 2px;
}

/* ========== BADGES ========== */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.55rem; border-radius: 999px;
  font-family: var(--font-sans); font-size: 0.68rem;
  font-weight: 600; letter-spacing: 0.03em; line-height: 1.4; text-transform: none;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: #7a6210; }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-primary { background: var(--primary-subtle); color: var(--primary-light); }

/* ========== FORMS ========== */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block; font-family: var(--font-sans); font-weight: 600;
  margin-bottom: 0.35rem; font-size: 0.82rem; color: var(--text); letter-spacing: 0.02em;
}
.form-hint { font-size: 0.78rem; color: var(--text-tertiary); margin-top: 0.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 1rem; }

/* ========== EMPTY STATE ========== */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--text-tertiary); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h2 { font-size: 1.2rem; margin-bottom: 0.5rem; color: var(--text-secondary); }
.empty-state p { font-size: 0.9rem; margin-bottom: 1.25rem; }

/* ========== ALERTS ========== */
.alert { padding: 0.85rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 0.9rem; line-height: 1.5; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 25%, transparent); }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); }
.alert-warning { background: var(--warning-bg); color: #7a6210; border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent); }
@media (prefers-color-scheme: dark) { .alert-warning { color: var(--warning); } }

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px); z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--bg-card); border-radius: var(--radius-2xl);
  width: 100%; max-width: 520px; max-height: 85vh; overflow-y: auto;
  padding: 1.5rem; box-shadow: var(--shadow-xl); animation: slideUp 0.2s var(--ease-out-expo);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border-light);
}
.modal-header h2 { margin: 0; font-size: 1.1rem; }
.modal-footer {
  display: flex; gap: 0.75rem; justify-content: flex-end;
  margin-top: 1.25rem; padding-top: 0.75rem; border-top: 1px solid var(--border-light);
}
.modal-close {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 1.25rem; color: var(--text-tertiary); transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-subtle); color: var(--text); }

/* ========== PROGRESS BAR ========== */
.progress-bar { height: 6px; background: var(--border); border-radius: var(--radius-pill); overflow: hidden; }
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius-pill); transition: width 0.6s var(--ease-out-expo); min-width: 2px;
}

/* ========== LOADING ========== */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4rem 1rem; color: var(--text-tertiary); gap: 0.85rem; }
.loading-spinner { width: 28px; height: 28px; border: 2.5px solid var(--border); border-top-color: var(--primary); border-radius: var(--radius-pill); animation: spin 0.75s linear infinite; }
.skeleton { background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border-light) 50%, var(--bg-subtle) 75%); background-size: 200% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }
.skeleton-line { height: 0.85rem; margin-bottom: 0.65rem; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-card { height: 120px; border-radius: var(--radius); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ========== ANIMATIONS ========== */
.reveal { opacity: 0; transform: translateY(24px); transition: all 0.8s var(--ease-out-expo); }
.reveal.in-view { opacity: 1; transform: translateY(0); }
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }
.reveal-delay-5 { transition-delay: 0.5s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .loading-spinner { animation: none !important; }
  .card:hover, .stat-card:hover, .course-card:hover, .debt-card:hover, .savings-card:hover, .post-card:hover { transform: none !important; }
  .btn:active { transform: none !important; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ========== OVERLAY ========== */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.25); backdrop-filter: blur(2px);
  z-index: var(--z-overlay); opacity: 0; transition: opacity var(--transition-slow);
  pointer-events: none;
}
.overlay.active { opacity: 1; pointer-events: all; }

/* ========== UTILITY ========== */
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border-light); margin: 1.5rem 0; }

.tooltip { position: relative; }
.tooltip::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); padding: 0.35rem 0.65rem;
  background: var(--text); color: var(--text-inverse);
  font-size: 0.75rem; border-radius: var(--radius-sm); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity var(--transition);
}
.tooltip:hover::after { opacity: 1; }

/* ========== STAT ICONS ========== */
.stat-icon {
  width: 42px; height: 42px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-sans); font-weight: 600; font-size: 0.9rem;
  line-height: 1; flex-shrink: 0;
}
.stat-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.stat-icon--primary { background: var(--primary-subtle); color: var(--primary); }
.stat-icon--secondary { background: var(--secondary-subtle); color: var(--secondary); }
.stat-icon--accent { background: color-mix(in srgb, var(--accent) 12%, white); color: var(--accent); }
.stat-icon--info { background: var(--info-bg); color: var(--info); }
.stat-icon--success { background: var(--success-bg); color: var(--success); }
.stat-icon--danger { background: var(--danger-bg); color: var(--danger); }

/* ========== STATS GRID ========== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius-2xl); padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  display: flex; align-items: flex-start; gap: 0.85rem;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 15%, var(--border-light)); }
.stat-card-body { flex: 1; min-width: 0; }
.stat-card .stat-label { font-family: var(--font-sans); font-size: 0.7rem; color: var(--text-tertiary); text-transform: none; letter-spacing: 0.02em; font-weight: 550; margin-bottom: 0.2rem; }
.stat-card .stat-value { font-family: var(--font-sans); font-size: 1.55rem; font-weight: 700; color: var(--text); letter-spacing: -0.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  html { font-size: 15px; }
  h1 { font-size: 1.65rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.15rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
