body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #1a1a1a;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: #1a1a1a;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background-color: transparent;
    color: white;
    text-align: left;
    padding: 1.2rem;
    z-index: 100;
}

header h1 {
    margin: 0;
    font-size: 2.15rem;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

main {
    flex: 1;
    padding: 1.25vw; /* Updated: 1.5rem ≈ 1.25% of 1920px */
    max-width: 100%;
    box-sizing: border-box;
}

/* Desktop: Add margin-top to main when search-section is visible */
@media (min-width: 601px) {
    main:has(#search-section:not([style*="display: none"])) {
        margin-top: 5.5rem;
    }
    /* Hide desktop headings when results-section is visible */
    main:has(#results-section:not([style*="display: none"])) .desktop-heading {
        display: none;
    }
    /* Reduce dropdown menu height for balanced spacing */
    .dropdown-content {
        min-height: 0;
    }
    /* Desktop background settings */
    body {
        background-size: 100% 100%;
        background-position: center;
        background-repeat: no-repeat;
    }
    /* Desktop hover effects for all buttons */
    .range-button:hover,
    .done-button:hover,
    button[type="submit"]:hover,
    .back-button:hover,
    #to-top-button:hover,
    #download-link:hover {
        opacity: 0.9;
        transform: translateY(-1px);
    }
    /* Center search section on desktop */
    #search-section {
        margin-left: auto;
        margin-right: auto;
    }
}

/* Desktop styles for h2 and h3 in main */
.desktop-heading {
    text-align: left;
    margin: 0.5vh 0; /* Updated: 0.5rem ≈ 0.5% of viewport height */
    padding: 0; /* Explicit for clarity */
    font-size: 2.1rem;
    color: #fff;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.mobile-heading {
    display: none;
}

section {
    padding: 1.25vw; /* Updated: 1.5rem ≈ 1.25% of 1920px */
    border-radius: 12px;
    margin: 0 auto;
    max-width: 600px;
}

#search-section {
    background: transparent;
}

/* Rest of section styles unchanged */
#results-section {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.results-header h2 {
    margin: 0;
    font-size: 1.6rem;
    color: #1a1a1a;
    font-weight: 600;
    text-align: center;
}

.results-header h2 .company-name {
    display: block;
    text-align: center;
    line-height: 1.4;
}

.results-header h2 .company-symbol {
    display: block;
    text-align: center;
    line-height: 1.4;
    border-bottom: 1px solid #d1d1d1;
    padding: 0 1rem 0.2rem 1rem;
    margin: 0 0 0.5rem 0;
    width: calc(100% - 2rem);
}

.search-bar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(248, 249, 250, 0.8);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.input-group {
    display: flex;
    flex-direction: column;
}

label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 0.3rem;
}

input {
    padding: 0.8rem;
    font-size: 1rem;
    border: 1px solid #d1d1d1;
    border-radius: 6px;
    background: white;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus:not([readonly]) {
    outline: none;
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

input[readonly] {
    background: #f1f3f5;
    cursor: not-allowed;
}

.dropdown {
    position: relative;
}

.dropdown-toggle {
    width: 100%;
    padding: 0.8rem;
    font-size: 1rem;
    font-weight: 500;
    border: 1px solid #d1d1d1;
    border-radius: 6px;
    background: white;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-toggle:hover {
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.dropdown-arrow {
    font-size: 0.9rem;
    color: #333;
    margin-left: auto;
}

.dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d1d1;
    border-radius: 6px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    z-index: 10;
    display: none;
    flex-direction: column;
    min-height: 150px;
}

.dropdown-content.show {
    display: flex;
}

.dropdown-content-inner {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-grow: 1;
}

.range-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.range-button {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid #d1d1d1;
    border-radius: 6px;
    background: linear-gradient(to right, #333, #000);
    color: white;
    cursor: pointer;
    transition: opacity 0.3s, border-color 0.3s;
}

.range-button:hover {
    opacity: 0.9;
    border-color: #000;
}

.range-button.active {
    background: linear-gradient(to right, #444, #111);
    color: white;
    border-color: #000;
}

#custom-dates {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.done-button {
    padding: 0.8rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    background: linear-gradient(to right, #333, #000);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.3s;
    align-self: flex-end;
}

.done-button:hover {
    opacity: 0.9;
}

button[type="submit"] {
    padding: 0.8rem;
    font-size: 1rem;
    font-weight: 500;
    background: linear-gradient(to right, #333, #000);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.3s, transform 0.1s;
}

button[type="submit"]:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

button[type="submit"]:active {
    transform: translateY(0);
}

.results-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.results-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

#results {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    border: 1px solid #e0e0e0;
    padding: 0.6rem;
}

th {
    background: #f1f3f5;
    font-weight: 600;
    color: #1a1a1a;
    text-align: right;
}

td {
    color: #333;
    text-align: right;
}

th.date-header, td.date-cell {
    text-align: left;
}

tr.even-row {
    background: #fff;
}

tr.odd-row {
    background: #f5f5f5;
}

a, .back-button, #to-top-button {
    display: inline-block;
    color: #fff;
    background: linear-gradient(to right, #333, #000);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    transition: opacity 0.3s;
    cursor: pointer;
    font-size: 1rem;
}

a:hover, .back-button:hover, #to-top-button:hover {
    opacity: 0.9;
}

#to-top-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1;
    padding: 0.5rem 1rem;
    font-size: 1.2rem;
    background: linear-gradient(to right, #333, #000);
    color: #fff;
    border: none;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    height: 40px;
}

/* Style date components for desktop (inline by default) */
.date-month, .date-day, .date-year {
    display: inline;
}

/* Footer styles */
footer {
    background-color: transparent;
    padding: 1rem;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
}

.footer-links a {
    color: #fff;
    background: none;
    padding: 0;
    text-decoration: none;
    font-weight: 700;
    transition: color 0.3s, text-decoration 0.3s;
}

.footer-links a:hover {
    color: #f0f0f0;
    opacity: 1;
    text-decoration: underline;
}

.footer-separator {
    color: #fff;
    font-weight: 700;
}

/* Mobile optimizations */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.8rem;
    }

    main {
        padding: 4.27vw; /* Updated: 1rem ≈ 4.27% of 375px */
    }

    .desktop-heading {
        display: none;
    }

    .mobile-heading {
        display: block;
        text-align: left;
        margin: 2.13vh 0; /* Updated: 0.5rem ≈ 2.13% of 375px height */
        padding: 0; /* Explicit for clarity */
        font-size: 1.3rem;
        color: #fff;
        font-weight: 600;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    }

    section {
        padding: 4.27vw; /* Updated: 1rem ≈ 4.27% of 375px */
        margin: 0 2.13vw; /* Updated: 0.5rem ≈ 2.13% of 375px */
    }

    .search-bar {
        padding: 0.8rem;
    }

    input, .range-button, button, a, #to-top-button {
        font-size: 0.9rem;
        padding: 0.7rem;
    }

    .range-button {
        padding: 0.5rem 0.8rem;
    }

    .done-button {
        padding: 0.7rem;
        font-size: 0.9rem;
        align-self: flex-end;
    }

    #custom-dates {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end;
    }

    .dropdown-content {
        position: static;
        box-shadow: none;
        border: 1px solid #d1d1d1;
        display: none;
    }

    .dropdown-content.show {
        display: flex;
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 0.5rem;
    }

    td.date-cell {
        padding: 0.5rem;
        line-height: 1.2;
    }

    .date-month, .date-day, .date-year {
        display: block;
        line-height: 1.2;
    }

    #to-top-button {
        bottom: 15px;
        right: 15px;
        padding: 0.5rem 0.8rem;
        font-size: 1rem;
        min-width: 50px;
        height: 36px;
    }

    .results-buttons {
        gap: 0.3rem;
    }

    .results-buttons a, .results-buttons .back-button {
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
    }

    .results-header h2 {
        font-size: 1.3rem;
        text-align: center;
    }

    .results-header h2 .company-name {
        line-height: 1.4;
    }

    .results-header h2 .company-symbol {
        line-height: 1.4;
        border-bottom: 1px solid #d1d1d1;
        padding: 0 1rem 0.2rem 1rem;
        margin: 0 0 0.5rem 0;
        width: calc(100% - 2rem);
    }

    /* Mobile footer styles */
    footer {
        padding: 0.8rem;
    }

    .footer-links {
        font-size: 0.8rem;
        gap: 0.3rem;
    }
}