/* ===== ROOT VARIABLES & DESIGN TOKENS ===== */
/* Light Mode (Default) */
:root {
    /* Color System - Light Theme */
    --color-bg-primary: #f5f7fa;
    --color-bg-secondary: #ffffff;
    --color-bg-tertiary: #eef1f5;
    --color-bg-elevated: #ffffff;
    --color-bg-hover: #e8ecf2;

    /* Accent Colors - Vibrant Cyan (slightly darker for light mode) */
    --color-accent-primary: #0097a7;
    --color-accent-secondary: #00838f;
    --color-accent-glow: rgba(0, 151, 167, 0.12);

    /* Text Colors */
    --color-text-primary: #1a1d26;
    --color-text-secondary: #5f6368;
    --color-text-tertiary: #9aa0a6;

    /* Status Colors */
    --color-success: #00c853;
    --color-success-bg: rgba(0, 200, 83, 0.1);
    --color-warning: #ff8f00;
    --color-warning-bg: rgba(255, 143, 0, 0.1);
    --color-error: #d32f2f;
    --color-error-bg: rgba(211, 47, 47, 0.1);

    /* Border & Divider */
    --color-border: #d0d5dd;
    --color-divider: #e4e7ec;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows - Light Mode (softer) */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px var(--color-accent-glow);

    /* Layout */
    --sidebar-width: 260px;
    --topbar-height: 72px;

    /* Mobile Layout */
    --mobile-header-height: 56px;
    --mobile-nav-height: 70px;

    /* Border Radius Additional */
    --radius-full: 9999px;

    /* Primary Color for filters */
    --color-primary: #0097a7;
    --color-surface: var(--color-bg-secondary);
}

/* ===== DARK MODE ===== */
@media (prefers-color-scheme: dark) {
    :root {
        /* Color System - Dark Industrial Theme */
        --color-bg-primary: #0a0b0d;
        --color-bg-secondary: #12141a;
        --color-bg-tertiary: #1a1d26;
        --color-bg-elevated: #1f2330;
        --color-bg-hover: #252938;

        /* Accent Colors - Vibrant Cyan */
        --color-accent-primary: #00e5ff;
        --color-accent-secondary: #00b8d4;
        --color-accent-glow: rgba(0, 229, 255, 0.15);

        /* Text Colors */
        --color-text-primary: #e8eaed;
        --color-text-secondary: #9aa0a6;
        --color-text-tertiary: #5f6368;

        /* Status Colors */
        --color-success: #00e676;
        --color-success-bg: rgba(0, 230, 118, 0.1);
        --color-warning: #ffd740;
        --color-warning-bg: rgba(255, 215, 64, 0.1);
        --color-error: #ff5252;
        --color-error-bg: rgba(255, 82, 82, 0.1);

        /* Border & Divider */
        --color-border: #2a2d3a;
        --color-divider: #1f2330;

        /* Primary Color for filters */
        --color-primary: #6366f1;

        /* Shadows - Dark Mode (stronger) */
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
        --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);
    }
}

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* ===== LAYOUT ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-bg-secondary);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: var(--spacing-xl) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--color-accent-primary);
    filter: drop-shadow(0 0 8px var(--color-accent-glow));
}

.logo-text {
    font-size: var(--font-size-xl);
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-accent-primary), var(--color-accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: var(--spacing-lg) 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--color-accent-primary);
    border-radius: 0 2px 2px 0;
    transition: height 0.2s ease;
}

.nav-item:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-hover);
}

.nav-item.active {
    color: var(--color-accent-primary);
    background: var(--color-accent-glow);
}

.nav-item.active::before {
    height: 60%;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== TOP BAR ===== */
.top-bar {
    height: var(--topbar-height);
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    padding: 0 var(--spacing-xl);
    display: flex;
    align-items: center;
    gap: var(--spacing-xl);
    position: sticky;
    top: 0;
    z-index: 90;
}

.search-container {
    flex: 1;
    max-width: 600px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: var(--spacing-md);
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--color-text-tertiary);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-md) var(--spacing-md) 44px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    transition: all 0.2s ease;
}

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

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

.filter-chips {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.chip {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

.chip.chip-active {
    background: var(--color-accent-glow);
    border-color: var(--color-accent-primary);
    color: var(--color-accent-primary);
}

.chip-divider {
    width: 1px;
    height: 20px;
    background: var(--color-border);
}

.profile-switcher {
    display: flex;
    gap: var(--spacing-sm);
}

.profile-btn {
    width: 40px;
    height: 40px;
    padding: var(--spacing-sm);
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-btn svg {
    width: 100%;
    height: 100%;
}

.profile-btn:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

.profile-btn.active {
    background: var(--color-accent-glow);
    border-color: var(--color-accent-primary);
    color: var(--color-accent-primary);
}

/* ===== VIEW CONTAINER ===== */
.view-container {
    flex: 1;
    padding: var(--spacing-xl);
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
}

.view-header h1 {
    font-size: var(--font-size-3xl);
    font-weight: 700;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--color-accent-primary);
    color: #000000;
    box-shadow: 0 0 15px var(--color-accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    background: #00ffff;
    box-shadow: 0 0 30px var(--color-accent-glow);
}

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

.btn-secondary:hover {
    background: var(--color-bg-hover);
}

.btn-sm {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-xs);
}

.link-btn {
    color: var(--color-accent-primary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all 0.2s ease;
}

.link-btn:hover {
    color: var(--color-accent-secondary);
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
}

.stat-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-accent-primary);
}

.stat-card-warning {
    border-left: 3px solid var(--color-warning);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-md);
}

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

.stat-icon {
    width: 24px;
    height: 24px;
    color: var(--color-accent-primary);
    opacity: 0.7;
}

.stat-value {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
    background: linear-gradient(135deg, var(--color-text-primary), var(--color-text-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-change {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
}

.stat-change.positive {
    color: var(--color-success);
}

.stat-breakdown {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
}

/* ===== SECTIONS ===== */
.section {
    margin-bottom: var(--spacing-2xl);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.section-header h2 {
    font-size: var(--font-size-2xl);
    font-weight: 600;
}

/* ===== ITEMS SCROLL ===== */
.items-scroll {
    display: flex;
    gap: var(--spacing-lg);
    overflow-x: auto;
    padding-bottom: var(--spacing-md);
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.items-scroll::-webkit-scrollbar {
    height: 6px;
}

.items-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.items-scroll::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.item-card {
    flex: 0 0 200px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.item-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-accent-primary);
}

.item-image {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.item-image-placeholder {
    font-size: 4rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.item-info {
    padding: var(--spacing-md);
}

.item-name {
    font-weight: 600;
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
}

/* ===== COLLECTIONS GRID ===== */
.collections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.collection-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: all 0.3s ease;
}

.collection-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-accent-primary);
}

.collection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.collection-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.collection-count {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    background: var(--color-bg-tertiary);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
}

.collection-preview {
    display: flex;
    gap: var(--spacing-sm);
}

.preview-item {
    flex: 1;
    height: 80px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.preview-more {
    flex: 0 0 80px;
    height: 80px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

/* ===== HINTS ===== */
.hints-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.hint-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-accent-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.hint-icon {
    width: 32px;
    height: 32px;
    color: var(--color-accent-primary);
    flex-shrink: 0;
}

.hint-content {
    flex: 1;
}

.hint-title {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.hint-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

/* ===== INVENTORY VIEW ===== */
.inventory-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: var(--spacing-xl);
}

.filter-panel {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    height: fit-content;
    position: sticky;
    top: calc(var(--topbar-height) + var(--spacing-xl));
}

.filter-panel h3 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-lg);
}

.filter-group {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.filter-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.filter-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--color-text-secondary);
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) 0;
    cursor: pointer;
    font-size: var(--font-size-sm);
}

.filter-checkbox input {
    cursor: pointer;
}

.filter-checkbox span {
    flex: 1;
}

.filter-count {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    background: var(--color-bg-tertiary);
    padding: 2px var(--spacing-sm);
    border-radius: var(--radius-sm);
}

.items-grid-container {
    display: flex;
    flex-direction: column;
}

.items-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.view-toggle {
    display: flex;
    gap: var(--spacing-xs);
}

.toggle-btn {
    width: 36px;
    height: 36px;
    padding: var(--spacing-sm);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-btn svg {
    width: 100%;
    height: 100%;
}

.toggle-btn:hover {
    background: var(--color-bg-hover);
}

.toggle-btn.active {
    background: var(--color-accent-glow);
    border-color: var(--color-accent-primary);
    color: var(--color-accent-primary);
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--spacing-lg);
}

.inventory-item-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.inventory-item-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-accent-primary);
}

.inventory-item-image {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inventory-item-info {
    padding: var(--spacing-md);
}

.inventory-item-name {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.inventory-item-category {
    font-size: var(--font-size-xs);
    color: var(--color-accent-primary);
    margin-bottom: var(--spacing-xs);
}

.inventory-item-location {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    margin-bottom: var(--spacing-sm);
}

.inventory-item-status {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.status-available {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.status-lent {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.status-sold {
    background: var(--color-error-bg);
    color: var(--color-error);
}

/* ===== LIST VIEW ===== */
.items-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.inventory-list-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.inventory-list-item:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-primary);
}

.list-item-image {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.list-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.list-item-icon {
    font-size: 1.5rem;
}

.list-item-info {
    flex: 1;
    min-width: 0;
}

.list-item-name {
    font-weight: 600;
    font-size: var(--font-size-base);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-details {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xs);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.list-item-brand {
    color: var(--color-text-secondary);
}

.list-item-category {
    color: var(--color-primary);
}

.list-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--spacing-xs);
    flex-shrink: 0;
}

.list-item-location {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.list-item-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.list-item-arrow {
    color: var(--color-text-tertiary);
    flex-shrink: 0;
}

/* Mobile List View */
@media (max-width: 768px) {
    .list-item-meta {
        display: none;
    }

    .list-item-image {
        width: 48px;
        height: 48px;
    }

    .inventory-list-item {
        padding: var(--spacing-sm) var(--spacing-md);
    }
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}

/* Mobile: Full-screen modal for better input experience */
@media (max-width: 768px) {
    .modal {
        z-index: 1001;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        display: flex;
        flex-direction: column;
    }

    .modal-body {
        padding: var(--spacing-md);
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        position: static;
        padding: var(--spacing-sm) var(--spacing-md);
        padding-bottom: calc(var(--spacing-sm) + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--color-border);
        background: var(--color-bg-secondary);
        flex-shrink: 0;
        display: flex;
        justify-content: center;
        gap: var(--spacing-sm);
    }

    .modal-footer .btn {
        flex: 1;
        min-width: 0;
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-xs);
        white-space: nowrap;
        justify-content: center;
        text-align: center;
    }
}

.modal-large {
    max-width: 1000px;
}

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

.modal-header h2 {
    font-size: var(--font-size-2xl);
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    padding: var(--spacing-xs);
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

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

.modal-close svg {
    width: 100%;
    height: 100%;
}

.modal-body {
    flex: 1;
    padding: var(--spacing-xl);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
    padding: var(--spacing-xl);
    border-top: 1px solid var(--color-border);
}

/* ===== DELETE CONFIRM MODAL ===== */
.delete-modal {
    max-width: 400px;
    text-align: center;
    padding: var(--spacing-xl) !important;
}

.delete-modal .delete-icon {
    font-size: 3.5rem;
    margin-bottom: var(--spacing-md);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px) rotate(-5deg); }
    75% { transform: translateX(5px) rotate(5deg); }
}

.delete-modal h2 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-primary);
}

.delete-modal .delete-item-highlight {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-error);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-error-bg);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    word-break: break-word;
}

.delete-modal .delete-warning {
    font-size: var(--font-size-sm);
    color: var(--color-text-tertiary);
    margin-bottom: var(--spacing-lg);
}

.delete-modal .modal-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
}

.delete-modal .modal-actions .btn {
    flex: 1;
    max-width: 160px;
}

.delete-modal .btn-danger {
    background: var(--color-error);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
}

.delete-modal .btn-danger:hover {
    background: #b71c1c;
    transform: translateY(-1px);
}

/* ===== QUICK ADD ===== */
.quick-add-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xl);
}

.drop-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-2xl);
    text-align: center;
    background: var(--color-bg-tertiary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.drop-zone:hover {
    border-color: var(--color-accent-primary);
    background: var(--color-bg-hover);
}

.drop-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--spacing-lg);
    color: var(--color-text-tertiary);
}

.drop-text {
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.drop-subtext {
    font-size: var(--font-size-sm);
    color: var(--color-text-tertiary);
}

.ai-detection {
    margin-top: var(--spacing-lg);
}

.detection-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-success-bg);
    border: 1px solid var(--color-success);
    border-radius: var(--radius-md);
    color: var(--color-success);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.detection-badge svg {
    width: 18px;
    height: 18px;
}

/* ===== FORM ELEMENTS ===== */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-secondary);
}

.form-input,
.form-select {
    width: 100%;
    padding: var(--spacing-md);
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 3px var(--color-accent-glow);
}

.toggle-group {
    display: flex;
    gap: var(--spacing-sm);
}

.toggle-option {
    flex: 1;
    padding: var(--spacing-md);
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-option:hover {
    background: var(--color-bg-hover);
}

.toggle-option.active {
    background: var(--color-accent-glow);
    border-color: var(--color-accent-primary);
    color: var(--color-accent-primary);
}

.smart-suggestions {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.suggestions-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-accent-primary);
}

.suggestions-header svg {
    width: 18px;
    height: 18px;
}

.suggestion-item {
    padding: var(--spacing-sm) 0;
}

.suggestion-checkbox {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    font-size: var(--font-size-sm);
}

.suggestion-checkbox input {
    cursor: pointer;
}

/* ===== TABS ===== */
.tab-navigation {
    display: flex;
    gap: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--spacing-xl);
}

.tab-btn {
    padding: var(--spacing-md) var(--spacing-lg);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
}

.tab-btn:hover {
    color: var(--color-text-primary);
}

.tab-btn.active {
    color: var(--color-accent-primary);
    border-bottom-color: var(--color-accent-primary);
}

.tab-content {
    display: none;
    padding: var(--spacing-md);
}

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

/* Lending Tab specific layout */
#tab-lending {
    min-height: 300px;
}

/* ===== ITEM DETAIL MODAL ===== */
.item-detail-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-2xl);
}

.item-detail-images {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.main-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    position: relative;
    overflow: hidden;
}

.checkered-bg {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(45deg, var(--color-bg-tertiary) 25%, transparent 25%),
        linear-gradient(-45deg, var(--color-bg-tertiary) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--color-bg-tertiary) 75%),
        linear-gradient(-45deg, transparent 75%, var(--color-bg-tertiary) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.main-image img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.image-thumbnails {
    display: flex;
    gap: var(--spacing-sm);
    overflow-x: auto;
}

.thumbnail {
    flex: 0 0 80px;
    height: 80px;
    border-radius: var(--radius-md);
    border: 2px solid var(--color-border);
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s ease;
    position: relative;
}

.thumbnail:hover {
    border-color: var(--color-accent-primary);
}

.thumbnail.active {
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 1px var(--color-accent-primary);
}

.thumbnail .checkered-bg {
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: relative;
    z-index: 1;
}

/* ===== ITEM DETAIL INFO ===== */
.item-detail-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.detail-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.detail-group label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: var(--font-size-base);
    color: var(--color-text-primary);
    font-weight: 500;
}

.detail-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
}

/* ===== METADATA CONTENT ===== */
.metadata-content {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    font-size: var(--font-size-sm);
}

.metadata-item {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--color-border);
}

.metadata-item:last-child {
    border-bottom: none;
}

.metadata-label {
    color: var(--color-text-secondary);
    font-weight: 500;
}

.metadata-value {
    color: var(--color-text-primary);
    text-align: right;
}

.metadata-description {
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin-top: var(--spacing-sm);
}

.metadata-price-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.price-range {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
}

.price-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
}

.price-amount {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-accent-primary);
}

/* ===== EDIT FORM ===== */
.edit-form-layout {
    max-width: 600px;
}

/* ===== DANGER BUTTON ===== */
.btn-danger {
    background: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

.btn-danger:hover {
    background: var(--color-error);
    color: var(--color-bg-primary);
    transform: translateY(-2px);
}

/* ===== LOCATIONS ===== */
.locations-list {
    display: grid;
    gap: var(--spacing-md);
}

.location-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    transition: all 0.3s ease;
    cursor: pointer;
}

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

.location-card:active {
    transform: scale(0.98);
}

.location-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.location-info {
    flex: 1;
    min-width: 0;
}

.location-name {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.location-count {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.location-path {
    font-size: var(--font-size-sm);
    color: var(--color-text-tertiary);
}

.location-arrow {
    color: var(--color-text-tertiary);
    flex-shrink: 0;
}

/* Mobile location cards */
@media (max-width: 768px) {
    .location-card {
        padding: var(--spacing-md);
        gap: var(--spacing-md);
        border-radius: var(--radius-md);
    }

    .location-icon {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .location-name {
        font-size: var(--font-size-sm);
    }

    .location-count {
        font-size: var(--font-size-xs);
    }
}

/* ===== EXPIRING ITEMS ===== */
#expiring-items-section {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-warning);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
}

#expiring-items-section .section-header h2 {
    color: var(--color-warning);
}

.expiring-group {
    margin-bottom: var(--spacing-md);
}

.expiring-group:last-child {
    margin-bottom: 0;
}

.expiring-group-header {
    margin-bottom: var(--spacing-sm);
}

.expiring-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
}

.expiring-badge.expired {
    background: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

.expiring-badge.soon {
    background: var(--color-warning-bg);
    color: var(--color-warning);
    border: 1px solid var(--color-warning);
}

.expiring-item {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-sm);
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
}

.expiring-item:hover {
    background: var(--color-bg-hover);
    transform: translateX(4px);
}

.expiring-item:last-child {
    margin-bottom: 0;
}

.expiring-item.expired {
    border-left: 3px solid var(--color-error);
}

.expiring-item.soon {
    border-left: 3px solid var(--color-warning);
}

.expiring-item-image {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--color-bg-elevated);
}

.expiring-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.expiring-item-image .no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.expiring-item-info {
    flex: 1;
    min-width: 0;
}

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

.expiring-item-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    display: flex;
    gap: var(--spacing-sm);
    margin-top: 0.125rem;
}

.expiring-item-date {
    font-size: var(--font-size-xs);
    font-weight: 500;
    margin-top: 0.25rem;
}

.expiring-item-date.expired {
    color: var(--color-error);
}

.expiring-item-date.soon {
    color: var(--color-warning);
}

/* ===== INVENTORY BY LOCATION ===== */
.inventory-by-location {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.location-section {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.location-section-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--color-bg-tertiary);
    cursor: pointer;
    transition: background 0.2s ease;
}

.location-section-header:hover {
    background: var(--color-bg-hover);
}

.location-section-icon {
    font-size: 1.25rem;
}

.location-section-name {
    flex: 1;
    font-weight: 600;
    font-size: var(--font-size-base);
    color: var(--color-text-primary);
}

.location-section-count {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    background: var(--color-bg-elevated);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    margin-right: var(--spacing-sm);
}

.location-expand-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.location-expand-btn:hover {
    background: var(--color-bg-elevated);
    color: var(--color-accent-primary);
    border-color: var(--color-accent-primary);
}

.location-expand-btn.expanded {
    background: var(--color-accent-glow);
    border-color: var(--color-accent-primary);
    color: var(--color-accent-primary);
}

.location-expand-btn svg {
    transition: transform 0.2s ease;
}

/* Horizontal scrollable preview (gallery style) */
.location-section-preview {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.location-section-preview::-webkit-scrollbar {
    display: none;
}

/* Preview item cards */
.location-section-preview .location-item-card {
    flex: 0 0 100px;
    min-width: 100px;
}

.location-item-card {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.location-item-card:active {
    transform: scale(0.98);
}

.location-item-image {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-elevated);
    overflow: hidden;
}

.location-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.location-item-icon {
    font-size: 1.5rem;
}

.location-item-name {
    padding: var(--spacing-xs);
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

/* Expanded grid view */
.location-section-expanded {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--color-bg-primary);
    border-top: 1px solid var(--color-border);
}

.location-item-card-expanded {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.location-item-card-expanded:hover {
    border-color: var(--color-accent-primary);
    background: var(--color-bg-hover);
}

.location-item-card-expanded:active {
    transform: scale(0.98);
}

.location-item-image-expanded {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
}

.location-item-image-expanded img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.location-item-info-expanded {
    flex: 1;
    min-width: 0;
}

.location-item-name-expanded {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.location-item-category-expanded {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    margin-top: 2px;
}

/* Mobile optimizations for location inventory */
@media (max-width: 768px) {
    .inventory-by-location {
        gap: var(--spacing-sm);
    }

    .location-section {
        border-radius: var(--radius-md);
    }

    .location-section-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .location-section-icon {
        font-size: 1.1rem;
    }

    .location-section-name {
        font-size: var(--font-size-sm);
    }

    .location-section-count {
        font-size: var(--font-size-xs);
        padding: 2px 6px;
    }

    .location-expand-btn {
        font-size: 10px;
        padding: 4px 8px;
    }

    .location-section-preview {
        padding: var(--spacing-sm);
        gap: var(--spacing-xs);
    }

    .location-section-preview .location-item-card {
        flex: 0 0 80px;
        min-width: 80px;
    }

    .location-item-image {
        height: 60px;
    }

    .location-item-icon {
        font-size: 1.25rem;
    }

    .location-item-name {
        padding: 4px;
        font-size: 10px;
    }

    .location-section-expanded {
        grid-template-columns: 1fr;
        padding: var(--spacing-sm);
        gap: var(--spacing-sm);
    }

    .location-item-card-expanded {
        padding: var(--spacing-sm);
    }

    .location-item-image-expanded {
        width: 48px;
        height: 48px;
    }
}

/* ===== LENDING ===== */
.lending-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.lending-list {
    margin-top: var(--spacing-xl);
}

/* ===== SETTINGS ===== */
.settings-content {
    max-width: 600px;
}

.settings-section {
    margin-bottom: var(--spacing-2xl);
}

.settings-section h3 {
    font-size: var(--font-size-xl);
    margin-bottom: var(--spacing-lg);
}

.settings-item {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--color-border);
}

.settings-item:last-child {
    border-bottom: none;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--color-text-secondary);
}

.empty-state svg {
    opacity: 0.3;
}

.empty-state h3 {
    margin-bottom: var(--spacing-md);
}

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

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

.stat-card,
.item-card,
.collection-card,
.inventory-item-card {
    animation: fadeIn 0.4s ease-out;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .quick-add-layout {
        grid-template-columns: 1fr;
    }

    .inventory-layout {
        grid-template-columns: 1fr;
    }

    .filter-panel {
        position: static;
    }

    .item-detail-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 72px;
    }

    .nav-item span {
        display: none;
    }

    .logo-text {
        display: none;
    }

    .filter-chips {
        display: none;
    }
}

/* ===== SMART COLLECTIONS ===== */

/* Smart Collections Filter Button (Inventar View) */
.smart-collections-filter-wrapper {
    padding: var(--spacing-sm) var(--spacing-md);
}

.smart-collections-filter-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    color: var(--color-text);
    font-size: var(--font-size-base);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.smart-collections-filter-btn:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-primary);
}

.smart-collections-filter-btn.has-filter {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent-secondary));
    border-color: transparent;
    color: white;
}

.smart-collections-filter-btn .chevron-icon {
    margin-left: auto;
    opacity: 0.6;
}

.active-filter-badge {
    background: var(--color-accent-secondary);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.smart-collections-filter-btn.has-filter .active-filter-badge {
    background: rgba(255, 255, 255, 0.25);
}

/* Smart Filter Modal (Bottom Sheet) */
.smart-filter-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
}

.smart-filter-modal.active {
    display: block;
}

.smart-filter-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.smart-filter-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    animation: slideUpSheet 0.3s ease;
    padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 70px);
}

@keyframes slideUpSheet {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.smart-filter-header {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    position: relative;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
}

.smart-filter-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.clear-all-btn {
    position: absolute;
    right: var(--spacing-lg);
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    padding: var(--spacing-xs) var(--spacing-sm);
}

.smart-filter-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

/* Filter Group Section - Collapsible */
.filter-group-section {
    background: var(--color-background);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-md);
    overflow: hidden;
}

.filter-group-section:last-child {
    margin-bottom: 0;
}

.filter-group-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    cursor: pointer;
    transition: background 0.15s ease;
}

.filter-group-header:hover {
    background: var(--color-bg-hover);
}

.filter-group-icon {
    font-size: 1.5rem;
}

.filter-group-info {
    flex: 1;
}

.filter-group-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
    padding: 0;
    text-transform: none;
    letter-spacing: normal;
}

.filter-group-count {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.filter-group-arrow {
    transition: transform 0.3s ease;
    color: var(--color-text-secondary);
}

.filter-group-arrow.expanded {
    transform: rotate(180deg);
}

.filter-group-items {
    display: none;
    padding: 0 var(--spacing-md) var(--spacing-md);
    flex-direction: column;
    gap: var(--spacing-xs);
}

.filter-group-items.expanded {
    display: flex;
    max-height: 40vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.filter-item:hover {
    border-color: var(--color-border);
}

.filter-item.active {
    background: var(--color-primary);
    color: white;
}

.filter-item-name {
    font-size: var(--font-size-base);
}

.filter-item-count {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    background: var(--color-bg-tertiary);
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.filter-item.active .filter-item-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Nav Section Container */
.nav-section {
    margin-top: var(--spacing-sm);
}

/* Section Header (like nav-item but with arrow) */
.nav-section-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    cursor: pointer;
}

.nav-section-header:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-hover);
}

.nav-section-header span {
    flex: 1;
}

.nav-section-arrow {
    transition: transform 0.3s ease;
    opacity: 0.6;
}

/* Section Content (collapsible) */
.nav-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-section-content.expanded {
    max-height: 1000px;
}

/* Smart Collection Type Groups */
.smart-collection-type {
    border-top: 1px solid var(--color-border);
}

.smart-collection-type:first-child {
    border-top: none;
}

.smart-collection-type-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    padding-left: calc(var(--spacing-lg) + 12px);
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    transition: all 0.2s ease;
    cursor: pointer;
}

.smart-collection-type-header:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-hover);
}

.smart-collection-type-icon {
    font-size: 1rem;
}

.smart-collection-type-label {
    flex: 1;
    font-weight: 500;
}

.smart-collection-type-count {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    background: var(--color-bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.smart-collection-type-arrow {
    transition: transform 0.2s ease;
    opacity: 0.5;
}

.smart-collection-type-arrow.rotated {
    transform: rotate(180deg);
}

/* Collection Type Items (collapsible list) */
.smart-collection-type-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--color-bg-primary);
}

.smart-collection-type-items.expanded {
    max-height: 500px;
}

/* Individual Collection Item */
.smart-collection-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    padding-left: calc(var(--spacing-lg) + 32px);
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

.smart-collection-item:hover {
    color: var(--color-accent-primary);
    background: var(--color-bg-hover);
    border-left-color: var(--color-accent-primary);
}

.smart-collection-item-icon {
    font-size: 0.875rem;
}

.smart-collection-item-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.smart-collection-item-count {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    background: var(--color-bg-tertiary);
    padding: 1px 5px;
    border-radius: var(--radius-sm);
    min-width: 20px;
    text-align: center;
}

.smart-collection-empty {
    padding: var(--spacing-sm) var(--spacing-lg);
    padding-left: calc(var(--spacing-lg) + 32px);
    color: var(--color-text-tertiary);
    font-size: var(--font-size-xs);
    font-style: italic;
}

/* Smart Collection View Header */
.smart-collection-header-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.smart-collection-header-info h1 {
    margin: 0;
    font-size: var(--font-size-xl);
}

.smart-collection-icon {
    font-size: 1.5rem;
}

.smart-collection-count {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    background: var(--color-bg-tertiary);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
}

/* Ghost Button for Back */
.btn-ghost {
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-ghost:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

/* ===== LENDING TAB STYLES ===== */
.lending-type-toggle {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--spacing-xs);
}

.lending-type-toggle .toggle-option {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all 0.2s ease;
}

.lending-type-toggle .toggle-option:hover {
    color: var(--color-text-primary);
}

.lending-type-toggle .toggle-option.active {
    background: var(--color-accent-primary);
    color: var(--color-bg-primary);
}

/* Friend Code Input Group */
.friend-code-input-group {
    display: flex;
    gap: var(--spacing-sm);
}

.friend-code-input-group .form-input {
    flex: 1;
    font-family: monospace;
    font-size: var(--font-size-lg);
    letter-spacing: 2px;
}

.friend-code-input-group .btn {
    white-space: nowrap;
}

/* Found User Card */
.found-user-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-success);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.found-user-avatar {
    width: 48px;
    height: 48px;
    background: var(--color-bg-elevated);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
}

.found-user-info {
    flex: 1;
}

.found-user-name {
    font-weight: 600;
    color: var(--color-text-primary);
    font-size: var(--font-size-base);
}

.found-user-code {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-family: monospace;
}

.found-user-check {
    color: var(--color-success);
}

/* Lending Status Card (Active Lending) */
.lending-status-card {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-warning);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
}

.lending-status-header {
    margin-bottom: var(--spacing-md);
}

.lending-details {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.lending-detail-row {
    display: flex;
    gap: var(--spacing-md);
}

.lending-label {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    min-width: 100px;
}

.lending-value {
    color: var(--color-text-primary);
    font-weight: 500;
}

/* Error and Loading Text */
.error-text {
    color: var(--color-error);
    font-size: var(--font-size-sm);
    padding: var(--spacing-sm);
}

.loading-text {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    padding: var(--spacing-sm);
}

/* ===== LENDING VIEW STYLES ===== */
.lending-section {
    margin-bottom: var(--spacing-xl);
}

.lending-section-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--color-border);
}

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

.lending-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--spacing-md);
}

.lending-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.lending-card:hover {
    border-color: var(--color-accent-primary);
    transform: translateY(-2px);
}

.lending-card-image {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-bg-tertiary);
    flex-shrink: 0;
}

.lending-card-info {
    flex: 1;
    min-width: 0;
}

.lending-card-name {
    font-weight: 600;
    color: var(--color-text-primary);
    font-size: var(--font-size-base);
    margin-bottom: var(--spacing-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lending-card-person,
.lending-card-date,
.lending-card-due {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    display: flex;
    gap: var(--spacing-xs);
    flex-wrap: wrap;
}

.lending-card-label {
    color: var(--color-text-tertiary);
}

.lending-card-value {
    color: var(--color-text-secondary);
}

.lending-card-code {
    color: var(--color-text-tertiary);
    font-family: monospace;
    font-size: var(--font-size-xs);
}

.lending-card-due {
    color: var(--color-warning);
    margin-top: var(--spacing-xs);
}

.lending-return-btn {
    flex-shrink: 0;
}

.empty-state-inline {
    text-align: center;
    padding: var(--spacing-lg);
    color: var(--color-text-secondary);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-sm);
}

/* ===== SETTINGS FRIEND CODE ===== */
.settings-description {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-md);
}

.friend-code-display {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    background: var(--color-bg-tertiary);
    border: 2px dashed var(--color-accent-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md) var(--spacing-lg);
}

.friend-code-value {
    font-family: monospace;
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-accent-primary);
    letter-spacing: 3px;
    flex: 1;
}

/* QR Code Display */
.friend-code-qr-container {
    display: flex;
    justify-content: center;
    margin-bottom: var(--spacing-lg);
}

.qr-code-display {
    background: white;
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: inline-block;
}

.qr-code-display svg {
    display: block;
}

.qr-error {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    text-align: center;
    padding: var(--spacing-lg);
}

.btn-icon {
    padding: var(--spacing-sm);
    min-width: auto;
}

/* QR Scanner Styles */
.qr-scanner-hint {
    text-align: center;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-md);
    font-size: var(--font-size-sm);
}

#qr-reader {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

#qr-reader video {
    border-radius: var(--radius-lg);
}

#qr-reader__scan_region {
    background: var(--color-surface);
}

#qr-reader__dashboard {
    padding: var(--spacing-sm) !important;
}

#qr-reader__dashboard_section_csr button {
    background: var(--color-primary) !important;
    color: white !important;
    border: none !important;
    padding: var(--spacing-sm) var(--spacing-md) !important;
    border-radius: var(--radius-md) !important;
    cursor: pointer !important;
}

#qr-reader__dashboard_section_csr select {
    padding: var(--spacing-sm) !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--color-border) !important;
}

.qr-scanner-result {
    margin-top: var(--spacing-md);
    text-align: center;
}

.qr-scanner-result .error {
    color: var(--color-error);
    background: var(--color-error-light);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    display: inline-block;
}

.qr-scanner-result .success {
    color: var(--color-success);
    background: var(--color-success-light);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    display: inline-block;
}

/* Image Source Selection Modal (Mobile) */
.image-source-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    align-items: flex-end;
    justify-content: center;
    padding: var(--spacing-md);
    /* Much larger bottom padding to account for navigation bar + safe area */
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 20px));
}

.image-source-modal.active {
    display: flex;
}

.image-source-options {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: var(--spacing-sm);
    padding-bottom: var(--spacing-md);
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

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

.image-source-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    border: none;
    background: var(--color-background);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: var(--font-size-md);
    color: var(--color-text);
    transition: background 0.2s;
}

.image-source-btn:hover {
    background: var(--color-border);
}

.image-source-btn svg {
    color: var(--color-primary);
    flex-shrink: 0;
}

.image-source-btn.cancel {
    justify-content: center;
    color: var(--color-text-secondary);
    margin-top: var(--spacing-sm);
}

.image-source-btn.cancel:hover {
    color: var(--color-text);
}

/* =====================================================
   MOBILE NAVIGATION & RESPONSIVE DESIGN
   ===================================================== */

/* Mobile Header - Hidden by default, shown on mobile */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 1000;
    padding: 0 var(--spacing-md);
    align-items: center;
    justify-content: space-between;
}

.mobile-header-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-weight: 700;
    font-size: var(--font-size-lg);
    color: var(--color-text);
}

.mobile-header-logo .logo-icon {
    width: 28px;
    height: 28px;
    color: var(--color-primary);
}

.mobile-header-actions {
    display: flex;
    gap: var(--spacing-xs);
}

.mobile-header-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-header-btn:hover,
.mobile-header-btn:active {
    background: var(--color-background);
    color: var(--color-text);
}

.mobile-header-btn svg {
    width: 22px;
    height: 22px;
}

/* Mobile Bottom Navigation */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 1000;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
    justify-content: space-around;
    align-items: center;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: var(--spacing-xs) var(--spacing-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s;
    min-width: 64px;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item svg {
    width: 24px;
    height: 24px;
    transition: transform 0.2s;
}

.mobile-nav-item.active {
    color: var(--color-primary);
}

.mobile-nav-item.active svg {
    transform: scale(1.1);
}

.mobile-nav-item:active {
    transform: scale(0.95);
}

/* Floating Action Button in Nav */
.mobile-nav-fab {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent-primary));
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    transform: translateY(-12px);
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-fab svg {
    width: 28px;
    height: 28px;
}

.mobile-nav-fab:active {
    transform: translateY(-12px) scale(0.95);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* =====================================================
   MOBILE RESPONSIVE BREAKPOINT
   ===================================================== */

@media (max-width: 768px) {

    /* Show mobile elements */
    .mobile-nav {
        display: flex;
    }

    .mobile-header {
        display: flex;
    }

    /* Hide desktop sidebar */
    .sidebar {
        display: none;
    }

    /* Adjust main content */
    .main-content {
        margin-left: 0;
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0) + var(--spacing-md));
        padding-top: calc(56px + var(--spacing-md));
    }

    /* Hide desktop top bar search on mobile - use mobile header instead */
    .top-bar {
        display: none;
    }

    /* Hide Quick Add buttons on mobile - FAB in bottom nav instead */
    .view-header .btn-primary {
        display: none;
    }

    /* Adjust content sections padding */
    .content-section {
        padding: var(--spacing-md);
    }

    /* Dashboard Grid - Stack on mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    .stat-card {
        padding: var(--spacing-md);
    }

    .stat-value {
        font-size: var(--font-size-xl);
    }

    /* Activity Section */
    .activity-section {
        grid-template-columns: 1fr;
    }

    /* Item Grid - 2 columns on mobile */
    .items-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    .item-card {
        padding: var(--spacing-sm);
    }

    .item-image {
        height: 120px;
    }

    .item-title {
        font-size: var(--font-size-sm);
    }

    /* Modals - Positioned between header and bottom nav (defined in earlier media query) */
    /* Additional modal size variants */
    .modal-content.modal-medium,
    .modal-content.modal-small {
        /* These variants still fill the available space between header/nav */
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    /* Quick Add Modal - Better mobile layout */
    .quick-add-layout {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-md);
    }

    .quick-add-left,
    .quick-add-right {
        width: 100%;
        max-width: 100%;
    }

    .drop-zone {
        min-height: 150px;
        height: auto;
        padding: var(--spacing-lg);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .drop-zone .drop-icon {
        width: 48px;
        height: 48px;
        margin-bottom: var(--spacing-sm);
    }

    .drop-zone .drop-text {
        font-size: var(--font-size-sm);
        margin-bottom: var(--spacing-xs);
    }

    .drop-zone .drop-subtext {
        font-size: var(--font-size-xs);
    }

    /* AI Detection Badge - inside drop zone area */
    .quick-add-left .ai-detection {
        margin-top: var(--spacing-sm);
        width: 100%;
        text-align: center;
    }

    .quick-add-left .detection-badge {
        font-size: var(--font-size-xs);
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    /* Form inputs - Larger touch targets */
    .form-input,
    .form-select {
        padding: var(--spacing-md);
        font-size: 16px;
        /* Prevents zoom on iOS */
        min-height: 48px;
    }

    .btn {
        min-height: 48px;
        padding: var(--spacing-md) var(--spacing-lg);
        font-size: var(--font-size-md);
    }

    /* Settings View */
    .settings-card {
        padding: var(--spacing-md);
    }

    /* Lending View */
    .lending-layout {
        flex-direction: column;
    }

    .lending-form,
    .lending-info {
        width: 100%;
    }

    /* Detail Modal */
    .detail-layout {
        flex-direction: column;
    }

    .detail-image-container {
        height: 250px;
    }

    /* Location Grid */
    .locations-grid {
        grid-template-columns: 1fr;
    }

    /* QR Code Display */
    .qr-code-display {
        padding: var(--spacing-md);
    }

    .qr-code-display svg {
        max-width: 200px;
    }

    /* Tabs - Scrollable on mobile */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: var(--spacing-xs);
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        white-space: nowrap;
        flex-shrink: 0;
        padding: var(--spacing-sm) var(--spacing-md);
    }

    /* Hide less important elements on mobile */
    .nav-section {
        display: none;
    }

    /* Toast notifications - Bottom positioned above nav */
    .toast {
        bottom: calc(80px + env(safe-area-inset-bottom, 0));
        left: var(--spacing-md);
        right: var(--spacing-md);
        max-width: calc(100% - var(--spacing-md) * 2);
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 375px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

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

    .mobile-nav-item {
        min-width: 50px;
        font-size: 10px;
    }

    .mobile-nav-fab {
        width: 48px;
        height: 48px;
    }

    .mobile-nav-fab svg {
        width: 24px;
        height: 24px;
    }
}

/* Tablet Portrait */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 80px;
    }

    .sidebar .logo-text,
    .sidebar .nav-item span,
    .sidebar .nav-section-header span {
        display: none;
    }

    .main-content {
        margin-left: 80px;
    }

    .nav-item {
        justify-content: center;
        padding: var(--spacing-md);
    }

    .nav-icon {
        margin-right: 0;
    }
}

/* Safe area for iOS notch/home indicator */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .main-content {
        padding-bottom: calc(64px + env(safe-area-inset-bottom) + var(--spacing-md));
    }
}

/* Dark mode adjustments for mobile */
@media (prefers-color-scheme: dark) {
    .mobile-header {
        background: rgba(30, 30, 30, 0.85);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .mobile-nav {
        background: rgba(30, 30, 30, 0.85);
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* =====================================================
   MOBILE DASHBOARD OPTIMIZATIONS
   ===================================================== */

/* Mobile Quick Stats - 2x2 Grid */
.mobile-quick-stats {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
    padding: 0 var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.mobile-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    text-align: center;
}

.mobile-stat-card .mobile-stat-value {
    font-weight: 700;
    font-size: var(--font-size-xl);
    color: var(--color-primary);
    line-height: 1;
}

.mobile-stat-card .mobile-stat-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    margin-top: 4px;
}

.mobile-stat-card.warning {
    background: var(--color-warning-bg);
    border-color: var(--color-warning);
}

.mobile-stat-card.warning .mobile-stat-value {
    color: var(--color-warning);
}

/* Smart Collections Horizontal Scroll */
.smart-collections-scroll {
    display: flex;
    gap: var(--spacing-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 var(--spacing-md);
    padding-bottom: var(--spacing-xs);
}

.smart-collections-scroll::-webkit-scrollbar {
    display: none;
}

.smart-collection-chip {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent-primary));
    color: white;
    border-radius: var(--radius-lg);
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.smart-collection-chip:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.smart-collection-chip svg {
    width: 16px;
    height: 16px;
}

.smart-collection-chip .chip-count {
    background: rgba(255, 255, 255, 0.25);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
}

/* Mobile Smart Collections Section */
.mobile-smart-collections {
    display: none;
}

/* Inventory Smart Collections - hidden on desktop */
.inventory-smart-collections {
    display: none;
}

/* Mobile Filter Bar - hidden on desktop */
.mobile-filter-bar {
    display: none;
}

/* Desktop only helper */
.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-quick-stats {
        display: grid;
    }

    /* Smart Collections im Dashboard ausblenden - nur im Inventar zeigen */
    .mobile-smart-collections {
        display: none;
    }

    /* Hide view header title on mobile - already shown in mobile header */
    .view-header h1 {
        display: none;
    }

    .view-header {
        justify-content: flex-end;
        padding: var(--spacing-sm) var(--spacing-md);
        min-height: auto;
    }

    /* Compact sections on mobile */
    .section {
        margin-bottom: var(--spacing-md);
    }

    .section-header {
        padding: 0 var(--spacing-md);
        margin-bottom: var(--spacing-sm);
    }

    .section-header h2 {
        font-size: var(--font-size-md);
    }

    /* Items scroll improvements */
    .items-scroll {
        padding: 0 var(--spacing-md);
        gap: var(--spacing-sm);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .items-scroll::-webkit-scrollbar {
        display: none;
    }

    .items-scroll .item-card {
        flex: 0 0 130px;
        min-width: 130px;
        max-width: 130px;
    }

    .items-scroll .item-image {
        height: 90px;
    }

    .items-scroll .item-info {
        padding: var(--spacing-sm);
    }

    .items-scroll .item-name {
        font-size: var(--font-size-sm);
        line-height: 1.2;
    }

    .items-scroll .item-meta {
        font-size: var(--font-size-xs);
        display: none;
        /* Hide meta on mobile for compactness */
    }

    /* Hide categories overview on mobile - use Smart Collections instead */
    #categories-container {
        display: none;
    }

    /* Compact main content padding - extra space for bottom nav */
    .main-content {
        padding: 0;
        padding-top: var(--mobile-header-height);
        padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
        min-height: 100vh;
    }

    /* Ensure view containers can scroll properly */
    .view-container {
        padding: var(--spacing-sm);
        padding-bottom: var(--spacing-lg);
    }

    /* Inventory view specific mobile styles */
    #inventory-view .view-header {
        display: none;
    }

    #inventory-view .inventory-layout {
        gap: var(--spacing-sm);
    }

    /* Hide filter panel on mobile - use mobile filter bar instead */
    #inventory-view .filter-panel {
        display: none;
    }

    /* Items grid container - tighter spacing */
    #inventory-view .items-grid-container {
        width: 100%;
    }

    #inventory-view .items-grid-header {
        padding: 0 var(--spacing-xs);
        margin-bottom: var(--spacing-sm);
    }

    /* Inventory items grid - 2 columns */
    #inventory-view .items-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    /* Inventory item cards - compact */
    .inventory-item-card {
        border-radius: var(--radius-md);
    }

    .inventory-item-image {
        height: 120px;
    }

    .inventory-item-info {
        padding: var(--spacing-sm);
    }

    .inventory-item-name {
        font-size: var(--font-size-sm);
        line-height: 1.3;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .inventory-item-category {
        display: none;
    }

    .inventory-item-location {
        display: none;
    }

    .inventory-item-status {
        font-size: 10px;
        padding: 2px 6px;
    }

    /* ===== MOBILE INVENTORY FILTERS ===== */
    /* Hide desktop filter sidebar */
    .filter-chips {
        display: none;
    }

    /* Mobile filter bar */
    .mobile-filter-bar {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-sm);
        padding: 0 var(--spacing-md);
        margin-bottom: var(--spacing-md);
    }

    .mobile-filter-row {
        display: flex;
        gap: var(--spacing-xs);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .mobile-filter-row::-webkit-scrollbar {
        display: none;
    }

    .mobile-filter-chip {
        display: flex;
        align-items: center;
        gap: 4px;
        padding: 8px 14px;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-full);
        font-size: var(--font-size-sm);
        color: var(--color-text-secondary);
        white-space: nowrap;
        flex-shrink: 0;
        cursor: pointer;
        transition: all 0.2s;
    }

    .mobile-filter-chip.active {
        background: var(--color-primary);
        border-color: var(--color-primary);
        color: white;
    }

    .mobile-filter-chip:active {
        transform: scale(0.95);
    }

    /* Smart Collections im Inventar */
    .inventory-smart-collections {
        display: block;
        margin-bottom: var(--spacing-md);
    }

    .inventory-smart-collections .smart-collections-scroll {
        padding: 0 var(--spacing-md);
    }
}