html {
    background-color: #0b0b10;
    height: 100%;
    overscroll-behavior: none;
}

body {
    color: #e4e4e7;
    font-family:
        "Inter",
        system-ui,
        -apple-system,
        Segoe UI,
        Roboto,
        Ubuntu,
        Cantarell,
        "Helvetica Neue",
        Arial,
        sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    overscroll-behavior: none;
}

/* Fixed gradient background to avoid flicker/white during overscroll */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: radial-gradient(
        1200px 800px at 10% -10%,
        #1f2937 0%,
        #0f172a 40%,
        #0b0b10 100%
    );
    background-attachment: fixed;
}

.container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 24px;
    background: linear-gradient(
        180deg,
        rgba(39, 39, 42, 0.85),
        rgba(24, 24, 27, 0.85)
    );
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    border: 1px solid #2f2f35;
    backdrop-filter: blur(6px);
}

h1 {
    font-size: 2.1rem;
    font-weight: 800;
    margin-bottom: 1.2rem;
    color: #fafafa;
    letter-spacing: -0.02em;
}

label {
    display: block;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: #a1a1aa;
}

input[type="file"] {
    background: #27272a;
    color: #e4e4e7;
    border: 1px solid #3f3f46;
    border-radius: 6px;
    padding: 8px;
    font-size: 1rem;
    margin-bottom: 2rem;
}

#filter-panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 2rem;
    background: linear-gradient(
        180deg,
        rgba(24, 24, 27, 0.85),
        rgba(17, 17, 20, 0.85)
    );
    border-radius: 12px;
    padding: 18px 16px 8px 16px;
    border: 1px solid #2b2b30;
}

#filter-panel-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #fafafa;
    margin-bottom: 0.5em;
    margin-top: 0;
    letter-spacing: 0.5px;
}

.filter-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    width: 100%;
}

.filter-dropdowns {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    min-width: 180px;
    max-width: 420px;
}

.filter-sliders {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    min-width: 180px;
    max-width: 350px;
}

#filter-panel label {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: #a1a1aa;
    display: block;
}

#filter-panel select,
#filter-panel input[type="range"] {
    background: #27272a;
    color: #e4e4e7;
    border: 1px solid #3f3f46;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    width: 100%;
}

/* Unify range slider accent color */
#filter-panel input[type="range"] {
    accent-color: #34d399;
    height: 4px;
}

/* Checkbox list styling */
.checkbox-group {
    position: relative;
    border: 1px solid #2b2b30;
    border-radius: 10px;
    padding: 18px 12px 10px 12px;
    margin-bottom: 12px;
    background: transparent;
}

.checkbox-group > label {
    position: absolute;
    top: -10px;
    left: 12px;
    padding: 0 6px;
    background: #18181b;
    color: #e4e4e7;
    font-weight: 600;
    font-size: 0.98rem;
    margin: 0 !important;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checkbox-list-damage {
    max-height: 240px;
    overflow: auto;
    padding-right: 4px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #34d399;
}

.checkbox-item label {
    margin: 0 !important;
    color: #e4e4e7 !important;
}

.checkbox-list.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.slider-group {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.98em;
    color: #a1a1aa;
    margin-bottom: 0.2em;
}

#chart-container {
    background: #18181b;
    border-radius: 12px;
    padding: 24px 16px 8px 16px;
    margin-bottom: 2rem;
    border: 1px solid #2b2b30;
}

#sort-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 1.5rem;
    margin-top: 0.5rem;
}

#sort-panel label {
    margin-bottom: 0rem;
    font-size: 1rem;
    color: #a1a1aa;
    display: block;
}

#sort-panel select {
    background: #27272a;
    color: #e4e4e7;
    border: 1px solid #3f3f46;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 1rem;
    margin-bottom: 0rem;
}

#sort-panel button {
    background: #34d399;
    color: #18181b;
    border: none;
    border-radius: 6px;
    padding: 7px 18px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-left: 2rem;
}

#sort-panel button:hover {
    background: #10b981;
    color: #fff;
}

#car-list {
    background: #18181b;
    border-radius: 12px;
    padding: 16px;
    min-height: 60px;
    border: 1px solid #2b2b30;
}

.car-item {
    display: flex;
    align-items: flex-start;
    gap: 36px;
    padding: 32px 16px;
    margin-left: -16px;
    margin-right: -16px;
    border-bottom: 1px solid #3f3f46;
    cursor: pointer;
    min-height: 170px;
    transition: background 0.15s;
    position: relative; /* to anchor chip */
}

.car-item:last-child {
    border-bottom: none;
}

.car-item:hover {
    background: #232329;
}

.car-img {
    width: 200px;
    height: 150px;
    object-fit: cover;
    border-radius: 12px;
    background: #27272a;
    flex-shrink: 0;
    border: 1px solid #3f3f46;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    margin-right: 12px;
    display: block;
}

.car-details {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 40px;
    align-items: center;
    font-size: 1.12rem;
    word-break: break-word;
}

.car-value {
    color: #e4e4e7;
    font-weight: 500;
    font-size: 1.12em;
    word-break: break-all;
}

.car-price {
    font-size: 1.25em;
    font-weight: 600;
}

.car-vin {
    font-family: monospace;
    font-size: 1em;
    background: #27272a;
    padding: 2px 8px;
    border-radius: 6px;
    letter-spacing: 1px;
    display: inline-block;
}

.hint {
    color: #a1a1aa;
    font-size: 1.08em;
    margin-bottom: 1.5em;
    margin-top: 0.5em;
    text-align: center;
}

/* Minimal scrollbar for dark mode */
::-webkit-scrollbar {
    width: 8px;
    background: #27272a;
}

::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 8px;
}

/* Help section styles */
.help-section {
    background: #18181b;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid #2b2b30;
}

.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 12px;
}

.help-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fafafa;
    margin: 0;
}

.help-toggle {
    font-size: 1.2rem;
    color: #a1a1aa;
    transition: transform 0.2s;
}

.help-toggle.expanded {
    transform: rotate(180deg);
}

.help-content {
    padding: 0 20px 20px 20px;
    display: none;
}

.help-content.expanded {
    display: block;
}

.help-step {
    margin-bottom: 1.5rem;
    color: #e4e4e7;
    line-height: 1.6;
}

.help-step:last-child {
    margin-bottom: 0;
}

.bookmarklet-container {
    position: relative;
    margin: 12px 0;
}

.bookmarklet-code {
    background: #27272a;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    padding: 12px 50px 12px 12px;
    font-family: "Courier New", monospace;
    font-size: 0.9rem;
    color: #34d399;
    word-break: break-all;
    line-height: 1.4;
    overflow-x: auto;
}

.copy-button {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #34d399;
    color: #18181b;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.copy-button:hover {
    background: #10b981;
    color: #fff;
}

.copy-button.copied {
    background: #10b981;
    color: #fff;
}

.help-content a {
    color: #34d399;
    text-decoration: none;
    transition: color 0.15s;
}

.help-content a:hover {
    color: #10b981;
    text-decoration: underline;
}

.help-content a:visited {
    color: #34d399;
    text-decoration: none;
}

.help-content a:visited:hover {
    color: #10b981;
    text-decoration: underline;
}

.price-toolbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.price-toolbar-card {
    background: #27272a;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.25);
    padding: 18px 32px 14px 32px;
    display: flex;
    align-items: center;
    gap: 24px;
    min-width: 320px;
    max-width: 600px;
    width: 100%;
    pointer-events: auto;
}

.price-toolbar-value {
    color: #a1a1aa;
    font-size: 1.1em;
    min-width: 80px;
    text-align: center;
    font-family: "Inter", system-ui, sans-serif;
}

.price-toolbar-slider-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

#price-toolbar-slider {
    width: 100%;
    accent-color: #34d399;
    height: 4px;
    margin: 0 0;
}

.price-toolbar-tooltip {
    position: absolute;
    left: 0;
    top: -38px;
    transform: translateX(-50%);
    background: #18181b;
    color: #fafafa;
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 1.05em;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.2s;
    opacity: 0.95;
    z-index: 10;
}

.graphs-section {
    background: #18181b;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid #3f3f46;
    margin-top: 2rem;
}

.graphs-header {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 16px 20px;
    border-radius: 12px 12px 0 0;
    transition: background 0.15s;
    user-select: none;
}

.graphs-header:hover {
    background: #232329;
}

.graphs-content {
    padding: 0 20px 20px 20px;
}

.graphs-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 1.2em;
}

.graphs-tab {
    background: #27272a;
    color: #e4e4e7;
    border: 1px solid #3f3f46;
    border-radius: 8px 8px 0 0;
    padding: 8px 18px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s;
    outline: none;
}

.graphs-tab-active {
    background: #34d399;
    color: #18181b;
    font-weight: 700;
    border-bottom: 2px solid #34d399;
}

.graphs-tab-content {
    display: none;
}

.graphs-tab-content[style*="display:block"] {
    display: block;
}

.histogram-controls {
    margin-bottom: 10px;
    color: #a1a1aa;
    user-select: none;
}

.histogram-controls input[type="checkbox"] {
    accent-color: #34d399;
    margin-right: 6px;
}

.scatter-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin: 12px 0 0 0;
    align-items: center;
    font-size: 1.02em;
}

.scatter-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-right: 18px;
}

.scatter-legend-color {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #232329;
    display: inline-block;
}

.scatter-legend-shape {
    width: 18px;
    height: 18px;
    display: inline-block;
    vertical-align: middle;
}

/* --- Calculator button on card --- */
.calc-btn {
    margin-left: auto;
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #34d399;
    color: #18181b;
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.98rem;
    font-weight: 700;
    cursor: pointer;
    transition:
        background 0.15s,
        transform 0.05s;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}

.calc-btn:hover {
    background: #10b981;
    color: #fff;
}

.calc-btn:active {
    transform: translateY(1px);
}

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

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    display: none;
    z-index: 2000;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 2001;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.modal.show,
.modal-overlay.show {
    display: flex;
}

.modal-card {
    background: #18181b;
    border: 1px solid #2b2b30;
    border-radius: 14px;
    max-width: 840px;
    width: 100%;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

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

.modal-title {
    font-weight: 700;
    color: #fafafa;
    margin: 0;
}

.modal-close {
    background: transparent;
    border: 1px solid #3f3f46;
    color: #e4e4e7;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

.modal-body {
    padding: 16px 18px 18px 18px;
    max-height: 75vh;
    overflow: auto;
}

.modal-section {
    background: #111113;
    border: 1px solid #2b2b30;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
}

.modal-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-field label {
    color: #a1a1aa;
    font-size: 0.96rem;
    margin: 0;
}

.modal-field select,
.modal-field input {
    background: #27272a;
    color: #e4e4e7;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 1rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 12px;
}

.btn-primary {
    background: #34d399;
    color: #18181b;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary:hover {
    background: #10b981;
    color: #fff;
}

.btn-ghost {
    background: transparent;
    border: 1px solid #3f3f46;
    color: #e4e4e7;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
}

/* --- Receipt --- */
.receipt {
    background: #111113;
    border: 1px solid #2b2b30;
    border-radius: 12px;
    padding: 14px;
}

.receipt-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.receipt-title {
    font-weight: 700;
    color: #fafafa;
}

.receipt-subtle {
    color: #a1a1aa;
    font-size: 0.92rem;
}

.receipt-port {
    margin-top: 14px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #2b2b30;
    background: #0f0f12;
}

.receipt-port h4 {
    margin: 0 0 8px 0;
    color: #e4e4e7;
    font-weight: 700;
}

.receipt-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0 14px 0;
    table-layout: fixed;
}

.receipt-table th,
.receipt-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #232329;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.receipt-table th:first-child,
.receipt-table td:first-child {
    text-align: left;
    color: #e4e4e7;
}

.receipt-table col.col-label {
    width: 48%;
}

.receipt-table col.col-usd,
.receipt-table col.col-lps {
    width: 26%;
}

.receipt-total {
    font-weight: 800;
    color: #fafafa;
}

/* Port selector */
.port-chooser {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0 12px 0;
}

.port-chooser select {
    background: #27272a;
    color: #e4e4e7;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 1rem;
}

/* --- Print button (top-right of Graphs header) --- */
.print-btn {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #34d399;
    color: #18181b;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.print-btn:hover {
    background: #10b981;
    color: #fff;
}

.print-btn svg {
    width: 16px;
    height: 16px;
}

/* --- Car selection chip on each card --- */
.report-chip {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #27272a;
    color: #e4e4e7;
    border: 1px solid #3f3f46;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
}

.report-chip.selected {
    background: #34d399;
    color: #18181b;
    border-color: #34d399;
    font-weight: 800;
}

/* Floating Print FAB */
.fab-print {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1200;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #34d399;
    color: #18181b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    border: none;
    transition:
        transform 0.1s,
        background 0.15s;
}

.fab-print:hover {
    background: #10b981;
    color: #fff;
}

.fab-print:active {
    transform: translateY(1px);
}

.fab-print svg {
    width: 24px;
    height: 24px;
}

.fab-print-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: #fff;
    font-weight: 800;
    font-size: 11px;
    border-radius: 999px;
    padding: 2px 6px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

/* --- Printable report container --- */
#print-root {
    display: none;
    background: #fff;
    color: #000;
    font-family:
        Inter,
        system-ui,
        -apple-system,
        Segoe UI,
        Roboto,
        Ubuntu,
        Cantarell,
        "Helvetica Neue",
        Arial,
        sans-serif;
}

.print-page {
    page-break-after: always;
    padding: 16px;
    font-size: 12.5px;
}

.print-h1 {
    font-size: 18px;
    font-weight: 800;
    margin: 0 0 6px 0;
}

.print-subtle {
    color: #555;
    font-size: 11px;
}

.print-section-title {
    font-weight: 800;
    margin: 12px 0 6px 0;
    font-size: 13px;
}

.print-two-col {
    display: grid;
    grid-template-columns: 1fr; /* one graph per row/column */
    gap: 14px;
}

.print-chart {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 6px;
    max-height: 460px; /* larger physical size on the printed page */
    object-fit: contain;
}

@media print {
    /* Slightly increase contrast/saturation for printed charts */
    .print-chart {
        filter: brightness(0.95) contrast(1.2) saturate(1.08);
    }
}

.print-receipt {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
}

.print-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.print-table col.col-label {
    width: 48%;
}

.print-table col.col-usd,
.print-table col.col-lps {
    width: 26%;
}

.print-table th,
.print-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #eee;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.print-table td:first-child,
.print-table th:first-child {
    text-align: left;
}

.print-total {
    font-weight: 800;
}

.print-car-img {
    max-height: 160px;
    width: auto;
    border: 1px solid #ddd;
    border-radius: 6px;
}

/* Responsive Design */
@media (max-width: 900px) {
    .container {
        padding: 8px;
    }
    #filter-panel {
        padding: 12px 6px 4px 6px;
    }
    .filter-content {
        grid-template-columns: 1fr;
        gap: 18px;
    }
    .car-item {
        flex-direction: column;
        align-items: stretch;
        min-height: 0;
        gap: 12px;
    }
    .car-img {
        width: 100%;
        height: 180px;
        margin-right: 0;
    }
    .car-details {
        grid-template-columns: 1fr;
        gap: 10px 0;
    }
    .filter-dropdowns,
    .filter-sliders {
        min-width: 0;
        width: 100%;
    }
    #sort-panel {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .help-header {
        padding: 12px 16px;
    }
    .help-content {
        padding: 0 16px 16px 16px;
    }
    .bookmarklet-code {
        padding: 10px 45px 10px 10px;
        font-size: 0.8rem;
    }
    .copy-button {
        top: 6px;
        right: 6px;
        padding: 4px 8px;
        font-size: 0.8rem;
    }
    .modal-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .price-toolbar-card {
        padding: 10px 8px 8px 8px;
        min-width: 0;
        max-width: 100vw;
        gap: 10px;
    }
    .price-toolbar-value {
        min-width: 40px;
        font-size: 0.95em;
    }
    .price-toolbar-tooltip {
        font-size: 0.95em;
        padding: 4px 10px;
    }
}

@media print {
    html,
    body {
        background: #fff !important;
    }
    body > *:not(#print-root) {
        display: none !important;
    }
    #print-root {
        display: block !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .fab-print {
        display: none !important;
    }
}
