:root {
    --bg-dark: #0a0a0a;
    --bg-card: #141414;
    --bg-input: #1f1f1f;
    --text-main: #e0e0e0;
    --text-muted: #888888;
    --neon-green: #39ff14;
    --neon-glow: 0 0 10px rgba(57, 255, 20, 0.5);
    --neon-green-rgb: 57, 255, 20;
    --background-color: #fff;
    --text-color: #111;
    --primary-accent: #3b82f6;
    --primary-accent-rgb: rgba(81, 124, 195, 0.25);
    --font-sans: 'Inter', system-ui, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Neon Typography */
h1, h2, h3, h4 { margin-bottom: 15px; }

.neon-text {
    color: var(--neon-green);
    text-shadow: var(--neon-glow);
    margin-bottom: 0.5rem;
}

/* Navbar */
.navbar {
    background-color: var(--bg-card);
    padding: 20px 0;
    border-bottom: 1px solid #333;
}
.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
}
.logo span { color: var(--neon-green); }

.nav-links {
    list-style: none;
    display: flex;
    gap: 20px;
}
.nav-links a {
    color: var(--text-main);
    text-decoration: none;
    transition: color 0.3s;
}
.nav-links a:hover { color: var(--neon-green); }

/* Hamburger Menu Toggle Engine */
.nav-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}
.hamburger {
    display: block;
    position: relative;
    width: 24px;
    height: 2px;
    background: #fff;
    transition: background 0.3s ease-in-out;
}
.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 2px;
    background: #fff;
    transition: all 0.3s ease-in-out;
}
.hamburger::before { top: -8px; }
.hamburger::after { bottom: -8px; }

/* Menu Morph Animations */
.nav-toggle.active .hamburger {
    background: transparent;
}
.nav-toggle.active .hamburger::before {
    transform: rotate(45deg);
    top: 0;
    background: var(--neon-green);
}
.nav-toggle.active .hamburger::after {
    transform: rotate(-45deg);
    bottom: 0;
    background: var(--neon-green);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 60px 0 40px;
}

/* Calculator Layout */
.calculator-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 60px;
}

.calc-card {
    background-color: var(--bg-card);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid #333;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    margin-top: 4rem;
}

/* Inputs */
.input-group {
    margin-bottom: 20px;
}
.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
}
.input-group input {
    width: 100%;
    padding: 12px;
    background-color: var(--bg-input);
    border: 1px solid #333;
    color: #fff;
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}
.input-group input:focus {
    border-color: var(--neon-green);
    box-shadow: 0 0 5px rgba(57, 255, 20, 0.2);
}

/* Buttons */
.btn-neon {
    width: 100%;
    padding: 15px;
    background-color: transparent;
    color: var(--neon-green);
    border: 2px solid var(--neon-green);
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-neon:hover {
    background-color: var(--neon-green);
    color: var(--bg-dark);
    box-shadow: var(--neon-glow);
}

/* Results */
.result-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 20px;
}
.result-box {
    background-color: var(--bg-input);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #333;
}
.amount {
    font-size: 32px;
    font-weight: 800;
}
.metrics-summary {
    text-align: center;
    padding-top: 15px;
    border-top: 1px solid #333;
}

/* Footer */
footer {
    background-color: var(--bg-card);
    padding: 40px 0 20px;
    border-top: 1px solid #333;
    margin-top: 40px;
}
.footer-content {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}
.footer-col ul {
    list-style: none;
}
.footer-col a {
    color: var(--text-muted);
    text-decoration: none;
}
.footer-col a:hover { color: var(--neon-green); }
.footer-bottom {
    text-align: center;
    margin-top: 30px;
    color: var(--text-muted);
}

/* --- Advanced Dashboard Additions --- */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 40px 0 20px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 10px;
    transition: 0.3s;
}
.btn-outline:hover {
    border-color: var(--neon-green);
    color: var(--neon-green);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 25px;
    margin-bottom: 60px;
}

/* Sidebar Styles */
.calc-sidebar {
    background-color: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #333;
    height: fit-content;
}
.sidebar-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #333;
}

select {
    width: 100%;
    padding: 12px;
    background-color: var(--bg-input);
    border: 1px solid #333;
    color: #fff;
    border-radius: 6px;
    margin-bottom: 15px;
    appearance: none;
}

/* Sliders */
.slider-group {
    margin-bottom: 25px;
}
.slider-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}
input[type=range] {
    width: 100%;
    -webkit-appearance: none;
    background: #333;
    height: 6px;
    border-radius: 3px;
    outline: none;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--neon-green);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--neon-glow);
}
.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Results Area */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}
.stat-card {
    background-color: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #333;
}
.stat-card h4 { color: var(--text-muted); font-size: 14px; }
.stat-card h2 { font-size: 32px; margin: 10px 0; }
.stat-card p { font-size: 13px; color: var(--text-muted); }

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}
.chart-card {
    background-color: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #333;
}
.chart-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

/* Advanced Metrics Bottom */
.metrics-row {
    background-color: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #333;
}
.metrics-row h4 { margin-bottom: 20px; border-bottom: 1px solid #333; padding-bottom: 10px; }
.metrics-flex {
    display: flex;
    justify-content: space-between;
    text-align: center;
}
.metric-item p { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* Toast Notification Styles */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    font-size: 14px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* History Modal Styles */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.history-modal {
    background-color: #1a1a1a;
    color: white;
    border-radius: 8px;
    padding: 24px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.history-modal h3 {
    color: #39ff14;
    margin-top: 0;
}

.history-item {
    border-bottom: 1px solid #333;
    padding: 12px 0;
}

.history-item div {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.history-item div span {
    font-weight: 600;
}

.history-item div button {
    background-color: transparent;
    color: var(--neon-green);
    border: 1px solid var(--neon-green);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item div button:hover {
    background-color: var(--neon-green);
    color: var(--bg-dark);
}

.history-item div div {
    font-size: 14px;
    opacity: 0.8;
}

.history-item div div div {
    margin-bottom: 4px;
}

/* Modal Button Styles */
.history-modal .btn-sm {
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 14px;
    margin: 0 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-modal .btn-sm:hover {
    border-color: var(--neon-green);
    color: var(--neon-green);
}

.history-modal .btn-sm:active {
    transform: scale(0.95);
}

/* Special button styles */
.history-modal #clearHistoryBtn {
    background-color: #ff3b30;
    border-color: #ff3b30;
    color: white;
}

.history-modal #clearHistoryBtn:hover {
    background-color: #ff453a;
    border-color: #ff453a;
}

/* Hero Section Styles */
.hero {
  padding: 4rem 1rem;
  background-color: var(--bg-dark, #fff);
  text-align: center;
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-content {
  max-width: 800px;
  width: 100%;
  padding: 0 1rem;
}

/* Top Badge */
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: rgba(81, 124, 195, 0.25);
  color: var(--neon-green, #3b82f6);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  margin-bottom: 1.5rem;
}

.badge-icon {
  font-size: 1rem;
}

/* Main Headline */
.hero-title {
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-muted, #111);
  margin: 0 0 1.5rem;
  position: relative;
}

.hero-title .accent {
  color: var(--neon-green, #3b82f6);
}

/* Subheadline */
.hero-subtitle {
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-muted, #6b7280);
  margin: 0 0 2.5rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Call to Action */
.hero-cta {
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
  font-size: 1.125rem;
  font-weight: 600;
  color: #fff;
  background-color: rgba(81, 124, 195, 0.25);
  border: none;
  padding: 1rem 2rem;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.hero-cta:hover {
  background-color: #1a1a1a;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hero-cta:active {
  transform: translateY(0);
}

.btn-sm2 {
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
  font-size: 0.6rem;
  font-weight: 500;
  color: #fff;
  background-color: rgba(81, 124, 195, 0.25);
  border: none;
  padding: 0.4rem 0.4rem;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.btn-sm2:hover {
  background-color: #1a1a1a;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-sm2:active {
  transform: translateY(0);
}

/* Social Proof / Stats */
.hero-stats {
  margin-top: 3rem;
  text-align: center;
}

.stats-heading {
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted, #6b7280);
  margin: 0 0 1.5rem;
}

.stats-row {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
  min-width: 80px;
}

.stat-number {
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: 800;
  color: var(--text-muted, #111);
  line-height: 1;
  display: block;
}

.stat-label {
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted, #6b7280);
  margin-top: 0.25rem;
  display: block;
}

/* =========================================
   Prevent Horizontal Overflow in Grids
   ========================================= */

/* 1. Force grid items to shrink below their content size if necessary */
.dashboard-grid > * {
    min-width: 0;
}

/* 2. Contain the Chart.js canvases so they scale down perfectly */
.chart-card {
    position: relative;
    width: 100%;
    min-width: 0;
    overflow: hidden; 
}

.chart-card canvas {
    max-width: 100%;
}

/* 3. Ensure the advanced metrics wrap neatly on tiny screens (like iPhone SE) */
.metrics-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: center; /* Centers them when they wrap */
}

.metric-item {
    flex: 1 1 30%; /* Allows them to grow and shrink, taking up about a third of the row */
    min-width: 80px; /* Prevents them from getting too squished */
}

/* Media Queries (Tablet Resolution Layouts) */
@media(max-width: 992px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
    .metrics-flex { flex-wrap: wrap; gap: 20px; }
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
}

/* Media Queries (Mobile Screen Layouts) */
@media(max-width: 768px) {
    .calculator-wrapper { grid-template-columns: 1fr; }
    .footer-content { grid-template-columns: 1fr; text-align: center; }
    .summary-cards { grid-template-columns: 1fr; }
    
    /* Reveal and activate layout toggle engines */
    .nav-toggle { 
        display: block; 
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 75%;
        max-width: 300px;
        height: 100vh;
        background-color: rgba(20, 20, 20, 0.98);
        backdrop-filter: blur(10px);
        border-left: 1px solid #333;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 35px;
        transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 1000;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .nav-links.active {
        right: 0;
    }
}

@media (max-width: 480px) {
  .hero {
    padding: 3rem 1rem;
  }

  .hero-title {
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .stats-row {
    gap: 1rem;
  }

  .stat-number {
    font-size: clamp(1.25rem, 6vw, 2rem);
  }
}