/* --- UNIVERSAL RESET (Fixes iPhone Overflow) --- */
*, *::before, *::after {
    box-sizing: border-box;
}

/* --- THEME VARIABLES --- */
:root {
    /* DEFAULT: LIGHT MODE */
    --bg-deep: #f0f2f5;
    --bg-surface: #ffffff;
    --bg-input: #e5e7eb;
    --border: #d4d4d8;
    --text-primary: #18181b;
    --text-secondary: #52525b;

    /* ACCENT COLOR: #0052FF (Strictly Enforced) */
    --accent: #0052FF;
    --accent-glow: rgba(0, 82, 255, 0.2);

    --shadow-heavy: rgba(0,0,0,0.15);
    --shadow-soft: rgba(0,0,0,0.1);

    /* FONTS */
    --font-ui: 'Inter', sans-serif;
    --font-data: 'JetBrains Mono', monospace;
}

/* DARK MODE OVERRIDES */
[data-theme="dark"] {
    --bg-deep: #0e0e10;
    --bg-surface: #18181b;
    --bg-input: #27272a;
    --border: #3f3f46;
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;

    /* Dark Mode Accent */
    --accent: #3377FF;
    --accent-glow: rgba(0, 82, 255, 0.4);

    --shadow-heavy: rgba(0,0,0,0.8);
    --shadow-soft: rgba(0,0,0,0.5);
}

body {
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-ui);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow-x: hidden;
}

/* --- BRANDING --- */
.brand-section {
    text-align: center;
    margin-bottom: 25px;
}

.site-name {
    font-family: var(--font-ui);
    font-weight: 800;
    font-size: 4rem;
    color: var(--text-primary);
    margin-bottom: 10px;
    letter-spacing: -2px;
    line-height: 1.1;
    cursor: pointer;
}

.site-name:hover {
    opacity: 0.8;
    transition: opacity 0.2s;
}

.tagline {
    font-family: var(--font-data);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 2px;
    letter-spacing: -0.5px;
    opacity: 1;
}

.sub-tagline {
    font-family: var(--font-ui);
    font-size: 1rem;
    color: var(--text-secondary);
    letter-spacing: 0.2px;
    opacity: 0.8;
}

/* --- THEME SWITCHER --- */
.theme-switch {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
    z-index: 2000;
    overflow: visible;
}

.theme-switch:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.theme-switch:hover .icon {
    transform: rotate(15deg);
    transition: transform 0.2s;
    display: inline-block;
}

.theme-tooltip {
    position: absolute;
    right: 120%;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    background-color: var(--text-primary);
    color: var(--bg-surface);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-family: var(--font-ui);
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
    pointer-events: none;
    box-shadow: 0 4px 15px var(--shadow-heavy);
}

.theme-switch:hover .theme-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

/* --- MOBILE TOOLTIP FIX --- */
/* Completely hides the tooltip on touch devices to prevent sticky text */
@media (hover: none) {
    .theme-tooltip {
        display: none !important;
    }
}

/* --- LAYOUT --- */
.main-container {
    max-width: 1000px;
    margin: 0 auto;
    padding-left: 20px;
    padding-right: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 25vh;
}

/* --- CONTROL BAR --- */
.control-bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 60px;
}

.control-bar {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 6px 15px;
    display: flex;
    align-items: center;
    box-shadow: 0 10px 40px var(--shadow-soft);
    width: 100%;
    max-width: 800px;
    transition: background 0.3s, border 0.3s, box-shadow 0.3s;
}

/* Helper Text Styling */
.search-helper {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    max-width: 800px; /* Increased width to prevent wrapping on laptop */
    opacity: 0.8;
    line-height: 1.4;
    transition: opacity 0.2s;
}

.search-section {
    flex-grow: 1;
    display: flex;
    align-items: center;
    padding-left: 10px;
}

.search-icon {
    width: 18px;
    height: 18px;
    opacity: 0.6;
    margin-right: 8px;
    color: var(--text-secondary);
}

#ticker {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-weight: 500;
    font-size: 1rem;
    width: 100%;
    padding: 10px 0;
    outline: none;
}

#ticker::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.divider {
    width: 1px;
    height: 24px;
    background-color: var(--border);
    margin: 0 15px;
}

.date-trigger {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 10px;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.date-trigger:hover {
    opacity: 0.7;
}

.arrow {
    font-size: 0.7rem;
    margin-left: 5px;
    vertical-align: middle;
}

.go-btn {
    background-color: var(--accent);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding-bottom: 3px;
}

.go-btn:hover {
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translateX(2px);
}

/* --- AUTOCOMPLETE SUGGESTIONS --- */
.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 0 0 12px 12px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 10px 20px var(--shadow-heavy);
    z-index: 1000;
    margin-top: 5px;
}

.suggestion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background-color 0.2s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: var(--bg-input);
}

.sugg-left {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.sugg-symbol {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent);
}

.sugg-name {
    font-family: var(--font-ui);
    font-size: 0.8rem;
    color: var(--text-primary);
    opacity: 0.8;
}

.sugg-right {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-data);
}

/* --- DROPDOWN MENU & INPUTS --- */
.monolith-dropdown {
    position: absolute;
    top: 60px;
    right: 0;
    width: 340px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 20px 50px var(--shadow-heavy);
    z-index: 100;
}

.shortcuts-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.mono-chip {
    width: 23%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 0;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-family: var(--font-ui);
}

.mono-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background-color: var(--bg-input);
}

.date-inputs {
    margin-top: 20px;
}

.date-inputs label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 5px;
    font-weight: 500;
}

/* --- MOBILE INPUT FIX --- */
.date-inputs input {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;

    /* FIX: Force minimum height for touch targets */
    min-height: 45px;

    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 30px;
    margin-bottom: 15px;
    font-family: var(--font-ui);
    color-scheme: light dark;
}

/* --- ACTION ROW --- */
.action-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.action-btn {
    flex: 1;
    padding: 10px;
    border-radius: 20px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: var(--font-data);
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    text-transform: uppercase;
    transition: all 0.2s;
}

.action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background-color: var(--bg-input);
}

/* --- RESULTS CONTAINER --- */
.results-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    width: 100%;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    gap: 20px;
}

h1 {
    font-size: 1.5rem;
    margin: 0;
    font-weight: 800;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    white-space: nowrap;
}

.currency-label {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
    opacity: 0.6;
}

.action-separator {
    color: var(--text-secondary);
    font-size: 0.75rem;
    opacity: 0.4;
}

.download-link {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
    font-size: 0.85rem;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: opacity 0.2s ease;
}

.download-link:hover {
    text-decoration: underline;
    opacity: 0.8;
}

/* --- TABLE --- */
.monolith-table {
    width: 100%;
    border-collapse: collapse;
}

.monolith-table th {
    text-align: left;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 15px;
    border-bottom: 1px solid var(--border);
}

.monolith-table td {
    padding: 15px;
    font-family: var(--font-data);
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s;
}

.monolith-table tbody tr:nth-child(odd) {
    background-color: var(--bg-surface);
}

.monolith-table tbody tr:hover {
    background-color: var(--bg-input);
}

.table-wrapper {
    margin-bottom: 40px;
}

/* --- FOOTER & MISC --- */
.footer-link {
    margin-top: auto;
    padding-top: 15px;
    padding-bottom: 20px;
    text-align: center;
    border-top: none;
    width: 100%;
}

.footer-link a {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    opacity: 0.7;
    transition: all 0.2s;
}

.footer-link a:hover {
    color: var(--accent);
    opacity: 1;
    text-decoration: underline;
}

#scrollTopBtn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--shadow-soft);
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 4px;
}

#scrollTopBtn.show {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

#scrollTopBtn:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translateY(-3px);
}

/* --- PAGES: DISCLAIMER & FEEDBACK --- */
.disclaimer-mode .main-container {
    justify-content: center !important;
    padding-top: 40px !important;
    padding-bottom: 40px !important;
    min-height: 100vh;
}

.disclaimer-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 20px 60px var(--shadow-heavy);
}

.disclaimer-card h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 25px;
    letter-spacing: -0.5px;
}

.disclaimer-alert {
    background-color: var(--bg-input);
    border-left: 4px solid var(--accent);
    padding: 15px 20px;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 35px;
    line-height: 1.5;
}

.disclaimer-alert strong {
    color: var(--text-primary);
}

.disclaimer-card h3 {
    font-family: var(--font-ui);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: 30px;
    margin-bottom: 10px;
}

.disclaimer-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.9rem;
    margin-bottom: 15px;
    opacity: 0.9;
}

.separator-line {
    height: 1px;
    background-color: var(--border);
    margin-top: 40px;
    margin-bottom: 30px;
    opacity: 0.5;
}

.close-link {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 20px;
    font-family: var(--font-data);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
    text-decoration: none;
    background-color: transparent;
    border: 1px solid var(--border);
    text-transform: uppercase;
    transition: all 0.2s;
}

.close-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    background-color: var(--bg-input);
}

.feedback-form {
    margin-top: 20px;
    text-align: left;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    margin-left: 10px;
}

.monolith-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 30px;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.monolith-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea.monolith-input {
    border-radius: 20px;
    resize: vertical;
    min-height: 120px;
}

.send-btn {
    width: 100%;
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 30px;
    font-family: var(--font-data);
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.send-btn:hover {
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-2px);
    opacity: 0.95;
}

.success-banner {
    background-color: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 25px;
    font-weight: 600;
}

/* --- RESULTS MODE --- */
body.results-mode .brand-section {
    position: absolute;
    top: 25px;
    left: 40px;
    text-align: left;
    margin: 0;
}

body.results-mode .site-name {
    font-size: 1.5rem;
    margin-bottom: 0;
}

/* FIX: Hide the helper text when results are shown */
body.results-mode .tagline,
body.results-mode .sub-tagline,
body.results-mode .search-helper {
    display: none;
}

body.results-mode .main-container {
    justify-content: flex-start;
    padding-top: 40px;
    min-height: 100vh;
}

body.results-mode .control-bar-wrapper {
    margin-bottom: 40px;
}

/* --- 404 PAGE STYLES (NEW) --- */
.error-card {
    text-align: center;
    padding: 60px 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 20px 60px var(--shadow-heavy);
    max-width: 500px;
    width: 100%;
}

.error-emoji {
    font-size: 5rem;
    margin-bottom: 20px;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 10px 10px var(--shadow-heavy));
}

.error-code {
    font-size: 6rem;
    font-weight: 800;
    line-height: 1;
    margin: 0;
    color: var(--accent);
    letter-spacing: -3px;
    text-shadow: 0 0 40px var(--accent-glow);
}

.error-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 10px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.error-desc {
    color: var(--text-secondary);
    margin-bottom: 35px;
    font-size: 1rem;
    line-height: 1.5;
}

.primary-btn {
    display: inline-block;
    padding: 12px 30px;
    border-radius: 30px;
    background-color: var(--accent);
    color: white;
    font-family: var(--font-data);
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    text-transform: uppercase;
    transition: all 0.2s;
    box-shadow: 0 5px 20px var(--accent-glow);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent-glow);
    opacity: 0.95;
    color: white;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-12px); }
    100% { transform: translateY(0px); }
}

/* --- MOBILE OPTIMIZATION --- */
@media (max-width: 768px) {
    .site-name { font-size: 2.8rem; }
    .main-container { padding-left: 15px; padding-right: 15px; }

    .control-bar {
        flex-direction: column;
        height: auto;
        padding: 20px;
        border-radius: 20px;
        align-items: stretch;
    }

    .search-section {
        padding-left: 0;
        margin-bottom: 15px;
        border-bottom: 1px solid var(--border);
        padding-bottom: 10px;
    }

    .divider { display: none; }

    .date-section { margin-bottom: 15px; }

    .date-trigger {
        width: 100%;
        text-align: left;
        padding: 10px 0;
        font-size: 1rem;
    }

    .go-btn {
        width: 100%;
        border-radius: 12px;
        height: 50px;
        margin-left: 0;
        font-size: 1.5rem;
    }

    .monolith-dropdown {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90vw;
        max-width: 340px;
        z-index: 3000;
    }

    .header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .monolith-table th, .monolith-table td {
        white-space: nowrap;
        padding: 12px;
    }

    body.results-mode .brand-section {
        position: static;
        text-align: center;
        margin-bottom: 20px;
    }

    body.results-mode .site-name {
        font-size: 2rem;
    }

    body.results-mode .main-container {
        padding-top: 20px;
    }

    /* --- MOBILE SPACER FIX (Recommended Option 1) --- */
    /* Pushes the Disclaimer/Feedback card down 90px so it sits BELOW the Theme Switch */
    .disclaimer-mode .main-container {
        padding-top: 90px !important;
    }
}