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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #000000;
    min-height: 100vh;
    padding: 20px;
    color: #e0e0e0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: #1a1a1a;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    border: 1px solid #2a2a2a;
}

header {
    background: #0a0a0a;
    color: #e0e0e0;
    padding: 30px;
    border-bottom: 2px solid #2a2a2a;
}

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

.header-title-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}

header h1 {
    font-size: 2.5em;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    text-align: left;
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-shrink: 0;
}

.back-link {
    color: #e0e0e0 !important;
    text-decoration: none !important;
    font-size: 0.9em !important;
    transition: all 0.3s ease;
    padding: 8px 16px !important;
    border-radius: 6px;
    border: 1px solid #4a4a4a !important;
    background: #2a2a2a !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-top: 8px;
}

.back-link:hover {
    color: #ffffff !important;
    background: #3a3a3a !important;
    border-color: #5a5a5a !important;
    transform: translateY(-2px);
}


.filters-panel, .pivot-panel {
    padding: 25px;
    background: #1a1a1a;
    border-bottom: 2px solid #2a2a2a;
}

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

.filters-header h2 {
    margin: 0;
    color: #ffffff;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
}

.filter-selector {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.filter-selector h3 {
    color: #ffffff;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.filter-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.filter-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

.filter-checkbox-item label {
    color: #e0e0e0;
    cursor: pointer;
    user-select: none;
}

.filter-checkbox-item label:hover {
    color: #ffffff;
}

/* Multi-select filter checkboxes */
.filter-checkbox-container {
    background: #0a0a0a;
    border: 2px solid #2a2a2a;
    border-radius: 6px;
    padding: 10px;
    margin-top: 8px;
}

.filter-checkbox-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #2a2a2a;
}

.filter-checkbox-scroll {
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 5px;
}

.filter-checkbox-scroll::-webkit-scrollbar {
    width: 8px;
}

.filter-checkbox-scroll::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 4px;
}

.filter-checkbox-scroll::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 4px;
}

.filter-checkbox-scroll::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

/* Numeric filter sliders */
.filter-slider-container {
    background: #0a0a0a;
    border: 2px solid #2a2a2a;
    border-radius: 6px;
    padding: 15px;
    margin-top: 8px;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.slider-group:last-child {
    margin-bottom: 0;
}

.slider-group label {
    min-width: 40px;
    font-size: 0.9em;
    color: #b0b0b0;
}

.filter-slider-container .slider {
    flex: 1;
    height: 6px;
    background: #2a2a2a;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.filter-slider-container .slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
}

.filter-slider-container .slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.slider-value {
    min-width: 60px;
    text-align: right;
    color: #e0e0e0;
    font-weight: 600;
    font-size: 0.9em;
}

.table-column-selector {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 25px;
}

.table-column-selector h3 {
    color: #ffffff;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.table-column-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.table-thumbnail {
    width: 100px;
    height: 100px;
    height: auto;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #3a3a3a;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.table-thumbnail:hover {
    transform: scale(1.5);
    z-index: 10;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
}

.filters-panel h2, .pivot-panel h2 {
    margin-bottom: 20px;
    color: #e0e0e0;
    font-size: 1.5em;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

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

.filter-group label {
    font-weight: 600;
    color: #b0b0b0;
    font-size: 0.9em;
}

.input, .select {
    padding: 10px 15px;
    border: 2px solid #3a3a3a;
    border-radius: 6px;
    font-size: 1em;
    transition: all 0.3s ease;
    background: #0a0a0a;
    color: #e0e0e0;
}

.input:focus, .select:focus {
    outline: none;
    border-color: #555555;
    box-shadow: 0 0 0 3px rgba(85, 85, 85, 0.2);
    background: #121212;
}

.input::placeholder {
    color: #666666;
}

.filter-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
}

.btn-primary:hover {
    transform: translateY(-2px);
    background: #3a3a3a;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    border-color: #4a4a4a;
}

.btn-secondary {
    background: #1a1a1a;
    color: #b0b0b0;
    border: 1px solid #3a3a3a;
}

.btn-secondary:hover {
    background: #2a2a2a;
    color: #e0e0e0;
    transform: translateY(-2px);
    border-color: #4a4a4a;
}

.results {
    padding: 30px;
    min-height: 400px;
    background: #0a0a0a;
}

.loading {
    text-align: center;
    padding: 40px;
    font-size: 1.2em;
    color: #666666;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
}

.card-view-controls {
    padding: 20px 25px;
    background: #1a1a1a;
    border-bottom: 2px solid #2a2a2a;
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.card-view-controls .control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-view-controls label {
    color: #e0e0e0;
    font-weight: 600;
    font-size: 0.9em;
}

.card-view-controls .slider {
    width: 150px;
    height: 6px;
    background: #2a2a2a;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.card-view-controls .slider {
    appearance: none;
}

.card-view-controls .slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
}

.card-view-controls .slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.card-view-controls #cardSizeValue {
    color: #b0b0b0;
    font-weight: 600;
    min-width: 50px;
}

.toy-card {
    background: #1a1a1a;
    border: 2px solid #2a2a2a;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.toy-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.8);
    border-color: #4a4a4a;
    background: #222222;
}

.toy-card .toy-id {
    font-size: 0.85em;
    color: #888888;
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.toy-card h3 {
    color: #ffffff;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid #2a2a2a;
    padding-bottom: 10px;
}

.toy-card .maker {
    font-weight: 600;
    color: #b0b0b0;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.toy-card .maker-link {
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s ease;
}

.toy-card .maker-link:hover {
    color: #ffffff;
    text-decoration: underline;
}

.data-table .maker-link {
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s ease;
}

.data-table .maker-link:hover {
    color: #ffffff;
    text-decoration: underline;
}

.toy-card .type {
    display: inline-block;
    background: #2a2a2a;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    margin-bottom: 15px;
    color: #b0b0b0;
    border: 1px solid #3a3a3a;
}

.toy-card .description {
    color: #999999;
    margin-bottom: 15px;
    line-height: 1.6;
}

.toy-card .details {
    display: grid;
    gap: 10px;
    margin-top: 15px;
}

.toy-card .detail-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #2a2a2a;
}

.toy-card .detail-label {
    font-weight: 600;
    color: #b0b0b0;
}

.toy-card .detail-value {
    color: #999999;
    text-align: right;
}

.toy-card .length-display {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.9em;
}

.toy-card .notes, .toy-card .usage {
    margin-top: 15px;
    padding: 12px;
    background: #0a0a0a;
    border-radius: 6px;
    border-left: 4px solid #3a3a3a;
    font-size: 0.9em;
    line-height: 1.6;
    color: #b0b0b0;
}

.toy-card .collapsible {
    cursor: pointer;
}

.toy-card .collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    user-select: none;
    padding: 4px 0;
}

.toy-card .collapsible-header:hover {
    color: #e0e0e0;
}

.toy-card .collapsible-header:hover .toggle-icon {
    color: #999999;
}

.toy-card .toggle-icon {
    font-size: 0.8em;
    color: #666666;
    transition: transform 0.3s ease;
    margin-left: 8px;
}

.toy-card .collapsible-preview {
    color: #999999;
    font-style: italic;
    line-height: 1.5;
    margin-bottom: 8px;
    padding: 4px 0;
}

.toy-card .collapsible-content {
    color: #b0b0b0;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 4px 0;
}

.toy-card .image-container {
    width: 100%;
    margin-bottom: 15px;
    border-radius: 6px;
    overflow: hidden;
    background: #0a0a0a;
}

.toy-card .toy-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}

.toy-card .image-placeholder {
    width: 100%;
    height: 200px;
    background: #0a0a0a;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666666;
    margin-bottom: 15px;
    font-size: 0.9em;
    border: 1px dashed #2a2a2a;
}

.pivot-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    border: 1px solid #2a2a2a;
}

.pivot-table th {
    background: #0a0a0a;
    color: #e0e0e0;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #2a2a2a;
}

.pivot-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #2a2a2a;
    color: #b0b0b0;
}

.pivot-table tr:hover {
    background: #222222;
}

.pivot-table tr:last-child td {
    border-bottom: none;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #666666;
}

.no-results h3 {
    font-size: 1.5em;
    margin-bottom: 10px;
    color: #b0b0b0;
}

select option {
    background: #1a1a1a;
    color: #e0e0e0;
}

.table-container {
    overflow-x: auto;
    margin-top: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #2a2a2a;
}

.data-table thead {
    background: #0a0a0a;
}

.data-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #e0e0e0;
    border-bottom: 2px solid #2a2a2a;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.data-table th.sortable:hover {
    background: #222222;
}

.data-table th .sort-indicator {
    color: #666666;
    margin-left: 5px;
    font-size: 0.8em;
}

.data-table tbody tr {
    border-bottom: 1px solid #2a2a2a;
    transition: background 0.2s ease;
}

.data-table tbody tr:hover {
    background: #222222;
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table td {
    padding: 12px 15px;
    color: #b0b0b0;
    vertical-align: top;
}

.data-table td strong {
    color: #ffffff;
}

.data-table .notes-cell {
    max-width: 300px;
    font-size: 0.9em;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    overflow-y: auto;
}

.modal-content {
    background-color: #1a1a1a;
    margin: 50px auto;
    padding: 0;
    border: 2px solid #2a2a2a;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
}

.modal-header {
    background: #0a0a0a;
    padding: 20px 30px;
    border-bottom: 2px solid #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: #ffffff;
    margin: 0;
    font-size: 1.5em;
}

.modal-close {
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 2em;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: #2a2a2a;
    color: #ffffff;
}

.modal-body {
    padding: 30px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

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

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 600;
    color: #b0b0b0;
    font-size: 0.9em;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 2px solid #2a2a2a;
}

.btn-danger {
    background: #8b0000;
    color: white;
    border: 1px solid #a00000;
}

.btn-danger:hover {
    background: #a00000;
    transform: translateY(-2px);
}

/* Image Selector Styles */
.image-selector {
    width: 100%;
}

.image-preview-container {
    margin: 15px 0;
}

.current-image-preview {
    width: 100%;
    max-width: 300px;
    height: 200px;
    background: #0a0a0a;
    border: 2px solid #2a2a2a;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 15px;
}

.current-image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.current-image-preview .no-image {
    color: #666666;
    font-size: 0.9em;
}

.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background: #0a0a0a;
    border: 2px solid #2a2a2a;
    border-radius: 6px;
    margin-top: 10px;
    display: none;
}

.image-gallery.show {
    display: grid;
}

.image-gallery-item {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #1a1a1a;
    border: 2px solid #2a2a2a;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.image-gallery-item:hover {
    border-color: #4a4a4a;
    transform: scale(1.05);
}

.image-gallery-item.selected {
    border-color: #667eea;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

.image-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-gallery-item .image-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: #e0e0e0;
    font-size: 0.7em;
    padding: 4px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toy-card .edit-btn {
    margin-top: 15px;
    padding: 8px 16px;
    font-size: 0.9em;
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toy-card .edit-btn:hover {
    background: #3a3a3a;
    border-color: #4a4a4a;
}

.data-table .edit-btn {
    padding: 6px 12px;
    font-size: 0.85em;
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.data-table .edit-btn:hover {
    background: #3a3a3a;
    border-color: #4a4a4a;
}

@media (max-width: 768px) {
    header {
        text-align: center;
    }
    
    .header-top {
        flex-direction: column;
    }
    
    .header-title-section {
        width: 100%;
        align-items: flex-start;
    }
    
    header h1 {
        text-align: left;
    }
    
    .filter-grid {
        grid-template-columns: 1fr;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px auto;
    }
}
