/* ========================================
   EINKAUFSLISTE PWA - MAIN STYLESHEET
   Mobile-First, iOS-like Design
   ======================================== */

/* CSS Custom Properties */
:root {
    /* Colors - Light Mode */
    --color-primary: #6366f1;
    --color-primary-dark: #4f46e5;
    --color-primary-light: #818cf8;
    --color-success: #22c55e;
    --color-success-light: #4ade80;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-danger-light: #fca5a5;
    
    --color-bg: #f8fafc;
    --color-bg-secondary: #ffffff;
    --color-bg-tertiary: #f1f5f9;
    --color-surface: #ffffff;
    --color-surface-elevated: #ffffff;
    
    --color-text: #0f172a;
    --color-text-secondary: #64748b;
    --color-text-tertiary: #94a3b8;
    --color-text-inverse: #ffffff;
    
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;
    --color-divider: #e2e8f0;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* 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;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 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: 1.875rem;
    
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* Z-Index */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-bottom-nav: 250;
    --z-modal-backdrop: 300;
    --z-modal: 400;
    --z-toast: 500;
    
    /* Layout */
    --nav-height: 56px;
    --bottom-nav-height: 64px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-top: env(safe-area-inset-top, 0px);
}

/* Dark Mode */
[data-theme="dark"] {
    --color-bg: #0f172a;
    --color-bg-secondary: #1e293b;
    --color-bg-tertiary: #334155;
    --color-surface: #1e293b;
    --color-surface-elevated: #334155;
    
    --color-text: #f8fafc;
    --color-text-secondary: #94a3b8;
    --color-text-tertiary: #64748b;
    
    --color-border: #334155;
    --color-border-light: #475569;
    --color-divider: #334155;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

/* Dark Mode Input Fix */
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea {
    background-color: var(--color-bg-tertiary);
    color: var(--color-text);
    border-color: var(--color-border);
}

/* ========================================
   BASE STYLES
   ======================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-x pan-y;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.modal-open {
    overflow: hidden;
}

/* ========================================
   APP LAYOUT
   ======================================== */

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--spacing-md);
    padding-top: calc(var(--spacing-md) + var(--safe-area-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.app-header h1 {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    flex: 1;
}

.app-header .header-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.app-main {
    flex: 1;
    padding: var(--spacing-md);
    padding-bottom: calc(var(--bottom-nav-height) + var(--spacing-xl) + var(--spacing-xl) + var(--spacing-xl) + 40px + var(--safe-area-bottom));
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* ========================================
   BOTTOM NAVIGATION
   ======================================== */

.bottom-nav,
.nav-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-bottom-nav);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding-bottom: var(--safe-area-bottom);
    display: flex;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm) var(--spacing-xs);
    min-height: var(--bottom-nav-height);
    color: var(--color-text-tertiary);
    text-decoration: none;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    border: none;
    background: none;
}

.nav-item:hover,
.nav-item:focus {
    color: var(--color-text-secondary);
}

.nav-item.active {
    color: var(--color-primary);
}

.nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 2px;
}

.nav-item span {
    display: block;
}

/* ========================================
   BUTTONS
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    line-height: 1;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    min-height: 44px;
}

.btn:hover:not(:disabled) {
    background: var(--color-bg-tertiary);
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    color: var(--color-text-inverse);
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

.btn-success {
    color: var(--color-text-inverse);
    background: var(--color-success);
    border-color: var(--color-success);
}

.btn-danger {
    color: var(--color-text-inverse);
    background: var(--color-danger);
    border-color: var(--color-danger);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--color-bg-tertiary);
}

.btn-icon {
    padding: var(--spacing-sm);
    width: 44px;
    height: 44px;
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: var(--font-size-base);
    min-height: 52px;
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-xs);
    min-height: 36px;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* FAB (Floating Action Button) */
.fab {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--spacing-md) + var(--safe-area-bottom));
    right: var(--spacing-md);
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: var(--z-dropdown);
}

.fab:hover {
    background: var(--color-primary-dark);
    transform: scale(1.05);
}

.fab:active {
    transform: scale(0.95);
}

.fab svg {
    width: 28px;
    height: 28px;
}

/* ========================================
   FORM ELEMENTS
   ======================================== */

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
}

.form-input,
.form-select,
.form-textarea {
    display: block;
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: inherit;
    font-size: var(--font-size-base);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    min-height: 48px;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input::placeholder {
    color: var(--color-text-tertiary);
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--spacing-md) center;
    padding-right: calc(var(--spacing-md) + 24px);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
}

.form-hint {
    margin-top: var(--spacing-xs);
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
}

.form-error {
    margin-top: var(--spacing-xs);
    font-size: var(--font-size-xs);
    color: var(--color-danger);
}

/* Checkbox & Toggle */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 22px;
    height: 22px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background: var(--color-surface);
    transition: all var(--transition-fast);
}

.checkbox-wrapper input[type="checkbox"]:checked {
    background: var(--color-primary);
    border-color: var(--color-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

.toggle {
    position: relative;
    width: 50px;
    height: 30px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.toggle input {
    display: none;
}

.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast);
}

.toggle.active {
    background: var(--color-primary);
}

.toggle.active::after {
    transform: translateX(20px);
}

/* ========================================
   CARDS
   ======================================== */

.card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
}

.card-header h2,
.card-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

.card-body {
    padding: var(--spacing-md);
}

.card-footer {
    padding: var(--spacing-md);
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
}

/* ========================================
   SHOPPING LIST ITEMS
   ======================================== */

.item-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    padding: 0 var(--spacing-sm);
}

.item-category-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    margin-top: var(--spacing-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
}

.item-category-header:first-child {
    margin-top: 0;
}

.item-category-header .category-icon {
    font-size: var(--font-size-lg);
}

.item-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.item-card:active {
    transform: scale(0.99);
    background: var(--color-bg-tertiary);
}

.item-card.checked {
    opacity: 0.6;
}

.item-card.checked .item-name {
    text-decoration: line-through;
    color: var(--color-text-secondary);
}

.item-checkbox {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.item-card.checked .item-checkbox {
    background: var(--color-success);
    border-color: var(--color-success);
    color: white;
}

.item-content {
    flex: 1;
    min-width: 0;
}

.item-name {
    font-weight: var(--font-weight-medium);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.item-meta .badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
}

.item-quantity {
    font-weight: var(--font-weight-semibold);
    color: var(--color-primary);
}

.item-price {
    color: var(--color-success);
    font-weight: var(--font-weight-medium);
}

.item-actions {
    flex-shrink: 0;
    display: flex;
    gap: var(--spacing-xs);
}

.item-actions .btn-icon {
    width: 36px;
    height: 36px;
    padding: var(--spacing-xs);
    color: var(--color-text-tertiary);
}

/* ==================== NEUE ITEM CARD STRUKTUR ==================== */

/* Swipe Container - nur für die Swipe-Hintergründe */
.item-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
}

/* Das ist die sichtbare Card die sich beim Swipen bewegt */
.item-inner {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    width: 100%;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

/* Schatten und Umrandung nur beim Swipen sichtbar */
.item-card.swiping-left .item-inner,
.item-card.swiping-right .item-inner {
    box-shadow: var(--shadow-md);
}

/* Swipe Backgrounds */
.swipe-background {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.swipe-left-bg {
    right: 0;
    justify-content: flex-end;
    background: linear-gradient(to left, var(--color-danger) 0%, var(--color-danger) 50%, transparent 100%);
    color: white;
}

.swipe-right-bg {
    left: 0;
    justify-content: flex-start;
    background: linear-gradient(to right, var(--color-primary) 0%, var(--color-primary) 50%, transparent 100%);
    color: white;
}

.swipe-icon {
    font-size: 1.5rem;
    margin: 0 var(--spacing-sm);
}

.item-card.swiping-left .swipe-left-bg,
.item-card.swiping-right .swipe-right-bg {
    opacity: 1;
}

/* Checkout Bar (fixed above footer) */
.checkout-bar {
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    z-index: 90;
}

/* Item Content in neuer Struktur */
.item-inner .item-content {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.item-inner .item-checkbox {
    cursor: pointer;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
    text-align: center;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    color: var(--color-text-tertiary);
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state h3 {
    margin: 0 0 var(--spacing-sm);
    color: var(--color-text-secondary);
}

.empty-state p {
    margin: 0;
    color: var(--color-text-tertiary);
    font-size: var(--font-size-sm);
}

/* ========================================
   QUICK ADD
   ======================================== */

.quick-add {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.quick-add .form-input {
    flex: 1;
}

.quick-add .btn {
    flex-shrink: 0;
}

/* ========================================
   STORE SELECTOR
   ======================================== */

.store-selector {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    padding: var(--spacing-md);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-md);
}

.store-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--color-bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.store-chip:hover {
    background: var(--color-bg-secondary);
}

.store-chip.selected {
    border-color: var(--color-primary);
    background: rgba(99, 102, 241, 0.1);
}

.store-chip .store-icon {
    font-size: var(--font-size-base);
}

/* ========================================
   MODAL
   ======================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-modal);
    background: var(--color-surface);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    max-height: 90vh;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform var(--transition-slow), visibility var(--transition-slow);
    padding-bottom: var(--safe-area-bottom);
    visibility: hidden;
}

.modal.active {
    transform: translateY(0);
    visibility: visible;
}

.modal-handle {
    width: 36px;
    height: 4px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    margin: var(--spacing-sm) auto;
    flex-shrink: 0;
}

.modal-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

.modal-body {
    flex: 1;
    padding: var(--spacing-md);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    padding: var(--spacing-md);
    padding-bottom: calc(var(--spacing-md) + var(--safe-area-bottom));
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: var(--spacing-sm);
    flex-shrink: 0;
}

.modal-footer .btn {
    flex: 1;
}

/* Full Modal (for desktop) */
@media (min-width: 640px) {
    .modal {
        bottom: auto;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0;
        max-width: 500px;
        width: calc(100% - 2 * var(--spacing-lg));
        max-height: 80vh;
        border-radius: var(--radius-2xl);
    }
    
    .modal.active {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    
    .modal-handle {
        display: none;
    }
}

/* ========================================
   TOAST / SNACKBAR
   ======================================== */

.toast-container {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--spacing-md) + var(--safe-area-bottom));
    left: var(--spacing-md);
    right: var(--spacing-md);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    pointer-events: none;
}

.toast-container:empty {
    display: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: #1e293b;
    color: #f8fafc;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toastIn var(--transition-slow) ease-out;
}

[data-theme="dark"] .toast {
    background: #334155;
    color: #f8fafc;
}

.toast.out {
    animation: toastOut var(--transition-normal) ease-in forwards;
}

.toast-message {
    flex: 1;
    font-size: var(--font-size-sm);
}

.toast-action {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--color-primary-light);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    cursor: pointer;
    padding: var(--spacing-xs) var(--spacing-sm);
}

@keyframes toastIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

/* ========================================
   LOGIN / KEYPAD
   ======================================== */

.login-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
}

.login-logo {
    width: 80px;
    height: 80px;
    margin-bottom: var(--spacing-lg);
    background: white;
    border-radius: var(--radius-2xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    box-shadow: var(--shadow-lg);
}

.login-title {
    color: white;
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    margin: 0 0 var(--spacing-xs);
    text-align: center;
}

.login-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: var(--font-size-sm);
    margin: 0 0 var(--spacing-xl);
    text-align: center;
}

.pin-dots {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.pin-dot {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-full);
    background: transparent;
    transition: all var(--transition-fast);
}

.pin-dot.filled {
    background: white;
    border-color: white;
    animation: pinPop 150ms ease-out;
}

.pin-dot.error {
    border-color: var(--color-danger-light);
    background: var(--color-danger-light);
    animation: pinShake 300ms ease-in-out;
}

@keyframes pinPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

@keyframes pinShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
    max-width: 280px;
}

.keypad-btn {
    width: 72px;
    height: 72px;
    border: none;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.keypad-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.keypad-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.35);
}

.keypad-btn.empty {
    background: transparent;
    cursor: default;
}

.keypad-btn.delete svg {
    width: 28px;
    height: 28px;
}

.login-error {
    color: var(--color-danger-light);
    font-size: var(--font-size-sm);
    margin-top: var(--spacing-md);
    text-align: center;
    min-height: 20px;
}

.login-locked {
    color: rgba(255, 255, 255, 0.8);
    font-size: var(--font-size-sm);
    margin-top: var(--spacing-md);
    text-align: center;
}

/* ========================================
   AUTOCOMPLETE / SUGGESTIONS
   ======================================== */

.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: var(--z-dropdown);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 250px;
    overflow-y: auto;
    display: none;
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background: var(--color-bg-tertiary);
}

.autocomplete-item-icon {
    font-size: var(--font-size-lg);
}

.autocomplete-item-content {
    flex: 1;
    min-width: 0;
}

.autocomplete-item-name {
    font-weight: var(--font-weight-medium);
}

.autocomplete-item-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
}

/* ========================================
   HISTORY
   ======================================== */

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.history-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.history-card:active {
    transform: scale(0.99);
    background: var(--color-bg-tertiary);
}

.history-date {
    flex-shrink: 0;
    text-align: center;
    width: 50px;
}

.history-date .day {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    line-height: 1;
    color: var(--color-primary);
}

.history-date .month {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    text-transform: uppercase;
}

.history-content {
    flex: 1;
    min-width: 0;
}

.history-stores {
    display: flex;
    gap: var(--spacing-xs);
    margin-bottom: 4px;
}

.history-stores .store-icon {
    font-size: var(--font-size-base);
}

.history-preview {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    flex-shrink: 0;
    text-align: right;
}

.history-total {
    font-weight: var(--font-weight-semibold);
    color: var(--color-success);
}

.history-count {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
}

/* ========================================
   STATISTICS
   ======================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    padding: var(--spacing-md);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
    line-height: 1;
    margin-bottom: var(--spacing-xs);
}

.stat-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

.stat-card.highlight {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
}

.stat-card.highlight .stat-value,
.stat-card.highlight .stat-label {
    color: white;
}

/* Charts */
.chart-container {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-sm);
}

.chart-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-md);
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.bar-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.bar-label {
    width: 100px;
    font-size: var(--font-size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-track {
    flex: 1;
    height: 24px;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-sm);
    transition: width var(--transition-slow);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: var(--spacing-sm);
    min-width: fit-content;
}

.bar-value {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: white;
}

/* ========================================
   ADMIN
   ======================================== */

.admin-section {
    margin-bottom: var(--spacing-xl);
}

.admin-section-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-sm);
    padding: 0 var(--spacing-sm);
}

.admin-list {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.admin-list-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.admin-list-item:last-child {
    border-bottom: none;
}

.admin-list-item:hover {
    background: var(--color-bg-tertiary);
}

.admin-list-item .icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    font-size: var(--font-size-xl);
}

.admin-list-item .content {
    flex: 1;
}

.admin-list-item .title {
    font-weight: var(--font-weight-medium);
}

.admin-list-item .subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.admin-list-item .arrow {
    color: var(--color-text-tertiary);
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item .label {
    font-weight: var(--font-weight-medium);
}

.settings-item .value {
    color: var(--color-text-secondary);
}

/* ========================================
   LOADING & SKELETON
   ======================================== */

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

[data-theme="dark"] .loading-overlay {
    background: rgba(15, 23, 42, 0.8);
}

.skeleton {
    background: linear-gradient(90deg, var(--color-bg-tertiary) 25%, var(--color-bg-secondary) 50%, var(--color-bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   UTILITIES
   ======================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center { text-align: center; }
.text-right { text-align: right; }

.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-muted { color: var(--color-text-secondary); }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

.hidden { display: none !important; }

/* ========================================
   ADMIN DROPDOWN MENUS
   ======================================== */

.admin-dropdown {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.admin-dropdown-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.admin-dropdown-header:hover {
    background: var(--color-bg-tertiary);
}

.admin-dropdown-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
}

.admin-dropdown-content {
    flex: 1;
}

.admin-dropdown-title {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-base);
}

.admin-dropdown-subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.admin-dropdown-arrow {
    transition: transform var(--transition-normal);
}

.admin-dropdown.open .admin-dropdown-arrow {
    transform: rotate(180deg);
}

.admin-dropdown-body {
    display: none;
    padding: var(--spacing-md);
    padding-top: 0;
    border-top: 1px solid var(--color-border);
    max-height: none;
    overflow: visible;
}

.admin-dropdown.open .admin-dropdown-body {
    display: block;
    max-height: none;
    overflow: visible;
}

.admin-dropdown-items {
    max-height: 300px;
    overflow-y: auto;
}

.admin-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-xs);
}

.admin-dropdown-item:hover {
    background: var(--color-bg-tertiary);
}

.admin-item-actions {
    display: flex;
    gap: var(--spacing-xs);
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Desktop Adjustments */
@media (min-width: 640px) {
    .app-main {
        padding: var(--spacing-lg);
        padding-bottom: calc(var(--bottom-nav-height) + var(--spacing-xl) + var(--spacing-xl) + 40px + var(--safe-area-bottom));
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
