/* ═══════════════════════ CORE CONFIG & THEMES ═══════════════════════ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ═══ LIGHT THEME ═══ */
:root {
  --bg: #edf6f0;
  --bg-mesh: radial-gradient(ellipse 90% 60% at 15% -5%, #bce8cc 0%, transparent 55%),
             radial-gradient(ellipse 70% 55% at 85% 105%, #c6ead8 0%, transparent 55%),
             #edf6f0;
  --surface: #ffffff;
  --surface-2: #f3faf6;
  --surface-3: #e6f4ec;
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.13);
  --text-primary: #0c1e13;
  --text-secondary: #3d6650;
  --text-muted: #85a895;
  --accent: #1b7d4e;
  --accent-soft: #ddf2e8;
  --accent-glow: rgba(27, 125, 78, 0.14);
  --lime: #d8f44a;
  --red: #f04646;
  --red-soft: #fff1f1;
  --shadow-sm: 0 2px 10px rgba(0, 30, 15, 0.06);
  --shadow-md: 0 4px 22px rgba(0, 30, 15, 0.1);
  --shadow-lg: 0 8px 42px rgba(0, 30, 15, 0.13);
  --shadow-glow: 0 6px 32px rgba(27, 125, 78, 0.22);
  --nav-bg: rgba(255, 255, 255, 0.88);
  --sidebar-bg: rgba(255, 255, 255, 0.93);
  --res-bg1: #1b7d4e;
  --res-bg2: #0d5231;
  --res-text: #ffffff;
  --res-muted: rgba(255, 255, 255, 0.58);
  --res-tile: rgba(255, 255, 255, 0.13);
  --chart-grid: rgba(0, 0, 0, 0.05);
}

/* ═══ DARK THEME ═══ */
[data-theme="dark"] {
  --bg: #0b1710;
  --bg-mesh: radial-gradient(ellipse 90% 60% at 15% -5%, rgba(27, 125, 78, 0.2) 0%, transparent 55%),
             radial-gradient(ellipse 70% 55% at 85% 105%, rgba(20, 90, 55, 0.16) 0%, transparent 55%),
             #0b1710;
  --surface: #121e16;
  --surface-2: #192a1e;
  --surface-3: #1d3224;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text-primary: #e4f2ea;
  --text-secondary: #6dac86;
  --text-muted: #3f6a52;
  --accent: #2ecc74;
  --accent-soft: #182e22;
  --accent-glow: rgba(46, 204, 116, 0.13);
  --lime: #d8f44a;
  --red: #ff6060;
  --red-soft: #271212;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 22px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 42px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 6px 32px rgba(46, 204, 116, 0.15);
  --nav-bg: rgba(12, 22, 15, 0.9);
  --sidebar-bg: rgba(9, 18, 12, 0.95);
  --res-bg1: #1d3224;
  --res-bg2: #0b1710;
  --res-text: #e4f2ea;
  --res-muted: rgba(228, 242, 234, 0.5);
  --res-tile: rgba(46, 204, 116, 0.1);
  --chart-grid: rgba(255, 255, 255, 0.05);
}

html { scroll-behavior: smooth; }

body {
  font-family: "Manrope", system-ui, sans-serif;
  background: var(--bg-mesh);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.45s, color 0.3s;
}

.font-display { font-family: "Syne", system-ui, sans-serif; }

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

/* Grain overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.028;
}

/* ═══════════════════════ COMPONENTS & LAYOUT ═══════════════════════ */

/* Main layout overrides */
.main-wrap { flex: 1; min-height: 100vh; padding-bottom: 80px; }
.main-content { flex: 1; min-height: 100vh; padding-bottom: 80px; }

/* Sidebar Base */
#sidebar {
  background: var(--sidebar-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--border);
  transition: background 0.45s, border-color 0.3s;
}

/* Sidebar Custom Utilities */
.sidebar-logo-container { padding: 22px 20px 18px; }
.logo-flex { display: flex; align-items: center; gap: 10px; }
.logo-box { width: 38px; height: 38px; border-radius: 13px; background: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-text { font-size: 20px; font-weight: 800; line-height: 1; color: var(--text-primary); }
.logo-subtext { font-size: 8.5px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); margin-top: 2px; }
.nav-container { flex: 1; padding: 4px 10px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav-header { font-size: 9px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); padding: 6px 11px 8px; }
.badge-soon { margin-left: auto; }
.sidebar-footer { padding: 16px 18px 20px; border-top: 1px solid var(--border); }
.theme-wrap { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.theme-toggle-left { display: flex; align-items: center; gap: 7px; }
.theme-lbl { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.disclaimer { font-size: 10px; color: var(--text-muted); line-height: 1.65; }

/* Nav items */
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border-radius: 14px; cursor: pointer; border: none; background: transparent; width: 100%; text-align: left; transition: background 0.2s; }
.nav-item:hover, .nav-item.active { background: var(--accent-soft); }
.nav-item.active .ni { background: var(--accent); color: #fff; }
.nav-item.active .nl { color: var(--accent); font-weight: 700; }
.ni { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--text-muted); transition: background 0.2s, color 0.2s; }
.nl { font-size: 13px; font-weight: 500; color: var(--text-secondary); transition: color 0.2s; }

/* Bottom Nav (Mobile) */
#bot-nav { background: var(--nav-bg); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border-top: 1px solid var(--border); transition: background 0.45s; }
.bot-nav { padding-bottom: env(safe-area-inset-bottom, 0); }
.bi { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 10px 2px; cursor: pointer; border: none; background: transparent; }
.bi svg, .bi i { color: var(--text-muted); transition: color 0.2s, transform 0.2s; }
.bi span { font-size: 9px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.02em; font-family: "Manrope", sans-serif; transition: color 0.2s; }
.bi.active svg, .bi.active i { color: var(--accent); transform: translateY(-1px); }
.bi.active span { color: var(--accent); }

/* Top bar (Mobile) */
#topbar { background: var(--nav-bg); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border-bottom: 1px solid var(--border); transition: background 0.45s; }
.mobile-topbar { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; }
.mobile-logo-flex { display: flex; align-items: center; gap: 9px; }
.mobile-logo-box { width: 30px; height: 30px; border-radius: 10px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.mobile-logo-text { font-size: 18px; font-weight: 800; color: var(--text-primary); }
.mobile-controls { display: flex; align-items: center; gap: 10px; }
.mobile-page-lbl { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.mobile-tog-track { width: 38px; height: 21px; }
.mobile-tog-thumb { width: 15px; height: 15px; top: 2px; left: 2px; }

/* Page Level Layouts */
.page { display: none; }
.page.active { display: block; animation: fs 0.3s ease; }
@keyframes fs { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.page-content { padding: 20px 14px 36px; max-width: 1120px; margin: 0 auto; }
.header-wrap { margin-bottom: 22px; }
.header-badge-wrap { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.header-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.header-badge-text { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); }
.header-title { font-size: clamp(22px, 5vw, 34px); font-weight: 800; color: var(--text-primary); line-height: 1.1; margin-bottom: 5px; }
.header-desc { font-size: 13px; color: var(--text-muted); font-weight: 500; line-height: 1.5; }

/* Cards & Inputs */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-sm); transition: background 0.35s, border-color 0.3s, box-shadow 0.2s; }
.card:hover { box-shadow: var(--shadow-md); }
.card-pad { padding: 17px; }
.col-flex { display: flex; flex-direction: column; gap: 13px; }
.grid-halves { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }

.inp-wrap { position: relative; }
.inp-prefix { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-weight: 700; font-size: 15px; pointer-events: none; }
.inp-suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-weight: 700; font-size: 13px; pointer-events: none; }
.inp-pad-prefix { padding: 12px 14px 12px 30px; }
.inp-pad-suffix { padding: 12px 36px 12px 13px; }
.inp-pad-long-suffix { padding: 12px 44px 12px 13px; }
.inp-pad-select { padding: 12px 38px 12px 13px; }
.range-mt { margin-top: 12px; }

.fin-input { width: 100%; background: var(--surface-2); border: 1.5px solid var(--border); border-radius: 13px; color: var(--text-primary); font-family: "Manrope", sans-serif; font-weight: 600; font-size: 14px; transition: border-color 0.2s, box-shadow 0.2s, background 0.35s; appearance: none; -webkit-appearance: none; }
.fin-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); background: var(--surface); }
.fin-input::placeholder { color: var(--text-muted); font-weight: 400; }
select.fin-input { background-image: url("data:image/svg+xml,%3Csvg width='10' height='7' viewBox='0 0 10 7' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2385a895' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; cursor: pointer; }

/* Range sliders */
input[type="range"] { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 99px; background: var(--surface-3); outline: none; cursor: pointer; width: 100%; transition: background 0.35s; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 2.5px solid var(--surface); cursor: pointer; box-shadow: 0 1px 6px var(--accent-glow); }

/* Labels & Hints */
.inp-label { display: block; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 10px; }
.range-hints { display: flex; justify-content: space-between; font-size: 10px; font-weight: 600; color: var(--text-muted); margin-top: 5px; }

/* ── Result card ── */
.res-card { border-radius: 24px; padding: 24px; position: relative; overflow: hidden; background: linear-gradient(145deg, var(--res-bg1) 0%, var(--res-bg2) 100%); box-shadow: var(--shadow-glow); transition: background 0.45s, box-shadow 0.45s; }
.res-blob1 { position: absolute; width: 220px; height: 220px; border-radius: 50%; background: rgba(255, 255, 255, 0.05); top: -70px; right: -70px; pointer-events: none; }
.res-blob2 { position: absolute; width: 140px; height: 140px; border-radius: 50%; background: rgba(255, 255, 255, 0.04); bottom: -45px; left: -35px; pointer-events: none; }
.res-layer { position: relative; z-index: 1; }
.res-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 3px; }
.res-title { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; color: var(--res-muted); }
.res-total { font-size: clamp(30px, 6vw, 46px); font-weight: 800; color: var(--res-text); line-height: 1; margin-bottom: 3px; }
.res-period { font-size: 12px; color: var(--res-muted); font-weight: 500; margin-bottom: 18px; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 16px; }

/* Stat tiles */
.lime-pill { background: var(--lime); color: #0c1e13; border-radius: 99px; font-weight: 800; font-size: 11px; padding: 3px 10px; display: inline-flex; align-items: center; }
.stat-tile { background: var(--res-tile); border-radius: 15px; padding: 13px 15px; }
.stat-label { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--res-muted); margin-bottom: 4px; }
.stat-value { font-family: "Syne", sans-serif; font-size: 19px; font-weight: 700; color: var(--res-text); line-height: 1.1; }
.txt-lime { color: var(--lime); }

/* Progress */
.prog-header { display: flex; justify-content: space-between; font-size: 10px; font-weight: 600; color: var(--res-muted); margin-bottom: 6px; }
.prog-track { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.prog-fill { height: 100%; border-radius: 99px; background: var(--lime); transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1); }
.prog-w-50 { width: 50%; }

/* ── Toggle switch ── */
.tog-wrap { display: flex; align-items: center; cursor: pointer; }
.tog-track { width: 42px; height: 23px; border-radius: 99px; background: var(--surface-3); border: 1.5px solid var(--border); position: relative; cursor: pointer; transition: background 0.3s, border-color 0.3s; }
[data-theme="dark"] .tog-track { background: var(--accent); border-color: var(--accent); }
.tog-thumb { width: 17px; height: 17px; border-radius: 50%; background: var(--surface); position: absolute; top: 2px; left: 2px; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 1px 5px rgba(0, 0, 0, 0.15); }
[data-theme="dark"] .tog-thumb { transform: translateX(19px); background: #fff; }

/* ── Chart Layout & Tabs ── */
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.chart-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.chart-tabs { display: flex; background: var(--surface-2); border-radius: 99px; padding: 3px; gap: 3px; border: 1px solid var(--border); }
.chart-container { position: relative; height: 196px; }
.legend-wrap { display: flex; align-items: center; gap: 14px; margin-top: 11px; justify-content: center; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-box-p { width: 10px; height: 10px; border-radius: 3px; background: var(--accent-soft); border: 1px solid rgba(27, 125, 78, 0.3); }
.legend-box-i { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
.legend-text { font-size: 11px; color: var(--text-muted); font-weight: 600; }

.ctab { font-size: 11px; font-weight: 700; padding: 6px 13px; border-radius: 99px; cursor: pointer; border: none; background: transparent; color: var(--text-muted); font-family: "Manrope", sans-serif; transition: background 0.2s, color 0.2s; }
.ctab.active { background: var(--accent); color: #fff; }

/* ── Time unit tabs ── */
.unit-toggle-wrap { display: flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; border: 1px solid var(--border); margin-bottom: 9px; }
.ttab { flex: 1; font-size: 12px; font-weight: 600; padding: 7px; border-radius: 10px; cursor: pointer; border: none; background: transparent; color: var(--text-muted); font-family: "Manrope", sans-serif; transition: background 0.2s, color 0.2s, box-shadow 0.2s; }
.ttab.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* ── Badges ── */
.soon { font-size: 9px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; background: var(--surface-3); color: var(--text-muted); }

/* ── Breakdown Table ── */
.table-card { overflow: hidden; }
.table-header { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.table-btn { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border: none; padding: 5px 13px; border-radius: 99px; cursor: pointer; font-family: 'Manrope', sans-serif; transition: background 0.2s; }
.table-wrap { display: none; overflow-x: auto; max-height: 320px; overflow-y: auto; }
.br-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.th-sticky { position: sticky; top: 0; z-index: 2; }
.tr-head { background: var(--surface-2); }
.th-left { padding: 10px 18px; text-align: left; font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
.th-right { padding: 10px 18px; text-align: right; font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }

.br-row { border-bottom: 1px solid var(--border); transition: background 0.15s; }
.br-row:hover { background: var(--accent-soft); }
.br-row:last-child { border-bottom: none; }
.br-row.row-alt { background: var(--surface-2); }
.td-label { padding: 11px 18px; font-weight: 600; color: var(--text-secondary); }
.td-invested { padding: 11px 18px; text-align: right; color: var(--text-muted); }
.td-interest { padding: 11px 18px; text-align: right; color: var(--accent); font-weight: 700; }
.td-total { padding: 11px 18px; text-align: right; font-weight: 800; color: var(--text-primary); }

/* ── Error ── */
.err-box { background: var(--red-soft); border: 1px solid rgba(240, 70, 70, 0.2); border-radius: 13px; color: var(--red); font-size: 13px; display: flex; align-items: center; gap: 8px; padding: 11px 15px; }
.hide-elem { display: none; }

/* ── Coming soon pages ── */
.soon-page-wrap { max-width: 1120px; margin: 0 auto; }
.soon-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 440px; text-align: center; padding: 40px 20px; }
.soon-icon { width: 68px; height: 68px; border-radius: 22px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.soon-title { font-size: 28px; font-weight: 800; color: var(--text-primary); margin-bottom: 8px; }
.soon-desc { color: var(--text-muted); font-size: 13px; max-width: 280px; line-height: 1.6; font-weight: 500; }

/* ── Global Icon Sizes & Colors ── */
.icon-sm { width: 14px; height: 14px; }
.icon-md { width: 18px; height: 18px; }
.icon-theme { width: 13px; height: 13px; color: var(--text-secondary); }
.icon-soon { width: 26px; height: 26px; stroke: var(--accent); }
.icon-white { color: #fff; }

/* ── Responsive grid ── */
#ci-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 820px) {
  #ci-grid { grid-template-columns: 360px 1fr; gap: 18px; }
  #page-compound { padding: 30px 32px 48px; }
}
@media (min-width: 1080px) {
  #ci-grid { grid-template-columns: 390px 1fr; gap: 22px; }
  #page-compound { padding: 36px 48px 60px; }
}
@media (max-width: 520px) {
  #rt-grid { grid-template-columns: 1fr; }
}

/* ── Quick Add Buttons ── */
.quick-add-wrap {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.quick-add-btn {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  padding: 5px 11px;
  border-radius: 99px;
  cursor: pointer;
  font-family: 'Manrope', sans-serif;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.quick-add-btn:hover {
  background: var(--accent);
  color: #fff;
}
/* ── Zero / Clear Button Styling ── */
.btn-zero {
  background: var(--surface-3);
  color: var(--text-muted);
}
.btn-zero:hover {
  background: var(--text-secondary);
  color: #fff;
}

/* ── Save Button ── */
.save-btn {
  margin-top: 18px;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 13px;
  font-family: "Manrope", sans-serif;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.3s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}

.save-btn:hover { 
  background: var(--text-primary); 
  box-shadow: var(--shadow-md);
}