:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --surface-glass: rgba(255, 255, 255, 0.03);
    --surface-glass-hover: rgba(255, 255, 255, 0.06);
    --surface-border: rgba(255, 255, 255, 0.08);
    --accent-primary: #3b82f6;
    --accent-secondary: #8b5cf6;
    --accent-success: #10b981;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --gradient-primary: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --gradient-success: linear-gradient(135deg, #10b981, #06b6d4);
    --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.15);
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

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

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

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

.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.3), transparent 70%);
    top: -200px;
    right: -200px;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.25), transparent 70%);
    bottom: -150px;
    left: -150px;
    animation-delay: -7s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.2), transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes float {

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

    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }
}

.app-container {
    position: relative;
    z-index: 1;
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
}

.glass-card {
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-normal);
}

.glass-card:hover {
    background: var(--surface-glass-hover);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-glow);
}

.app-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 16px 24px;
    margin-bottom: 24px;
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
}

.header-nav {
    justify-self: center;
    display: flex;
    gap: 8px;
    margin: 0;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    padding: 8px 16px;
    border-radius: var(--radius-md);
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.logo {
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.logo-icon {
    width: 40px;
    height: 40px;
    color: var(--accent-primary);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
}

.logo-accent {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--surface-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-primary);
}

.upload-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    margin: 40px 0;
    border: 2px dashed var(--surface-border);
    border-radius: 24px;
    background: var(--surface-glass);
    transition: all var(--transition-normal);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.05);
}

.upload-content {
    text-align: center;
    padding: 60px;
}

.upload-icon {
    display: inline-flex;
    padding: 24px;
    background: linear-gradient(135deg, #06b6d4, #3b82f6);
    border-radius: 50%;
    margin-bottom: 24px;
    color: white;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

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

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

.upload-content h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.upload-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 23, 0.85);
    /* Slightly darker bg-primary base */
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    /* hidden by default */
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.drop-overlay.active {
    display: flex;
    opacity: 1;
}

.drop-overlay .drop-content {
    text-align: center;
    padding: 60px;
    border: 2px dashed var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.drop-overlay.active .drop-content {
    transform: scale(1);
}

.hidden {
    display: none !important;
}

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

.stat-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.order-icon {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.05));
    color: #60a5fa;
}

.parts-icon {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.05));
    color: #a78bfa;
}

.patterns-icon {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(6, 182, 212, 0.05));
    color: #22d3ee;
}

.boards-icon {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.05));
    color: #fbbf24;
}

.efficiency-icon {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.05));
    color: #34d399;
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

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

.efficiency-card {
    grid-column: span 2;
}

.efficiency-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.efficiency-fill {
    height: 100%;
    background: var(--gradient-success);
    border-radius: 4px;
    transition: width 1s ease-out;
    width: 0%;
}

.material-section {
    padding: 24px;
    margin-bottom: 32px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.section-title svg {
    color: #22d3ee;
}

.material-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
}

.material-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.material-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.material-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.tab-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    padding: 8px;
    background: var(--surface-glass);
    border-radius: var(--radius-lg);
    border: 1px solid var(--surface-border);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.table-container {
    padding: 24px;
    overflow: hidden;
}

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

.table-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.table-search {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
}

.table-search svg {
    color: var(--text-muted);
}

.table-search input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 200px;
    outline: none;
}

.table-search input::placeholder {
    color: var(--text-muted);
}

.table-wrapper {
    overflow-x: auto;
}

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

thead th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--surface-border);
    white-space: nowrap;
}

tbody td {
    padding: 14px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.grain-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.view-btn {
    padding: 6px 12px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    color: var(--accent-primary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.view-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    transform: translateY(-1px);
}

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

.pattern-card {
    padding: 20px;
    cursor: pointer;
}

.pattern-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

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

.pattern-id {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.pattern-rep {
    display: inline-flex;
    padding: 4px 12px;
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.pattern-preview {
    aspect-ratio: 16/10;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    overflow: hidden;
}

.pattern-preview canvas {
    width: 100%;
    height: 100%;
}

.pattern-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.pattern-stat {
    text-align: center;
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.pattern-stat-value {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

.costs-container {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .costs-container {
        grid-template-columns: 1fr;
    }
}

.cost-summary {
    padding: 24px;
    height: fit-content;
}

.cost-summary h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.cost-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
}

.cost-item.total {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(6, 182, 212, 0.1));
    border: 1px solid rgba(16, 185, 129, 0.3);
}

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

.cost-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.cost-item.total .cost-value {
    color: var(--accent-success);
}

.cost-breakdown {
    padding: 24px;
}

.cost-breakdown h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.modal-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
}

.pattern-visual {
    aspect-ratio: 16/9;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    overflow: hidden;
}

.pattern-visual canvas {
    width: 100%;
    height: 100%;
}

.pattern-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.pattern-info-item {
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
}

.pattern-info-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

.pattern-info-value {
    font-size: 1rem;
    font-weight: 600;
}

@media (max-width: 768px) {
    .app-container {
        padding: 16px;
    }

    .app-header {
        display: flex;
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .logo,
    .header-nav,
    .header-actions {
        justify-self: auto;
    }

    .summary-section {
        grid-template-columns: 1fr 1fr;
    }

    .efficiency-card {
        grid-column: span 2;
    }

    .tab-nav {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: 1;
        justify-content: center;
        min-width: 120px;
    }

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

@media (max-width: 480px) {
    .summary-section {
        grid-template-columns: 1fr;
    }

    .efficiency-card {
        grid-column: span 1;
    }
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

::selection {
    background: rgba(59, 130, 246, 0.3);
    color: white;
}

/* Help Button */
.header-actions {
    justify-self: end;
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-help {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.btn-help:hover {
    background: rgba(139, 92, 246, 0.25);
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateY(-2px);
}

/* Help Modal */
.help-modal {
    max-width: 800px;
}

.help-modal h2 {
    font-size: 1.75rem;
    margin-bottom: 16px;
}

.help-intro {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--surface-border);
}

.help-sections {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.help-section h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.legend-grid {
    display: grid;
    gap: 16px;
}

.legend-item {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 14px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.04);
    transition: all var(--transition-fast);
}

.legend-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.legend-icon {
    width: 48px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
}

.legend-text {
    flex: 1;
}

.legend-text strong {
    display: block;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.legend-text span {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.legend-badge {
    width: 48px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    color: white;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 8px;
}

.legend-badge.grain {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(245, 158, 11, 0.15));
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.legend-badge.cost {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(16, 185, 129, 0.15));
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.help-context {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.help-steps {
    margin: 0;
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.8;
}

.help-steps li {
    margin-bottom: 8px;
    padding-left: 8px;
}

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

@media (max-width: 768px) {
    .header-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .legend-item {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .legend-icon,
    .legend-badge {
        margin-bottom: 8px;
    }
}

/* Main App Wrapper */
.app-main-wrapper {
    max-width: 1800px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* App Layout - Grid/Flex for Sidebar + Content */
.app-layout {
    display: flex;
    gap: 24px;
    flex: 1;
    position: relative;
    z-index: 1;
}

/* Override existing app-container to fit inside flex layout */
.app-container {
    flex: 1;
    min-width: 0;
    /* Prevent flex item from overflowing */
    margin: 0;
    padding: 0;
    /* Padding is now on app-main-wrapper */
    max-width: none;
}

/* Sidebar */
.sidebar {
    width: 300px;
    flex-shrink: 0;
    height: calc(100vh - 120px);
    /* Height minus header and padding */
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--surface-border);
}

.sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.02);
}

.history-content {
    flex: 1;
    overflow: hidden;
}

.delete-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s ease;
    margin-left: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-item:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.history-item.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
}

.history-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-date {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.empty-history {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        max-height: 300px;
    }
}

/* Search Chips Styling */
.table-search {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.1);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    width: 300px;
    transition: var(--transition-fast);
}

.table-search:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.search-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    align-items: center;
}

.chips-wrapper {
    display: contents;
}

.search-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #93c5fd;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.search-chip .close-chip {
    cursor: pointer;
    opacity: 0.7;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transition: all 0.2s;
}

.search-chip .close-chip:hover {
    opacity: 1;
    background: rgba(59, 130, 246, 0.3);
}

.table-search input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 100%;
    outline: none;
    min-width: 60px;
    padding: 0;
}

.table-search input::placeholder {
    color: var(--text-muted);
}

/* --- Print Modal & Label Styles --- */

.btn-icon-only {
    padding: 8px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.btn-icon-only:hover {
    background: rgba(59, 130, 246, 0.2);
    transform: translateY(-1px);
}

.print-modal {
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.print-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--surface-border);
}

.locked-feature {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid #334155;
    color: #94a3b8;
    cursor: not-allowed;
}

.locked-feature svg {
    color: #fbbf24;
    /* Gold lock */
}

.label-settings-panel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

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

.setting-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-select {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--surface-border);
    color: var(--text-primary);
    border-radius: 6px;
    outline: none;
    cursor: pointer;
}

.checkbox-group {
    display: flex;
    gap: 12px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-primary);
}

.print-actions {
    display: flex;
    justify-content: flex-end;
    /* Push everything to the right by default or use space-between */
    align-items: center;
    width: 100%;
    gap: 12px;
}

.print-upgrade-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    /* Push this group to the right if there's other content */
}

.print-text-info {
    margin-right: auto;
    /* Push text to the left */
}

/* Grand Total Lock Overlay Specifics */
.grand-total-lock-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 100%;
}

.label-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 20px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid var(--surface-border);
    max-height: 500px;
}

/* Individual Label Card (Screen Preview) */
.label-card {
    background: white;
    color: black;
    padding: 16px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    font-family: 'Arial', sans-serif;
    /* Standard font for labels */
}

.label-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #000;
    padding-bottom: 8px;
    margin-bottom: 4px;
}

.label-id {
    font-size: 24px;
    font-weight: 900;
}

.label-dims {
    font-size: 18px;
    font-weight: 700;
}

.label-body {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.label-info {
    font-size: 12px;
}

.label-info div {
    margin-bottom: 2px;
}

.label-qr {
    width: 70px;
    height: 70px;
    /* Border and padding removed to maximize size */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.label-qr svg,
.label-qr canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

/* --- Print Media Query --- */
@media print {
    body * {
        visibility: hidden;
    }

    #labelContainerPrint,
    #labelContainerPrint * {
        visibility: visible;
    }

    #labelContainerPrint {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        /* 2 per row A4 */
        gap: 10px;
        padding: 10px;
    }

    .label-card {
        border: 1px solid #000;
        page-break-inside: avoid;
        box-shadow: none;
        width: 100%;
        height: 100%;
        /* Adjust for sticker size */
        max-width: 350px;
        /* Limit width */
    }

    /* Hide scrollbars, backgrounds etc */
    .bg-animation,
    .app-header,
    .sidebar,
    .modal {
        display: none !important;
    }
}

/* --- Time Estimator Styles --- */
.time-card {
    position: relative;
    /* Maintain grid flow, acts as normal card */
}

.time-icon {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.2), rgba(236, 72, 153, 0.05));
    color: #f472b6;
}

.btn-xs-settings {
    position: absolute;
    top: 24px;
    right: 24px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-xs-settings:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Debug / Premium Unlocked State */
body.premium-unlocked .locked-feature {
    background: var(--primary-color, #3b82f6);
    border-color: var(--primary-color, #3b82f6);
    color: white;
    cursor: pointer;
}

/* Utility for modal scroll locking */
body.no-scroll {
    overflow: hidden;
}

.form-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--surface-border);
    padding: 10px;
    border-radius: 6px;
    color: white;
    font-family: inherit;
    margin-top: 4px;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.text-muted {
    color: var(--text-secondary);
    font-size: 0.8em;
    display: block;
    margin-top: 2px;
}

/* Locked & Blurred UI Patterns */
.relative-lock-container {
    position: relative;
    /* overflow: hidden;  Allow lock icon to pop if needed, but usually contain it */
}

.blurred-content {
    filter: blur(6px);
    opacity: 0.6;
    pointer-events: none;
    user-select: none;
}

.lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    background: rgba(10, 14, 23, 0.2);
    /* Slight tint */
}

.lock-badge {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    padding: 16px 24px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
    transform: translateY(0);
    transition: transform 0.2s ease;
}

.lock-badge:hover {
    transform: translateY(-2px);
}

.lock-icon-lg {
    width: 32px;
    height: 32px;
    color: #fbbf24;
    /* Amber-400 */
}

.lock-text h3 {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.lock-text p {
    color: #94a3b8;
    font-size: 0.85rem;
    margin: 0;
}

.btn-upgrade {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    text-decoration: none;
    /* In case applied to links */
}

.btn-upgrade:hover {
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    transform: translateY(-1px);
}

/* Locked Label specific */
.label-card.locked {
    position: relative;
    overflow: hidden;
}

.label-card.locked .label-header,
.label-card.locked .label-body {
    filter: blur(4px);
    opacity: 0.5;
    pointer-events: none;
}

.label-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
}

.mini-lock {
    background: #1e293b;
    color: #fbbf24;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

/* Blog Grid Layout */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
}

@media (max-width: 1024px) {
    .blog-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .blog-grid {
        grid-template-columns: 1fr;
    }
}