/* ==========================================
   Upscents OS - Premium Design System CSS
   ========================================== */

/* Design Tokens & Theme Variables */
:root {
    --bg-base: #090d16;
    --bg-surface: rgba(17, 24, 39, 0.6);
    --bg-surface-solid: #111827;
    --bg-card: rgba(30, 41, 59, 0.35);
    --bg-sidebar: rgba(10, 15, 26, 0.85);
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Branding Colors: Warm Candle Glow & Luxury Cosmetics (Gold-Rose to Coral-Amber) */
    --primary: #f43f5e;
    --primary-hover: #e11d48;
    --primary-glow: rgba(244, 63, 94, 0.25);
    
    --accent: #f59e0b;
    --accent-glow: rgba(245, 158, 11, 0.2);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.15);
    
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.15);
    
    --info: #3b82f6;
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    
    --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 20px -4px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 12px 40px -10px rgba(0, 0, 0, 0.8);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --blur: 16px;
}

/* Reset & Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(244, 63, 94, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(245, 158, 11, 0.05) 0%, transparent 40%);
    background-attachment: fixed;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Core Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100vw;
}

/* Sidebar Navigation */
.app-sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    backdrop-filter: blur(var(--blur));
    flex-shrink: 0;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 28px 12px;
}

.sidebar-header .logo-icon {
    font-size: 24px;
    animation: pulseGlow 3s infinite ease-in-out;
}

.sidebar-header h1 {
    font-family: var(--font-heading);
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
}

.menu-item:hover:not([disabled]) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.menu-item.active {
    color: var(--text-primary);
    background: rgba(244, 63, 94, 0.08);
    border-color: rgba(244, 63, 94, 0.25);
    box-shadow: inset 0 0 12px rgba(244, 63, 94, 0.05);
}

.menu-item.active::after {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    height: 50%;
    width: 3px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

.menu-item[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.menu-icon {
    width: 18px;
    height: 18px;
    stroke-width: 1.8px;
}

.badge {
    margin-left: auto;
    font-size: 9px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 4px;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.db-status-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
}

.status-indicator::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    opacity: 0.4;
}

.status-indicator.online {
    background: var(--success);
}
.status-indicator.online::after {
    background: var(--success);
    animation: ping 1.5s infinite ease-out;
}

.status-indicator.offline {
    background: var(--danger);
}

.status-indicator.connecting {
    background: var(--accent);
}
.status-indicator.connecting::after {
    background: var(--accent);
    animation: ping 1s infinite ease-out;
}

#db-status-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Main Dashboard Panel */
.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    padding: 32px;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.main-header h2 {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.main-header p {
    color: var(--text-secondary);
    margin-top: 4px;
    font-size: 13.5px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.btn-icon {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px var(--primary-glow);
}
.btn-primary:active {
    transform: translateY(0);
}

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

.btn-danger {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}
.btn-danger:hover {
    background: var(--danger);
    color: var(--text-primary);
    box-shadow: 0 4px 12px var(--danger-glow);
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 6px 12px;
}
.btn-text:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

/* Toolbar Panel */
.toolbar-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex-grow: 1;
    max-width: 420px;
    min-width: 240px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13.5px;
    transition: var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: rgba(244, 63, 94, 0.4);
    box-shadow: 0 0 10px rgba(244, 63, 94, 0.1);
    background: rgba(15, 23, 42, 0.85);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

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

select {
    padding: 10px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13.5px;
    cursor: pointer;
    outline: none;
    transition: var(--transition-fast);
}

select:focus {
    border-color: rgba(244, 63, 94, 0.4);
}

select option {
    background: var(--bg-surface-solid);
    color: var(--text-primary);
}

/* Tabs Content Container */
.tab-content-container {
    flex-grow: 1;
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

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

/* Loading & Empty States */
.loading-state, .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(var(--blur));
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.7;
}

.empty-state h4 {
    font-family: var(--font-heading);
    font-size: 18px;
    margin-bottom: 6px;
}

.empty-state p {
    color: var(--text-secondary);
    max-width: 320px;
    margin-bottom: 20px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.material-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    backdrop-filter: blur(var(--blur));
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.material-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--card-accent, var(--text-muted));
    opacity: 0.6;
}

.material-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

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

.card-header h3 {
    font-family: var(--font-heading);
    font-size: 16.5px;
    font-weight: 600;
    line-height: 1.3;
}

.mat-type-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2.5px 7px;
    border-radius: 50px;
    white-space: nowrap;
    border: 1px solid transparent;
}

.type-fragrance_oil { color: #f43f5e; background: rgba(244, 63, 94, 0.1); border-color: rgba(244, 63, 94, 0.15); }
.type-essential_oil { color: #ec4899; background: rgba(236, 72, 153, 0.1); border-color: rgba(236, 72, 153, 0.15); }
.type-wax { color: #f59e0b; background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.15); }
.type-wick { color: #10b981; background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.15); }
.type-vessel { color: #3b82f6; background: rgba(59, 130, 246, 0.1); border-color: rgba(59, 130, 246, 0.15); }
.type-cap { color: #8b5cf6; background: rgba(139, 92, 246, 0.1); border-color: rgba(139, 92, 246, 0.15); }
.type-label { color: #06b6d4; background: rgba(6, 182, 212, 0.1); border-color: rgba(6, 182, 212, 0.15); }
.type-box { color: #a8a29e; background: rgba(168, 162, 158, 0.1); border-color: rgba(168, 162, 158, 0.15); }
.type-mailer { color: #78716c; background: rgba(120, 113, 108, 0.1); border-color: rgba(120, 113, 108, 0.15); }
.type-diluent_carrier { color: #14b8a6; background: rgba(20, 184, 166, 0.1); border-color: rgba(20, 184, 166, 0.15); }
.type-general_supply { color: #64748b; background: rgba(100, 116, 139, 0.1); border-color: rgba(100, 116, 139, 0.15); }

.card-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.card-meta div {
    display: flex;
    justify-content: space-between;
}

.card-meta span {
    color: var(--text-muted);
}

.sku-badge {
    font-family: monospace;
    font-size: 11px;
    background: rgba(0, 0, 0, 0.25);
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Card Stock / Inventory Indicator */
.card-stock-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.stock-value {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-heading);
}

.stock-status {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
}

.stock-status.in-stock {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stock-status.out-of-stock {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Safety Limits Subtable */
.safety-limits-container {
    margin-bottom: 18px;
}

.safety-header {
    font-size: 10.5px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.safety-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    text-align: center;
}

.safety-cell {
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-sm);
    padding: 6px 2px;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.safety-cell .lbl {
    font-size: 8px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.safety-cell .val {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2px;
}

.safety-cell.no-limit {
    opacity: 0.35;
}

/* Card Actions */
.card-actions {
    display: flex;
    gap: 8px;
}

.card-actions .btn {
    flex-grow: 1;
}

/* Settings Form Styles */
.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 600px;
    margin: 0 auto;
    backdrop-filter: blur(var(--blur));
}

.settings-card h3 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.settings-help {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 13.5px;
    line-height: 1.6;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.form-field label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}

.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="email"],
.form-field input[type="url"],
.form-field input[type="number"],
.form-field input[type="datetime-local"],
.form-field textarea {
    padding: 10px 14px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13.5px;
    transition: var(--transition-fast);
    outline: none;
}

.form-field input:focus,
.form-field textarea:focus {
    border-color: rgba(244, 63, 94, 0.45);
    box-shadow: 0 0 10px rgba(244, 63, 94, 0.1);
}

.form-field input[type="password"] {
    font-family: monospace;
    letter-spacing: 0.1em;
}

.form-field input[readonly] {
    background: rgba(15, 23, 42, 0.4) !important;
    color: var(--text-secondary);
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.03);
}

.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* Modals Overlay & Modals Box */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.7);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-box {
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 640px;
    padding: 28px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.show .modal-box {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 20px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Modals Grid Helpers */
.modal-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.modal-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.modal-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.modal-grid-5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 20px 0 16px 0;
}

.section-divider::after,
.section-divider::before {
    content: '';
    flex-grow: 1;
    height: 1px;
    background: var(--border-color);
}

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

/* Specific Setup Modal styles */
.setup-box {
    max-width: 500px;
}

.setup-welcome p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.6;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 13px;
    border: 1px solid transparent;
}

.alert-info {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.15);
    color: #fde047;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

/* Banner summaries inside modals */
.material-summary-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 18px;
    border: 1px solid var(--border-color);
}

/* Animation Keyframes */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes ping {
    75%, 100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

@keyframes pulseGlow {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(244, 63, 94, 0.2)) drop-shadow(0 0 10px rgba(244, 63, 94, 0.2));
    }
    50% {
        filter: drop-shadow(0 0 6px rgba(244, 63, 94, 0.6)) drop-shadow(0 0 20px rgba(244, 63, 94, 0.4));
    }
}

/* Responsive Grid/Flex Adaptations */
@media (max-width: 860px) {
    .app-container {
        flex-direction: column;
    }
    
    .app-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 16px;
        height: auto;
    }
    
    .sidebar-header {
        padding-bottom: 16px;
    }
    
    .sidebar-menu {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 6px;
    }
    
    .menu-item {
        white-space: nowrap;
    }
    
    .app-main {
        padding: 20px;
        height: auto;
    }
    
    .main-header {
        flex-direction: column;
        gap: 16px;
    }
    
    .header-actions {
        width: 100%;
    }
    
    .header-actions .btn {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .modal-grid-2, .modal-grid-3, .modal-grid-5 {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .modal-box {
        padding: 18px;
    }
}

/* Ledger Modal Tabs & History Styles */
.modal-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    padding-bottom: 8px;
}

.modal-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 13px;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

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

.modal-tab.active {
    color: var(--text-primary);
    background: rgba(244, 63, 94, 0.1);
    box-shadow: inset 0 0 8px rgba(244, 63, 94, 0.05);
}

.modal-tab-panel {
    display: none;
}

.modal-tab-panel.active {
    display: block;
}

.ledger-history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 4px;
}

.ledger-history-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    transition: var(--transition-fast);
}

.ledger-history-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-hover);
}

.history-item-left {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 75%;
}

.history-item-left-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-item-date {
    font-size: 11px;
    color: var(--text-muted);
}

.history-item-type {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 4px;
    width: fit-content;
    letter-spacing: 0.03em;
}

.history-item-type.type-purchase {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.history-item-type.type-waste {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.history-item-type.type-adjustment {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent);
}

.history-item-type.type-production_deduction {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.history-item-type.type-production {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.history-item-qty {
    font-size: 14px;
    font-weight: 600;
    margin-top: 2px;
}

.history-item-cost {
    font-size: 12px;
    color: var(--text-secondary);
}

.history-item-notes {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 2px;
}

.history-item-actions {
    display: flex;
    gap: 6px;
}

.btn-icon-only {
    padding: 6px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-only:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-hover);
}

.btn-icon-only.btn-delete:hover {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.2);
}

/* ==========================================
   Finished Products & Recipe Builder
   ========================================== */

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(var(--blur));
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.product-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.product-card-header-gradient {
    height: 70px;
    background: linear-gradient(135deg, var(--grad-start, var(--primary)), var(--grad-end, var(--accent)));
    position: relative;
    display: flex;
    align-items: flex-end;
    padding: 14px 20px;
}

.product-card-header-gradient h3 {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.6);
    line-height: 1.2;
}

.product-card-header-gradient .mat-type-badge {
    position: absolute;
    top: 14px;
    right: 16px;
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.15);
    color: #fff;
    backdrop-filter: blur(4px);
}

.product-card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
}

/* Margin Indicator Colors */
.margin-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2.5px 7px;
    border-radius: 4px;
    letter-spacing: 0.03em;
}

.margin-high {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.margin-medium {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent);
}

.margin-low {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Recipe Ingredient Form Layout */
.recipe-header-row {
    display: grid;
    grid-template-columns: 2fr 70px 1fr 60px 80px 100px 40px;
    gap: 12px;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.recipe-ingredient-row {
    display: grid;
    grid-template-columns: 2fr 70px 1fr 60px 80px 100px 40px;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.recipe-row-cost {
    font-family: monospace;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.ifra-status-col {
    display: flex;
    justify-content: center;
    align-items: center;
}

.ifra-warning-badge {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-align: center;
    cursor: help;
    display: inline-block;
    width: 100%;
}

.ifra-safe-badge {
    background: rgba(16, 185, 129, 0.15);
    color: #a7f3d0;
    border: 1px solid rgba(16, 185, 129, 0.3);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-align: center;
    display: inline-block;
    width: 100%;
}

.recipe-row-unit-cost {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

/* ==========================================
   Production Logs & Manufacturing UI
   ========================================== */

.production-logs-container {
    margin-top: 16px;
    box-shadow: var(--shadow-md);
}

.production-log-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1.2fr 1fr 2fr 80px;
    gap: 10px;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    background: rgba(255, 255, 255, 0.01);
    transition: var(--transition-fast);
}

.production-log-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.production-log-row:last-child {
    border-bottom: none;
}

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

.production-log-qty {
    font-weight: 600;
    color: var(--text-primary);
}

.production-log-cogs {
    font-family: monospace;
    font-weight: 600;
    color: var(--text-primary);
}

.production-log-notes {
    color: var(--text-secondary);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Stock Availability Preview in Modal */
.preview-item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.5fr;
    gap: 10px;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    transition: var(--transition-fast);
}

.preview-item-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.preview-item-name {
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-item-req, .preview-item-avail {
    color: var(--text-secondary);
}

.preview-status-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    text-align: center;
    letter-spacing: 0.02em;
}

.preview-status-badge.in-stock {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.preview-status-badge.short {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.recipe-pct-input, .recipe-qty-input {
    width: 100%;
    padding: 6px 10px;
    font-size: 12.5px;
    height: 32px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
    text-align: center;
    transition: var(--transition-fast);
}

.recipe-pct-input:focus, .recipe-qty-input:focus {
    border-color: rgba(244, 63, 94, 0.45);
    box-shadow: 0 0 8px rgba(244, 63, 94, 0.1);
}

.recipe-pct-input:disabled, .recipe-qty-input:disabled {
    background: rgba(15, 23, 42, 0.4) !important;
    color: var(--text-muted);
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.03);
}

/* Card QR Code button */
.btn-qr-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-qr-icon:hover {
    color: var(--accent);
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

/* Quick-Sale portal specific styling */
.mobile-portal-box {
    max-width: 400px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    padding: 0 !important; /* Managed by inner components for full banner width */
}

/* Quantity Picker for Quick-Sale */
.quantity-picker .qty-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.quantity-picker input {
    width: 60px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 8px 0;
}

.quantity-picker input::-webkit-outer-spin-button,
.quantity-picker input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.history-item-type.type-sale {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

/* Thermal Label print stylesheet override */
@media print {
    /* Hide the entire app container and all other modals completely */
    .app-container,
    .modal-overlay:not(#qr-generator-modal) {
        display: none !important;
    }
    
    /* Make the QR code modal overlay relative and non-disruptive */
    #qr-generator-modal {
        display: block !important;
        position: static !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        opacity: 1 !important;
        width: auto !important;
        height: auto !important;
    }
    
    .modal-box.qr-gen-box {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: none !important;
        display: block !important;
    }
    
    .modal-header,
    .qr-gen-actions {
        display: none !important;
    }
    
    #qr-print-area {
        padding: 0 !important;
        margin: 0 !important;
        display: flex !important;
        justify-content: flex-start !important;
        align-items: flex-start !important;
    }
    
    .thermal-label-wrapper {
        box-shadow: none !important;
        border: none !important;
        width: 2.0in !important;
        height: 1.0in !important;
        padding: 0.1in !important;
        box-sizing: border-box !important;
        background: white !important;
        color: black !important;
        display: grid !important;
        grid-template-columns: 1.2fr 1fr !important;
        gap: 0.05in !important;
        align-items: center !important;
        page-break-inside: avoid !important;
    }

    .label-brand {
        font-family: 'Inter', sans-serif !important;
        font-size: 8pt !important;
        font-weight: 800 !important;
        letter-spacing: 0.08em !important;
        color: black !important;
    }

    .label-name {
        font-family: 'Outfit', sans-serif !important;
        font-size: 11pt !important;
        font-weight: 700 !important;
        line-height: 1.1 !important;
        color: black !important;
        word-break: break-word !important;
        margin-top: 2pt !important;
    }

    .label-sku {
        font-family: 'Inter', sans-serif !important;
        font-size: 7pt !important;
        font-weight: 600 !important;
        color: #444 !important;
        margin-top: 2pt !important;
    }

    .label-qr-col canvas {
        width: 0.8in !important;
        height: 0.8in !important;
    }

    @page {
        size: 2.0in 1.0in;
        margin: 0;
    }
}

/* QR Scan Analytics Dashboard */
.scan-rank-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
}

.scan-rank-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.scan-rank-sku {
    font-weight: 600;
    color: var(--text-primary);
}

.scan-rank-name {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 6px;
}

.scan-rank-count {
    font-weight: 700;
    color: var(--primary);
}

.scan-rank-bar-bg {
    height: 6px;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.scan-rank-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.device-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 12px;
}

.device-badge.mobile {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.device-badge.tablet {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.device-badge.desktop {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

.device-badge.unknown {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
}

.action-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.action-badge.redirect {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.action-badge.admin {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.action-badge.unauthorized {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* GTM Branding Pipeline Styles */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255,255,255,0.02);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #a855f7);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.pipeline-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.pipeline-checkbox:hover {
    transform: scale(1.1);
}

.print-counter-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.print-counter-cell input {
    width: 45px;
    text-align: center;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 11px;
    padding: 2px 0;
}

.print-counter-cell button {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    transition: background 0.2s;
}

.print-counter-cell button:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* Card Button Hover Effects */
.product-actions-btn-duplicate {
    color: var(--text-secondary);
    transition: color 0.2s;
}
.product-actions-btn-duplicate:hover {
    color: #a855f7;
}

/* Profile Card Styling inside modal */
.profile-card-front::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
    background-size: 40px 40px;
    opacity: 0.15;
    pointer-events: none;
}


