:root {
    --primary: #ff6f00;
    --primary-dark: #e65100;
    --primary-light: #ffa040;
    --secondary: #F54337;
    --accent: #ff6f00;
    --background: #f5f5f5;
    --surface: #FFFFFF;
    --text-primary: #000000;
    --text-secondary: #424242;
    --border: #E0E0E0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

header {
    background: #FFFFFF;
    padding: 16px 24px;
    border-bottom: 3px solid var(--primary);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.load-type-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.load-type-selector label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.load-type-selector select {
    padding: 8px 32px 8px 12px;
    border: 2px solid var(--primary);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    background: #fff;
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ff6f00' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 200px;
}

.load-type-selector select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 111, 0, 0.2);
}

.header-logo {
    height: 50px;
    width: auto;
}

header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.header-divider {
    color: var(--primary);
    font-size: 28px;
    font-weight: 300;
}

.header-subtitle {
    font-size: 18px;
    color: var(--primary);
    font-weight: 600;
}

.summary {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 10px;
}

.summary span {
    margin-right: 16px;
}

.summary strong {
    color: var(--text-primary);
}

/* Tabs */
.tabs {
    background: var(--surface);
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 4px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Main Content */
main {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.product-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.product-model {
    font-size: 18px;
    font-weight: 600;
}

.product-part {
    font-size: 13px;
    color: #6e6e73;
    margin-top: 2px;
}

.product-badge {
    background: var(--primary);
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.product-details {
    font-size: 13px;
    color: #6e6e73;
}

.product-details p {
    margin: 4px 0;
}

.product-details strong {
    color: #1d1d1f;
}

.product-stats {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e8e8ed;
}

.stat {
    text-align: center;
}

.stat-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary);
}

.stat-label {
    font-size: 11px;
    color: #6e6e73;
    text-transform: uppercase;
}

/* Images Grid */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.image-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.image-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.image-thumb {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #f5f5f7;
}

.image-info {
    padding: 16px;
}

.image-id {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.image-package-id {
    font-size: 11px;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 8px;
}

.image-serials {
    font-size: 12px;
    color: #6e6e73;
}

.image-serials-list {
    margin-top: 4px;
    font-family: 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
    color: #1d1d1f;
    max-height: 60px;
    overflow-y: auto;
}

.image-product-info {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e8e8ed;
    font-size: 11px;
    color: #6e6e73;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0,0,0,0.1);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s;
}

.modal-close:hover {
    background: rgba(0,0,0,0.2);
}

/* Serials Modal */
.serials-modal-content {
    width: 500px;
    max-height: 80vh;
    padding: 24px;
}

.serials-modal-content h2 {
    font-size: 18px;
    margin-bottom: 16px;
    padding-right: 40px;
}

.serials-list {
    max-height: 60vh;
    overflow-y: auto;
}

.serial-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.serial-item:hover {
    background: #f5f5f7;
}

.serial-number {
    font-family: 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 14px;
    flex: 1;
}

.serial-image-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: #6e6e73;
    transition: all 0.2s;
}

.serial-image-btn:hover {
    background: #e8e8ed;
    color: var(--primary);
}

.serial-image-btn svg {
    width: 20px;
    height: 20px;
}

/* Image Modal */
.image-modal-content {
    width: 1000px;
    max-width: 95vw;
}

.image-modal-body {
    display: flex;
    max-height: 85vh;
}

.image-container {
    flex: 1;
    background: #1a1a1a;
    display: flex;
    flex-direction: column;
    min-height: 400px;
    position: relative;
    overflow: hidden;
}

.zoom-controls {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 10;
    background: rgba(0,0,0,0.7);
    padding: 8px 12px;
    border-radius: 8px;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.zoom-btn:hover {
    background: var(--primary);
}

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

.zoom-level {
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    min-width: 50px;
    text-align: center;
}

.zoom-hint {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: #9e9e9e;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.3s;
}

.image-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: zoom-in;
}

.image-wrapper.zoomed {
    cursor: grab;
}

.image-wrapper.zoomed.dragging {
    cursor: grabbing;
}

.image-wrapper img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    transition: transform 0.1s ease-out;
    transform-origin: center center;
    user-select: none;
}

.image-meta {
    width: 280px;
    padding: 24px;
    background: #f5f5f7;
    overflow-y: auto;
}

.image-meta h3 {
    font-size: 16px;
    margin-bottom: 4px;
}

.package-id {
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 16px;
}

.meta-section {
    margin-bottom: 16px;
}

.meta-section h4 {
    font-size: 12px;
    color: #6e6e73;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.meta-section p {
    font-size: 14px;
    margin: 4px 0;
}

.meta-serials {
    font-family: 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
}

.meta-serials div {
    padding: 4px 0;
    border-bottom: 1px solid #e8e8ed;
}

/* Responsive */
@media (max-width: 768px) {
    .image-modal-body {
        flex-direction: column;
    }

    .image-meta {
        width: 100%;
        max-height: 200px;
    }

    .products-grid,
    .images-grid {
        grid-template-columns: 1fr;
    }
}

/* Loading state */
.loading {
    text-align: center;
    padding: 40px;
    color: #6e6e73;
}

/* No image placeholder */
.no-image {
    background: #e8e8ed;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6e6e73;
    font-size: 14px;
}

/* Search Bar */
.search-container {
    background: #fff;
    padding: 16px 24px;
    border-bottom: 1px solid #d2d2d7;
    position: relative;
}

.search-box {
    display: flex;
    align-items: center;
    background: #f5f5f7;
    border-radius: 10px;
    padding: 0 16px;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
}

.search-icon {
    width: 20px;
    height: 20px;
    color: #6e6e73;
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    border: none;
    background: none;
    padding: 12px;
    font-size: 15px;
    outline: none;
}

.search-box input::placeholder {
    color: #6e6e73;
}

.search-clear {
    background: none;
    border: none;
    font-size: 20px;
    color: #6e6e73;
    cursor: pointer;
    padding: 4px 8px;
}

.search-clear:hover {
    color: #1d1d1f;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 500px;
    max-width: calc(100% - 48px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}

.search-results.active {
    display: block;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #e8e8ed;
    transition: background 0.2s;
}

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

.search-result-item:hover {
    background: #f5f5f7;
}

.search-result-serial {
    font-family: 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 14px;
    font-weight: 500;
    flex: 1;
}

.search-result-meta {
    font-size: 12px;
    color: #6e6e73;
}

.search-result-images {
    display: flex;
    gap: 4px;
}

.search-no-results {
    padding: 24px;
    text-align: center;
    color: #6e6e73;
}

/* Serials Tab */
.serials-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.serials-filter {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
}

.serials-filter input,
.serials-filter select {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--surface);
    outline: none;
}

.serials-filter input {
    flex: 1;
    min-width: 200px;
}

.serials-filter input:focus,
.serials-filter select:focus {
    border-color: var(--primary);
}

.serials-actions {
    display: flex;
    gap: 8px;
}

.download-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.download-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.download-btn:nth-child(2) {
    background: #000000;
}

.download-btn:nth-child(2):hover {
    background: #333333;
}

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

.serials-table-container {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.serials-table {
    width: 100%;
    border-collapse: collapse;
}

.serials-table th {
    background: #f5f5f7;
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #6e6e73;
    text-transform: uppercase;
    border-bottom: 1px solid #d2d2d7;
}

.serials-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e8e8ed;
    font-size: 14px;
}

.serials-table tbody tr:hover {
    background: #f5f5f7;
}

.serials-table .serial-cell {
    font-family: 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 500;
}

.serials-table .images-cell {
    display: flex;
    gap: 4px;
}

.serials-table .image-link {
    background: #e8e8ed;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    color: var(--primary);
    transition: all 0.2s;
}

.serials-table .image-link:hover {
    background: var(--primary);
    color: #fff;
}

/* Responsive for serials table */
@media (max-width: 768px) {
    .serials-table-container {
        overflow-x: auto;
    }

    .serials-table {
        min-width: 600px;
    }

    .search-box {
        max-width: 100%;
    }

    .search-results {
        width: calc(100% - 48px);
    }
}
