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

:root {
    --primary: #1a73e8;
    --success: #34a853;
    --warning: #fbbc04;
    --danger: #ea4335;
    --text: #202124;
    --muted: #5f6368;
    --bg: #f8f9fa;
    --card: #ffffff;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

/* Header - Not Fixed */
header {
    background: var(--primary);
    color: white;
    padding: 12px 20px;
}

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

header h1 {
    font-size: 1.3rem;
    font-weight: 600;
}

header h1 a {
    color: inherit;
    text-decoration: none;
}

/* Navigation - Compact */
nav {
    background: white;
    border-bottom: 1px solid #e0e0e0;
}

.nav-container {
    max-width: 1100px;
    margin: 0 auto;
}

.nav-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
}

.nav-item {
    position: relative;
    margin: 0;
}

.nav-link {
    display: block;
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

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

.arrow {
    font-size: 0.65rem;
    margin-left: 4px;
    opacity: 0.7;
}

/* Dropdown Menu */
.nav-item:hover > .dropdown {
    display: grid;
}

.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 500px;
    max-width: 650px;
    list-style: none;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    border-radius: var(--radius);
    z-index: 1000;
    padding: 12px;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin: 0;
    animation: dropdownFade 0.2s ease;
}

@keyframes dropdownFade {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: block;
    margin: 0;
}

.dropdown-item a {
    display: block;
    padding: 10px 12px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.dropdown-item a:hover {
    background: var(--bg);
    color: var(--primary);
}

/* Main Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 20px 40px;
}

/* Breadcrumb - Compact */
.breadcrumb {
    display: flex;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 12px;
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

/* Page Header - Compact */
.page-header {
    margin-bottom: 20px;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.page-header p {
    font-size: 0.9rem;
    color: var(--muted);
}

/* Ad Slots - Compact */
.ad-slot {
    margin: 15px 0;
    text-align: center;
}

.ad-placeholder {
    background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
    border: 2px dashed #bdbdbd;
    border-radius: var(--radius);
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9e9e9e;
    font-size: 0.85rem;
}

/* Calculator Box - Compact */
.calculator-box {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 20px;
}

/* Form - Compact Grid */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group small {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 4px;
}

/* Buttons - Compact */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.btn-success {
    background: var(--success);
    color: white;
    width: 100%;
}

.btn-success:hover {
    background: #2d9249;
}

.mode-toggle {
    text-align: center;
    margin: 15px 0;
}

/* Results - Compact */
.results-section {
    margin-top: 20px;
}

.result-card {
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.result-card-success {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    border-left: 4px solid var(--success);
}

.result-card-warning {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
    border-left: 4px solid var(--warning);
}

.result-card-info {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border-left: 4px solid var(--primary);
}

.result-card-danger {
    background: linear-gradient(135deg, #ffebee, #ffcdd2);
    border-left: 4px solid var(--danger);
}

.result-card h3,
.result-card h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 10px;
    opacity: 0.9;
}

.result-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.result-grid {
    display: grid;
    gap: 8px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    font-size: 0.85rem;
}

.result-row.highlight {
    background: rgba(255,255,255,0.5);
    font-weight: 600;
}

/* Table - Compact */
.table-responsive {
    overflow-x: auto;
    margin-top: 15px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th,
.data-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.data-table th {
    background: var(--text);
    color: white;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.data-table tbody tr:hover {
    background: var(--bg);
}

/* Footer - Compact */
footer {
    background: var(--text);
    color: white;
    padding: 20px;
    margin-top: 40px;
}

.footer-content {
    max-width: 1100px;
    margin: 0 auto;
    text-align: center;
}

.footer-content p {
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.footer-links {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin: 10px 0;
}

.footer-links a {
    color: white;
    text-decoration: none;
    font-size: 0.85rem;
    opacity: 0.8;
}

.footer-links a:hover {
    opacity: 1;
}

/* Sidebar Ad */
.sidebar-ad-container {
    display: none;
}

/* Mobile Menu */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    -webkit-tap-highlight-color: transparent;
    z-index: 1001;
    position: relative;
}

/* Utility */
.hidden { display: none; }
.text-center { text-align: center; }

/* Responsive */
@media (max-width: 768px) {
    .header-container {
        padding: 0;
    }

    .mobile-menu-toggle {
        display: flex;
        padding: 10px;
        z-index: 1001;
        min-width: 44px;
        min-height: 44px;
        align-items: center;
        justify-content: center;
    }

    nav {
        position: relative;
        z-index: 1000;
    }

    .nav-list {
        display: none;
        flex-direction: column;
        width: 100%;
        background: white;
        z-index: 999;
    }

    .nav-list.active {
        display: flex;
        animation: slideDown 0.3s ease;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .nav-item {
        border-bottom: 1px solid #f0f0f0;
    }

    .nav-link {
        padding: 14px 16px;
        -webkit-tap-highlight-color: transparent;
    }

    .nav-item.has-dropdown > .nav-link {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    /* Arrow span styling for mobile */
    .arrow {
        display: inline-block;
        margin-left: 8px;
        font-size: 0.6rem;
        transition: transform 0.3s ease;
        min-width: 20px;
        min-height: 20px;
        text-align: center;
        line-height: 20px;
    }

    .nav-item.has-dropdown.mobile-open > .arrow {
        transform: rotate(180deg);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

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

    .container {
        padding: 15px 15px 30px;
    }

    /* Mobile dropdown */
    .nav-item:hover > .dropdown {
        display: none !important;
    }

    .nav-item.mobile-open > .dropdown {
        display: block !important;
        position: static;
        box-shadow: none;
        min-width: 100%;
        padding: 0;
        margin: 0;
        border-radius: 0;
        animation: none;
        background: #fafafa;
    }

    .nav-item.mobile-open > .dropdown .dropdown-item {
        display: block;
        border-bottom: 1px solid #f0f0f0;
    }

    .dropdown-item a {
        padding: 12px 12px 12px 24px;
        font-size: 0.9rem;
    }

    .dropdown {
        grid-template-columns: 1fr;
    }

    /* Improve touch targets */
    .btn, input, select {
        min-height: 44px;
    }

    input[type="range"] {
        min-height: auto;
    }
    
    /* Fix for iOS Safari - prevent zoom on double tap */
    * {
        touch-action: manipulation;
    }
    
    /* Ensure buttons are easily tappable */
    button, .btn {
        -webkit-tap-highlight-color: transparent;
        cursor: pointer;
    }
    
    /* Fix dropdown touch issues */
    .nav-item.has-dropdown > .nav-link {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Print */
@media print {
    header, footer, nav, .ad-slot, .mode-toggle, .btn {
        display: none !important;
    }
}
