/* === ROI Calculator Additions v3 — World-Class Edition === */

/* ─── LIGHT MODE ──────────────────────────────────────────────── */
[data-theme="light"] {
  --bg-app: #F1F5F9;
  --bg-card: #ffffff;
  --bg-input: #E2E8F0;
  --bg-elevated: #DBE1EA;
  --bg-hover: #CBD5E1;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --border: rgba(0,0,0,0.15);
  --border-accent: rgba(16,185,129,0.50);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.06);
  --accent-dim: rgba(16,185,129,0.12);
  --accent-glow: rgba(16,185,129,0.18);
  --negative-dim: rgba(239,68,68,0.1);
  --warning-dim: rgba(245,158,11,0.1);
  --info-dim: rgba(59,130,246,0.1);
}
[data-theme="light"] body { color: #0F172A; background: var(--bg-app); }
[data-theme="light"] .glass-navbar { background: rgba(255,255,255,0.95); border-bottom: 1px solid rgba(0,0,0,0.12); }
[data-theme="light"] .calc-breadcrumb { background: rgba(0,0,0,0.04); }
[data-theme="light"] .hero-result { background: linear-gradient(135deg,rgba(16,185,129,0.06) 0%,rgba(16,185,129,0.01) 100%); }
[data-theme="light"] .yearly-table thead { background: #F1F5F9; }
[data-theme="light"] .accordion-group summary { background: #F1F5F9; }
[data-theme="light"] .matrix-cell.heat-0 { background: rgba(239,68,68,0.08); }
[data-theme="light"] .hero-value.positive { text-shadow: none; }
[data-theme="light"] .scenario-card { background: #fff; border-color: rgba(0,0,0,0.12); }
[data-theme="light"] .projector-section { background: #fff; }
[data-theme="light"] input, [data-theme="light"] select { color-scheme: light; background: var(--bg-input); color: var(--text-primary); }

/* ─── SKIP LINK (ACCESSIBILITY) ───────────────────────────────── */
.skip-link {
  position: absolute; top: -50px; left: 12px; z-index: 9999;
  padding: 8px 16px; background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 700; border-radius: 0 0 8px 8px;
  text-decoration: none; transition: top 0.2s;
}
.skip-link:focus { top: 0; outline: 3px solid #fff; outline-offset: 2px; }

/* ─── COMPLEXITY TOGGLE ───────────────────────────────────────── */
.mode-complexity-toggle {
  display: flex; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 3px; gap: 3px;
}
.complexity-btn {
  flex: 1; padding: 6px 10px; border: none; border-radius: 5px;
  background: transparent; color: var(--text-muted); font-size: 11px;
  font-weight: 600; cursor: pointer; transition: all 0.2s; letter-spacing: 0.3px;
  text-transform: uppercase;
}
.complexity-btn.active {
  background: var(--bg-elevated); color: var(--text-primary); font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.complexity-btn:not(.active):hover { color: var(--text-primary); }

/* ─── CURRENCY SELECTOR ROW ───────────────────────────────────── */
.currency-initial-row { display: flex; gap: 6px; align-items: flex-end; }
.currency-initial-row .input-group { flex: 1; }
#input-currency {
  width: 88px; flex-shrink: 0;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 13px; padding: 9px 6px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 5px center;
  padding-right: 18px; cursor: pointer;
  transition: border-color 0.2s;
}
#input-currency:focus { outline: none; border-color: var(--border-accent); box-shadow: 0 0 0 3px var(--accent-dim); }

/* ─── HERO NARRATIVE ──────────────────────────────────────────── */
.hero-narrative {
  font-size: 13px; color: var(--text-secondary); line-height: 1.65;
  padding: 10px 14px; background: var(--bg-input); border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent); margin-top: 10px;
  display: none;
}
.hero-narrative.visible { display: block; animation: fade-up 0.35s ease; }

/* ─── ANIMATIONS ──────────────────────────────────────────────── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% center; }
  100% { background-position: -200% center; }
}
@keyframes count-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.stat-card.updating .stat-value { animation: count-flash 0.2s ease; }

/* Stats grid entry animation */
.stats-grid .stat-card { animation: fade-up 0.3s ease both; }
.stats-grid .stat-card:nth-child(1) { animation-delay: 0.00s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 0.05s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.10s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.15s; }
.stats-grid .stat-card:nth-child(5) { animation-delay: 0.20s; }
.stats-grid .stat-card:nth-child(6) { animation-delay: 0.25s; }

/* ─── RULE OF 72 BADGE ────────────────────────────────────────── */
.rule72-badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  padding: 2px 8px; background: var(--info-dim); color: var(--info);
  border: 1px solid rgba(59,130,246,0.3); border-radius: 20px;
  margin-top: 3px; letter-spacing: 0.2px;
}

/* ─── HEALTH GAUGE SVG ────────────────────────────────────────── */
.health-gauge-wrap { display: flex; align-items: center; gap: 16px; }
.health-gauge {
  width: 88px; height: 88px; flex-shrink: 0;
  transform: rotate(-90deg); overflow: visible;
}
.gauge-track { fill: none; stroke: var(--bg-elevated); stroke-width: 10; }
.gauge-fill {
  fill: none; stroke: var(--accent); stroke-width: 10;
  stroke-linecap: round; stroke-dasharray: 220; stroke-dashoffset: 220;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.25,0.46,0.45,0.94), stroke 0.4s ease;
}
.gauge-center { transform: rotate(90deg); }
.gauge-score-num {
  fill: var(--text-primary); font-size: 22px; font-weight: 900;
  font-family: 'Inter', sans-serif; text-anchor: middle; dominant-baseline: central;
}
.gauge-score-label {
  fill: var(--text-muted); font-size: 8px; font-weight: 600;
  font-family: 'Inter', sans-serif; text-anchor: middle; text-transform: uppercase; letter-spacing: 1px;
}
.health-gauge-info { flex: 1; }
.health-gauge-info .health-score-value { font-size: 28px; }

/* ─── INVESTMENT JOURNAL ──────────────────────────────────────── */
.journal-panel {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden;
}
.journal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; background: var(--bg-input); cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  user-select: none; transition: all 0.2s; list-style: none;
}
.journal-header::-webkit-details-marker { display: none; }
.journal-header:hover { color: var(--text-primary); background: var(--bg-elevated); }
.journal-header::after { content: '+'; font-size: 16px; color: var(--text-muted); }
details.journal-panel[open] .journal-header { color: var(--accent); border-bottom: 1px solid var(--border); }
details.journal-panel[open] .journal-header::after { content: '−'; color: var(--accent); }
.journal-count { font-size: 11px; background: var(--accent-dim); color: var(--accent); padding: 2px 7px; border-radius: 10px; margin-left: 6px; }
.journal-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.journal-save-row { display: flex; gap: 6px; }
.journal-name-input {
  flex: 1; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 13px; padding: 7px 10px; font-family: inherit;
}
.journal-name-input:focus { outline: none; border-color: var(--border-accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.journal-name-input::placeholder { color: var(--text-muted); }
.journal-save-btn {
  padding: 7px 12px; background: var(--accent); border: none;
  border-radius: var(--radius-sm); color: #fff; font-size: 12px;
  font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: background 0.2s; font-family: inherit;
}
.journal-save-btn:hover { background: var(--accent-hover); }
.journal-entries { display: flex; flex-direction: column; gap: 5px; max-height: 210px; overflow-y: auto; }
.journal-entry {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
  cursor: pointer; transition: all 0.2s;
}
.journal-entry:hover { border-color: var(--border-accent); background: var(--bg-hover); }
.journal-entry-info { flex: 1; min-width: 0; }
.journal-entry-name { font-size: 12px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.journal-entry-meta { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.journal-entry-val { font-size: 12px; font-weight: 700; color: var(--accent); flex-shrink: 0; }
.journal-del-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 15px; padding: 2px 5px; border-radius: 3px; flex-shrink: 0;
  line-height: 1; transition: color 0.15s;
}
.journal-del-btn:hover { color: var(--negative); }
.journal-empty { font-size: 12px; color: var(--text-muted); text-align: center; padding: 12px 0; }

/* ─── LEVERAGE SECTION ────────────────────────────────────────── */
.leverage-section {
  padding: 10px 0 4px; border-top: 1px solid var(--border); margin-top: 4px;
}
.leverage-section-label {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 8px;
}
.leverage-warning {
  font-size: 11px; color: var(--warning); background: var(--warning-dim);
  border: 1px solid rgba(245,158,11,0.25); border-radius: 6px;
  padding: 6px 10px; margin-top: 6px; display: none;
}
.leverage-warning.visible { display: block; }

/* ─── DIVIDEND GROWTH ─────────────────────────────────────────── */
#group-div-growth { transition: opacity 0.2s; }
.div-growth-note { font-size: 10px; color: var(--text-muted); margin-top: 3px; }

/* ─── LOG SCALE TOGGLE ────────────────────────────────────────── */
.chart-controls { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 4px; align-items: center; }
.chart-toggle-btn {
  padding: 3px 10px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 20px; color: var(--text-muted); font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.chart-toggle-btn:hover { color: var(--accent); border-color: var(--border-accent); }
.chart-toggle-btn.active { background: var(--accent-dim); color: var(--accent); border-color: var(--border-accent); }

/* ─── MOBILE BOTTOM SHEET ─────────────────────────────────────── */
.mobile-edit-fab {
  display: none; position: fixed; bottom: 76px; right: 18px; z-index: 88;
  align-items: center; gap: 6px;
  padding: 12px 18px; background: var(--accent); color: #fff; border: none;
  border-radius: 28px; font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 24px rgba(16,185,129,0.45);
  transition: transform 0.2s, box-shadow 0.2s; font-family: inherit;
}
.mobile-edit-fab:hover { transform: scale(1.05); box-shadow: 0 6px 30px rgba(16,185,129,0.55); }
@media (max-width: 600px) { .mobile-edit-fab { display: flex; } }

dialog.inputs-sheet {
  position: fixed; bottom: 0; left: 0; right: 0; top: auto;
  width: 100%; max-width: 100%; margin: 0;
  padding: 0; background: var(--bg-card); border: none;
  border-top: 1px solid var(--border); border-radius: 20px 20px 0 0;
  max-height: 85vh; overflow-y: auto; z-index: 200;
}
dialog.inputs-sheet::backdrop {
  background: rgba(0,0,0,0.6); backdrop-filter: blur(3px);
}
@keyframes sheet-slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
dialog.inputs-sheet[open] { animation: sheet-slide-up 0.3s cubic-bezier(0.25,0.46,0.45,0.94); }
.inputs-sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 12px; position: sticky; top: 0; background: var(--bg-card);
  border-bottom: 1px solid var(--border); z-index: 1;
}
.inputs-sheet-drag { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 12px; }
.inputs-sheet-header h3 { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.inputs-sheet-close {
  background: var(--bg-elevated); border: none; color: var(--text-secondary);
  width: 28px; height: 28px; border-radius: 50%; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.inputs-sheet-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.inputs-sheet-body { padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.inputs-sheet-calc-btn {
  width: 100%; padding: 13px; background: var(--accent); border: none;
  border-radius: var(--radius-sm); color: #fff; font-size: 15px; font-weight: 700;
  cursor: pointer; margin-top: 8px; transition: background 0.2s; font-family: inherit;
}
.inputs-sheet-calc-btn:hover { background: var(--accent-hover); }

/* ─── HISTORICAL LOOKUP ───────────────────────────────────────── */
.historical-lookup-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; }
.historical-lookup-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.historical-lookup-card .section-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.lookup-controls { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; align-items: end; margin-bottom: 14px; }
.lookup-field label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; display: block; margin-bottom: 5px; }
.lookup-input {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14px; padding: 9px 12px;
  font-family: inherit;
}
.lookup-input:focus { outline: none; border-color: var(--border-accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.lookup-btn {
  padding: 9px 16px; background: var(--accent); border: none; border-radius: var(--radius-sm);
  color: #fff; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: background 0.2s; align-self: end; font-family: inherit;
}
.lookup-btn:hover { background: var(--accent-hover); }
.lookup-result { display: none; background: var(--bg-input); border: 1px solid var(--border-accent); border-radius: var(--radius-sm); padding: 16px; }
.lookup-result.visible { display: block; animation: fade-up 0.3s ease; }
.lookup-result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.lookup-result-item { text-align: center; }
.lookup-result-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.lookup-result-value { font-size: 22px; font-weight: 800; color: var(--accent); letter-spacing: -0.5px; }
.lookup-result-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
@media (max-width: 700px) { .lookup-controls { grid-template-columns: 1fr 1fr; } }

/* ─── SEQUENCE OF RETURNS ─────────────────────────────────────── */
.sor-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; }
.sor-section h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.sor-section .section-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 14px; }
.sor-controls { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.sor-result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.sor-card { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.sor-card-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 8px; }
.sor-survival { font-size: 30px; font-weight: 800; color: var(--accent); letter-spacing: -0.5px; }
.sor-survival.warn { color: var(--warning); }
.sor-survival.danger { color: var(--negative); }
.sor-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
@media (max-width: 600px) { .sor-result-grid { grid-template-columns: minmax(0, 1fr); } }
    overflow: hidden;

/* ─── WATERFALL CHART ─────────────────────────────────────────── */
.waterfall-container { padding: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.waterfall-row { display: flex; align-items: center; gap: 10px; }
.waterfall-label { font-size: 11px; color: var(--text-secondary); width: 120px; text-align: right; flex-shrink: 0; font-weight: 500; }
.waterfall-track { flex: 1; background: var(--bg-elevated); border-radius: 4px; height: 26px; overflow: visible; position: relative; }
.waterfall-fill { height: 100%; border-radius: 4px; display: flex; align-items: center; padding: 0 8px; transition: width 0.7s cubic-bezier(0.25,0.46,0.45,0.94); min-width: 2px; }
.waterfall-fill.gain { background: linear-gradient(90deg, rgba(16,185,129,0.8), rgba(16,185,129,0.6)); }
.waterfall-fill.loss { background: linear-gradient(90deg, rgba(239,68,68,0.75), rgba(239,68,68,0.55)); }
.waterfall-fill.result { background: linear-gradient(90deg, var(--accent), var(--accent-hover)); }
.waterfall-fill.neutral { background: linear-gradient(90deg, rgba(59,130,246,0.7), rgba(59,130,246,0.5)); }
.waterfall-val-label { font-size: 11px; font-weight: 700; color: #fff; white-space: nowrap; }
.waterfall-divider { border-top: 1px dashed var(--border); margin: 4px 0; }
.waterfall-row.total .waterfall-label { font-weight: 700; color: var(--text-primary); }

/* ─── SENSITIVITY MATRIX DRILLDOWN ───────────────────────────── */
.matrix-cell { cursor: pointer; }
.matrix-cell.drilled { outline: 3px solid var(--accent); outline-offset: -1px; }
.matrix-reset-btn {
  margin-top: 8px; padding: 5px 12px; background: transparent;
  border: 1px solid var(--border); border-radius: 20px; color: var(--text-muted);
  font-size: 11px; cursor: pointer; display: none; font-family: inherit;
  transition: all 0.2s;
}
.matrix-reset-btn.visible { display: inline-flex; align-items: center; gap: 4px; }
.matrix-reset-btn:hover { color: var(--accent); border-color: var(--border-accent); }

/* ─── INPUT VALIDATION ────────────────────────────────────────── */
.input-error-msg { font-size: 10px; color: var(--negative); margin-top: 3px; display: none; }
.input-warn-msg { font-size: 10px; color: var(--warning); margin-top: 3px; display: none; }
.input-group.has-error input,
.input-group.has-error select { border-color: var(--negative) !important; box-shadow: 0 0 0 2px rgba(239,68,68,0.15) !important; }
.input-group.has-error .input-error-msg { display: block; }
.input-group.has-warn input,
.input-group.has-warn select { border-color: var(--warning) !important; }
.input-group.has-warn .input-warn-msg { display: block; }

/* ─── KEYBOARD SHORTCUT HINTS ─────────────────────────────────── */
.kbd-hint {
  display: inline-block; font-size: 9px; font-weight: 600;
  padding: 1px 5px; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 3px; color: var(--text-muted); font-family: var(--font-mono);
  margin-left: 4px; vertical-align: middle;
}

/* ─── PREFERS REDUCED MOTION ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.05ms !important;
  }
  .stats-grid .stat-card { animation: none; }
  .hero-narrative { animation: none; }
  dialog.inputs-sheet[open] { animation: none; }
}

/* ─── PRINT ENHANCEMENTS ──────────────────────────────────────── */
@media print {
  .mobile-edit-fab, dialog.inputs-sheet, .theme-toggle-btn,
  .journal-panel, .lookup-controls { display: none !important; }
  .hero-narrative { display: block !important; }
  .hero-result::before { display: none; }
  .lookup-result.visible { display: grid; }
}

/* ─── LEGACY: Keep existing styles from original file ─────────── */
.results-header-strip { flex-wrap: wrap; gap: 16px 20px; }
.results-header-strip .metric-item { min-width: 80px; }
.results-header-strip .value.positive { color: var(--positive); }
.results-header-strip .value.negative { color: var(--negative); }
.key-insights-panel { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; min-height: 0; }
.key-insights-panel:empty { margin: 0; padding: 0; }
.insight-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 20px; font-size: 0.78rem; font-weight: 500; color: var(--text-secondary); white-space: nowrap; transition: border-color 0.2s; }
.insight-chip.positive { border-color: rgba(16,185,129,0.4); color: var(--positive); background: rgba(16,185,129,0.07); }
.insight-chip.negative { border-color: rgba(239,68,68,0.4); color: var(--negative); background: rgba(239,68,68,0.07); }
.insight-icon { font-size: 0.72rem; font-weight: 700; color: var(--accent); opacity: 0.85; }
.insight-chip.positive .insight-icon { color: var(--positive); }
.insight-chip.negative .insight-icon { color: var(--negative); }
.share-button { display: inline-flex; align-items: center; gap: 5px; padding: 5px 14px; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s ease; white-space: nowrap; font-family: var(--font-main); }
.share-button:hover { color: var(--text-primary); border-color: var(--accent); background: rgba(16,185,129,0.08); }
#inputs-realestate-leverage .input-row + .input-row { margin-top: 8px; }
@media (max-width: 900px) { .key-insights-panel { gap: 6px; } .insight-chip { font-size: 0.74rem; padding: 4px 10px; } .share-button { width: 100%; justify-content: center; } }
