@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@100..900&display=swap');
/* @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap'); */
/* @import url('https://fonts.googleapis.com/css2?family=Work+Sans:ital,wght@300;400;500;600;700&display=swap'); */

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

:root {
    /* Dark mode colors */
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #bcbcbc;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    --border-color: #333333;
    --border-color-light: #404040;
    --shadow: rgba(0, 0, 0, 0.4);
    --shadow-hover: rgba(0, 0, 0, 0.6);
    --accent-blue: #0064D2;
    --accent-green: #4ade80;
    --table-header-bg: #333333;
    --table-row-bg: #2a2a2a;
    --table-row-bg-alt: #252525;
}

body {
    font-family: 'Geist Mono', 'Courier New', monospace;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
    /* Prevent horizontal scrolling */
    width: 100%;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    background: var(--bg-secondary);
    overflow-x: hidden;
    /* Prevent horizontal overflow */
    width: 100%;
    transition: background-color 0.3s;
}

/* Home Page */
.home-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    text-align: center;
}

.home-title {
    font-size: 4em;
    font-weight: 700;
    /* font-family: 'Geist Mono', 'Courier New', monospace; */
    color: var(--accent-blue);
    margin: 0;
}

/* Main Header */
.main-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 0;
    margin-bottom: 0;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 4px var(--shadow);
    transition: background-color 0.3s, border-color 0.3s;
}

.header-content {
    max-width: 100%;
    margin: auto;
    padding: 8px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    min-height: 44px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 1.8em;
    font-weight: 700;
    /* font-family: 'Geist Mono', 'Courier New', monospace; */
    color: var(--accent-blue);
    margin: 0;
    white-space: nowrap;
    transition: color 0.3s;
    display: flex;
    align-items: center;
    line-height: 1;
}

.search-box {
    display: flex;
    gap: 15px;
    flex: 1;
    max-width: 800px;
}

.mobile-menu-btn {
    display: none;
}

.header-top-row {
    display: contents;
    /* On desktop, these children just sit in the grid/flex parent */
}

.header-collapsible {
    display: contents;
    /* On desktop, children act as if this wrapper doesn't exist */
}

/* Pill-shaped container for search input */
/* Soft rectangle for search input */
.category-select-container {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    outline: 2.5px solid var(--text-primary);
    outline-offset: -2.5px;
    border-radius: 12px;
    padding: 0 10px;
    height: 44px;
    box-sizing: border-box;
    width: 100%;
}

#categorySelect {
    width: 100%;
    font-size: 15px;
    font-family: inherit;
    background: transparent;
    color: var(--text-primary);
    border: none;
    outline: none;
    cursor: pointer;
    height: 100%;
}

#categorySelect option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.search-input-container {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    /* outline: 1px solid var(--border-color);
    outline-offset: -2.5px; */
    border-radius: 12px;
    padding: 4px;
    transition: background-color 0.3s, outline-color 0.3s;
    height: 44px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
}

.price-range-container {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    background: transparent;
    outline: none;
    border-radius: 0;
    height: auto;
    box-sizing: border-box;
    transition: none;
}

.price-range-container input {
    flex: 1;
    padding: 10px;
    font-size: 14px;
    line-height: 1.2;
    font-family: inherit;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    outline: none;
    height: 44px;
    box-sizing: border-box;
    border-radius: 8px;
    width: 100%;
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.price-range-separator {
    color: var(--text-tertiary);
    font-weight: 600;
}

.price-range-container input::placeholder {
    color: var(--text-tertiary);
}

#searchInput {
    width: 100%;
    padding: 0 20px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.2;
    background: transparent;
    color: var(--text-primary);
    border: none;
    border-radius: 12px;
    outline: none;
    transition: all 0.3s;
    height: 100%;
    box-sizing: border-box;
}

#searchInput:focus {
    background: var(--bg-secondary);
}

#searchInput::placeholder {
    color: var(--text-tertiary);
}

#searchButton {
    padding: 0 60px;
    font-size: 15px;
    line-height: 1.2;
    font-weight: 600;
    font-family: inherit;
    background: #0064D2;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    height: 44px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

#searchButton:hover {
    background: #0052a3;
}

#searchButton:active {
    transform: scale(0.98);
}

#searchButton:disabled {
    background: #ccc;
    color: #666;
    cursor: not-allowed;
    box-shadow: none;
}

.history-btn {
    padding: 0 16px;
    font-family: inherit;
    line-height: 1.2;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    height: 44px;
    min-width: 44px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Filters Button Styling */
.filters-btn {
    padding: 0 20px;
    font-family: inherit;
    line-height: 1.2;
    font-weight: 600;
    font-size: 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    height: 44px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filters-btn:hover {
    background: var(--border-color);
}

.filters-btn svg {
    width: 18px;
    height: 18px;
}

/* Modal Form Styling */
.filters-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-secondary);
}

.category-select-container,
.condition-select-container {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 10px;
    height: 44px;
    display: flex;
    align-items: center;
    outline: none;
    /* Removed header outline style */
}

/* Ensuring Selects take full width in modal */
#categorySelect,
#conditionSelect {
    width: 100%;
    font-size: 15px;
    font-family: inherit;
    background: transparent;
    color: var(--text-primary);
    border: none;
    outline: none;
    height: 100%;
    cursor: pointer;
}

#categorySelect option,
#conditionSelect option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Filter Modal Toggle & Strength Styles */
/* Filter Modal Toggle & Strength Styles */
.mode-toggle-container {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 0;
    gap: 0;
    /* Remove gap so buttons touch */
    height: 44px;
    box-sizing: border-box;
    overflow: hidden;
    /* Ensure corners respect radius */
}

.mode-toggle-container input[type="radio"] {
    display: none;
}

.mode-toggle-container .mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s, color 0.3s;
    font-weight: 400;
    /* Normal weight */
    font-size: 14px;
    color: var(--text-secondary);
    height: 100%;
}

.mode-toggle-container input[type="radio"]:checked+.mode-btn {
    background: var(--text-primary);
    color: var(--bg-secondary);
}

.strength-select-container {
    display: flex;
    gap: 10px;
}

.strength-option {
    flex: 1;
    position: relative;
    height: 44px;
    /* Match inputs */
}

.strength-option input[type="radio"] {
    display: none;
}

.strength-option label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 400;
    /* Normal weight */
    color: var(--text-secondary);
    box-sizing: border-box;
}

.strength-option input[type="radio"]:checked+label {
    background: var(--bg-tertiary);
    border-color: var(--text-primary);
    box-shadow: 0 0 0 1px var(--text-primary);
    font-weight: 400;
    /* Normal weight */
    color: var(--text-primary);
}

.filter-actions-row {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

/* Side-by-Side Filter Layout */
.price-filter-row {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.filter-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mode-col {
    flex: 0 0 220px;
    /* Increased to 220px */
}

.content-col {
    flex: 1;
}

/* Higher specificity to override .filter-group label */
.filter-group .sub-label {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
}

.dynamic-group {
    /* Script sets display: flex, so we ensure column direction */
    display: flex;
    /* Added to ensure initial state matches JS toggle state */
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.apply-filters-btn {
    padding: 0 24px;
    height: 44px;
    background: #0064D2;
    color: white;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.2s;
}

.apply-filters-btn:hover {
    background: #0052a3;
}

/* History Button Container */
.history-button-container {
    background: transparent;
    border: none;
    border-radius: 12px;
    padding: 0;
    height: 44px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
}

.history-btn {
    padding: 0 16px;
    font-family: inherit;
    line-height: 1.2;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    height: 44px;
    min-width: 44px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-btn:hover {
    background: var(--border-color);
}


.history-icon {
    width: 22px;
    height: 22px;
    display: block;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #333;
}

.spinner {
    border: 4px solid #e5e5e5;
    border-top: 4px solid #0064D2;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.error-message {
    background: #ffcdcd;
    color: #000000;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 4px solid #ff0707;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 800;
}

/* Dashboard Section */
.dashboard-section {
    margin-top: 20px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    /* Prevent horizontal overflow */
}

.dashboard-title {
    font-size: 1.8em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: auto auto;
    gap: 20px;
    margin-bottom: 30px;
    min-width: 0;
    /* Prevent grid overflow */
    width: 100%;
}

/* Left Sidebar: Metric Cards */
.left-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    grid-row: 1 / 3;
}

.metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px var(--shadow);
    transition: background-color 0.3s, border-color 0.3s;
}

.metric-label {
    font-size: 0.85em;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-weight: 500;
}

.metric-value {
    font-size: 1.5em;
    font-weight: 700;
    color: #0064D2;
}

/* Top Row: Listings by Price with Info Cards */
.top-row {
    display: grid;
    grid-template-columns: 1fr minmax(200px, 280px);
    gap: 20px;
    grid-column: 2;
    grid-row: 1;
    align-items: start;
    min-width: 0;
    /* Prevent grid overflow */
    width: 100%;
}

.chart-panel.dot-plot {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    /* Prevent overflow */
    /* Match info card height: padding (32px) + title (~27px) + square content (248px) = ~307px */
    height: 307px;
}

.chart-panel.dot-plot .chart-title {
    flex-shrink: 0;
    margin-bottom: 4px;
}

.chart-panel.dot-plot .chart-subtitle {
    flex-shrink: 0;
    margin-bottom: 16px;
}

.chart-panel.dot-plot .chart-placeholder {
    flex: 1;
    min-height: 0;
}

/* Main Content: Chart Panels (2x2 grid) */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    /* Prevent grid overflow */
    width: 100%;
}

.chart-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px var(--shadow);
    min-width: 0;
    /* Prevent grid overflow */
    max-width: 100%;
    /* Prevent expansion beyond container */
    overflow: hidden;
    /* Prevent content from spilling */
    width: 100%;
    box-sizing: border-box;
    transition: background-color 0.3s, border-color 0.3s;
    display: flex;
    flex-direction: column;
}

.chart-panel.large {
    height: 400px;
    max-height: 400px;
    display: flex;
    flex-direction: column;
}

.chart-panel.large .chart-placeholder {
    flex: 1;
    min-height: 0;
    height: auto;
    max-height: none;
}

.chart-title {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    flex-shrink: 0;
}

.chart-subtitle {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 16px;
    flex-shrink: 0;
}

.chart-placeholder {
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color-light);
    border-radius: 4px;
    padding: 10px;
    text-align: center;
    height: 320px;
    max-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    /* Prevent overflow */
    max-width: 100%;
    /* Constrain to parent */
    overflow: hidden;
    /* Prevent content spill */
    width: 100%;
    box-sizing: border-box;
    transition: background-color 0.3s, border-color 0.3s;
}

/* Constrain canvas elements within chart placeholders */
.chart-placeholder canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    height: 100% !important;
    box-sizing: border-box;
    object-fit: contain;
}

.placeholder-content {
    color: #999;
    font-size: 0.9em;
}

.info-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px var(--shadow);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 280px;
    min-width: 0;
    /* Prevent overflow */
    /* Height: padding (32px) + title (~27px) + square content (248px) = 307px */
    height: 307px;
    transition: background-color 0.3s, border-color 0.3s;
}

.info-card-title {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    flex-shrink: 0;
}

.info-card-content {
    width: 100%;
    /* Square content: calculate based on available width (card width - padding) */
    /* aspect-ratio: 1; REMOVED to prevent overflow */
    flex: 1;
    /* Take remaining height */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    /* Ensure minimum size for readability */
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    max-height: 100%;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.info-card-content canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    height: 100% !important;
    box-sizing: border-box;
    object-fit: contain;
}

/* Modal for Search History */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s;
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
}

.modal-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.clear-history-btn,
.close-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 5px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.clear-history-btn svg,
.close-btn svg {
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.clear-history-btn:hover {
    background: var(--bg-tertiary);
    color: #ff4444;
}

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

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    padding: 15px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    border-left: 4px solid #0064D2;
}

.history-item:hover {
    background: var(--border-color);
    transform: translateX(5px);
}

.history-item-text {
    font-weight: 500;
    color: var(--text-primary);
}

.history-item-range {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-top: 4px;
}

.history-item-date {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-top: 5px;
}

.no-history {
    text-align: center;
    color: #999;
    padding: 40px;
}

.results-section {
    margin-top: 30px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.results-section h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5em;
    font-weight: 600;
}

.download-btn {
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    background: #0064D2;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s;
}

.download-btn:hover {
    background: #0052a3;
}

#resultsTableContainer {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 575px;
    /* Shows approximately 7 rows (header + 7 data rows) */
    border-radius: 8px;
}

/* Custom scrollbar styling for table container */
#resultsTableContainer::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#resultsTableContainer::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

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

#resultsTableContainer::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

#resultsTable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-tertiary);
    box-shadow: 0 1px 3px var(--shadow);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s, border-color 0.3s;
}

#resultsTable thead {
    background: var(--table-header-bg);
    color: var(--text-primary);
}

#resultsTable th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: -1px;
    z-index: 100;
    background: var(--table-header-bg) !important;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
}

#resultsTable tbody tr {
    background: var(--table-row-bg);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

#resultsTable tbody tr:nth-child(even) {
    background: var(--table-row-bg-alt);
}

#resultsTable tbody tr:hover {
    background: var(--border-color);
}

#resultsTable tbody tr:last-child {
    border-bottom: none;
}

#resultsTable td {
    padding: 15px;
    font-size: 14px;
    color: var(--text-primary);
}

#resultsTable td:nth-child(2) {
    font-weight: 600;
    color: var(--accent-blue);
    text-align: center;
    width: 50px;
}

#resultsTable td:nth-child(3) {
    font-weight: 500;
    max-width: 400px;
    color: var(--text-primary);
}

#resultsTable td:nth-child(4) {
    font-weight: 600;
    color: var(--accent-blue);
    font-size: 16px;
}

#resultsTable td:nth-child(5) {
    color: var(--text-secondary);
    font-size: 13px;
}

#resultsTable td:nth-child(6) a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

#resultsTable td:nth-child(6) a:hover {
    color: #0052a3;
    text-decoration: underline;
}

.unselectable-text {
    /* Standard property (supported by most modern browsers) */
    user-select: none;

    /* Vendor prefixes for broader compatibility */
    -webkit-touch-callout: none;
    /* iOS Safari */
    -webkit-user-select: none;
    /* Safari, Chrome, Opera */
    -khtml-user-select: none;
    /* Konqueror HTML */
    -moz-user-select: none;
    /* Firefox */
    -ms-user-select: none;
    /* Internet Explorer/Edge */
}

/* Medium screens: Adjust layout for fixed-width cards */
@media (max-width: 1200px) and (min-width: 901px) {
    .dashboard-layout {
        grid-template-columns: 180px 1fr;
        width: 100%;
    }

    .top-row {
        grid-template-columns: 1fr;
        gap: 20px;
        width: 100%;
    }

    .info-card {
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
    }

    .info-card-content {
        height: auto;
        aspect-ratio: 1;
    }

    .chart-panel.dot-plot {
        height: auto;
        min-height: 307px;
        width: 100%;
        max-width: 100%;
    }

    .main-content {
        width: 100%;
    }

    .chart-panel {
        width: 100%;
        max-width: 100%;
    }
}

/* Tablet screens: Further adjustments */
@media (max-width: 900px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .left-sidebar {
        grid-row: auto;
        width: 100%;
    }

    .top-row {
        grid-column: 1;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .main-content {
        grid-column: 1;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .chart-panel {
        width: 100%;
        max-width: 100%;
    }

    .chart-placeholder {
        width: 100%;
        max-width: 100%;
    }
}

/* Small screens: Stack everything */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
    }

    .header-top-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .mobile-menu-btn {
        display: block;
        background: none;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        padding: 5px;
    }

    .header-collapsible {
        display: none;
        flex-direction: column;
        gap: 15px;
        width: 100%;
        padding-top: 15px;
        border-top: 1px solid var(--border-color);
        margin-top: 10px;
    }

    .header-collapsible.expanded {
        display: flex;
    }

    .logo {
        text-align: left;
        margin-bottom: 0;
    }

    .search-box {
        flex-direction: row;
        flex-wrap: wrap;
        max-width: 100%;
        gap: 10px;
    }

    .search-input-container {
        width: 100%;
        flex: none;
    }

    #searchButton {
        width: calc(50% - 5px);
        flex: none;
    }

    .filters-btn {
        width: calc(50% - 5px);
        flex: none;
    }

    .header-actions {
        width: 100%;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        gap: 10px;
    }

    .history-button-container {
        flex: 1;
        width: auto;
    }

    .theme-toggle-btn {
        flex: none;
        width: 44px;
    }

    #searchInput,
    .history-btn {
        width: 100%;
    }

    .dashboard-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        width: 100%;
    }

    .left-sidebar {
        grid-row: auto;
        order: 1;
        /* Metrics first */
        width: 100%;
    }

    .top-row {
        grid-column: 1;
        grid-row: auto;
        grid-template-columns: 1fr;
        order: 2;
        /* Charts after metrics */
        width: 100%;
    }

    .info-card {
        width: 70%;
        /* "sized down by like 30%" */
        max-width: 100%;
        margin: 0 auto;
        /* Center it */
        height: auto;
        min-height: 215px;
        /* ~30% less than 307px */
    }

    .info-card-content {
        height: auto;
        min-height: 174px;
        /* ~30% less than 248px */
        aspect-ratio: 1;
        width: 100%;
        max-width: 100%;
    }

    .chart-panel.dot-plot {
        height: auto;
        min-height: 307px;
        width: 100%;
        max-width: 100%;
    }

    .main-content {
        grid-column: 1;
        grid-row: auto;
        order: 3;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .chart-panel {
        width: 100%;
        max-width: 100%;
    }

    .chart-placeholder {
        width: 100%;
        max-width: 100%;
    }

    .chart-placeholder {
        min-height: 200px;
        padding: 30px;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
    }

    #resultsTable {
        font-size: 12px;
    }

    #resultsTable th,
    #resultsTable td {
        padding: 10px 8px;
    }
}