/* ===========================================
   INCOBE - Extractor de Etiquetas PDF
   Design System & Styles
   =========================================== */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
    /* Colors - Dark Theme */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2332;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-card-hover: rgba(26, 35, 50, 0.95);
    --bg-glass: rgba(17, 24, 39, 0.6);

    --text-primary: #f0f4f8;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --accent-secondary: #06b6d4;
    --accent-secondary-glow: rgba(6, 182, 212, 0.2);

    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.2);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.2);

    --border-color: rgba(99, 102, 241, 0.15);
    --border-subtle: rgba(148, 163, 184, 0.1);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px var(--accent-glow);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* --- Background Particles --- */
.bg-particles {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: var(--accent-primary);
    opacity: 0.06;
    animation: float-particle linear infinite;
}

@keyframes float-particle {
    0% { transform: translateY(100vh) scale(0); opacity: 0; }
    10% { opacity: 0.06; }
    90% { opacity: 0.06; }
    100% { transform: translateY(-100px) scale(1); opacity: 0; }
}

/* --- Header --- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 23, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-md);
    color: white;
    box-shadow: var(--shadow-glow);
}

.logo-text {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, var(--accent-primary-hover), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.02em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.printer-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background var(--transition-normal);
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 8px var(--success-glow);
    animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot.warning {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning-glow);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* --- Buttons --- */
.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md), 0 0 20px var(--accent-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-primary-hover), var(--accent-primary));
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 35px var(--accent-glow);
}

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

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-color);
    transform: translateY(-1px);
}

.btn-accent {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: linear-gradient(135deg, var(--accent-secondary), #0891b2);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 0 15px var(--accent-secondary-glow);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px var(--accent-secondary-glow);
    filter: brightness(1.1);
}

/* --- Main Content --- */
.main-content {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* --- Upload Section --- */
.upload-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
}

.upload-container {
    width: 100%;
    max-width: 640px;
}

.upload-zone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 2rem;
    background: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-normal);
    backdrop-filter: blur(12px);
    text-align: center;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent-primary);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-4px);
}

.upload-zone.dragover {
    border-style: solid;
    border-color: var(--accent-secondary);
    box-shadow: 0 0 40px var(--accent-secondary-glow);
}

.upload-icon {
    color: var(--accent-primary);
    margin-bottom: 1.5rem;
    transition: transform var(--transition-normal);
}

.upload-zone:hover .upload-icon {
    transform: translateY(-8px);
}

.upload-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.upload-formats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.format-badge {
    padding: 0.25rem 0.65rem;
    background: var(--accent-glow);
    color: var(--accent-primary-hover);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
}

.format-info {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Progress Section --- */
.progress-section {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.progress-card {
    width: 100%;
    max-width: 520px;
    padding: 1.5rem 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
}

.progress-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

.progress-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.progress-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    transition: width 0.3s ease;
    animation: progress-shimmer 2s ease-in-out infinite;
}

@keyframes progress-shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

/* --- Results Section --- */
.results-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
}

.results-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.results-title svg {
    color: var(--accent-primary);
}

.results-file {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 0.25rem;
}

.results-actions {
    display: flex;
    gap: 0.75rem;
}

/* --- Labels Grid --- */
.labels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.label-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-normal);
    backdrop-filter: blur(8px);
    animation: card-appear 0.4s ease forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes card-appear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.label-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg), 0 0 20px var(--accent-glow);
    transform: translateY(-4px);
}

.label-card-preview {
    position: relative;
    height: 200px;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
}

.label-card-preview img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: transform var(--transition-normal);
    filter: drop-shadow(0 2px 10px rgba(0,0,0,0.3));
}

.label-card:hover .label-card-preview img {
    transform: scale(1.05);
}

.preview-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.label-card-preview:hover .preview-overlay {
    opacity: 1;
}

.preview-overlay svg {
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.label-card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.label-card-id {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.label-id {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.label-page {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.2rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
}

.label-meta {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.label-meta span {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.label-meta svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.label-card-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
    background: rgba(10, 14, 23, 0.4);
}

.label-card-actions button {
    flex: 1;
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4rem 2rem;
}

.empty-content {
    text-align: center;
    max-width: 400px;
}

.empty-icon {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.empty-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-content p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    animation: modal-fade-in 0.2s ease;
}

@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-xl), var(--shadow-glow);
    animation: modal-slide-up 0.3s ease;
}

.modal-sm {
    max-width: 450px;
}

@keyframes modal-slide-up {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body img {
    max-width: 100%;
    max-height: 55vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
    background: rgba(10, 14, 23, 0.4);
}

/* --- Printers List --- */
.printers-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.printer-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    transition: all var(--transition-fast);
}

.printer-item.brother {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.08);
}

.printer-item-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}

.printer-item.brother .printer-item-icon {
    background: var(--accent-glow);
    color: var(--accent-primary);
}

.printer-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.printer-item-badge {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    background: var(--accent-primary);
    color: white;
    border-radius: var(--radius-sm);
}

.printer-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.printer-loading .spinner {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    font-size: 0.85rem;
    color: var(--text-primary);
    min-width: 280px;
    max-width: 400px;
    animation: toast-in 0.3s ease;
    backdrop-filter: blur(12px);
}

.toast.toast-success {
    border-left: 3px solid var(--success);
}

.toast.toast-error {
    border-left: 3px solid var(--danger);
}

.toast.toast-info {
    border-left: 3px solid var(--accent-primary);
}

.toast.toast-warning {
    border-left: 3px solid var(--warning);
}

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast-icon {
    flex-shrink: 0;
}

/* --- Config Bar Section (Impresora y Medidas) --- */
.config-bar-section {
    background: rgba(17, 24, 39, 0.7);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.65rem 1.5rem;
    position: relative;
    z-index: 90;
}

.config-bar-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.config-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
}

.config-item:hover, .config-item:focus-within {
    border-color: var(--accent-primary);
}

.config-icon {
    display: flex;
    align-items: center;
    color: var(--accent-primary-hover);
}

.config-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.config-select {
    background: transparent;
    color: var(--text-primary);
    border: none;
    font-family: var(--font-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    max-width: 380px;
}

.config-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.5rem;
}

.config-select optgroup {
    background: var(--bg-tertiary);
    color: var(--accent-secondary);
    font-weight: 700;
}

.btn-refresh-printers {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-refresh-printers:hover {
    color: var(--accent-primary-hover);
    transform: rotate(45deg);
}

/* Custom dimensions input */
.custom-dims-wrapper {
    display: flex;
    align-items: center;
}

.custom-input-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-primary);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

.custom-input-group input[type="number"] {
    width: 60px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0.2rem 0.4rem;
    text-align: center;
    outline: none;
}

.custom-input-group input[type="number"]:focus {
    border-color: var(--accent-primary);
}

.times-sign {
    color: var(--text-muted);
    font-weight: bold;
}

.unit-label {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Botón aplicar medida */
.btn-apply-size {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--success-glow);
    transition: all var(--transition-fast);
    animation: pulse-apply 2s infinite;
}

@keyframes pulse-apply {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.btn-apply-size:hover {
    filter: brightness(1.1);
}

/* Badges de metadata en toolbar */
.results-meta-badges {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.25rem;
}

.active-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-weight: 600;
}

.size-badge {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.printer-badge {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* --- Modal Sizes & Pre-Print Inspection --- */
.modal-lg {
    max-width: 860px;
    width: 95%;
}

.pre-print-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pre-print-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border-radius: var(--radius-md);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.pre-print-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.pre-print-summary-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid var(--border-subtle);
}

.summary-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

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

.summary-chip.highlight strong {
    color: #10b981;
}

.pre-print-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background: #090e17;
}

.carousel-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
}

.btn-carousel {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-carousel:hover:not(:disabled) {
    background: var(--accent-primary);
    color: white;
    transform: scale(1.08);
}

.btn-carousel:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pre-print-preview-area {
    position: relative;
    max-width: 520px;
    width: 100%;
    min-height: 380px;
    max-height: 55vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.75rem;
}

.pre-print-image {
    max-width: 100%;
    max-height: 50vh;
    object-fit: contain;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    border-radius: 4px;
}

.pre-print-info-badge {
    position: absolute;
    bottom: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-xl);
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.thumbnails-strip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    overflow-x: auto;
    padding: 0.5rem 0.25rem;
}

.thumb-item {
    width: 52px;
    height: 70px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.6;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    background: #000;
}

.thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.thumb-item:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.thumb-item.active {
    opacity: 1;
    border-color: #10b981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.btn-confirm-print {
    background: linear-gradient(135deg, #059669, #10b981) !important;
}

.btn-confirm-print:hover {
    filter: brightness(1.1);
}

/* --- Card Selection & Checkboxes --- */
.label-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.95rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-subtle);
}

.label-card.selected {
    border-color: #10b981;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.25);
}

.label-checkbox-container {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.label-checkbox-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #10b981;
}

.badge-pos {
    background: #000;
    color: #10b981;
    font-weight: 800;
    font-size: 0.85rem;
    padding: 0.25rem 0.55rem;
    border-radius: 4px;
    border: 1px solid #10b981;
    letter-spacing: 0.5px;
}

.label-client-tag {
    font-size: 0.85rem;
    font-weight: 700;
    color: #e2e8f0;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.4);
    padding: 0.2rem 0.65rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.label-info {
    padding: 1rem 1.15rem;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.label-piece-id {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.5px;
    margin: 0;
    line-height: 1.3;
}

.label-meta-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.35rem;
    font-size: 0.88rem;
    color: #cbd5e1;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 0.25rem;
}

.meta-row strong {
    color: #94a3b8;
    font-weight: 600;
}

.meta-row span {
    color: #ffffff;
    font-weight: 700;
}

/* --- Label Preview Wrapper (Full Visibility, No Cutoff) --- */
.label-preview-wrapper {
    position: relative;
    height: 240px;
    background: #080d16;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    padding: 0.5rem;
}

.label-preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform var(--transition-normal);
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
}

.label-card:hover .label-preview-img {
    transform: scale(1.03);
}

.label-preview-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.label-preview-wrapper:hover .label-preview-overlay {
    opacity: 1;
}

/* --- Utilities --- */
.hidden {
    display: none !important;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .header-content {
        padding: 0.75rem 1rem;
    }

    .main-content {
        padding: 1rem;
    }

    .labels-grid {
        grid-template-columns: 1fr;
    }

    .results-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-actions {
        width: 100%;
    }

    .results-actions button {
        flex: 1;
    }

    .upload-zone {
        padding: 2rem 1.5rem;
    }

    .modal-card {
        width: 95%;
        margin: 1rem;
    }
}

@media (max-width: 480px) {
    .logo-subtitle {
        display: none;
    }

    .printer-status .status-text {
        display: none;
    }

    .upload-title {
        font-size: 1.2rem;
    }
}

/* --- Botón Header Registro & Informes --- */
.btn-header-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(6, 182, 212, 0.2));
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn-header-action:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(6, 182, 212, 0.35));
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translateY(-1px);
}

/* --- Modal XL (Historial) --- */
.modal-xl {
    width: 95vw !important;
    max-width: 1250px !important;
    max-height: 90vh !important;
    display: flex;
    flex-direction: column;
}

.modal-header-titles h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-header-titles .modal-subtitle {
    margin: 0.2rem 0 0 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* Toolbar Historial */
.historial-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: rgba(10, 14, 23, 0.5);
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.historial-filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-field {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.filter-field label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-input {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: inherit;
    transition: border-color var(--transition-fast);
}

.filter-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.historial-export-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-export-excel {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: linear-gradient(135deg, #059669, #10b981);
    color: #fff;
    padding: 0.5rem 0.95rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-export-excel:hover {
    background: linear-gradient(135deg, #047857, #059669);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.btn-export-pdf {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: #fff;
    padding: 0.5rem 0.95rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.btn-export-pdf:hover {
    background: linear-gradient(135deg, #b91c1c, #dc2626);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

/* KPIs */
.historial-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: rgba(17, 24, 39, 0.4);
    border-bottom: 1px solid var(--border-subtle);
}

.kpi-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
}

.kpi-card.highlight {
    border-color: rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(6, 182, 212, 0.08));
}

.kpi-num {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.kpi-card.highlight .kpi-num {
    color: var(--accent-secondary);
}

.kpi-label {
    font-size: 0.76rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.3rem;
}

/* Tabla Historial */
.historial-table-container {
    flex: 1;
    overflow-y: auto;
    max-height: 48vh;
    padding: 0;
}

.historial-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    text-align: left;
}

.historial-table th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.75rem 0.9rem;
    border-bottom: 2px solid var(--border-color);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 1;
}

.historial-table td {
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    white-space: nowrap;
}

.historial-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.06);
}

.historial-table .badge-table-pos {
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid #334155;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 700;
    font-family: var(--font-mono);
}

.historial-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.5rem;
    background: rgba(10, 14, 23, 0.4);
    border-top: 1px solid var(--border-subtle);
}
