/* Reset & Base Variables */
:root {
    --deep-navy: #0A192F;
    --emerald-green: #2ECC71;
    --soft-crimson: #E74C3C;
    --bg-color: #F4F7FA;
    --card-bg: #FFFFFF;
    --text-main: #1A1A1A;
    --text-muted: #6C757D;
    --border-color: #E9ECEF;
    --input-bg: #F8F9FA;
    
    --sidebar-bg: rgba(255, 255, 255, 0.7);
    --sidebar-border: rgba(10, 25, 47, 0.08);
    
    --border-radius: 20px;
    --shadow-soft: 0 10px 30px rgba(10, 25, 47, 0.05);
    --shadow-hover: 0 16px 40px rgba(10, 25, 47, 0.08);
    --transition: all 0.3s ease;
    
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.hidden {
    display: none !important;
}

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    padding: 2.5rem 1.5rem;
    box-shadow: 2px 0 20px rgba(0,0,0,0.02);
    z-index: 10;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: none; /* Hide scrollbar for Firefox */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
    color: var(--deep-navy);
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 12px;
}

.sidebar h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: 12px;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover {
    background-color: rgba(10, 25, 47, 0.04);
    color: var(--deep-navy);
}

.nav-item.active {
    background-color: var(--deep-navy);
    color: white;
    box-shadow: 0 4px 15px rgba(10, 25, 47, 0.1);
}

/* Main Content Area */
.content-area, .main-content {
    flex-grow: 1;
    padding: 3rem;
    position: relative;
}

.mobile-header {
    display: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 3rem;
    padding-bottom: 3rem;
}

/* Typography */
h1, h2, h3, h4 {
    color: var(--deep-navy);
    font-weight: 600;
}

/* Cards */
.calculator-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
}

.calculator-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.calculator-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 1rem;
}

/* Inputs */
.inputs {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Segmented Control */
.target-savings-control {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.segmented-control {
    display: flex;
    background-color: var(--input-bg);
    border-radius: 12px;
    padding: 4px;
    border: 1px solid var(--border-color);
}

.segment {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.segment.active {
    background-color: white;
    color: var(--deep-navy);
    box-shadow: 0 2px 8px rgba(10, 25, 47, 0.08);
}

.input-wrapper {
    position: relative;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

input, select {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--input-bg);
    color: var(--text-main);
    font-family: var(--font-main);
    transition: var(--transition);
    appearance: none;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--deep-navy);
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(10, 25, 47, 0.1);
}

/* Incomes & Expenses Rows */
.transactions-header, .incomes-header, .expenses-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.transactions-header h3, .incomes-header h3, .expenses-header h3, .target-savings-header h3 {
    font-size: 1.1rem;
    margin: 0;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--deep-navy);
}

.expense-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.expense-row input, .expense-row select {
    flex: 1;
}

.expense-row select.item-type {
    flex: 0.6;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--soft-crimson);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    border-radius: 50%;
    transition: var(--transition);
}

.btn-remove:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

/* Outputs */
.outputs {
    background-color: var(--deep-navy);
    border-radius: 16px;
    padding: 1.5rem;
    color: white;
    margin-bottom: 1.5rem;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.result-row:last-child {
    border-bottom: none;
}

.result-row span {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.8);
}

.result-row strong {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Colors for positive/negative */
.positive { color: var(--emerald-green) !important; }
.negative { color: var(--soft-crimson) !important; }

.badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.badge.profit { background-color: var(--emerald-green); color: white; }
.badge.loss { background-color: var(--soft-crimson); color: white; }
.badge.neutral { background-color: rgba(255,255,255,0.2); color: white; }

.warning-badge {
    background-color: rgba(231, 76, 60, 0.2);
    color: #ff8a80;
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid var(--soft-crimson);
}

/* Insight & Educational */
.insight {
    font-size: 1rem;
    color: var(--deep-navy);
    font-style: italic;
    background-color: rgba(10, 25, 47, 0.05);
    padding: 1rem;
    border-left: 4px solid var(--deep-navy);
    border-radius: 4px 12px 12px 4px;
    margin-bottom: 1.5rem;
}

.educational-content {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border-color);
}

.educational-content h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.educational-content p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Buttons */
.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--deep-navy);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    transform: scale(1.05);
    background-color: #1a365d;
}

.btn-secondary {
    width: 100%;
    padding: 1rem;
    background-color: transparent;
    color: var(--deep-navy);
    border: 2px solid var(--deep-navy);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background-color: var(--deep-navy);
    color: white;
}

.app-footer {
    text-align: center;
    padding-bottom: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.timeframe-input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.timeframe-input-wrapper input {
    flex: 2;
}

.timeframe-input-wrapper select {
    flex: 1;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
}
    
    /* 1. Structural Transformation (Navigation) */
    .sidebar {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        height: auto;
        padding: 0;
        background: rgba(255, 255, 255, 0.85); /* Semi-transparent background */
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: none;
        border-top: 1px solid rgba(10, 25, 47, 0.08); /* Subtle top border */
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05); /* Shadow to distinguish */
        z-index: 1000;
    }
    
    .sidebar .brand {
        display: none;
    }
    
    .nav-menu {
        flex-direction: row;
        justify-content: space-around; /* Center icons */
        align-items: center;
        padding: 0.25rem 0 0.5rem 0; 
        margin: 0;
    }
    
    .nav-item {
        flex-direction: column;
        gap: 0.25rem;
        padding: 0.5rem;
        background: transparent !important; /* Override desktop active background */
        box-shadow: none !important;
        color: var(--text-muted);
        flex: 1;
        justify-content: center;
        align-items: center;
    }
    
    .nav-item span {
        font-size: 10px; /* Microscopic labels */
        display: block;
        line-height: 1;
    }
    
    .nav-item.active {
        color: var(--deep-navy) !important; /* Active icon color */
    }

    /* 2. Layout & Content Area Mobile Overrides */
    .content-area, .main-content {
        padding: 1.25rem 16px !important;
        padding-bottom: 110px !important; /* Spacious cushion so the fixed bottom nav bar never covers text or buttons */
    }
    
    .container {
        width: 100%;
        gap: 1.5rem;
        padding: 0;
    }
    
    .calculator-card {
        padding: 16px; /* Consistent 16px padding to prevent touching edges */
        border-radius: 0; /* Remove rounded corners to fit 100% width smoothly */
        border-left: none;
        border-right: none;
        box-shadow: none; 
        border-bottom: 1px solid var(--border-color); /* Separate stacked cards */
    }
    
    /* Stacking Logic */
    .segmented-control {
        flex-direction: column; /* Stack Percentage vs Fixed Amount */
    }
    
    .rapid-entry-inputs {
        flex-wrap: wrap;
    }
    #re-amount, #re-category {
        flex: 1 1 40% !important;
    }
    #re-submit-btn {
        flex: 1 1 100% !important;
        width: 100% !important;
        border-radius: 12px !important;
    }

    /* 3. Touch-Target Optimization */
    input, select, .btn-icon, .btn-secondary, .segment {
        min-height: 48px; /* 48px minimum height for fat thumbs */
    }
    
    .segment {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .inputs {
        gap: 1.5rem; /* Increase vertical spacing between input groups */
    }

    .input-group {
        gap: 0.75rem;
    }

    /* 4. Typography & Scaling */
    .calculator-card h2 {
        font-size: 1.25rem; /* Down from 1.5rem (~16% smaller) */
    }
    
    .transactions-header h3, .incomes-header h3, .expenses-header h3, .target-savings-header h3 {
        font-size: 0.95rem; /* Down from 1.1rem */
    }

    input, select {
        font-size: 16px !important; /* Minimum 16px to prevent iOS auto-zoom */
    }

    /* Existing Mobile Overrides */
    .mobile-header {
        display: flex;
        padding: 1rem 16px;
        align-items: center;
        gap: 0.75rem;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border-color);
        color: var(--deep-navy);
    }

    .mobile-header h2 { 
        margin: 0; 
        font-size: 1.25rem; 
    }

    .expense-row {
        flex-direction: column;
        gap: 0.5rem;
        position: relative;
        padding-top: 1.5rem;
        border-top: 1px solid var(--border-color);
    }
    
    .btn-remove {
        position: absolute;
        top: 0;
        right: 0;
        padding: 0;
        width: 48px; /* Touch target */
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Hide desktop controls inside the mobile bottom navigation */
    .sidebar-controls {
        display: none !important;
    }
}

/* Ad Slots & New Sections */
.ad-slot {
    min-height: 90px;
    background: #f9f9f9;
    border: 1px dashed #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    border-radius: 4px;
}

.affiliate-suggestion {
    background-color: rgba(46, 204, 113, 0.1);
    border-left: 4px solid var(--emerald-green);
    padding: 1rem;
    margin: 1.5rem 0;
    border-radius: 4px 8px 8px 4px;
}

.page-header {
    text-align: center;
    margin-bottom: 2rem;
}
.page-header h1 {
    font-size: 2.2rem;
    color: var(--deep-navy);
    margin-bottom: 0.5rem;
}
.page-header p {
    font-size: 1.1rem;
    color: var(--text-muted);
}

.footer-nav {
    margin: 1rem 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}
.footer-nav a {
    color: var(--deep-navy);
    text-decoration: none;
    font-weight: 500;
}
.footer-nav a:hover {
    text-decoration: underline;
}

/* Core Web Vitals Optimization (CLS) */
.outputs {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.result-row {
    min-height: 32px;
}

/* Embed Mode */
body.embed-mode {
    background-color: transparent !important;
}
body.embed-mode .sidebar, 
body.embed-mode .mobile-header,
body.embed-mode .educational-content,
body.embed-mode .app-footer {
    display: none !important;
}
body.embed-mode .content-area, .main-content {
    flex-grow: 1;
    padding: 3rem;
    position: relative;
}
body.embed-mode .container {
    max-width: 100% !important;
    gap: 0 !important;
    padding: 0 !important;
}
body.embed-mode .calculator-card {
    box-shadow: none !important;
    border-radius: 0 !important;
    border: none !important;
    padding: 16px !important;
    margin: 0 !important;
}

/* ================================================================
   UPGRADES — Dark Mode, Currency, Charts, PDF, Email, Social, Embed
   ================================================================ */

/* ── CSS VARIABLES (Dark Mode) ────────────────────────────── */
body.dark-mode {
  background: #0f0f0f;
  color: #f0f0f0;
}
body.dark-mode .sidebar         { background: #141414; border-right-color: #333; }
body.dark-mode .calculator-card { background: #1e1e1e; border: 1px solid #333; color: #f0f0f0; }
body.dark-mode input,
body.dark-mode select           { background: #1a1a1a; color: #f0f0f0; border-color: #333; }
body.dark-mode .result-row,
body.dark-mode .total-row       { border-color: #333; }
body.dark-mode .insight         { background: #1a2a1a; color: #a8e6a8; }
body.dark-mode .how-to-use      { background: #1a1a1a; border-color: #333; }
body.dark-mode .ad-slot         { background: #1a1a1a; border-color: #333; color: #aaa; }
body.dark-mode .hero-section    { background: #1e1e1e; }
body.dark-mode .social-proof-bar{ background: #1a1a1a; border-color: #333; }
body.dark-mode .email-capture   { background: #1a1a1a; border-color: #333; }
body.dark-mode .email-form input{ background: #1e1e1e; color: #f0f0f0; border-color: #333; }
body.dark-mode .embed-section   { background: #1a1a1a; border-color: #333; }
body.dark-mode .calc-card       { background: #1a1a1a; border-color: #333; }
body.dark-mode .seo-content     { color: #d0d0d0; }
body.dark-mode .seo-content h2  { color: #e0e0e0; }
body.dark-mode .seo-content details { border-color: #333; background: #1e1e1e; }
body.dark-mode .seo-content summary { color: #90caf9; }
body.dark-mode .app-footer      { background: #141414; border-top-color: #333; }
body.dark-mode table th         { background: #1a1a1a; color: #ddd; }
body.dark-mode table td,
body.dark-mode table th         { border-color: #333; color: #ddd; }
body.dark-mode .related-calculators { border-top-color: #333; }
body.dark-mode .share-section   { background: #1a1a1a; border-color: #333; }

/* ── SIDEBAR CONTROLS ─────────────────────────────────────── */
.sidebar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 1rem 12px;
  border-bottom: 1px solid var(--border-color, #e9ecef);
  margin-bottom: 8px;
}
#currency-selector {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border-color, #e9ecef);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
#dark-mode-toggle {
  background: none;
  border: 1px solid var(--border-color, #e9ecef);
  border-radius: 20px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.2s;
  white-space: nowrap;
}
#dark-mode-toggle:hover { background: #f0f0f0; }

/* ── HERO SECTION ─────────────────────────────────────────── */
.hero-section {
  text-align: center;
  margin-bottom: 1.5rem;
  padding: 2.5rem 1.5rem;
  background: var(--card-bg, #fff);
  border-radius: 16px;
  box-shadow: 0 2px 20px rgba(0,0,0,0.06);
}
.hero-section h1 {
  font-size: 2.2rem;
  color: var(--deep-navy, #1a237e);
  margin-bottom: 1rem;
  line-height: 1.2;
}
.hero-section > p {
  font-size: 1.1rem;
  color: var(--text-muted, #666);
  margin-bottom: 1.5rem;
}
.trust-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.trust-badges span {
  background: rgba(46,204,113,0.1);
  color: #2e7d32;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ── SOCIAL PROOF BAR ─────────────────────────────────────── */
.social-proof-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 24px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 12px;
  margin: 0 0 1.5rem 0;
  border: 1px solid #e9ecef;
}
.proof-item { text-align: center; display: flex; flex-direction: column; gap: 4px; }
.proof-item strong { font-size: 15px; }
.proof-item span { font-size: 12px; color: #666; }

/* ── CHART CONTAINER ──────────────────────────────────────── */
.chart-container {
  max-width: 500px;
  margin: 20px auto;
  padding: 20px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border: 1px solid #e9ecef;
}
body.dark-mode .chart-container { background: #1e1e1e; border-color: #333; }

/* ── ACTION BUTTONS ───────────────────────────────────────── */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 8px;
}
.btn-pdf {
  background: #1a1a1a;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}
.btn-pdf:hover { background: #333; }

/* ── SHARE BUTTONS ────────────────────────────────────────── */
.share-section {
  margin: 16px 0;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 1px solid #e9ecef;
}
.share-section > p { font-size: 13px; color: #666; margin: 0 0 10px; font-weight: 500; }
.share-btn {
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  margin: 0 6px 6px 0;
  transition: opacity 0.2s;
}
.share-btn:hover { opacity: 0.85; }
.share-whatsapp { background: #25d366; color: #fff; }
.share-twitter  { background: #000000; color: #fff; }
.share-facebook { background: #1877f2; color: #fff; }

/* ── AD SLOTS ─────────────────────────────────────────────── */
.ad-slot {
  min-height: 90px;
  background: #f8f9fa;
  border: 1px dashed #dee2e6;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px auto;
  max-width: 728px;
  color: #adb5bd;
  font-size: 12px;
}

/* ── AFFILIATE BOX ────────────────────────────────────────── */
.affiliate-box {
  background: #fff8e1;
  border-left: 4px solid #ffc107;
  border-radius: 8px;
  padding: 16px 20px;
  margin: 20px auto;
  max-width: 640px;
  font-size: 15px;
  line-height: 1.6;
}
.affiliate-link { color: #e65100; font-weight: 600; text-decoration: underline; }

/* ── EMAIL CAPTURE ────────────────────────────────────────── */
.email-capture {
  max-width: 520px;
  margin: 24px auto;
  padding: 28px;
  background: #f8f9fa;
  border-radius: 12px;
  border: 1px solid #e9ecef;
  text-align: center;
}
.email-capture h3 { margin: 0 0 8px; font-size: 17px; }
.email-capture > p { font-size: 14px; color: #666; margin: 0 0 16px; }
.email-form { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 12px 0; }
.email-form input {
  flex: 1;
  min-width: 220px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  font-size: 15px;
}
.email-form button {
  padding: 10px 20px;
  background: #4caf50;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}
.email-form button:hover { background: #388e3c; }
.email-privacy { font-size: 12px; color: #666; margin: 8px 0 0; }
.success-msg { color: #4caf50; font-weight: 600; font-size: 16px; }

/* ── RELATED CALCULATORS ──────────────────────────────────── */
.related-calculators {
  padding: 2rem 1rem;
  border-top: 1px solid #e9ecef;
  margin-top: 2rem;
}
.related-calculators h2 {
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--deep-navy, #1a237e);
}
.calculator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  max-width: 800px;
  margin: 0 auto;
}
.calc-card {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  border: 1px solid #e9ecef;
  transition: transform 0.2s, box-shadow 0.2s;
}
.calc-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.calc-card-icon { font-size: 2rem; margin-bottom: 10px; }
.calc-card h3 { font-size: 15px; margin: 0 0 6px; color: var(--deep-navy, #1a237e); }
.calc-card p { font-size: 13px; color: #666; margin: 0; line-height: 1.5; }

/* ── EMBED SECTION ────────────────────────────────────────── */
.embed-section {
  max-width: 640px;
  margin: 2rem auto;
  padding: 32px;
  background: #f8f9fa;
  border-radius: 12px;
  border: 1px solid #e9ecef;
  text-align: center;
}
.embed-section h2 { font-size: 1.3rem; margin: 0 0 10px; color: var(--deep-navy, #1a237e); }
.embed-section > p { font-size: 14px; color: #666; margin: 0 0 16px; }
.embed-code-box {
  background: #1a1a1a;
  color: #a8ff78;
  padding: 16px;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  text-align: left;
  margin: 16px 0;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.embed-section button {
  background: #1a1a1a;
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.embed-section button:hover { background: #333; }
.embed-note { font-size: 12px; color: #666; margin: 12px 0 0; }

/* ── SEO CONTENT ──────────────────────────────────────────── */
.seo-content {
  max-width: 720px;
  margin: 32px auto 0;
  padding: 0 4px;
  font-size: 16px;
  line-height: 1.8;
  color: #333;
}
.seo-content h2 { font-size: 22px; margin-top: 36px; margin-bottom: 12px; color: #1a1a1a; border: none; padding: 0; }
.seo-content p { margin: 0 0 14px; }
.seo-content code { background: #f0f0f0; padding: 2px 8px; border-radius: 4px; font-family: monospace; font-size: 14px; }
.seo-content details { border: 1px solid #e9ecef; border-radius: 8px; padding: 12px 16px; margin: 12px 0; background: #fff; }
.seo-content summary { font-weight: 600; cursor: pointer; padding: 4px 0; color: var(--deep-navy, #1a237e); list-style: none; }
.seo-content summary::before { content: '▶ '; font-size: 11px; }
details[open] summary::before { content: '▼ '; }
.seo-content details p { margin: 12px 0 4px; font-size: 15px; }

/* ── FOOTER UPGRADE ───────────────────────────────────────── */
.footer-links { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 12px; }
.footer-links a { color: #666; text-decoration: none; font-size: 14px; transition: color 0.2s; }
.footer-links a:hover { color: var(--deep-navy, #1a237e); text-decoration: underline; }
.footer-tagline { font-size: 13px; color: #666; margin: 4px 0; }
.footer-copy { font-size: 12px; color: #999; margin: 4px 0 0; }

/* ── HOW-TO-USE ───────────────────────────────────────────── */
.how-to-use { background: #f8f9fa; padding: 1.25rem 1.5rem; border-radius: 12px; margin-bottom: 1.5rem; border: 1px solid #e9ecef; }
.how-to-use h2 { font-size: 1rem; margin: 0 0 10px; color: var(--deep-navy, #1a237e); border: none; padding: 0; }
.how-to-use ol { padding-left: 1.4rem; margin: 0; color: #555; }
.how-to-use li { margin-bottom: 6px; font-size: 14px; line-height: 1.5; }

/* ── TIMEFRAME WRAPPER ────────────────────────────────────── */
.timeframe-input-wrapper { display: flex; gap: 8px; }
.timeframe-input-wrapper input { flex: 1; }
.timeframe-input-wrapper select { flex: 0 0 110px; }

/* ── MOBILE ───────────────────────────────────────────────── */
@media (max-width: 480px) {
    color: #ffffff;
}

/* ================================================================
   NEW: MODERN ARTICLE BLOG LAYOUT (MEDIUM STYLE)
   ================================================================ */
.blog-article-container a {
    color: #4f7df3;
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 600;
    transition: var(--transition);
}

.blog-article-container a:hover {
    color: var(--deep-navy, #0A192F);
}

.blog-article-container hr {
    border: none;
    border-top: 1px solid var(--border-color, #E9ECEF);
    margin: 2.5rem 0;
}

/* Dark Mode Support for Blog Article */
body.dark-mode .blog-article-container {
    background: #1e1e1e;
    color: #f0f0f0;
    border: none;
    box-shadow: none;
}

body.dark-mode .blog-article-container h1,
body.dark-mode .blog-article-container h2,
body.dark-mode .blog-article-container h3 {
    color: #ffffff;
}

body.dark-mode .blog-article-container a:hover {
    color: #ffffff;
}

.blog-article-container {
    background: #ffffff;
    max-width: 800px;
    margin: 2rem auto;
    padding: 3rem 2.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(10, 25, 47, 0.02);
    line-height: 1.8;
    color: var(--text-main, #1a1a1a);
    font-size: 1.1rem;
}
.blog-article-container h1 { font-size: 2.5rem; font-weight: 700; color: var(--deep-navy, #0A192F); margin-bottom: 1.5rem; letter-spacing: -0.02em; }
.blog-article-container h2 { font-size: 1.75rem; font-weight: 600; color: var(--deep-navy, #0A192F); margin-top: 2.5rem; margin-bottom: 1rem; }
.blog-article-container h3 { font-size: 1.3rem; font-weight: 600; color: var(--text-main, #1a1a1a); margin-top: 1.8rem; margin-bottom: 0.75rem; }
.blog-article-container p { margin-bottom: 1.5rem; }
.blog-article-container ul { padding-left: 1.75rem; margin-bottom: 1.5rem; }
.blog-article-container li { margin-bottom: 0.5rem; }

@media (max-width: 768px) {
    .blog-article-container { margin: 1rem; padding: 2rem 1.25rem; font-size: 1.05rem; }
    .blog-article-container h1 { font-size: 2rem; }
    .blog-article-container h2 { font-size: 1.5rem; }
}

/* ================================================================
   NEW: FINANCIAL STATEMENTS CALCULATOR SUITE PREMIUM STYLING
   ================================================================ */

/* ── 1. Horizontal Tab Switcher ────────────────────────────── */
.statement-tabs-container {
    margin-bottom: 2rem;
    overflow-x: auto;
    scrollbar-width: none; /* Hide default scrollbars */
}
.statement-tabs-container::-webkit-scrollbar {
    display: none;
}

.statement-tabs {
    display: flex;
    gap: 0.75rem;
    background-color: var(--input-bg);
    border-radius: 16px;
    padding: 6px;
    border: 1px solid var(--border-color);
    min-width: max-content;
    width: 100%;
}

.statement-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.85rem 1.5rem;
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.statement-tab:hover {
    color: var(--deep-navy);
    background-color: rgba(10, 25, 47, 0.04);
}

.statement-tab.active {
    background-color: var(--deep-navy);
    color: white;
    box-shadow: 0 4px 15px rgba(10, 25, 47, 0.15);
}

/* ── 2. Suggestion Pills ────────────────────────────────────── */
.suggestion-pills-box {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    width: 100%;
}

.suggestion-pill {
    background-color: rgba(10, 25, 47, 0.05);
    color: var(--deep-navy);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.suggestion-pill:hover {
    background-color: var(--deep-navy);
    color: white;
    transform: translateY(-1px);
}

/* ── 3. Visual Balance Sheet Balancer ───────────────────────── */
.balancer-container {
    background-color: var(--input-bg);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: var(--transition);
}

.balancer-container.balanced {
    border-color: var(--emerald-green);
    background-color: rgba(46, 204, 113, 0.05);
}

.balancer-container.unbalanced {
    border-color: var(--soft-crimson);
    background-color: rgba(231, 76, 60, 0.05);
}

.balancer-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--deep-navy);
    font-size: 1rem;
}

.balancer-bar {
    width: 100%;
    height: 12px;
    background-color: rgba(10, 25, 47, 0.1);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.balancer-fill {
    height: 100%;
    width: 50%;
    background-color: var(--soft-crimson);
    border-radius: 6px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.5s ease;
}

.balancer-container.balanced .balancer-fill {
    background-color: var(--emerald-green);
}

/* ── 4. Cash Flow Routing and UI adjustments ───────────────── */
.cf-row-layout {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.25rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    margin-bottom: 1rem;
}

.cf-row-inputs {
    display: flex;
    gap: 1rem;
    align-items: center;
    width: 100%;
}
.cf-row-inputs input {
    flex: 1;
}

.cf-routing-box {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: white;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.cf-routing-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.mini-segmented {
    padding: 2px !important;
    border-radius: 8px !important;
    background-color: var(--input-bg) !important;
    width: auto !important;
}

.mini-segmented .segment {
    padding: 0.4rem 0.75rem !important;
    font-size: 0.75rem !important;
    border-radius: 6px !important;
    min-height: auto !important;
}

.mini-segmented .segment.active {
    box-shadow: 0 1px 4px rgba(10,25,47,0.08) !important;
}

.tri-segmented {
    max-width: 100%;
}

.segment-inflow.active {
    background-color: var(--emerald-green) !important;
    color: white !important;
}

.segment-outflow.active {
    background-color: var(--soft-crimson) !important;
    color: white !important;
}

/* ── 5. Dark Mode compliance overrides ─────────────────────── */
body.dark-mode .statement-tabs {
    background-color: #141414;
    border-color: #333;
}

body.dark-mode .statement-tab:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.04);
}

body.dark-mode .statement-tab.active {
    background-color: #f0f0f0;
    color: #0f0f0f;
}

body.dark-mode .suggestion-pill {
    background-color: rgba(255, 255, 255, 0.06);
    color: #e0e0e0;
}

body.dark-mode .suggestion-pill:hover {
    background-color: #f0f0f0;
    color: #0f0f0f;
}

body.dark-mode .balancer-container {
    background-color: #1a1a1a;
    border-color: #333;
}

body.dark-mode .balancer-container.balanced {
    border-color: var(--emerald-green);
    background-color: rgba(46, 204, 113, 0.08);
}

body.dark-mode .balancer-container.unbalanced {
    border-color: var(--soft-crimson);
    background-color: rgba(231, 76, 60, 0.08);
}

body.dark-mode .balancer-bar {
    background-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .cf-row-layout {
    background-color: #1e1e1e;
    border-color: #333;
}

body.dark-mode .cf-routing-box {
    background-color: #141414;
    border-color: #333;
}

/* ── 6. Mobile Optimization overrides ──────────────────────── */
@media (max-width: 768px) {
    .cf-row-inputs {
        flex-direction: column;
        align-items: stretch;
    }
    .cf-routing-question {
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
    }
    .mini-segmented {
        width: 100% !important;
    }
}

/* ── 7. Unified Two-Wing Calculator Grid ─────────────────────── */
.calculator-workspace {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 2rem;
    align-items: start;
    width: 100%;
}

.left-wing {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
}

.right-wing-canvas {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
    position: sticky;
    top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    transition: var(--transition);
    width: 100%;
}

.right-wing-canvas:hover {
    box-shadow: var(--shadow-hover);
}

.canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 0.75rem;
}

.canvas-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--deep-navy);
}

.btn-copy-summary {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    background-color: var(--deep-navy);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-copy-summary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.canvas-pre {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    white-space: pre-wrap;
    margin: 0;
    line-height: 1.52;
    color: var(--text-main);
    text-align: left;
}

body.dark-mode .right-wing-canvas {
    background: #1e1e1e;
    border-color: #333;
}

body.dark-mode .canvas-pre {
    background-color: #141414;
    border-color: #333;
    color: #e0e0e0;
}

body.dark-mode .btn-copy-summary {
    background-color: #f0f0f0;
    color: #0f0f0f;
}

body.dark-mode .canvas-header {
    border-bottom-color: #333;
}

@media (max-width: 992px) {
    .calculator-workspace {
        grid-template-columns: 1fr;
    }
    .right-wing-canvas {
        position: static;
    }
}

/* ==========================================================================
   MOBILE OVERRIDE PATCH (Max Width 768px)
   Forces native mobile stacking, readable text, and touch-friendly inputs
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* 1. Base Typography & iOS Auto-Zoom Prevention */
    html, body {
        font-size: 16px !important; /* Prevents Apple auto-zoom on inputs */
        overflow-x: hidden;
        width: 100%;
    }

    /* 2. Core Layout Stacking */
    .app-layout {
        flex-direction: column !important;
        display: block;
    }

    /* 3. Transform Vertical Sidebar to Premium Scrollable Bottom Navigation */
    .sidebar {
        display: flex !important;
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: auto !important;
        padding: 0 !important;
        background: var(--card-bg) !important;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: none !important;
        border-top: 1px solid var(--border-color) !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08) !important;
        z-index: 1000 !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap !important;
        scrollbar-width: none !important; /* Hide for Firefox */
    }
    
    .sidebar::-webkit-scrollbar {
        display: none !important; /* Hide for Chrome/Safari */
    }
    
    .sidebar .brand {
        display: none !important;
    }
    
    .nav-menu {
        flex-direction: row !important;
        justify-content: flex-start !important;
        align-items: center !important;
        padding: 0.5rem 1rem !important;
        margin: 0 !important;
        width: auto !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 1.5rem !important;
    }
    
    .nav-item {
        flex-direction: column !important;
        gap: 0.25rem !important;
        padding: 0.5rem !important;
        background: transparent !important;
        box-shadow: none !important;
        color: var(--text-muted) !important;
        flex-shrink: 0 !important;
        justify-content: center !important;
        align-items: center !important;
        min-width: 64px !important;
    }
    
    .nav-item span {
        font-size: 11px !important;
        display: block !important;
        line-height: 1 !important;
    }
    
    .nav-item.active {
        color: var(--accent, #4f7df3) !important;
    }

    /* 4. Fix Padding and Margins for Small Screens */
    .content-area, 
    .main-content {
        padding: 1rem !important;
        padding-bottom: 90px !important; /* Cushion so fixed bottom nav never obscures content */
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box;
    }

    /* 5. Fluid Calculator Cards and Blog Containers */
    .calculator-card, 
    .blog-article-container,
    .canvas-pre {
        width: 100% !important;
        padding: 1.25rem !important;
        margin-bottom: 1.5rem !important;
        border-radius: 12px !important;
        box-sizing: border-box;
    }

    /* 6. Enlarge Touch Targets (Localized inputs & buttons) */
    .calculator-card .inputs input,
    .calculator-card .inputs select,
    .calculator-card .expense-row input,
    .calculator-card .expense-row select,
    .calculator-card .cf-row-inputs input,
    .calculator-card .cf-row-inputs select,
    .email-form input,
    .email-form button,
    .btn-secondary,
    .btn-pdf,
    .btn-copy-summary {
        font-size: 16px; /* Critical for readability and iOS auto-zoom prevention */
        padding: 14px 12px; /* Taller touch targets for thumbs */
    }

    .calculator-card .inputs input,
    .calculator-card .inputs select,
    .calculator-card .expense-row input:not(.btn-remove),
    .calculator-card .expense-row select,
    .calculator-card .cf-row-inputs input:not(.btn-remove),
    .calculator-card .cf-row-inputs select,
    .email-form input,
    .email-form button,
    .btn-secondary,
    .btn-pdf,
    .btn-copy-summary {
        width: 100%;
    }

    /* 7. Readability Adjustments for Text */
    h1 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
    }

    p, span, label {
        font-size: 1rem !important;
        line-height: 1.6 !important;
    }

    /* 8. Fix Grid Layouts (Force 1 column on mobile) */
    .input-grid, 
    .results-grid, 
    .footer-links ul {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }

    /* 9. Compact Icon Buttons & Stacked Dynamic Input Rows Override */
    .btn-icon {
        width: 36px;
        height: 36px;
        padding: 0;
        border-radius: 50%;
        flex: none;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .btn-remove {
        width: 48px;
        height: 48px;
        padding: 0;
        position: absolute;
        top: 0;
        right: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        flex: none;
    }
    .expense-row {
        flex-direction: column !important;
        align-items: stretch !important;
        padding-right: 48px !important;
        position: relative !important;
        gap: 0.5rem !important;
        scroll-margin-bottom: 140px;
    }
    .cf-row-inputs {
        flex-direction: column !important;
        align-items: stretch !important;
        padding-right: 48px !important;
        position: relative !important;
        gap: 0.5rem !important;
        scroll-margin-bottom: 140px;
    }

    /* 10. Responsive Column Drop for Calculator Workspace */
    .calculator-workspace {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
    }
    .right-wing-canvas {
        width: 100% !important;
    }

    /* 11. Suggestion Pills Mobile Layout Optimization */
    .suggestion-pills-box {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 0.5rem !important;
        padding: 4px 0 !important;
        width: 100% !important;
        scrollbar-width: none !important;
    }
    .suggestion-pills-box::-webkit-scrollbar {
        display: none !important;
    }
    .suggestion-pill {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        padding: 0.35rem 0.75rem !important;
        font-size: 0.75rem !important;
    }
}

