/* ============================================
   EMBROIDERY CATALOG - Premium Dark UI
   ============================================ */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #222240;
    --bg-glass: rgba(26, 26, 46, 0.7);
    --bg-input: rgba(255, 255, 255, 0.06);

    --text-primary: #f0f0f5;
    --text-secondary: #9898b0;
    --text-muted: #66667a;

    --accent-primary: #6366f1;
    --accent-secondary: #a855f7;
    --accent-pink: #ec4899;
    --accent-magenta: #ec4899;
    --accent-orange: #f97316;
    --accent-teal: #14b8a6;
    --accent-blue: #3b82f6;

    --gradient-primary: linear-gradient(135deg, #6366f1, #a855f7);
    --gradient-warm: linear-gradient(135deg, #ec4899, #f97316);
    --gradient-cool: linear-gradient(135deg, #3b82f6, #14b8a6);

    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(99, 102, 241, 0.3);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body.light-theme,
:root.light-theme {
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-glass: rgba(255, 255, 255, 0.85);
    --bg-input: rgba(0, 0, 0, 0.04);

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --border-color: rgba(0, 0, 0, 0.1);
    --border-glow: rgba(99, 102, 241, 0.4);

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.2);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Background gradient effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 500px;
    background: radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   HEADER
   ============================================ */

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
}

.logo h1 {
    font-size: 1.3rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.5px;
}

.header-stats {
    display: flex;
    gap: 8px;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.stat-pill:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.stat-icon {
    font-size: 0.9rem;
}

.stat-value {
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    color: var(--text-muted);
    font-weight: 400;
}

/* ============================================
   CONTROLS
   ============================================ */

.controls {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 24px 0;
    position: relative;
    z-index: 1;
}

.controls-inner {
    display: flex;
    gap: 12px;
    align-items: stretch;
    flex-wrap: wrap;
}

.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 280px;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.3s ease;
}

.search-input {
    width: 100%;
    padding: 14px 44px 14px 48px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: rgba(255, 255, 255, 0.08);
}

.search-input:focus~.search-icon {
    color: var(--accent-primary);
}

.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
    opacity: 0;
    transition: all 0.2s ease;
}

.search-clear.visible {
    opacity: 1;
}

.search-clear:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

.filter-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-select {
    padding: 14px 36px 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239898b0' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    min-width: 140px;
}

.filter-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.filter-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.results-info {
    padding: 12px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================
   CATALOG GRID
   ============================================ */

.catalog-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 24px 60px;
    position: relative;
    z-index: 1;
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

/* ============================================
   CARD
   ============================================ */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    animation: cardIn 0.4s ease backwards;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow), var(--shadow-md);
    transform: translateY(-4px);
}

.card-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-secondary);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.4s ease, filter 0.4s ease;
    padding: 8px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

.card:hover .card-image {
    transform: scale(1.08);
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.5));
}

.card-format-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-format-badge.pes {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.card-format-badge.emb {
    background: rgba(236, 72, 153, 0.2);
    color: #f472b6;
    border: 1px solid rgba(236, 72, 153, 0.3);
}

.card-info {
    padding: 10px 12px 12px;
}

.card-filename {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.card-meta {
    display: flex;
    gap: 10px;
    font-size: 0.68rem;
    color: var(--text-muted);
}

.card-meta span {
    display: flex;
    align-items: center;
    gap: 3px;
}

/* ============================================
   LOADING
   ============================================ */

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 20px;
    color: var(--text-muted);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.empty-state h2 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.btn-primary {
    padding: 14px 28px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.4);
}

/* Secondary button — visible on dark backgrounds */
.btn-secondary {
    padding: 14px 28px !important;
    background: transparent !important;
    border: 2px solid rgba(255, 255, 255, 0.35) !important;
    border-radius: var(--radius-md) !important;
    color: #e2e8f0 !important;
    font-family: var(--font) !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.6);
    color: #fff;
}

/* ============================================
   PRINT AREA — Hidden on screen, visible only when printing
   ============================================ */

#printArea {
    display: none;
}

@media print {
    body > *:not(#printArea) {
        display: none !important;
    }
    #printArea {
        display: block !important;
    }
}
/* ============================================
   LOAD MORE
   ============================================ */

.load-more-container {
    text-align: center;
    padding: 40px 20px;
}

.btn-load-more {
    padding: 14px 40px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-load-more:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: var(--shadow-glow);
}

.load-more-info {
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    max-width: 720px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(30px) scale(0.95);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.modal-content {
    display: flex;
    flex-direction: column;
}

.modal-image-container {
    width: 100%;
    aspect-ratio: 1;
    max-height: 400px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
}

.modal-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    filter: drop-shadow(0 8px 16px rgba(0,0,0,0.5));
}

.modal-info {
    padding: 24px;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 12px;
    word-break: break-all;
}

.modal-badges {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.badge {
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-format {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-category {
    background: rgba(20, 184, 166, 0.15);
    color: #5eead4;
    border: 1px solid rgba(20, 184, 166, 0.2);
}

.modal-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-label {
    flex-shrink: 0;
    width: 120px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.detail-value {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

.detail-path {
    font-size: 0.75rem;
    word-break: break-all;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.modal-colors-preview {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    transition: transform 0.2s ease;
    cursor: default;
    position: relative;
}

.color-swatch:hover {
    transform: scale(1.3);
    z-index: 2;
}

.color-swatch[title]::after {
    content: attr(title);
    display: none;
}

/* ============================================
   BACK TO TOP
   ============================================ */

.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 50;
    box-shadow: var(--shadow-md);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.back-to-top svg {
    width: 22px;
    height: 22px;
    color: var(--text-secondary);
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-card-hover);
}

/* ============================================
   LOGIN OVERLAY (SaaS Entrance)
   ============================================ */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background-image: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 40%),
        radial-gradient(circle at bottom left, rgba(236, 72, 153, 0.1), transparent 40%);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: fadeIn 0.4s ease-out forwards;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 15px;
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
    transition: all 0.3s;
}

.login-form input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 12px 16px;
    }

    .header-stats {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .header-stats::-webkit-scrollbar {
        display: none;
    }

    .stat-pill {
        flex-shrink: 0;
        font-size: 0.72rem;
        padding: 5px 10px;
    }

    .controls {
        padding: 12px 16px 0;
    }

    .controls-inner {
        flex-direction: column;
    }

    .search-wrapper {
        min-width: unset;
    }

    .filter-group {
        width: 100%;
    }

    .filter-select {
        flex: 1;
        min-width: 0;
        font-size: 0.8rem;
        padding: 12px 30px 12px 12px;
    }

    .catalog-container {
        padding: 12px 16px 60px;
    }

    .catalog-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    .card-info {
        padding: 8px 10px 10px;
    }

    .card-filename {
        font-size: 0.72rem;
    }

    .card-meta {
        font-size: 0.62rem;
    }

    .modal {
        width: 95%;
    }

    .modal-info {
        padding: 16px;
    }

    .detail-row {
        flex-direction: column;
        gap: 4px;
    }

    .detail-label {
        width: auto;
    }

    .form-row {
        flex-direction: column;
        gap: 10px;
    }

    .cart-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .item-config-row {
        flex-wrap: wrap;
    }

    .item-config-row input,
    .item-config-row select {
        width: 100% !important;
    }
}

@media (max-width: 480px) {
    .catalog-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .logo h1 {
        font-size: 1.1rem;
    }
}

/* ============================================
   RECEIPT & CART SYSTEM
   ============================================ */

/* Floating Cart Button */
.floating-cart {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 65px;
    height: 65px;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(79, 70, 229, 0.4);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.floating-cart:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 15px 35px rgba(79, 70, 229, 0.5);
}

.cart-icon {
    font-size: 28px;
}

.cart-count {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: 700;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-dark);
}

/* Cart Drawer */
.cart-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.cart-overlay.active {
    visibility: visible;
    opacity: 1;
}

.cart-drawer {
    position: fixed;
    top: 20px; /* Small gap from top */
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    width: 95%;
    max-width: 1000px;
    /* Remove fixed height, allow content to dictate height up to max */
    height: auto;
    max-height: calc(100vh - 40px);
    background: var(--bg-card);
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.7);
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 35px;
    overflow-y: auto !important; /* The entire modal is scrollable now */
    border-radius: 20px;
    border: 1px solid var(--border-color);
    visibility: hidden;
    opacity: 0;
    z-index: 1001;
}

#cartView, #historyView {
    flex: none; /* Let them grow to content */
    display: block; /* Simpler than flex for full-overflow */
    min-height: 0;
}

.cart-overlay.active .cart-drawer {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.cart-items, .history-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
    overflow: visible; /* Don't scroll internally anymore */
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.cart-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 32px;
    cursor: pointer;
}

.cart-items {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.cart-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.cart-item-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 8px;
    background: transparent;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

.cart-item-info {
    flex: 1;
}

.cart-item-title {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.cart-item-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item-config-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.item-config-row label {
    font-size: 11px;
    color: var(--text-muted);
}

.item-config-row input,
.item-config-row select {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 13px;
    width: 100%;
}

.btn-remove-item {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 11px;
    cursor: pointer;
    text-align: left;
    padding: 0;
}

/* Order Form */
.order-form h3 {
    margin-bottom: 20px;
    color: var(--indigo-400);
}

.form-row {
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
}

.form-group input:focus {
    border-color: var(--primary);
    outline: none;
}

.cart-summary {
    margin: 30px 0;
    padding: 20px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 12px;
    border: 1px dashed var(--primary);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 15px;
}

.summary-row.total {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    font-weight: 700;
    font-size: 20px;
    color: var(--indigo-400);
}

.btn-full {
    width: 100%;
    padding: 16px;
}

/* Modal Add Button Group */
.btn-group-modal {
    margin-top: 20px;
}
/* .btn-add-cart width set to auto/flex in main styles */

/* ============================================
   DROP ZONE (Image Upload)
   ============================================ */

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-zone:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
}

.drop-zone.dragover {
    border-color: var(--accent-pink);
    background: rgba(236, 72, 153, 0.1);
    border-style: solid;
}

.drop-zone-prompt {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.drop-zone-dragging {
    display: none;
    align-items: center;
    gap: 8px;
    color: var(--accent-pink);
    font-size: 0.9rem;
    font-weight: 600;
}

.drop-zone.dragover .drop-zone-prompt {
    display: none;
}

.drop-zone.dragover .drop-zone-dragging {
    display: flex;
}

.drop-zone-icon {
    font-size: 1.5rem;
}

.drop-zone kbd {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.7rem;
    font-family: inherit;
}

/* PRINT STYLES - TIER-BASED ADAPTIVE LAYOUT FOR A4 */
@media print {
    body>*:not(#printArea) {
        display: none !important;
    }

    #printArea {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: white !important;
        color: black !important;
    }

    @page {
        size: A4 portrait;
        margin: 0;
    }

    body {
        background: #fff;
        color: #000;
        margin: 0;
        padding: 0;
    }

    .print-receipt {
        display: flex;
        flex-direction: column;
        width: 210mm;
        min-height: 296mm;
        /* Almost exactly A4 to prevent unexpected blank pages */
        margin: 0 auto;
        background: #fff;
    }

    /* Expand production area to fill empty space, pushing client to the bottom */
    .print-receipt:not(.tier-5) .receipt-part.production {
        flex: 1;
    }

    /* Keep signature area at the very bottom of the production part (right above dashed line) */
    .print-receipt:not(.tier-5) .receipt-part.production .footer-area {
        margin-top: auto;
    }

    /* ============================================
       SHARED LAYOUT PARTS
    ============================================ */

    /* Production Part (Top) */
    .receipt-part.production {
        padding: 4mm 10mm 3mm;
        box-sizing: border-box;
        border-bottom: 2px dashed #333;
        display: flex;
        flex-direction: column;
        position: relative;
    }

    /* Client Part (Bottom) */
    .receipt-part.client {
        padding: 4mm 10mm 3mm;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        position: relative;
    }

    /* Force client section to new page if it risks overflow (Tier 5) */
    .print-receipt.tier-5 .receipt-part.client {
        page-break-before: always;
        padding-top: 6mm;
    }

    .receipt-header-new {
        display: grid;
        grid-template-columns: 170px 1fr auto;
        border-bottom: 2px solid #000;
        padding-bottom: 4px;
        margin-bottom: 7px;
        min-height: 50px;
        align-items: center;
    }

    .brand-side {
        display: flex;
        align-items: center;
    }

    .receipt-logo-img {
        max-height: 45px;
        max-width: 160px;
        width: auto;
        display: block;
        object-fit: contain;
    }

    .title-side {
        text-align: right;
    }

    .title-side h1 {
        margin: 0;
        font-size: 20px;
        color: #000;
    }

    .warning-box {
        background: #fff;
        border: 2px solid #000;
        color: #d00;
        text-align: center;
        padding: 4px 5px;
        font-weight: 800;
        font-size: 16px;
        margin-bottom: 7px;
    }

    .info-row {
        display: flex;
        gap: 30px;
        margin-bottom: 7px;
        font-size: 13px;
    }

    .prod-observations {
        margin-top: 5px;
        padding: 4px 6px;
        border: 1px solid #000;
        background: #fdfdfd;
        font-size: 11px;
        border-radius: 2px;
        line-height: 1.3;
    }

    .prod-observations strong {
        color: #d00;
    }

    /* ============================================
       PRODUCTION GRID BASE
    ============================================ */

    .production-grid-container {
        display: grid;
        gap: 5px;
        align-content: flex-start;
    }

    .production-item-box {
        border: 1px solid #000;
        display: flex;
        flex-direction: column;
        padding: 3px;
        background: #fff;
        overflow: hidden;
    }

    .prod-preview {
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        border-bottom: 1px solid #eee;
        background: #f9f9f9;
    }

    .prod-preview img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }

    .prod-meta {
        padding: 3px 4px;
        line-height: 1.2;
    }

    .prod-filename {
        font-weight: bold;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .prod-placement {
        font-weight: 800;
        color: #d00;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .prod-piece {
        color: #555;
    }

    /* ============================================
       TIER 1 — 1 a 4 itens (Generoso, 2 colunas)
    ============================================ */
    .print-receipt.tier-1 .production-grid-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .print-receipt.tier-1 .production-item-box {
        height: 60mm;
    }

    .print-receipt.tier-1 .prod-preview {
        height: 42mm;
    }

    .print-receipt.tier-1 .prod-filename {
        font-size: 11px;
    }

    .print-receipt.tier-1 .prod-placement {
        font-size: 13px;
    }

    .print-receipt.tier-1 .prod-piece {
        font-size: 9px;
    }

    .print-receipt.tier-1 .warning-box {
        font-size: 18px;
        margin-bottom: 10px;
    }

    .print-receipt.tier-1 .info-row {
        font-size: 14px;
        margin-bottom: 10px;
    }

    /* ============================================
       TIER 2 — 5 a 6 itens (Padrão, 3 colunas)
    ============================================ */
    .print-receipt.tier-2 .production-grid-container {
        grid-template-columns: repeat(3, 1fr);
    }

    .print-receipt.tier-2 .production-item-box {
        height: 48mm;
    }

    .print-receipt.tier-2 .prod-preview {
        height: 32mm;
    }

    .print-receipt.tier-2 .prod-filename {
        font-size: 10px;
    }

    .print-receipt.tier-2 .prod-placement {
        font-size: 12px;
    }

    .print-receipt.tier-2 .prod-piece {
        font-size: 8px;
    }

    .print-receipt.tier-2 .warning-box {
        font-size: 15px;
        padding: 3px;
        margin-bottom: 6px;
    }

    .print-receipt.tier-2 .info-row {
        font-size: 12px;
        margin-bottom: 6px;
    }

    /* ============================================
       TIER 3 — 7 a 9 itens (Otimizado, 3 colunas compactas)
    ============================================ */
    .print-receipt.tier-3 .production-grid-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 3px;
    }

    .print-receipt.tier-3 .production-item-box {
        height: 38mm;
    }

    .print-receipt.tier-3 .prod-preview {
        height: 24mm;
    }

    .print-receipt.tier-3 .prod-filename {
        font-size: 9px;
    }

    .print-receipt.tier-3 .prod-placement {
        font-size: 10px;
    }

    .print-receipt.tier-3 .prod-piece {
        font-size: 7px;
    }

    .print-receipt.tier-3 .warning-box {
        font-size: 12px;
        padding: 2px;
        margin-bottom: 4px;
        border-width: 1.5px;
    }

    .print-receipt.tier-3 .info-row {
        font-size: 11px;
        margin-bottom: 4px;
    }

    .print-receipt.tier-3 .prod-observations {
        font-size: 9px;
        padding: 2px 4px;
        margin-top: 3px;
    }

    .print-receipt.tier-3 .receipt-header-new {
        min-height: 40px;
        margin-bottom: 5px;
    }

    .print-receipt.tier-3 .receipt-logo-img {
        max-height: 35px;
    }

    .print-receipt.tier-3 .title-side h1 {
        font-size: 17px;
    }

    /* ============================================
       TIER 4 — 10 a 12 itens (Compacto, 4 colunas, sem preview)
    ============================================ */
    .print-receipt.tier-4 .production-grid-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 3px;
    }

    .print-receipt.tier-4 .production-item-box {
        height: 36mm;
    }

    .print-receipt.tier-4 .prod-preview {
        height: 22mm;
    }

    .print-receipt.tier-4 .prod-filename {
        font-size: 8px;
    }

    .print-receipt.tier-4 .prod-placement {
        font-size: 9px;
    }

    .print-receipt.tier-4 .prod-piece {
        font-size: 7px;
    }

    .print-receipt.tier-4 .warning-box {
        font-size: 11px;
        padding: 2px;
        margin-bottom: 3px;
        border-width: 1px;
    }

    .print-receipt.tier-4 .info-row {
        font-size: 10px;
        margin-bottom: 3px;
    }

    .print-receipt.tier-4 .prod-observations {
        font-size: 8.5px;
        padding: 2px 4px;
        margin-top: 2px;
    }

    .print-receipt.tier-4 .receipt-header-new {
        min-height: 36px;
        margin-bottom: 4px;
    }

    .print-receipt.tier-4 .receipt-logo-img {
        max-height: 30px;
    }

    .print-receipt.tier-4 .title-side h1 {
        font-size: 15px;
    }

    /* ============================================
       TIER 5 — 13+ itens (Múltipla página)
    ============================================ */
    .print-receipt.tier-5 .production-grid-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 2px;
    }

    .print-receipt.tier-5 .production-item-box {
        height: 32mm;
    }

    .print-receipt.tier-5 .prod-preview {
        height: 18mm;
    }

    .print-receipt.tier-5 .prod-filename {
        font-size: 7px;
    }

    .print-receipt.tier-5 .prod-placement {
        font-size: 8px;
    }

    .print-receipt.tier-5 .prod-piece {
        font-size: 6px;
    }

    .print-receipt.tier-5 .warning-box {
        font-size: 10px;
        padding: 2px;
        margin-bottom: 3px;
    }

    .print-receipt.tier-5 .info-row {
        font-size: 10px;
        margin-bottom: 3px;
    }

    .print-receipt.tier-5 .receipt-header-new {
        min-height: 34px;
        margin-bottom: 4px;
    }

    .print-receipt.tier-5 .receipt-logo-img {
        max-height: 28px;
    }

    .print-receipt.tier-5 .title-side h1 {
        font-size: 14px;
    }

    /* ============================================
       CLIENT TABLE (TODOS OS TIERS)
    ============================================ */

    .compact-table {
        width: 100%;
        border-collapse: collapse;
        margin: 5px 0;
    }

    .compact-table th,
    .compact-table td {
        border: 1px solid #000;
        padding: 3px 6px;
        text-align: left;
    }

    .compact-table th {
        background: #f2f2f2;
    }

    /* Client table sizes por tier */
    .print-receipt.tier-1 .compact-table {
        font-size: 13px;
    }

    .print-receipt.tier-2 .compact-table {
        font-size: 12px;
    }

    .print-receipt.tier-3 .compact-table {
        font-size: 11px;
    }

    .print-receipt.tier-4 .compact-table {
        font-size: 10px;
    }

    .print-receipt.tier-5 .compact-table {
        font-size: 9px;
    }

    /* Client table image sizes */
    .print-receipt.tier-1 .compact-table img,
    .print-receipt.tier-2 .compact-table img {
        width: 30px;
        height: 30px;
    }

    .print-receipt.tier-3 .compact-table img,
    .print-receipt.tier-4 .compact-table img,
    .print-receipt.tier-5 .compact-table img {
        width: 22px;
        height: 22px;
    }

    /* ============================================
       FOOTER / SIGNATURE
    ============================================ */

    .footer-area {
        margin-top: 5px;
        display: grid;
        grid-template-columns: 1.5fr 1fr;
        gap: 15px;
        align-items: flex-end;
    }

    .signature-area {
        text-align: center;
    }

    .signature-line {
        border-top: 1px solid #000;
        margin-top: 20px;
        padding-top: 4px;
        font-size: 12px;
        font-weight: bold;
    }

    .business-footer {
        font-size: 9px;
        text-align: center;
        border-top: 1px solid #ccc;
        margin-top: 5px;
        padding-top: 3px;
    }

    .receipt-badge-col {
        background: #eee;
        padding: 4px 10px;
        font-size: 10px;
        font-weight: bold;
        text-align: center;
        white-space: nowrap;
        align-self: center;
        border: 1px solid #ccc;
    }

}

/* ============================================
   ORDER HISTORY & TABS (UI - NOT PRINTED)
============================================ */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 12px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    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);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.history-item:hover {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
}

.history-item-info h4 {
    margin: 0 0 5px 0;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.history-item-info p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.history-actions {
    display: flex;
    gap: 10px;
}

.btn-icon-print {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-icon-print:hover {
    color: var(--text-primary);
    background: var(--primary);
    border-color: var(--primary);
}

/* Adjustments for Drawer on Mobile */
/* Removido media query que forçava right drawer em telas pequenas, 
   pois agora usamos um modal centralizado universal melhorado. */

/* Professional History Styles */
.history-dashboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    padding: 0 5px;
}

.h-stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.3s ease;
}

.h-stat-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-primary);
}

.h-stat-icon {
    font-size: 1.5rem;
    background: var(--bg-input);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.h-stat-info {
    display: flex;
    flex-direction: column;
}

.h-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.h-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.history-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding: 0 5px;
}

.h-search-wrapper {
    flex: 1;
    position: relative;
}

.h-search-wrapper input {
    width: 100%;
    padding: 10px 15px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
}

.h-search-wrapper input:focus {
    border-color: var(--accent-primary);
}

/* Redesigned History Cards */
.history-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: cardIn 0.4s ease backwards;
}

.history-item:hover {
    border-color: var(--accent-primary);
    background: var(--bg-card-hover);
    transform: scale(1.02);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.h-item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.h-customer-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.h-avatar {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
    text-transform: uppercase;
}

.h-customer-details h4 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.h-customer-details p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.h-status-badge {
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.h-status-today {
    background: rgba(249, 115, 22, 0.2);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.h-status-late {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.h-status-ok {
    background: rgba(20, 184, 166, 0.2);
    color: #2dd4bf;
    border: 1px solid rgba(20, 184, 166, 0.3);
}

.h-item-previews {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.h-preview-mini {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.h-preview-mini img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
}

.h-item-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

.h-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-teal);
}

.h-btn-reprint {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.h-btn-reprint:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Order Detail Modal */
.order-detail-header {
    padding: 24px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.od-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.od-title h2 {
    margin: 0;
    font-size: 1.5rem;
}

.order-detail-body {
    padding: 24px;
}

.od-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    background: var(--bg-input);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}

.od-info-block label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.od-info-block p {
    margin: 0;
    font-weight: 600;
    font-size: 0.9rem;
}

.od-items-section h3 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.od-table-wrapper {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.od-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.od-table th {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    text-align: left;
    color: var(--text-muted);
}

.od-table td {
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
}

.od-item-preview {
    width: 40px;
    height: 40px;
    object-fit: contain;
    background: transparent;
    border-radius: 4px;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
}

.od-footer {
    margin-top: 24px;
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 20px;
    align-items: center;
}

.od-obs label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.od-obs p {
    font-size: 0.85rem;
    font-style: italic;
}

.od-total-block {
    background: var(--gradient-primary);
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: center;
    color: white;
}

.total-label {
    font-size: 0.7rem;
    font-weight: 700;
    opacity: 0.9;
}

.total-value {
    font-size: 1.5rem;
    font-weight: 800;
}

/* Skeleton Loading */
.h-skeleton {
    height: 120px;
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

@media (max-width: 600px) {
    .history-dashboard {
        grid-template-columns: 1fr;
    }

    .od-info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .od-footer {
        grid-template-columns: 1fr;
    }
}

.od-edit-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin: 2px 0;
}

textarea.od-edit-input {
    min-height: 60px;
    resize: vertical;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   QA ANALYZER STYLES
   ============================================ */

/* QA button in detail modal */
.btn-qa {
    padding: 10px 18px;
    background: linear-gradient(135deg, #14b8a6, #3b82f6);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-qa:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(20,184,166,0.4); }
.btn-qa:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-group-modal {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

/* Spinners */
.qa-spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}
.qa-spinner-large {
    width: 36px; height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-teal);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

/* Loading state */
.qa-loading {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.qa-loading p { margin-bottom: 4px; color: var(--text-primary); }
.qa-loading small { font-size: 0.75rem; }

/* Error state */
.qa-error-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--text-primary);
}
.qa-error-box span { font-size: 1.2rem; }
.qa-error-box p { margin-top: 3px; color: var(--text-muted); font-size: 0.8rem; }

/* Result panel */
.qa-result-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.qa-result-header {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 16px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--border-color);
}

/* Score circle */
.qa-score-circle {
    flex-shrink: 0;
    width: 68px; height: 68px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px solid currentColor;
    gap: 0;
}
.qa-score-circle.qa-score-good { color: #10b981; background: rgba(16,185,129,0.1); }
.qa-score-circle.qa-score-warn { color: #f59e0b; background: rgba(245,158,11,0.1); }
.qa-score-circle.qa-score-bad  { color: #ef4444; background: rgba(239,68,68,0.1); }
.qa-score-number { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.qa-score-label  { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.8; }

.qa-result-meta { flex: 1; min-width: 0; }
.qa-result-status-label { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.qa-preset-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 8px;
    background: rgba(99,102,241,0.15);
    color: #818cf8;
    border-radius: 100px;
    margin-bottom: 8px;
}
.qa-summary-text { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5; }

/* Stats grid */
.qa-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border-color);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}
.qa-stat {
    background: var(--bg-secondary);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.qa-stat span { font-size: 0.88rem; font-weight: 700; color: var(--accent-teal); }
.qa-stat label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }

/* Alerts */
.qa-alerts-section { padding: 12px 16px; }
.qa-alerts-section h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 10px; }

.qa-alert-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 0.82rem;
    border-left: 3px solid transparent;
}
.qa-alert-ok    { background: rgba(16,185,129,0.06); border-color: #10b981; }
.qa-alert-warn  { background: rgba(245,158,11,0.08); border-color: #f59e0b; }
.qa-alert-error { background: rgba(239,68,68,0.08);  border-color: #ef4444; }
.qa-alert-icon  { font-size: 1rem; flex-shrink: 0; }
.qa-alert-body strong { display: block; margin-bottom: 2px; }
.qa-alert-body p { color: var(--text-secondary); line-height: 1.4; margin: 0; }

/* Action row */
.qa-action-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: rgba(255,255,255,0.02);
}
.btn-qa-pdf {
    padding: 8px 16px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-qa-pdf:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }

.qa-preset-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.qa-preset-switcher select {
    padding: 5px 24px 5px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239898b0' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}
.btn-qa-reanalyze {
    padding: 5px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-qa-reanalyze:hover { border-color: var(--accent-teal); color: var(--accent-teal); }

/* Custom params form */
.qa-custom-params {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: rgba(255,255,255,0.02);
}
.qa-custom-params h4 { font-size: 0.8rem; margin-bottom: 10px; color: var(--text-muted); }
.qa-params-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.qa-params-grid label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.qa-params-grid input {
    padding: 5px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.82rem;
    width: 100%;
}

/* ─── BATCH BAR ─── */
.results-row-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0 0;
}

.btn-qa-batch-toggle {
    padding: 7px 14px;
    background: rgba(20,184,166,0.12);
    border: 1px solid rgba(20,184,166,0.3);
    border-radius: 100px;
    color: var(--accent-teal);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-qa-batch-toggle:hover,
.btn-qa-batch-toggle.active {
    background: rgba(20,184,166,0.2);
    box-shadow: 0 0 0 2px rgba(20,184,166,0.2);
}

.qa-batch-bar {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
    display: none;
}
.qa-batch-bar.visible { display: block; }
.qa-batch-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(20,184,166,0.08);
    border: 1px solid rgba(20,184,166,0.2);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--text-primary);
}
.qa-batch-preset-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.qa-batch-preset-row label { font-size: 0.8rem; color: var(--text-muted); }
.qa-batch-preset-row select {
    padding: 5px 24px 5px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239898b0' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

/* Card QA checkbox */
.card-qa-check {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    width: 26px;
    height: 26px;
    background: var(--bg-secondary);
    border: 2px solid var(--accent-teal);
    border-radius: 6px;
    align-items: center;
    justify-content: center;
    display: none;
    cursor: pointer;
}
.card-qa-check input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent-teal);
    cursor: pointer;
}

/* ─── BATCH RESULTS MODAL ─── */
.qa-batch-modal {
    max-width: 860px;
    width: 95%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.qa-batch-modal-header {
    padding: 20px 24px 12px;
    border-bottom: 1px solid var(--border-color);
}
.qa-batch-modal-header h2 { font-size: 1.1rem; }
.qa-batch-results-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

/* Batch loading */
.batch-loading {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
}
.batch-progress-bar-wrap {
    height: 6px;
    background: var(--border-color);
    border-radius: 10px;
    margin-top: 12px;
    overflow: hidden;
}
.batch-progress-bar {
    height: 100%;
    background: var(--gradient-cool);
    border-radius: 10px;
    transition: width 0.4s ease;
}

/* Batch summary cards */
.batch-summary-cards {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.batch-sum-card {
    flex: 1;
    min-width: 80px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    text-align: center;
}
.batch-sum-card span { display: block; font-size: 1.5rem; font-weight: 800; color: var(--text-primary); }
.batch-sum-card label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.batch-sum-card.good span { color: #10b981; }
.batch-sum-card.bad  span { color: #ef4444; }

.batch-export-row { margin-bottom: 16px; }

/* Individual rows */
.batch-results-list { display: flex; flex-direction: column; gap: 6px; }
.batch-result-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.batch-result-row:hover { border-color: var(--border-glow); background: var(--bg-card-hover); }
.batch-result-row.batch-row-error { opacity: 0.7; cursor: default; }
.batch-thumb {
    width: 44px; height: 44px;
    object-fit: contain;
    border-radius: 6px;
    background: transparent;
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.4));
    flex-shrink: 0;
}
.batch-row-info { flex: 1; min-width: 0; }
.batch-row-info strong { display: block; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.batch-row-alerts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.batch-row-err-msg { font-size: 0.75rem; color: #ef4444; margin-top: 3px; }
.batch-alert-chip {
    padding: 2px 7px;
    border-radius: 100px;
    font-size: 0.68rem;
    font-weight: 600;
}
.chip-ok   { background: rgba(16,185,129,0.15); color: #10b981; }
.chip-warn { background: rgba(245,158,11,0.15);  color: #f59e0b; }
.chip-error{ background: rgba(239,68,68,0.15);   color: #ef4444; }
.batch-row-score { font-size: 1.1rem; font-weight: 800; flex-shrink: 0; }
.batch-row-score small { font-size: 0.65rem; color: var(--text-muted); font-weight: 400; }

@media (max-width: 600px) {
    .qa-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .qa-result-header { flex-direction: column; align-items: center; text-align: center; }
    .qa-preset-switcher { margin-left: 0; width: 100%; flex-wrap: wrap; justify-content: center; }
    .qa-action-row { flex-direction: column; align-items: stretch; }
    .batch-summary-cards { grid-template-columns: repeat(2, 1fr); }
}

/* Admin Catalog & Batch Bar */
.qa-batch-bar {
    display: none;
    background: #ef4444; 
    color: white; 
    padding: 12px 20px; 
    border-radius: 8px; 
    margin-bottom: 20px; 
    align-items: center; 
    justify-content: space-between;
}

#adminCatalogTable img {
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.5));
    transition: transform 0.2s, filter 0.2s;
}
#adminCatalogTable tr:hover img {
    transform: scale(1.15);
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6));
}

.page-btn {
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.page-btn:hover {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}
.page-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
