:root {
    --bg-primary: #0a0a0b;
    --bg-secondary: #121214;
    --bg-tertiary: #1a1a1e;
    --bg-card: #16161a;
    --border-color: #2a2a30;
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent-gold: #d4a853;
    --accent-gold-dim: #b8943f;
    --accent-green: #22c55e;
    --accent-green-dim: #16a34a;
    --accent-blue: #3b82f6;
    --accent-purple: #a855f7;
    --accent-red: #ef4444;
    --accent-cyan: #06b6d4;
    --accent-orange: #f97316;
    --gradient-gold: linear-gradient(135deg, #d4a853 0%, #f0d78c 50%, #d4a853 100%);
    --gradient-fire: linear-gradient(135deg, #ef4444 0%, #f97316 50%, #d4a853 100%);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(212, 168, 83, 0.15);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* Typography */
h1, h2, h3 {
    font-family: 'Instrument Serif', serif;
    font-weight: 400;
    letter-spacing: -0.02em;
}

/* Navigation */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(10, 10, 11, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
}

.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.logo-img {
    height: 40px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.6rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* Main container */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 7rem 2rem 4rem;
}

/* Hero Section */
.hero {
    text-align: center;
    margin-bottom: 4rem;
    animation: fadeInUp 0.8s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.hero-badge-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-orange);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.hero h1 {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    line-height: 1.1;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero h1 em {
    font-style: italic;
    background: var(--gradient-fire);
    -webkit-background-clip: text;
    background-clip: text;
}

.hero p {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Mode Toggle */
.mode-toggle-container {
    display: flex;
    justify-content: center;
    margin-bottom: 3rem;
    animation: fadeInUp 0.8s ease 0.2s both;
}

.mode-toggle {
    display: flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 4px;
}

.mode-btn {
    padding: 0.75rem 2rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Calculator Grid */
.calculator-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 2rem;
    animation: fadeInUp 0.8s ease 0.3s both;
}

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

/* Input Panel */
.input-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
    height: fit-content;
    position: sticky;
    top: 100px;
}

.panel-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-title {
    font-size: 1.35rem;
    color: var(--text-primary);
}

/* Form Groups */
.form-section {
    margin-bottom: 2rem;
}

.form-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

.input-wrapper {
    position: relative;
}

.input-prefix {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
}

.input-suffix {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

input[type="number"],
input[type="text"],
select {
    width: 100%;
    padding: 0.9rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s ease;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

input.has-prefix {
    padding-left: 2rem;
}

input.has-suffix {
    padding-right: 3rem;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a1a1aa' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* Toggle Row */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.toggle {
    position: relative;
    width: 48px;
    height: 26px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.toggle.active {
    background: var(--accent-orange);
    border-color: var(--accent-orange);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.toggle.active::after {
    transform: translateX(22px);
}

/* Inline Input Group */
.inline-group {
    display: flex;
    gap: 0.75rem;
}

.inline-group .form-group {
    flex: 1;
}

/* Max Button */
.max-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.35rem 0.75rem;
    background: var(--accent-orange);
    color: var(--bg-primary);
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.max-btn:hover {
    background: var(--accent-gold);
}

/* Collapsible Section */
.collapsible {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: background 0.2s ease;
}

.collapsible-header:hover {
    background: var(--bg-tertiary);
}

.collapsible-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.collapsible-icon {
    width: 28px;
    height: 28px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.collapsible-arrow {
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.collapsible.open .collapsible-arrow {
    transform: rotate(180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible.open .collapsible-content {
    max-height: 500px;
}

.collapsible-inner {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Chart Panel */
.chart-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
}

.chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.chart-title-group h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.chart-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.chart-stats {
    display: flex;
    gap: 2rem;
    text-align: right;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-family: 'Instrument Serif', serif;
    font-size: 1.75rem;
    color: var(--text-primary);
}

.stat-value.green {
    color: var(--accent-green);
}

.stat-value.gold {
    color: var(--accent-gold);
}

.stat-value.orange {
    color: var(--accent-orange);
}

.chart-container {
    position: relative;
    height: 400px;
    margin-bottom: 2rem;
}

/* Burn Rate Section */
.burn-rate-section {
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
    margin-top: 1rem;
}

.burn-rate-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.burn-rate-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.burn-rate-title h3 {
    font-size: 1.1rem;
}

.burn-rate-badge {
    padding: 0.3rem 0.6rem;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--accent-green);
}

.burn-rate-inputs {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.burn-rate-inputs .form-group {
    flex: 1;
    min-width: 150px;
    margin: 0;
}

.burn-rate-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.burn-rate-toggle:hover {
    border-color: var(--accent-orange);
}

.burn-rate-toggle.active {
    background: rgba(249, 115, 22, 0.1);
    border-color: var(--accent-orange);
}

.burn-rate-toggle .toggle-label {
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Income Display */
.income-display {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
}

.income-item {
    text-align: center;
}

.income-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.income-value {
    font-family: 'Instrument Serif', serif;
    font-size: 1.5rem;
    color: var(--accent-green);
}

.income-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Legend */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    padding-top: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* Allocation Breakdown */
.allocation-section {
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
    margin-top: 2rem;
}

.allocation-title {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.allocation-bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.allocation-item {
    display: grid;
    grid-template-columns: 120px 1fr 80px;
    align-items: center;
    gap: 1rem;
}

.allocation-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.allocation-bar-bg {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.allocation-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.allocation-value {
    font-size: 0.9rem;
    font-weight: 500;
    text-align: right;
}

/* Historical Page */
.historical-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    animation: fadeInUp 0.8s ease 0.3s both;
}

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

.historical-info {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
}

.historical-info h4 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.historical-info p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.historical-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

.historical-stat {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 1rem;
}

.historical-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.historical-stat-value {
    font-family: 'Instrument Serif', serif;
    font-size: 1.5rem;
    margin-top: 0.25rem;
}

.historical-stat-note {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Inflation Toggle */
.inflation-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-top: 1rem;
}

.inflation-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.inflation-label {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.inflation-sublabel {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Final Value Display */
.final-value-breakdown {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    margin-top: 1rem;
}

.final-value-item {
    text-align: center;
}

.final-value-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.final-value-amount {
    font-family: 'Instrument Serif', serif;
    font-size: 1.75rem;
    margin-top: 0.25rem;
}

.final-value-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Ad Placeholder */
.ad-container {
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    margin: 3rem 0;
}

.ad-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Footer */
footer {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-text {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer-links {
    display: flex;
    gap: 2rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--accent-orange);
}

/* Legal Pages */
.legal-page {
    max-width: 800px;
    margin: 0 auto;
}

.legal-page h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.legal-page .last-updated {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.legal-page h2 {
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--accent-orange);
}

.legal-page p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.8;
}

.legal-page ul {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.legal-page li {
    margin-bottom: 0.5rem;
    line-height: 1.7;
}

.legal-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-orange);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 2rem;
    transition: opacity 0.2s ease;
}

.legal-back-link:hover {
    opacity: 0.8;
}

/* ============================================
   MOBILE MENU STYLES
   ============================================ */

/* Hamburger Menu Button */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.hamburger-line {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-line:nth-child(1) {
    margin-bottom: 6px;
}

.hamburger-line:nth-child(3) {
    margin-top: 6px;
}

/* Hamburger animation to X */
.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Body scroll lock when menu open */
body.menu-open {
    overflow: hidden;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Large tablets and small desktops */
@media (max-width: 1100px) {
    .calculator-grid {
        grid-template-columns: 1fr;
    }

    .input-panel {
        position: static;
    }
}

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

/* Tablets */
@media (max-width: 900px) {
    .chart-stats {
        gap: 1.5rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    /* Navigation */
    nav {
        padding: 0.75rem 1rem;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: var(--bg-card);
        flex-direction: column;
        padding: 5rem 1.5rem 2rem;
        gap: 0.5rem;
        border-left: 1px solid var(--border-color);
        transition: right 0.3s ease;
        z-index: 1000;
    }

    .nav-links.mobile-open {
        right: 0;
    }

    .nav-link {
        padding: 1rem 1.25rem;
        font-size: 1rem;
        border-radius: 10px;
    }

    /* Main container */
    main {
        padding: 5rem 1rem 2rem;
    }

    /* Hero Section */
    .hero {
        margin-bottom: 2.5rem;
    }

    .hero h1 {
        font-size: clamp(2rem, 8vw, 2.5rem);
        margin-bottom: 1rem;
    }

    .hero p {
        font-size: 1rem;
        line-height: 1.7;
    }

    .hero-badge {
        font-size: 0.8rem;
        padding: 0.4rem 0.85rem;
    }

    /* Mode Toggle */
    .mode-toggle-container {
        margin-bottom: 2rem;
    }

    .mode-btn {
        padding: 0.65rem 1.5rem;
        font-size: 0.9rem;
    }

    /* Input Panel */
    .input-panel {
        position: static;
        padding: 1.5rem;
        border-radius: 16px;
    }

    .panel-header {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }

    .panel-title {
        font-size: 1.2rem;
    }

    /* Form elements - larger touch targets */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-group label {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
    }

    input[type="number"],
    input[type="text"],
    select {
        padding: 1rem;
        font-size: 16px; /* Prevents iOS zoom on focus */
        border-radius: 12px;
        min-height: 48px; /* Touch-friendly height */
    }

    .input-prefix {
        left: 1rem;
        font-size: 1rem;
    }

    .input-suffix {
        right: 1rem;
        font-size: 0.9rem;
    }

    input.has-prefix {
        padding-left: 2.25rem;
    }

    input.has-suffix {
        padding-right: 3.5rem;
    }

    /* Collapsibles */
    .collapsible {
        border-radius: 12px;
    }

    .collapsible-header {
        padding: 0.9rem 1rem;
    }

    .collapsible-inner {
        padding: 1rem;
    }

    /* Chart Panel */
    .chart-panel {
        padding: 1.5rem;
        border-radius: 16px;
    }

    .chart-header {
        flex-direction: column;
        gap: 1.25rem;
        margin-bottom: 1.5rem;
    }

    .chart-title-group h2 {
        font-size: 1.25rem;
    }

    .chart-subtitle {
        font-size: 0.85rem;
    }

    .chart-stats {
        width: 100%;
        justify-content: space-between;
        text-align: left;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .stat-value {
        font-size: 1.35rem;
    }

    .chart-container {
        height: 280px;
        margin-bottom: 1.5rem;
    }

    /* Chart Legend */
    .chart-legend {
        gap: 1rem;
        padding-top: 0.75rem;
    }

    .legend-item {
        font-size: 0.8rem;
    }

    /* Burn Rate Section */
    .burn-rate-section {
        padding-top: 1.5rem;
    }

    .burn-rate-header {
        margin-bottom: 1rem;
    }

    .burn-rate-title {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .burn-rate-title h3 {
        font-size: 1rem;
    }

    .burn-rate-badge {
        font-size: 0.7rem;
    }

    .burn-rate-toggle {
        padding: 0.85rem 1rem;
    }

    .burn-rate-toggle .toggle-label {
        font-size: 0.85rem;
    }

    .burn-rate-inputs {
        flex-direction: column;
        gap: 1rem;
    }

    .burn-rate-inputs .form-group {
        min-width: 100%;
    }

    /* Income Display */
    .income-display {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }

    .income-value {
        font-size: 1.35rem;
    }

    /* Allocation Section */
    .allocation-section {
        padding-top: 1.5rem;
        margin-top: 1.5rem;
    }

    .allocation-title {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .allocation-item {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    .allocation-label {
        font-size: 0.8rem;
    }

    .allocation-bar-bg {
        order: 2;
        height: 6px;
    }

    .allocation-value {
        order: 3;
        text-align: left;
        font-size: 0.85rem;
    }

    /* Historical page stats */
    .historical-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .historical-stat {
        padding: 0.85rem;
    }

    .historical-stat-value {
        font-size: 1.25rem;
    }

    .historical-info {
        padding: 1.25rem;
    }

    /* Final value breakdown */
    .final-value-breakdown {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1.25rem;
    }

    .final-value-amount {
        font-size: 1.5rem;
    }

    /* Inline groups */
    .inline-group {
        flex-direction: column;
        gap: 0;
    }

    /* Max Button - larger touch target */
    .max-btn {
        padding: 0.45rem 0.85rem;
        font-size: 0.75rem;
    }

    /* Ad Container */
    .ad-container {
        padding: 1.5rem;
        margin: 2rem 0;
    }

    /* Footer */
    footer {
        flex-direction: column;
        text-align: center;
        padding: 2rem 1rem;
        gap: 1rem;
    }

    .footer-links {
        justify-content: center;
        gap: 1.5rem;
        flex-wrap: wrap;
    }

    /* Legal Pages */
    .legal-page h1 {
        font-size: 2rem;
    }

    .legal-page h2 {
        font-size: 1.3rem;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    main {
        padding: 4.5rem 0.75rem 1.5rem;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .hero p {
        font-size: 0.95rem;
    }

    .input-panel,
    .chart-panel {
        padding: 1.25rem;
        border-radius: 14px;
    }

    .mode-btn {
        padding: 0.6rem 1.25rem;
        font-size: 0.85rem;
    }

    .chart-container {
        height: 250px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .historical-stats-grid {
        grid-template-columns: 1fr;
    }

    .chart-legend {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .nav-links {
        width: 100%;
        right: -100%;
    }

    .footer-links {
        gap: 1rem;
    }

    .footer-links a {
        font-size: 0.8rem;
    }

    .footer-text {
        font-size: 0.8rem;
    }
}

/* Handle safe areas for notched devices */
@supports (padding: max(0px)) {
    nav {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    main {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    footer {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
}

/* Hide number input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Cookie Consent Banner */
#cookie-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    z-index: 10000;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#cookie-consent-banner.cookie-consent-hidden {
    animation: slideDown 0.3s ease-out forwards;
}

@keyframes slideDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

.cookie-consent-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.cookie-consent-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
    flex: 1;
    min-width: 200px;
}

.cookie-consent-content a {
    color: var(--accent-orange);
    text-decoration: underline;
}

.cookie-consent-buttons {
    display: flex;
    gap: 0.75rem;
}

.cookie-btn {
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: inherit;
}

.cookie-btn-primary {
    background: var(--accent-orange);
    color: white;
}

.cookie-btn-primary:hover {
    background: #ea580c;
    transform: translateY(-1px);
}

.cookie-btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.cookie-btn-secondary:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

@media (max-width: 600px) {
    #cookie-consent-banner {
        padding: 1rem;
    }

    .cookie-consent-content {
        flex-direction: column;
        text-align: center;
    }

    .cookie-consent-buttons {
        width: 100%;
        justify-content: center;
    }
}
