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

:root {
    --primary-color: #8B4513;
    --primary-dark: #6B3410;
    --primary-light: #D2691E;
    --success-color: #2D7A4F;
    --secondary-color: #6B7280;
    --bg-color: #F9FAFB;
    --card-bg: #FFFFFF;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-bottom: 40px;
    color: white;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: pulse 8s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.header-content {
    position: relative;
    z-index: 1;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 400;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 30px;
    margin-bottom: 30px;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    margin-bottom: 25px;
}

.card-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Input Section */
.product-input {
    width: 100%;
    min-height: 300px;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s ease;
    background: #FAFBFC;
}

.product-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.product-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #38A169 100%);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #245C3F 0%, var(--success-color) 100%);
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

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

.btn-icon {
    font-size: 1.2rem;
}

/* Stats */
.stats {
    display: flex;
    gap: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #F0F9FF 0%, #E0F2FE 100%);
    border-radius: var(--radius-md);
    margin-top: 10px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1rem;
}

/* Results */
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    overflow: hidden;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.results-table thead {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
}

.results-table th {
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
}

.results-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.results-table tbody tr:hover {
    background: #F9FAFB;
    transform: scale(1.01);
}

.results-table td {
    padding: 14px 12px;
    font-size: 0.9rem;
}

.product-name {
    font-weight: 600;
    color: var(--text-primary);
}

.product-spec {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.price {
    font-weight: 700;
    color: var(--success-color);
    font-size: 1.05rem;
}

/* Not Found Items */
.not-found-section {
    margin-top: 30px;
    padding: 20px;
    background: #FEF2F2;
    border-left: 4px solid #EF4444;
    border-radius: var(--radius-md);
}

.not-found-section h3 {
    color: #DC2626;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.not-found-list {
    list-style: none;
    padding: 0;
}

.not-found-list li {
    padding: 8px 0;
    color: #991B1B;
    display: flex;
    align-items: center;
    gap: 8px;
}

.not-found-list li::before {
    content: '⚠️';
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay p {
    color: white;
    margin-top: 20px;
    font-size: 1.1rem;
    font-weight: 500;
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }

    .card {
        padding: 20px;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .stats {
        flex-direction: column;
        gap: 10px;
    }

    .results-table {
        font-size: 0.85rem;
    }

    .results-table th,
    .results-table td {
        padding: 10px 8px;
    }
}

/* Match Quality Indicators */
.match-quality {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
}

.match-exact {
    background: #D1FAE5;
    color: #065F46;
}

.match-good {
    background: #FEF3C7;
    color: #92400E;
}

.match-fuzzy {
    background: #DBEAFE;
    color: #1E40AF;
}

/* Quantity Input */
.quantity-input {
    width: 70px;
    padding: 6px 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    text-align: center;
    transition: all 0.2s ease;
}

.quantity-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.quantity-input:hover {
    border-color: var(--primary-light);
}

/* Price Input */
.price-input {
    width: 100px;
    padding: 6px 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    text-align: right;
    transition: all 0.2s ease;
    font-weight: 600;
    color: var(--success-color);
}

.price-input:focus {
    outline: none;
    border-color: var(--success-color);
    box-shadow: 0 0 0 3px rgba(45, 122, 79, 0.1);
}

.price-input:hover {
    border-color: var(--success-color);
}

/* Subtotal */
.subtotal {
    font-weight: 600;
    color: var(--success-color);
    font-size: 1rem;
}

/* Total Row */
.total-row {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    font-weight: 700;
    border-top: 3px solid var(--primary-color);
}

.total-row td {
    padding: 16px 12px !important;
    font-size: 1.05rem;
}

.total-price {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.2rem !important;
}


/* Export Success Notification */
.export-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInRight {
    from {
        transform: translateX(120%);
        opacity: 0;
    }

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

.export-notification-hide {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideOutRight {
    to {
        transform: translateX(120%);
        opacity: 0;
    }
}

.export-notification-content {
    background: linear-gradient(135deg, #FFFFFF 0%, #F0FDF4 100%);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(45, 122, 79, 0.2);
    padding: 20px 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    max-width: 420px;
    position: relative;
}

.export-notification-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.export-notification-text {
    flex: 1;
}

.export-notification-text strong {
    display: block;
    font-size: 1.1rem;
    color: var(--success-color);
    margin-bottom: 6px;
}

.export-notification-text p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 4px 0;
}

.export-filename {
    background: #ECFDF5;
    padding: 6px 10px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
    font-size: 0.85rem !important;
    color: var(--success-color) !important;
    word-break: break-all;
    margin-top: 8px !important;
}

.export-hint {
    font-size: 0.85rem !important;
    color: var(--text-secondary) !important;
    margin-top: 8px !important;
}

.export-notification-download {
    background: linear-gradient(135deg, var(--success-color) 0%, #38A169 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    font-family: inherit;
}

.export-notification-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(45, 122, 79, 0.3);
}

.export-notification-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    line-height: 1;
    padding: 4px;
}

.export-notification-close:hover {
    opacity: 1;
}

/* Responsive for notification */
@media (max-width: 480px) {
    .export-notification {
        left: 10px;
        right: 10px;
    }

    .export-notification-content {
        flex-wrap: wrap;
        max-width: none;
    }

    .export-notification-download {
        width: 100%;
        margin-top: 10px;
    }
}

/* Table Controls */
.table-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    background: #F9FAFB;
    border-radius: var(--radius-md);
    align-items: center;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-danger {
    background: linear-gradient(135deg, #DC2626 0%, #EF4444 100%);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #991B1B 0%, #DC2626 100%);
}

/* Delete Button */
.btn-delete {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s ease;
    padding: 4px 8px;
}

.btn-delete:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* Product Name Input for New Rows */
.product-name-input,
.editable-field {
    width: 100%;
    padding: 6px 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.product-name-input:focus,
.editable-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.product-name-input {
    font-weight: 600;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

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

.autocomplete-item:hover {
    background: #F3F4F6;
}

.autocomplete-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.autocomplete-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Checkbox Styling */
input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

input[type="checkbox"]:indeterminate {
    opacity: 0.5;
}

/* Highlight animation for newly added rows */
@keyframes highlightPulse {

    0%,
    100% {
        background-color: transparent;
    }

    50% {
        background-color: #FEF3C7;
    }
}

.highlight-new-row {
    animation: highlightPulse 1s ease-in-out 3;
}

.highlight-new-row td {
    transition: background-color 0.3s ease;
}

/* Manual entry badge */
.manual-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FDE68A;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-right: 8px;
    vertical-align: middle;
}