/* ==========================================
   CSS Variables & Design System
   ========================================== */
:root {
    /* Color Palette - Dark Mode (Default) */
    --bg-gradient: radial-gradient(circle at 50% 50%, #0f111a 0%, #06070a 100%);
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --primary-color: #6366f1;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --primary-hover: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    --accent-glow: rgba(99, 102, 241, 0.25);

    /* Category Colors */
    --color-dough: #3b82f6;
    /* 도우 */
    --color-meat: #ef4444;
    /* 미트 */
    --color-vegetable: #10b981;
    /* 야채 */
    --color-cheese: #f59e0b;
    /* 치즈 */
    --color-sauce: #8b5cf6;
    /* 소스 */
    --color-can: #06b6d4;
    /* 캔 */
    --color-other: #64748b;
    /* 기타 */

    /* Label Size (dynamic, overridden by JS) */
    --label-w: 55;
    --label-h: 20;

    /* Layout Tokens */
    --border-radius-sm: 8px;
    --border-radius-md: 14px;
    --border-radius-lg: 24px;
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-premium: 0 10px 40px 0 rgba(0, 0, 0, 0.5);
    --font-main: 'Outfit', 'Noto Sans KR', sans-serif;
}

/* Light Theme Overrides */
body.light-theme {
    --bg-gradient: radial-gradient(circle at 50% 50%, #f1f5f9 0%, #cbd5e1 100%);
    --card-bg: rgba(255, 255, 255, 0.75);
    --card-border: rgba(255, 255, 255, 0.6);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --shadow-premium: 0 10px 40px 0 rgba(15, 23, 42, 0.06);
}

/* ==========================================
   Base Styles & Background Glows
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 30px 15px;
    overflow-x: hidden;
    position: relative;
    transition: var(--transition-smooth);
}

body.modal-open {
    overflow: hidden;
}

.background-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.1;
    animation: float 20s infinite alternate;
}

body.light-theme .circle {
    opacity: 0.15;
    filter: blur(150px);
}

.circle-1 {
    width: 500px;
    height: 500px;
    background: var(--primary-color);
    top: -100px;
    left: -100px;
}

.circle-2 {
    width: 600px;
    height: 600px;
    background: #a855f7;
    bottom: -150px;
    right: -100px;
    animation-delay: -6s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(40px, 40px) scale(1.1);
    }
}

/* ==========================================
   App Container & Navigation Layout
   ========================================== */
.app-container {
    width: 100%;
    max-width: 1200px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-premium);
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    transition: var(--transition-smooth);
    overflow: hidden;
    box-sizing: border-box;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--card-border);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--primary-color);
}

.header-logo h1 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* APK Download Badge Button */
.apk-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border-radius: var(--border-radius-sm);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(5, 150, 105, 0.22));
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #10b981 !important;
    text-decoration: none;
    font-family: var(--font-main);
    transition: var(--transition-smooth);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.12);
}

.apk-download-btn:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.28), rgba(5, 150, 105, 0.38));
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.apk-info-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.apk-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-primary);
}

.apk-meta {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-family: monospace;
}

/* Navigation Main Tabs */
.main-tabs {
    display: flex;
    gap: 10px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 14px;
    margin-bottom: 4px;
}

.main-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 700;
    font-family: var(--font-main);
    cursor: pointer;
    transition: var(--transition-smooth);
}

body.light-theme .main-tab {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.12);
    color: var(--text-secondary);
}

.main-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.main-tab.active {
    background: var(--primary-gradient);
    color: #ffffff !important;
    border-color: transparent;
    box-shadow: 0 4px 15px var(--accent-glow);
}

/* Tab Content Visibility */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

body.light-theme .icon-btn {
    background: rgba(0, 0, 0, 0.04);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

body:not(.light-theme) .sun-icon {
    display: none;
}

body.light-theme .moon-icon {
    display: none;
}

/* Main Grid Layout */
.app-main-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
    min-width: 0;
    width: 100%;
}

.app-main-layout>* {
    min-width: 0;
}

@media (max-width: 1100px) {
    .app-main-layout {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   Left Panel: Ingredients List
   ========================================== */
.ingredients-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    padding: 20px;
    min-width: 0;
    overflow: hidden;
}

/* Search Bar */
.search-bar-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

#ingredient-search, #mgmt-ingredient-search {
    width: 100%;
    padding: 12px 14px 12px 42px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-smooth);
}

body.light-theme #ingredient-search, body.light-theme #mgmt-ingredient-search {
    background: #ffffff;
}

#ingredient-search:focus, #mgmt-ingredient-search:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Category Tabs Container & Scroll Buttons */
.category-tabs-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.category-tabs {
    flex: 1;
    overflow-x: auto;
    scroll-behavior: smooth;
    display: flex;
    gap: 6px;
    padding-bottom: 6px;
    /* Hide scrollbar for clean layout */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.category-tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.tabs-scroll-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
    width: 34px;
    height: 34px;
    display: none; /* Managed by JS .visible class */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: var(--transition-smooth);
    flex-shrink: 0;
}

.tabs-scroll-btn:hover {
    background: var(--primary-gradient);
    color: var(--text-primary);
    border-color: transparent;
    box-shadow: 0 0 10px var(--accent-glow);
}

.tabs-scroll-btn.left {
    margin-right: 6px;
}

.tabs-scroll-btn.right {
    margin-left: 6px;
}

.tabs-scroll-btn.visible {
    display: flex;
}

/* Light Theme Scroll Buttons Override */
body.light-theme .tabs-scroll-btn {
    background: rgba(0, 0, 0, 0.04);
}

.category-tab {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 8px 14px;
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition-smooth);
}

body.light-theme .category-tab {
    background: rgba(0, 0, 0, 0.02);
}

.category-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.category-tab.active {
    background: var(--primary-gradient);
    color: #70a975;
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.2);
}

/* Ingredients Grid & Card */
.ingredients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    max-height: 1200px;
    overflow-y: auto;
    padding-right: 6px;
}

.ingredients-grid::-webkit-scrollbar {
    width: 6px;
}

.ingredients-grid::-webkit-scrollbar-track {
    background: transparent;
}

.ingredients-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

body.light-theme .ingredients-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}

.ingredient-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    padding: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

body.light-theme .ingredient-card {
    background: #ffffff;
}

.ingredient-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

body.light-theme .ingredient-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.ingredient-card.selected {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Category Indicators */
.card-category {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    padding: 1px 6px;
    border-radius: 4px;
    width: fit-content;
}

.cat-dough {
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-dough);
}

.cat-meat {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-meat);
}

.cat-veg {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-vegetable);
}

.cat-cheese {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-cheese);
}

.cat-sauce {
    background: rgba(139, 92, 246, 0.15);
    color: var(--color-sauce);
}

.cat-can {
    background: rgba(6, 182, 212, 0.15);
    color: var(--color-can);
}

.cat-other {
    background: rgba(100, 116, 139, 0.15);
    color: var(--color-other);
}

.card-name {
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
    word-break: keep-all;
}

.card-abbr-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.72rem;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 5px;
    border-radius: 3px;
    color: var(--text-secondary);
}

body.light-theme .card-abbr-badge {
    background: rgba(0, 0, 0, 0.05);
}

.card-limits {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.card-limit-pill {
    background: rgba(255, 255, 255, 0.03);
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid var(--card-border);
}

/* ==========================================
   Right Panel: Configuration Panel
   ========================================== */
.config-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
    overflow: hidden;
}

.config-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    overflow: visible;
}

body.light-theme .config-card {
    background: rgba(255, 255, 255, 0.3);
}

.config-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    border-left: 3px solid var(--primary-color);
    padding-left: 8px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-row {
    display: flex;
    gap: 12px;
    min-width: 0;
}

.col-6 {
    flex: 1;
    min-width: 0;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Selected Ingredient Pill */
.selected-item-pill {
    background: rgba(99, 102, 241, 0.06);
    border: 1px dashed var(--primary-color);
    padding: 12px;
    border-radius: var(--border-radius-sm);
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Storage Options Radio Grid */
.storage-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px;
}

.storage-option-card {
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    background: rgba(255, 255, 255, 0.01);
}

body.light-theme .storage-option-card {
    background: #ffffff;
}

.storage-option-card:hover {
    border-color: var(--primary-color);
}

.storage-option-card.selected {
    background: rgba(99, 102, 241, 0.06);
    border-color: var(--primary-color);
    box-shadow: 0 0 8px var(--accent-glow);
}

.storage-option-card.disabled {
    opacity: 0.3;
    pointer-events: none;
    cursor: not-allowed;
}

.storage-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.storage-days {
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-top: 4px;
}

/* Inputs */
.config-card input[type="datetime-local"],
.config-card input[type="text"],
.config-card input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-smooth);
    min-width: 0;
    box-sizing: border-box;
}

body.light-theme .config-card input[type="datetime-local"],
body.light-theme .config-card input[type="text"],
body.light-theme .config-card input[type="number"] {
    background: #ffffff;
}

.config-card input:focus {
    border-color: var(--primary-color);
}

/* Time offset adjustments buttons */
.time-adjustments {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
    min-width: 0;
}

.time-adjust-btn {
    flex: 1 1 auto;
    min-width: 40px;
    padding: 6px 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
}

body.light-theme .time-adjust-btn {
    background: #ffffff;
}

.time-adjust-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* Label Size Controls */
.label-size-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.size-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.size-input-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.size-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.size-input-group input[type="number"] {
    width: 72px !important;
    text-align: center;
    padding: 8px 4px !important;
    font-weight: 700;
    font-size: 0.95rem !important;
}

.size-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.size-x {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
}

.size-presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
    width: 100%;
}

.size-preset-btn {
    position: relative;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    min-width: 70px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

body.light-theme .size-preset-btn {
    background: #ffffff;
}

.size-preset-btn:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
}

.size-preset-btn.active,
body.light-theme .size-preset-btn.active {
    background: var(--primary-gradient) !important;
    color: #ffffff !important;
    border-color: transparent !important;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25) !important;
}

.size-preset-btn.has-delete {
    padding-right: 22px;
}

.delete-preset-x {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition-smooth);
    opacity: 0.5;
}

.size-preset-btn:hover .delete-preset-x {
    opacity: 1;
}

.delete-preset-x:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #ef4444 !important;
}

.size-preset-btn.active .delete-preset-x {
    color: rgba(255, 255, 255, 0.6);
}

.size-preset-btn.active .delete-preset-x:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff !important;
}

/* Print Button */
.print-primary-btn {
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--border-radius-sm);
    color: white;
    padding: 14px;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.print-primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.print-primary-btn svg {
    width: 20px;
    height: 20px;
}

/* ==========================================
   Sticker Live Preview Card (Cream background)
   ========================================== */
.sticker-preview-outer {
    background: #e2e8f0;
    border-radius: var(--border-radius-sm);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
}

body.light-theme .sticker-preview-outer {
    background: #cbd5e1;
}

.sticker-preview-content {
    /* Scale: 1mm ≈ 6.4px for on-screen preview */
    width: calc(var(--label-w) * 6.4px);
    height: calc(var(--label-h) * 6.4px);
    min-width: calc(var(--label-w) * 6.4px);
    min-height: calc(var(--label-h) * 6.4px);
    flex-shrink: 0;
    background: #ffffff;
    /* outline (not border) so the content box is exactly label-size,
       matching the borderless print output 1:1 */
    outline: 1px solid #94a3b8;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    padding: calc(var(--label-h) * 0.12px * 6.4) calc(var(--label-w) * 0.08px * 6.4);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-family: 'Noto Sans KR', sans-serif;
    color: #000000 !important;
    position: relative;
    user-select: none;
    transition: width 0.3s ease, height 0.3s ease;
}

.sticker-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.sticker-abbr-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 900;
    color: #000000;
}

.sticker-location-title {
    font-size: 0.8rem;
    font-weight: 800;
    border: 1px solid #000000;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    color: #000000;
    margin-left: auto;
}

.sticker-main-name {
    font-size: 1.6rem;
    font-weight: 900;
    text-align: center;
    margin: 8px 0;
    letter-spacing: -0.5px;
    color: #000000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sticker-dates {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.72rem;
    color: #1e293b;
    border-top: 1px dashed #cbd5e1;
    padding-top: 6px;
}

.sticker-dates strong {
    font-weight: 700;
    color: #000000;
}

.expire-date-row {
    font-size: 0.8rem;
}

.highlight-expire {
    color: #ef4444;
    font-weight: 900;
    background: #fee2e2;
    padding: 1px 4px;
    border-radius: 2px;
}

.sticker-bottom-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: #64748b;
    margin-top: 4px;
}

.sticker-staff {
    font-weight: 500;
}

.sticker-watermark {
    font-family: 'Outfit', sans-serif;
    font-weight: 900;
    font-size: 0.6rem;
    letter-spacing: 1px;
    opacity: 0.5;
}

/* ==========================================
   Settings Modal Overlay
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    display: none;
    /* Controlled by JS */
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-container {
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    background: #111422;
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
    animation: zoomIn 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

body.light-theme .modal-container {
    background: #ffffff;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--card-border);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-form {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

body.light-theme .modal-form {
    background: rgba(0, 0, 0, 0.01);
}

.modal-form h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.modal-form input,
.modal-form select {
    width: 100%;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.88rem;
    outline: none;
    transition: var(--transition-smooth);
}

body.light-theme .modal-form input,
body.light-theme .modal-form select {
    background: #ffffff;
}

.modal-form input:focus,
.modal-form select:focus {
    border-color: var(--primary-color);
}

.submit-new-btn {
    background: var(--primary-gradient);
    border: none;
    color: white;
    padding: 10px;
    border-radius: 4px;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    width: 100%;
    margin-top: 6px;
}

.submit-new-btn:hover {
    background: var(--primary-hover);
}

.modal-divider {
    border: 0;
    height: 1px;
    background: var(--card-border);
}

.modal-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.modal-actions-row h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.reset-danger-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--color-meat);
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-main);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-smooth);
}

.reset-danger-btn:hover {
    background: var(--color-meat);
    color: white;
}

.reset-danger-btn svg {
    width: 12px;
    height: 12px;
}

/* Database Table */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
}

.db-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: left;
}

.db-table th,
.db-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--card-border);
}

.db-table th {
    background: rgba(255, 255, 255, 0.02);
    font-weight: 700;
    color: var(--text-secondary);
}

body.light-theme .db-table th {
    background: rgba(0, 0, 0, 0.02);
}

.db-table td {
    color: var(--text-primary);
}

.db-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    transition: var(--transition-smooth);
    margin-right: 4px;
}

.db-action-btn:hover {
    color: var(--text-primary);
}

.db-action-btn.delete:hover {
    color: var(--color-meat);
}

.db-action-btn.edit:hover {
    color: var(--primary-color);
}

/* ==========================================
   Footer
   ========================================== */
.app-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-top: 15px;
    border-top: 1px solid var(--card-border);
}

/* ==========================================
   Print Only Container - Hidden by Default
   ========================================== */
.print-only-container {
    display: none;
}

/* ==========================================
   CRITICAL PRINT MEDIA STYLES
   ========================================== */
/* NOTE: @media print @page cannot use CSS variables.
   The triggerPrint() function in app.js injects a dynamic
   <style id="dynamic-print-style"> element just before
   calling window.print() to set the correct mm sizes. */
@media print {

    /* Hide everything on screen */
    .no-print,
    .background-decorations,
    .app-container,
    .modal-overlay,
    header,
    footer,
    main {
        display: none !important;
    }

    /* Show print layout container */
    body {
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        display: block !important;
        color: #000000 !important;
    }

    .print-only-container {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .sticker-preview-content {
        /* width & height are set by injected dynamic style.
           min-* must be cleared: the screen rule's px min sizes would
           otherwise override the mm print size (min beats width/height). */
        min-width: 0 !important;
        min-height: 0 !important;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        transition: none !important;
        page-break-after: always !important;
        break-after: page !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        background: #ffffff !important;
        color: #000000 !important;
        box-sizing: border-box !important;
    }

    /* No forced page break after the last sticker — otherwise the printer
       feeds one extra blank label at the end of every batch. */
    .print-only-container .sticker-preview-content:last-child {
        page-break-after: auto !important;
        break-after: auto !important;
    }

    .sticker-top-row {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 0.5mm !important;
    }

    .sticker-abbr-badge {
        border: 1.5pt solid #000000 !important;
        width: 7.5mm !important;
        height: 7.5mm !important;
        font-size: 11pt !important;
        font-weight: 900 !important;
        line-height: 1 !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #000000 !important;
    }

    .sticker-location-title {
        font-size: 7.2pt !important;
        font-weight: 850 !important;
        border: 1pt solid #000000 !important;
        padding: 0.4mm 1.6mm !important;
        border-radius: 2mm !important;
        color: #000000 !important;
        margin-left: auto !important;
    }

    .sticker-main-name {
        font-size: 12.5pt !important;
        font-weight: 950 !important;
        text-align: center !important;
        margin: 0.5mm 0 !important;
        color: #000000 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
    }

    .sticker-dates {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.4mm !important;
        font-size: 6.2pt !important;
        color: #000000 !important;
        border-top: 0.8pt dashed #000000 !important;
        padding-top: 0.8mm !important;
        margin-bottom: 0.4mm !important;
    }

    .sticker-dates strong {
        font-weight: 800 !important;
    }

    .expire-date-row {
        font-size: 6.6pt !important;
    }

    .highlight-expire {
        color: #000000 !important;
        font-weight: 950 !important;
        background: transparent !important;
        padding: 0 !important;
        border-radius: 0 !important;
        text-decoration: underline !important;
    }

    .sticker-bottom-row {
        display: flex !important;
        justify-content: space-between !important;
        font-size: 5.5pt !important;
        color: #000000 !important;
        margin-top: 0.2mm !important;
    }
}

/* ==========================================================================
   TAB STYLING
   ========================================================================== */
.main-tabs {
    display: flex;
    gap: 8px;
    margin: 15px 0 25px 0;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 8px;
}

.main-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-muted);
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.main-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

body.light-theme .main-tab:hover {
    background: rgba(0, 0, 0, 0.02);
}

.main-tab.active {
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.2);
}

body.light-theme .main-tab.active {
    background: rgba(99, 102, 241, 0.08);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeInTab 0.3s ease-in-out;
}

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   MANAGEMENT LAYOUT & CHIPS
   ========================================================================== */
.management-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    align-items: start;
    width: 100%;
}

@media (max-width: 1100px) {
    .management-layout {
        grid-template-columns: 1fr;
    }
}

.management-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.management-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.management-inline-form {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.management-inline-form input {
    flex: 1;
    min-width: 0;
}

.action-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--border-radius-sm);
    color: white;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.action-add-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px dashed var(--card-border);
    border-radius: var(--border-radius-sm);
    margin-top: 10px;
}

.tag-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

body.light-theme .tag-chip {
    background: #ffffff;
}

.tag-chip:hover {
    border-color: rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
}

.delete-chip-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transition: var(--transition-smooth);
}

.delete-chip-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Mgmt Form Styles */
.mgmt-ingredient-form {
    display: flex;
    flex-direction: column;
}

.form-grid-three {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

@media (max-width: 768px) {
    .form-grid-three {
        grid-template-columns: 1fr;
    }
}

.storage-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    padding: 15px;
    margin-top: 5px;
}

.storage-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.storage-field-group label {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.storage-field-input-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.storage-field-input-wrapper input {
    width: 100% !important;
    text-align: center;
}

/* Dynamic category color badges */
.cat-tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* ==========================================
   Login Page Overlay (Glassmorphism)
   ========================================== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 50%, #0f111a 0%, #06070a 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

body.light-theme .login-overlay {
    background: radial-gradient(circle at 50% 50%, #f1f5f9 0%, #cbd5e1 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-premium);
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    box-sizing: border-box;
    animation: zoomIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

body.light-theme .login-card {
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.login-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.login-logo-icon {
    width: 48px;
    height: 48px;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.login-header p {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-smooth);
    box-sizing: border-box;
}

body.light-theme .login-form input[type="text"],
body.light-theme .login-form input[type="password"] {
    background: #ffffff;
}

.login-form input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

.login-submit-btn {
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--border-radius-sm);
    color: white;
    padding: 14px;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    margin-top: 10px;
    text-align: center;
}

.login-submit-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.login-error-msg {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--border-radius-sm);
    color: #ef4444;
    padding: 10px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
}

/* Emoji Picker Popover */
.emoji-input-wrapper {
    position: relative;
    display: inline-block;
}

.emoji-picker-popover {
    position: absolute;
    bottom: 50px;
    right: 0;
    width: 250px;
    max-height: 200px;
    overflow-y: auto;
    background: rgba(30, 30, 40, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    padding: 10px;
    z-index: 1000;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

body.light-theme .emoji-picker-popover {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.emoji-picker-item {
    font-size: 22px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-smooth);
    user-select: none;
}

.emoji-picker-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.15);
}

body.light-theme .emoji-picker-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* ==========================================
   Pizza Sauce Labeling System Styles
   ========================================== */
.sauce-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

body.light-theme .sauce-card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
}

.sauce-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.sauce-card.selected {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.sauce-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sauce-id {
    font-family: monospace;
    font-size: 0.95rem;
    font-weight: 700;
}

.badge-sauce {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

.badge-prep { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.badge-in { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.badge-out { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.badge-discard { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

.sauce-card .progress-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.sauce-card .progress-bar {
    height: 100%;
    background: #3b82f6;
    transition: width 0.4s ease;
}

.sauce-card .progress-bar.warning { background: #f59e0b; }
.sauce-card .progress-bar.danger { background: #ef4444; }
.sauce-card .progress-bar.paused { background: #64748b; }

.label-2050 {
    width: 280px;
    border: 2px solid #000;
    padding: 8px 12px;
    background: #fff;
    color: #000;
    font-family: sans-serif;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.label-2050 .label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

@media (max-width: 900px) {
    .sauce-responsive-grid {
        grid-template-columns: 1fr !important;
    }
}