/* ========================================
   CSS Variables & Reset
======================================== */
:root {
    /* Primary colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-50: rgba(99, 102, 241, 0.05);
    --success: #22c55e;
    --success-dark: #16a34a;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --warning: #f59e0b;

    /* Gray scale - Light mode */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Semantic colors - Light mode */
    --bg: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f3f4f6;

    /* Card & surface colors */
    --card-bg: #ffffff;
    --card-hover: #f9fafb;
    --input-bg: #ffffff;
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --loading-overlay-bg: rgba(255, 255, 255, 0.85);

    /* Shadows - Light mode */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --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);

    /* Layout */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --header-height: 56px;
    --max-width: 600px;

    /* Animation */
    --transition: 0.2s ease;

    /* Badge colors - Light mode */
    --badge-admin-bg: #dbeafe;
    --badge-admin-text: #1e40af;
    --badge-pending-bg: #fef3c7;
    --badge-pending-text: #92400e;
    --badge-done-bg: #d1fae5;
    --badge-done-text: #065f46;
    --badge-danger-bg: #fef2f2;
    --badge-danger-text: #991b1b;
    --checked-bg: #dcfce7;
    --checked-bg-light: #f0fdf4;

    /* Color scheme indicator */
    color-scheme: light dark;
}

/* ========================================
   Dark Mode (system preference)
======================================== */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        /* Gray scale - Dark mode (inverted) */
        --gray-50: #18181b;
        --gray-100: #27272a;
        --gray-200: #3f3f46;
        --gray-300: #52525b;
        --gray-400: #71717a;
        --gray-500: #a1a1aa;
        --gray-600: #d4d4d8;
        --gray-700: #e4e4e7;
        --gray-800: #f4f4f5;
        --gray-900: #fafafa;

        /* Semantic colors - Dark mode */
        --bg: #09090b;
        --bg-secondary: #18181b;
        --bg-tertiary: #27272a;
        --text: #fafafa;
        --text-secondary: #a1a1aa;
        --text-muted: #71717a;
        --border: #3f3f46;
        --border-light: #27272a;

        /* Card & surface colors - Dark mode */
        --card-bg: #18181b;
        --card-hover: #27272a;
        --input-bg: #27272a;
        --overlay-bg: rgba(0, 0, 0, 0.75);
        --loading-overlay-bg: rgba(9, 9, 11, 0.85);

        /* Primary colors - Slightly adjusted for dark mode */
        --primary: #818cf8;
        --primary-dark: #6366f1;
        --primary-light: #a5b4fc;
        --primary-50: rgba(129, 140, 248, 0.1);

        /* Status colors - Adjusted for dark mode contrast */
        --success: #4ade80;
        --success-dark: #22c55e;
        --danger: #f87171;
        --danger-dark: #ef4444;
        --warning: #fbbf24;

        /* Badge colors - Dark mode */
        --badge-admin-bg: #1e3a5f;
        --badge-admin-text: #93c5fd;
        --badge-pending-bg: #451a03;
        --badge-pending-text: #fcd34d;
        --badge-done-bg: #052e16;
        --badge-done-text: #86efac;
        --badge-danger-bg: #450a0a;
        --badge-danger-text: #fca5a5;
        --checked-bg: #052e16;
        --checked-bg-light: #052e16;

        /* Shadows - Dark mode (subtler, using highlights) */
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
        --shadow: 0 1px 3px rgba(0,0,0,0.4), 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);

        color-scheme: dark;
    }
}

/* ========================================
   Dark Mode (manual toggle)
======================================== */
:root[data-theme="dark"] {
    /* Gray scale - Dark mode (inverted) */
    --gray-50: #18181b;
    --gray-100: #27272a;
    --gray-200: #3f3f46;
    --gray-300: #52525b;
    --gray-400: #71717a;
    --gray-500: #a1a1aa;
    --gray-600: #d4d4d8;
    --gray-700: #e4e4e7;
    --gray-800: #f4f4f5;
    --gray-900: #fafafa;

    /* Semantic colors - Dark mode */
    --bg: #09090b;
    --bg-secondary: #18181b;
    --bg-tertiary: #27272a;
    --text: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --border: #3f3f46;
    --border-light: #27272a;

    /* Card & surface colors - Dark mode */
    --card-bg: #18181b;
    --card-hover: #27272a;
    --input-bg: #27272a;
    --overlay-bg: rgba(0, 0, 0, 0.75);
    --loading-overlay-bg: rgba(9, 9, 11, 0.85);

    /* Primary colors - Slightly adjusted for dark mode */
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-light: #a5b4fc;
    --primary-50: rgba(129, 140, 248, 0.1);

    /* Status colors - Adjusted for dark mode contrast */
    --success: #4ade80;
    --success-dark: #22c55e;
    --danger: #f87171;
    --danger-dark: #ef4444;
    --warning: #fbbf24;

    /* Badge colors - Dark mode */
    --badge-admin-bg: #1e3a5f;
    --badge-admin-text: #93c5fd;
    --badge-pending-bg: #451a03;
    --badge-pending-text: #fcd34d;
    --badge-done-bg: #052e16;
    --badge-done-text: #86efac;
    --badge-danger-bg: #450a0a;
    --badge-danger-text: #fca5a5;
    --checked-bg: #052e16;
    --checked-bg-light: #052e16;

    /* Shadows - Dark mode (subtler, using highlights) */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 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);

    color-scheme: dark;
}

/* Theme transition */
html {
    transition: background-color 0.3s ease, color 0.3s ease;
}

html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

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

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ========================================
   Utilities
======================================== */
.hidden { display: none !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-muted { color: var(--text-muted) !important; }

/* ========================================
   Buttons
======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--gray-200);
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover:not(:disabled) {
    background: var(--success-dark);
}

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover:not(:disabled) {
    background: var(--danger-dark);
}

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

.btn-full {
    width: 100%;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-icon:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

/* ========================================
   Form Elements
======================================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.checkbox-group label {
    margin-bottom: 0;
}

.error-text {
    color: var(--danger);
    font-size: 14px;
    margin-top: 8px;
}

/* ========================================
   Login Screen
======================================== */
#login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 50%, #ec4899 100%);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.login-container {
    width: 100%;
    max-width: 400px;
    background: var(--bg);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.login-header {
    text-align: center;
    padding: 40px 24px 32px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.logo {
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
}

.login-header p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    margin: 0;
}

.login-form {
    padding: 32px 24px;
}

/* ========================================
   App Header
======================================== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-left h1 {
    font-size: 18px;
    font-weight: 600;
    margin-left: 8px;
}

/* ========================================
   Dropdown Menu
======================================== */
.dropdown-menu {
    position: fixed;
    top: calc(var(--header-height) + 4px);
    right: 8px;
    width: 220px;
    background: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 200;
    overflow: hidden;
}

.dropdown-header {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dropdown-header span:first-child {
    font-weight: 500;
    font-size: 14px;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.dropdown-item:hover {
    background: var(--gray-50);
}

.dropdown-item.text-danger:hover {
    background: var(--badge-danger-bg);
}

/* Language Selector */
.dropdown-item.language-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.dropdown-item.language-selector span {
    flex: 1;
}

.language-dropdown {
    padding: 4px 8px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    cursor: pointer;
    min-width: 100px;
}

.language-dropdown:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-50);
}

/* ========================================
   Badge
======================================== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 100px;
    background: var(--gray-100);
    color: var(--gray-600);
}

.badge.admin {
    background: var(--badge-admin-bg);
    color: var(--badge-admin-text);
}

.badge.superadmin {
    background: #dc2626;
    color: white;
}

.badge.pending {
    background: var(--badge-pending-bg);
    color: var(--badge-pending-text);
}

.badge.done {
    background: var(--badge-done-bg);
    color: var(--badge-done-text);
}

.badge.skipped {
    background: var(--gray-200);
    color: var(--gray-600);
}

/* ========================================
   Content Area
======================================== */
.content {
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    padding: 16px;
    max-width: var(--max-width);
    margin-left: auto;
    margin-right: auto;
}

.view {
    animation: fadeIn 0.2s ease;
}

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

/* ========================================
   Lists
======================================== */
.list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.list-item:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.list-item-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
    font-size: 20px;
    flex-shrink: 0;
}

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

.list-item-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 2px;
}

.list-item-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-item-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.list-item-actions .btn-sm {
    padding: 4px 8px;
    font-size: 11px;
}

.user-item .list-item-actions {
    gap: 6px;
}

.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--gray-700);
}

/* ========================================
   Tabs
======================================== */
.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--gray-100);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.tab {
    flex: 1;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition);
}

.tab.active {
    background: var(--bg);
    color: var(--gray-900);
    box-shadow: var(--shadow-sm);
}

/* ========================================
   FAB
======================================== */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: all var(--transition);
    z-index: 50;
}

.fab:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* ========================================
   Template Detail
======================================== */
.template-header {
    background: var(--bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

.template-header h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.template-header p {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    padding: 4px 10px;
    font-size: 12px;
    background: var(--primary);
    color: white;
    border-radius: 100px;
}

.template-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.template-actions .btn {
    flex: 1;
}

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

.steps-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
}

.step-item:hover {
    box-shadow: var(--shadow-md);
}

.step-item.dragging {
    opacity: 0.5;
    box-shadow: var(--shadow-lg);
}

.step-item.drag-over {
    border: 2px dashed var(--primary);
    background: var(--primary-50);
}

.step-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--gray-400);
    cursor: grab;
    flex-shrink: 0;
    border-radius: 4px;
    transition: all var(--transition);
}

.step-drag-handle:hover {
    color: var(--gray-600);
    background: var(--gray-100);
}

.step-drag-handle:active {
    cursor: grabbing;
}

.step-item .step-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    color: var(--gray-600);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.step-item .step-content {
    flex: 1;
    min-width: 0;
}

.step-item .step-title {
    font-weight: 500;
    margin-bottom: 2px;
}

.step-item .step-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ========================================
   Step Detail
======================================== */
.step-header {
    background: var(--bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

.step-header .step-number {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary);
    color: white;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

.step-header h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.step-header p {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.step-meta {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.step-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.media-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.media-section h3 {
    font-size: 16px;
    font-weight: 600;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.media-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    background: var(--gray-100);
}

.media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition);
}

.media-item:hover img {
    transform: scale(1.05);
}

.media-item.selectable {
    border: 2px solid transparent;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.media-item.selectable:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.media-item .annotation-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 11px;
    border-radius: 100px;
}

/* ========================================
   Media Viewer & Annotations
======================================== */
#media-viewer-view {
    position: fixed;
    top: var(--header-height, 56px);
    left: 0;
    width: 100vw;
    height: calc(100vh - var(--header-height, 56px));
    max-width: none;
    max-height: none;
    min-width: 0;
    min-height: 0;
    background: var(--gray-900);
    z-index: 100;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.media-viewer-container {
    width: 100vw;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--gray-900);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
}

.canvas-container .image-canvas-wrapper {
    position: relative;
    display: inline-block;
}

.canvas-container img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.canvas-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
}

body, html {
    overflow-x: hidden !important;
}

/* ========================================
   Instance Execution
======================================== */
.instance-header {
    background: var(--bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

.instance-header h2 {
    font-size: 20px;
    margin-bottom: 12px;
}

.instance-progress {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--gray-200);
    border-radius: 100px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 100px;
    transition: width 0.3s ease;
}

#instance-progress-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.instance-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.instance-step-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
}

.instance-step-item:hover {
    box-shadow: var(--shadow-md);
}

.instance-step-item .step-status {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 14px;
    flex-shrink: 0;
}

.instance-step-item .step-status.pending {
    background: var(--gray-200);
    color: var(--gray-500);
}

.instance-step-item .step-status.done {
    background: var(--success);
    color: white;
}

.instance-step-item .step-status.skipped {
    background: var(--gray-400);
    color: white;
}

.instance-step-item .step-content {
    flex: 1;
}

.instance-step-item .step-title {
    font-weight: 500;
}

.instance-step-item.completed {
    opacity: 0.6;
}

.instance-step-header {
    background: var(--bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

.instance-step-header .step-number {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary);
    color: white;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

.instance-step-header h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.instance-step-header p {
    color: var(--text-secondary);
}

.instance-step-actions {
    margin-top: 20px;
}

.instance-step-actions textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 12px;
}

.instance-step-actions textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.action-buttons {
    display: flex;
    gap: 12px;
}

.action-buttons .btn {
    flex: 1;
}

/* ========================================
   Search Overlay
======================================== */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 300;
}

.search-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 16px;
}

.search-header {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.search-header input {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}

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

.search-results {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-section h4 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.search-item {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
}

.search-item:hover {
    background: var(--gray-200);
}

.search-item-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.search-item-snippet {
    font-size: 13px;
    color: var(--text-secondary);
}

.search-item-snippet b {
    color: var(--primary);
    font-weight: 600;
}

/* ========================================
   Admin Panel
======================================== */
.admin-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--gray-100);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.admin-section {
    animation: fadeIn 0.2s ease;
}

.admin-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.admin-section h3 {
    font-size: 16px;
    font-weight: 600;
}

.member-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.add-member-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.add-member-section h4 {
    font-size: 14px;
    margin-bottom: 12px;
}

.add-member-section select {
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

/* ========================================
   Modal
======================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 400;
    animation: fadeIn 0.2s ease;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 32px);
    max-width: 400px;
    max-height: calc(100vh - 64px);
    background: var(--bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    z-index: 401;
    overflow: hidden;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

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

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: var(--radius);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

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

/* ========================================
   Toast
======================================== */
#toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    background: var(--gray-800);
    color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    animation: toastIn 0.3s ease;
    pointer-events: auto;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Loading
======================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--loading-overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 600;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========================================
   Responsive
======================================== */
@media (min-width: 768px) {
    .content {
        padding: 24px;
    }

    .login-container {
        padding: 48px;
    }

    .template-actions {
        max-width: 400px;
    }
}

/* ========================================
   Task Overview Timeline
======================================== */
.task-overview-header {
    background: var(--bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.task-overview-header h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.task-overview-header p {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.task-overview-meta {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 12px;
}

.task-overview-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-timeline {
    position: relative;
    padding-left: 0;
}

.timeline-steps {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.timeline-step {
    position: relative;
    padding-left: 48px;
    padding-bottom: 24px;
}

.timeline-step:last-child {
    padding-bottom: 0;
}

.timeline-step::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 32px;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}

.timeline-step:last-child::before {
    display: none;
}

.timeline-step-number {
    position: absolute;
    left: 0;
    top: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 600;
    z-index: 1;
}

.timeline-step-content {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.timeline-step-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.timeline-step-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.timeline-step-meta {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.timeline-step-images {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px 0;
}

.timeline-step-images::-webkit-scrollbar {
    height: 4px;
}

.timeline-step-images::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 2px;
}

.timeline-image-thumb {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    background: var(--gray-100);
    position: relative;
}

.timeline-image-thumb img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    transition: transform var(--transition);
}

.timeline-image-thumb:hover img {
    transform: scale(1.05);
}

.timeline-image-thumb canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.task-overview-actions {
    margin-top: 24px;
    padding: 0 0 24px 0;
}

/* ========================================
   Image Carousel Modal
======================================== */
.modal-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 500;
    display: flex;
    flex-direction: column;
}

.carousel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    color: white;
}

.carousel-counter {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

.carousel-close {
    color: white;
}

.carousel-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.carousel-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.carousel-image-wrapper {
    position: relative;
    display: inline-block;
}

.carousel-image-wrapper img {
    display: block;
    max-width: calc(100vw - 120px);
    max-height: calc(100vh - 100px);
    object-fit: contain;
}

.carousel-image-wrapper canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all var(--transition);
    z-index: 10;
}

.carousel-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.carousel-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.carousel-prev-btn {
    left: 16px;
}

.carousel-next-btn {
    right: 16px;
}

/* ========================================
   Tasks View
======================================== */
#tasks-view .list-item-meta {
    display: flex;
    gap: 12px;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.task-card-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    background: var(--warning);
    color: white;
    border-radius: 100px;
    margin-left: 8px;
}

/* Small screens carousel adjustments */
@media (max-width: 600px) {
    .carousel-nav {
        width: 40px;
        height: 40px;
    }

    .carousel-prev-btn {
        left: 8px;
    }

    .carousel-next-btn {
        right: 8px;
    }

    .carousel-image-wrapper img {
        max-width: calc(100vw - 80px);
    }

    .timeline-image-thumb {
        width: 64px;
        height: 64px;
    }
}

/* ========================================
   Freezer View
======================================== */
.freezer-header {
    padding: 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.freezer-header h2 {
    margin-bottom: 12px;
    font-size: 20px;
}

.freezer-nav-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    margin: 0 -16px -16px;
    padding: 0 16px;
}

.freezer-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

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

.freezer-tab:hover:not(.active) {
    color: var(--text);
}

.freezer-tab-content {
    padding: 16px;
}

.freezer-tab-content.hidden {
    display: none !important;
}

/* Freezer Selector */
.freezer-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.freezer-selector .btn {
    flex: 1;
    min-width: 120px;
}

.freezer-selector .btn.active {
    background: var(--primary);
    color: white;
}

/* Freezer Occupancy Bar */
.freezer-occupancy {
    margin-bottom: 16px;
}

.occupancy-bar {
    height: 32px;
    background: var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.occupancy-fill {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
    transition: width 0.3s ease;
}

.occupancy-fill.low {
    background: var(--success);
}

.occupancy-fill.medium {
    background: var(--primary);
}

.occupancy-fill.high {
    background: var(--danger);
}

/* Meal Filters */
.meal-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.meal-filters .btn {
    padding: 6px 12px;
    font-size: 13px;
}

.meal-filters .btn.active {
    background: var(--primary);
    color: white;
}

/* Meals List */
.meals-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 80px; /* Space for FAB */
}

.meals-count {
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.meal-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.meal-card.checked {
    background: var(--checked-bg);
    border-color: var(--success);
    opacity: 0.8;
}

.meal-card.checked .meal-content {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.meal-checkbox {
    width: 24px;
    height: 24px;
    accent-color: var(--success);
    cursor: pointer;
}

.meal-emoji {
    font-size: 28px;
    flex-shrink: 0;
}

.meal-serving-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.meal-serving-icon.small {
    width: 28px;
    height: 28px;
}

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

.meal-content {
    font-weight: 500;
    word-break: break-word;
}

.meal-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.meal-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.meal-actions .btn-icon {
    width: 32px;
    height: 32px;
}

/* Freezer Actions */
.freezer-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.freezer-actions .btn {
    flex: 1;
    min-width: 140px;
}

/* Inventory Check Mode */
.inventory-mode #inventory-check-btn {
    background: var(--success);
    color: white;
}

/* Audit Log List */
.audit-log-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.audit-log-item {
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.audit-log-date {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.audit-log-action {
    font-size: 14px;
}

/* Settings Section */
.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    margin-bottom: 12px;
    font-size: 16px;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.settings-item-info {
    flex: 1;
}

.settings-item-title {
    font-weight: 500;
}

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

.settings-item-actions {
    display: flex;
    gap: 4px;
}

/* Serving Size Icons (embedded as data URIs for simplicity) */
.serving-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.serving-icon.small {
    width: 28px;
    height: 28px;
    font-size: 12px;
}

/* Modal additions for freezer */
#modal-meal .form-group input[type="month"] {
    width: 100%;
}

/* Delete unchecked preview */
#delete-unchecked-preview {
    max-height: 300px;
    overflow-y: auto;
}

#delete-unchecked-preview .list-item {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

#delete-unchecked-preview .list-item:last-child {
    border-bottom: none;
}

#delete-unchecked-preview .empty-message {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
}

/* Responsive adjustments for freezer */
@media (max-width: 600px) {
    .freezer-selector {
        flex-direction: column;
    }

    .freezer-selector .btn {
        width: 100%;
    }

    .meal-card {
        flex-wrap: wrap;
    }

    .meal-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 8px;
    }
}

/* ========================================
   Dashboard View - Clean Card Layout
======================================== */
.dashboard-container {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.dashboard-section {
    margin-bottom: 24px;
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-header-row h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: all var(--transition);
}

.btn-link:hover {
    background: var(--gray-100);
}

/* Card List */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Dashboard Cards */
.dashboard-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
}

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

.dashboard-card:active {
    transform: translateY(0);
}

.card-icon-large {
    font-size: 36px;
    line-height: 1;
    flex-shrink: 0;
}

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

.card-content h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: var(--text);
}

.card-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
}

.card-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin: 4px 0 0 0;
}

.card-arrow {
    color: var(--gray-400);
    flex-shrink: 0;
    transition: transform var(--transition);
}

.dashboard-card:hover .card-arrow {
    transform: translateX(4px);
    color: var(--primary);
}

/* Progress Bar Mini */
.progress-bar-mini {
    height: 6px;
    background: var(--gray-200);
    border-radius: 100px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 100px;
    transition: width 0.3s ease;
}

/* Badge */
.badge-complex {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    background: var(--warning);
    color: white;
    border-radius: 100px;
    text-transform: uppercase;
    margin-left: 8px;
    vertical-align: middle;
}

/* Card Tags */
.card-tags {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.tag-mini {
    padding: 2px 8px;
    background: var(--gray-100);
    border-radius: 100px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* Empty Card */
.empty-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 24px;
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    text-align: center;
}

.empty-card-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--text);
}

.empty-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
}

/* ========================================
   Freezer Detail View
======================================== */
.freezer-detail-header {
    padding: 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.freezer-detail-info h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 12px 0;
}

.occupancy-inline {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.occupancy-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.occupancy-text strong {
    color: var(--text);
    font-size: 18px;
}

.occupancy-bar-inline {
    height: 8px;
    background: var(--gray-200);
    border-radius: 100px;
    overflow: hidden;
}

.occupancy-fill-inline {
    height: 100%;
    border-radius: 100px;
    transition: width 0.3s ease;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-bar::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    padding: 8px 16px;
    background: var(--gray-100);
    border: none;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-chip:hover {
    background: var(--gray-200);
}

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

/* Inventory Banner */
.inventory-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    font-size: 14px;
}

.inventory-banner .btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 8px 16px;
}

.inventory-banner .btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Meals List Detail */
.meals-list-detail {
    padding: 16px;
    padding-bottom: 140px; /* Space for FAB and action bar */
}

.meal-group {
    margin-bottom: 20px;
}

.meal-group-header {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.meal-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    transition: all var(--transition);
}

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

.meal-item.checked {
    background: var(--checked-bg-light);
    border-color: var(--success);
}

.meal-item.checked .meal-item-name {
    text-decoration: line-through;
    color: var(--text-muted);
}

.meal-item-checkbox {
    width: 22px;
    height: 22px;
    accent-color: var(--success);
    flex-shrink: 0;
}

.meal-item-emoji {
    font-size: 28px;
    line-height: 1;
    flex-shrink: 0;
}

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

.meal-item-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.meal-item-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.serving-badge {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 100px;
}

.type-badge {
    font-size: 12px;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 100px;
}

.meal-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.btn-icon-mini {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius);
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon-mini:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.btn-icon-mini.danger:hover {
    background: var(--badge-danger-bg);
    color: var(--danger);
}

/* Bottom Action Bar */
.bottom-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    z-index: 50;
}

.bottom-action-bar .btn {
    flex: 1;
}

/* FAB positioning for freezer detail */
#freezer-detail-view .fab {
    bottom: 80px;
}

/* Empty State Small */
.empty-state-small {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-secondary);
}

/* Unchecked List in Modal */
.unchecked-list {
    max-height: 200px;
    overflow-y: auto;
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.unchecked-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

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

.mt-16 {
    margin-top: 16px;
}

/* ========================================
   Freezer Settings View (existing)
======================================== */
.freezer-header {
    padding: 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.freezer-header h2 {
    margin-bottom: 12px;
    font-size: 20px;
}

.freezer-nav-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    margin: 0 -16px -16px;
    padding: 0 16px;
}

.freezer-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

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

.freezer-tab:hover:not(.active) {
    color: var(--text);
}

.freezer-tab-content {
    padding: 16px;
}

.freezer-tab-content.hidden {
    display: none !important;
}

/* Settings sections */
.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    margin-bottom: 12px;
    font-size: 16px;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.settings-item-info {
    flex: 1;
}

.settings-item-title {
    font-weight: 500;
}

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

.settings-item-actions {
    display: flex;
    gap: 4px;
}

/* ========================================
   Household Cards (Welcome Screen)
======================================== */
#households-view {
    padding: 24px 16px;
}

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

.household-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

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

.household-card:active {
    transform: translateY(-2px);
}

.household-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    border-radius: var(--radius-lg);
    font-size: 28px;
    flex-shrink: 0;
}

.household-card-content {
    flex: 1;
    min-width: 0;
}

.household-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 4px 0;
}

.household-card-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.household-card-arrow {
    color: var(--gray-400);
    flex-shrink: 0;
    transition: transform var(--transition);
}

.household-card:hover .household-card-arrow {
    transform: translateX(4px);
    color: var(--primary);
}

@media (min-width: 600px) {
    .households-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

/* ========================================
   Enhanced Login Screen
======================================== */
.login-container {
    background: var(--bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 40px 24px;
    text-align: center;
    color: white;
}

.login-header .logo {
    font-size: 64px;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 8px 0;
}

.login-header p {
    font-size: 14px;
    opacity: 0.9;
    margin: 0;
}

.login-form {
    padding: 32px 24px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 8px;
}

.login-form input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    transition: all var(--transition);
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.login-form .btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    margin-top: 8px;
}

.login-form .error-text {
    color: var(--danger);
    font-size: 14px;
    margin-top: 12px;
    text-align: center;
}

/* ========================================
   Enhanced Header
======================================== */
.app-header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-left h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ========================================
   App-wide Enhancements
======================================== */

/* Smooth page transitions */
.view {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Better scrolling */
.content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Toast improvements */
.toast {
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.toast.success {
    background: var(--success);
    color: white;
}

.toast.error {
    background: var(--danger);
    color: white;
}

#toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}


