:root {
    /* Maqadi Pro Brand Palette */
    --primary: #2D6A59;       /* Dark Green */
    --primary-hover: #7FA983; /* Light Green */
    --accent: #E85C2A;        /* Bright Orange */
    --accent-hover: #D87B22;  /* Deep Orange */
    --secondary: #EEA636;     /* Yellow-Orange */

    /* Backgrounds & Surfaces */
    --bg-color: #F7EAE0;      /* Logo Beige */
    --card-bg: #ffffff;

    /* Typography */
    --text-main: #1a2420;     /* Very dark green-tinted text */
    --text-muted: #4a6358;    /* Muted green-grey */

    /* Borders & Shadows (using Dark Green RGB: 45, 106, 89) */
    --border: rgba(45, 106, 89, 0.2);
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(45, 106, 89, 0.2), 0 2px 4px -1px rgba(45, 106, 89, 0.1);
    --nav-height: 70px;
}

[data-theme="dark"] {
    /* Dark Mode Tailored to Brand */
    --bg-color: #121815;      /* Deep dark green-black */
    --card-bg: #1c2621;       /* Slightly lighter surface */

    /* Typography inverted for dark mode */
    --text-main: #F7EAE0;     /* Logo Beige */
    --text-muted: #7FA983;    /* Light Green */

    /* Borders & Shadows (using Light Green RGB: 127, 169, 131) */
    --border: rgba(127, 169, 131, 0.2);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.6), 0 2px 4px -1px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding-top: var(--nav-height);
}

[dir="rtl"] body {
    font-family: 'Almarai', sans-serif;
}

/* --- Logo Sizing and Spacing --- */
.app-logo {
    height: 200px;
    width: auto;
    margin-right: 10px;
}

[dir="rtl"] .app-logo {
    margin-right: 0;
    margin-left: 10px;
}

/* --- Light Mode (Default) --- */
.logo-light {
    display: block;
}

.logo-dark {
    display: none;
}

/* --- Dark Mode --- */
[data-theme="dark"] .logo-light {
    display: none;
}

[data-theme="dark"] .logo-dark {
    display: block;
}

/* --- Navbar Fix --- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    min-height: var(--nav-height);
    height: auto;
    background-color: var(--card-bg);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 2rem;
    z-index: 1000;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex-shrink: 1;
}

.nav-title span {
    white-space: nowrap;
}

.app-logo {
    height: 44px;
    width: auto;
    margin-right: 10px;
    flex-shrink: 0;
}

[dir="rtl"] .app-logo {
    margin-right: 0;
    margin-left: 10px;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex: 1;
    min-width: 0;
}

.nav-actions>* {
    flex-shrink: 0;
}

#langSelect {
    max-width: 110px;
}

/* --- Mobile --- */
@media (max-width: 768px) {
    :root {
        --nav-height: 110px;
    }
    body {
        padding-top: var(--nav-height);
    }
    .navbar {
        padding: 0.75rem 1rem;
        align-items: flex-start;
    }
    .nav-title {
        width: 100%;
        font-size: 1.1rem;
    }
    .nav-title span {
        white-space: normal;
        line-height: 1.2;
    }
    .app-logo {
        height: 36px;
    }
    .nav-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .btn-secondary,
    .btn-danger,
    #langSelect {
        min-height: 40px;
    }
}

@media (max-width: 480px) {
    :root {
        --nav-height: 140px;
    }
    body {
        padding-top: var(--nav-height);
    }
    .navbar {
        padding: 0.75rem;
    }
    .nav-actions {
        gap: 0.4rem;
    }
    .btn-secondary,
    .btn-danger {
        padding: 0.45rem 0.75rem;
        font-size: 0.9rem;
    }
    #langSelect {
        max-width: 90px;
        font-size: 0.9rem;
    }
}

/* --- General Layout --- */
.app-container {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.hidden {
    display: none !important;
}

.greeting-section {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.greeting-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.greeting-subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 0.25rem;
}

/* --- Buttons --- */
button {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--accent);
    color: var(--bg-color); /* Updated to Maqadi Beige */
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

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

.btn-secondary {
    background-color: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    font-size: 1rem;
}

.btn-secondary:hover {
    background-color: var(--border);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-secondary:active {
    transform: translateY(0);
}

select.btn-secondary {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.2rem;
    /* Updated stroke to match Maqadi text-muted (#4a6358) */
    background-image: url('data:image/svg+xml;utf8,<svg fill="none" stroke="%234a6358" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><polyline points="6 9 12 15 18 9"/></svg>');
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1.2em;
    font-size: 1rem;
    cursor: pointer;
    outline: none;
    border-radius: 8px;
}

[dir="rtl"] select.btn-secondary {
    padding-right: 1rem;
    padding-left: 2.2rem;
    background-position: left 0.5rem center;
}

[data-theme="dark"] select.btn-secondary {
    /* Updated stroke to match Maqadi dark mode text-muted (#7FA983) */
    background-image: url('data:image/svg+xml;utf8,<svg fill="none" stroke="%237FA983" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><polyline points="6 9 12 15 18 9"/></svg>');
}

select.btn-secondary option {
    background-color: var(--card-bg);
    color: var(--text-main);
}

.btn-danger {
    background-color: transparent;
    color: #ef4444;
    border: 1px solid #ef4444;
    padding: 0.5rem 1rem;
    font-size: 1rem;
}

.btn-danger:hover {
    background-color: #ef4444;
    color: white;
}

/* --- Auth Form Styles --- */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--nav-height) - 4rem);
    padding: 2rem 1rem;
}

.auth-split-container {
    display: flex;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    width: 100%;
    max-width: 1100px;
    min-height: 600px;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="dark"] .auth-split-container {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.auth-marketing {
    flex: 1;
    /* Updated gradient to use Maqadi variables */
    background: linear-gradient(-45deg, var(--primary), var(--secondary), var(--accent), var(--primary-hover));
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: white;
    padding: 4rem 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

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

.marketing-content {
    position: relative;
    z-index: 2;
}

.marketing-title {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.marketing-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 2.5rem;
    line-height: 1.6;
}

.marketing-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.marketing-features li {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: 500;
    transition: transform 0.3s ease, background 0.3s ease;
}

.marketing-features li:hover {
    transform: translateX(10px);
    background: rgba(255, 255, 255, 0.15);
}

[dir="rtl"] .marketing-features li:hover {
    transform: translateX(-10px);
}

.marketing-features .icon {
    font-size: 1.5rem;
    margin-right: 1rem;
}

[dir="rtl"] .marketing-features .icon {
    margin-right: 0;
    margin-left: 1rem;
}

/* Floating Food SVGs */
.floating-food {
    position: absolute;
    color: rgba(255, 255, 255, 0.25);
    z-index: 1;
    animation: float-food var(--dur) ease-in-out infinite;
    animation-delay: var(--del);
}

@keyframes float-food {
    0%,
    100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(10deg); }
}

.food-1 { top: 15%; left: 10%; --dur: 6s; --del: 0s; width: 48px; height: 48px; }
.food-2 { top: 20%; right: 15%; --dur: 8s; --del: 1s; width: 64px; height: 64px; }
.food-3 { bottom: 20%; left: 15%; --dur: 7s; --del: 2s; width: 56px; height: 56px; }
.food-4 { bottom: 15%; right: 10%; --dur: 9s; --del: 0.5s; width: 40px; height: 40px; }

.auth-form-side {
    flex: 1;
    padding: 4rem 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.auth-card {
    background: transparent;
    padding: 0;
    box-shadow: none;
    max-width: 400px;
    width: 100%;
    margin: 0;
    text-align: center;
}

@media (max-width: 900px) {
    .auth-split-container {
        flex-direction: column;
    }
    .auth-marketing {
        padding: 3rem 2rem;
    }
    .auth-form-side {
        padding: 3rem 2rem;
    }
    .marketing-title {
        font-size: 2rem;
    }
    .auth-wrapper {
        padding: 1rem;
    }
}

.auth-toggle {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-toggle a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.password-wrapper {
    position: relative;
    display: flex;
    width: 100%;
}

.password-wrapper input {
    width: 100%;
    padding-right: 2.5rem;
}

[dir="rtl"] .password-wrapper input {
    padding-right: 1rem;
    padding-left: 2.5rem;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

[dir="rtl"] .password-toggle {
    right: auto;
    left: 0.75rem;
}

.password-toggle:hover {
    color: var(--text-main);
}

.error-text {
    color: #ef4444;
    font-size: 0.85rem;
    text-align: left;
    margin-top: -0.5rem;
    margin-bottom: 0.25rem;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.5rem;
    border-radius: 6px;
}

[dir="rtl"] .error-text {
    text-align: right;
}

.password-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: left;
    margin-top: -0.5rem;
    margin-bottom: 0.25rem;
}

[dir="rtl"] .password-hint {
    text-align: right;
}

/* --- App Styles --- */
.input-section {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    position: relative;
}

.input-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    background: var(--card-bg);
    color: var(--text-main);
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 2;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    /* Updated RGB for focus shadow to Dark Green */
    box-shadow: 0 0 0 3px rgba(45, 106, 89, 0.3);
}

/* --- Presets & Meals Menus --- */
.dropdown-menu {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-top: 0.5rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    animation: slideIn 0.2s ease;
    position: absolute;
    z-index: 50;
    left: 0;
}

.dropdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 2px;
}

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

.preset-save-row {
    display: flex;
    gap: 0.5rem;
}

.preset-save-row input {
    flex: 1;
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.preset-save-row button {
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    border: none;
    cursor: pointer;
}

.meals-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.meal-category-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.25rem;
}

.total-banner {
    /* Updated to use Accent (Bright Orange) RGB */
    background: rgba(232, 92, 42, 0.1);
    border: 1px solid rgba(232, 92, 42, 0.3);
    color: var(--accent);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

/* Price Input */
.price-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-color);
    border-radius: 6px;
    padding: 0.2rem 0.5rem;
    border: 1px solid transparent;
    transition: border 0.2s;
}

.price-input-wrapper:focus-within {
    border-color: var(--primary);
}

.price-input-wrapper input {
    width: 60px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    text-align: right;
}

[dir="rtl"] .price-input-wrapper input {
    text-align: left;
}

.price-input-wrapper input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.item.low-stock {
    background: rgba(234, 179, 8, 0.05);
    border-left: 4px solid #eab308;
}

[dir="rtl"] .item.low-stock {
    border-left: none;
    border-right: 4px solid #eab308;
}

.low-stock-btn.active {
    color: #eab308;
    background: rgba(234, 179, 8, 0.15);
}

/* --- Suggestions Styling --- */
.suggestions-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
}

.suggestions-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.suggestions-list {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.suggestion-chip {
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    position: relative;
}

.suggestion-chip.seasonal {
    /* Updated RGB to Maqadi Primary (Dark Green) */
    background: rgba(45, 106, 89, 0.15);
    border-color: var(--primary);
    color: var(--primary-hover);
}

.suggestion-chip:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

.suggestion-chip.seasonal:hover {
    background: var(--primary-hover);
    color: white;
}

[data-theme="dark"] .suggestion-chip {
    background: var(--card-bg);
    border-color: var(--border);
}

[data-theme="dark"] .suggestion-chip:hover,
[data-theme="dark"] .suggestion-chip.seasonal:hover {
    background: var(--primary);
    color: #1a1816;
}

.refill-badge {
    background: #ef4444;
    color: white;
    font-size: 0.6rem;
    padding: 2px 5px;
    border-radius: 10px;
    margin-left: 4px;
    font-weight: bold;
}

[dir="rtl"] .refill-badge {
    margin-left: 0;
    margin-right: 4px;
}

.behavior-badge {
    background: var(--accent);
    color: white;
    font-size: 0.6rem;
    padding: 2px 5px;
    border-radius: 10px;
    margin-left: 4px;
    font-weight: bold;
}

[dir="rtl"] .behavior-badge {
    margin-left: 0;
    margin-right: 4px;
}

.item-qty {
    font-weight: 700;
    color: var(--accent);
    margin-left: 0.5rem;
    font-size: 0.9em;
}

[dir="rtl"] .item-qty {
    margin-left: 0;
    margin-right: 0.5rem;
}

/* Tabs and Search Styling */
.tabs-and-search {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}

.tabs-container {
    display: flex;
    gap: 1rem;
    margin-bottom: -2px;
}

.search-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    max-width: 300px;
    margin-bottom: 0.5rem;
}

.search-input-wrapper input {
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border-radius: 20px;
    width: 100%;
    background-color: var(--card-bg);
}

[dir="rtl"] .search-input-wrapper input {
    padding: 0.5rem 2.5rem 0.5rem 1rem;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

[dir="rtl"] .search-icon {
    left: auto;
    right: 0.75rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    border-radius: 8px 8px 0 0;
    margin-bottom: -2px;
}

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

.tab-btn:hover:not(.active) {
    background-color: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .tab-btn:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.03);
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    align-items: start;
}

/* For the export view, we temporarily override grid so it looks clean */
.exporting .categories-grid {
    display: block !important;
    columns: 2;
    column-gap: 2rem;
    background: var(--bg-color);
    padding: 2rem;
}

.exporting .category-card {
    break-inside: avoid;
    margin-bottom: 1.5rem;
    box-shadow: none;
    border: 1px solid var(--border);
}

.category-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 1.5rem 1.5rem 1rem 1.5rem;
    border-bottom: 2px solid var(--bg-color);
    user-select: none;
    transition: padding 0.3s ease, border-color 0.3s ease, background-color 0.2s ease;
}

.category-header:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .category-header:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.category-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent);
}

.chevron {
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.category-card.collapsed .chevron {
    transform: rotate(180deg);
}

.category-card.collapsed .category-header {
    padding-bottom: 1.5rem;
    border-bottom-color: transparent;
}

.category-content-wrapper {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.3s ease;
}

.category-card.collapsed .category-content-wrapper {
    grid-template-rows: 0fr;
}

.category-content {
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.3s ease;
    min-height: 0;
}

.category-inner {
    padding: 0.5rem 1.5rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
}

.category-card.collapsed .category-content {
    opacity: 0;
    pointer-events: none;
}

.item-list {
    list-style: none;
}

/* ITEM RESPONSIVE REDESIGN */
.item {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--bg-color);
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
    border-radius: 6px;
    gap: 0.5rem;
}

.item-main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    width: 100%;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.checkbox-container {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    flex: 1 1 120px;
    min-width: 0;
    padding: 0 0.5rem;
    user-select: none;
}

.checkbox-container input {
    appearance: none;
    -webkit-appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--text-muted);
    border-radius: 6px;
    background-color: transparent;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    opacity: 0.7;
    margin-top: 0.15rem;
}

.checkbox-container:hover input {
    opacity: 1;
    border-color: var(--primary);
}

.checkbox-container input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
    opacity: 1;
}

.checkbox-container input:checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-container span {
    font-size: 1.05rem;
    word-break: break-word;
    line-height: 1.4;
}

.item-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: auto;
    padding: 0 0 0 0.5rem;
}

[dir="rtl"] .item-controls {
    margin-right: 0.5rem;
    margin-left: 0;
}

.item-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    border-radius: 6px;
    transition: background-color 0.2s;
    color: var(--text-muted);
}

.action-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--accent);
}

[data-theme="dark"] .action-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.delete-btn {
    color: #ef4444;
    margin-left: 0.5rem;
}

[dir="rtl"] .delete-btn {
    margin-left: 0;
    margin-right: 0.5rem;
}

.delete-btn:hover {
    background-color: #fee2e2;
    color: #ef4444;
}

[data-theme="dark"] .delete-btn:hover {
    background-color: rgba(239, 68, 68, 0.15);
}

.ai-alt-box {
    margin-left: 2.25rem;
    /* Updated RGB to Maqadi Accent (Bright Orange) */
    background: rgba(232, 92, 42, 0.1);
    color: var(--accent-hover);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    border: 1px dashed var(--accent);
    transition: all 0.2s ease;
    width: fit-content;
}

[dir="rtl"] .ai-alt-box {
    margin-left: 0;
    margin-right: 2.25rem;
}

.ai-alt-box:hover {
    background: rgba(232, 92, 42, 0.2);
    transform: scale(1.02);
}

.item:hover {
    background-color: #f9fafb;
}

[data-theme="dark"] .item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

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

.item.removing {
    opacity: 0;
    transform: translateX(20px);
}

[dir="rtl"] .item.removing {
    transform: translateX(-20px);
}

.strikethrough {
    text-decoration: line-through;
    color: var(--text-muted);
}

.empty-state {
    color: var(--text-muted);
    font-size: 0.95rem;
    text-align: center;
    padding: 1.5rem 0;
    font-style: italic;
    background-color: transparent;
    border-radius: 8px;
    border: 1px dashed var(--border);
}

/* --- Thinking Spinner --- */
.thinking-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    color: var(--accent);
    font-weight: 600;
    font-size: 1.15rem;
    background: rgba(255, 255, 255, 0.4);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    /* Updated RGB to Maqadi Accent (Bright Orange) */
    border: 1px solid rgba(232, 92, 42, 0.15);
    box-shadow: 0 4px 6px -1px rgba(232, 92, 42, 0.05);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

[data-theme="dark"] .thinking-spinner {
    background: rgba(0, 0, 0, 0.2);
    /* Updated RGB to Maqadi Light Green */
    border-color: rgba(127, 169, 131, 0.2);
}

.pulse-icon {
    animation: pulse 1.5s infinite ease-in-out;
    margin-right: 0.5rem;
    color: var(--primary);
}

[dir="rtl"] .pulse-icon {
    margin-right: 0;
    margin-left: 0.5rem;
}

@keyframes pulse {
    0%,
    100% {
        transform: scale(0.9);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.15);
        opacity: 1;
    }
}

.bouncing-dots {
    display: inline-flex;
    margin-left: 2px;
}

[dir="rtl"] .bouncing-dots {
    margin-left: 0;
    margin-right: 2px;
}

.bouncing-dots span {
    animation: dotBounce 1.4s infinite ease-in-out both;
    display: inline-block;
}

.bouncing-dots span:nth-child(1) { animation-delay: -0.32s; }
.bouncing-dots span:nth-child(2) { animation-delay: -0.16s; }
.bouncing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes dotBounce {
    0%,
    80%,
    100% { transform: translateY(0); }
    40% { transform: translateY(-4px); }
}

/* --- Insights Page --- */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.insight-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.insight-val {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
}

.insight-title {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--bg-color);
}

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

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.wide {
    max-width: 600px;
    text-align: left;
}

[dir="rtl"] .modal-content.wide {
    text-align: right;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: center;
}

.recipe-content h2,
.recipe-content h3 {
    color: var(--accent);
    margin-bottom: 1rem;
    margin-top: 1.5rem;
}

.recipe-content ul,
.recipe-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

[dir="rtl"] .recipe-content ul,
[dir="rtl"] .recipe-content ol {
    margin-left: 0;
    margin-right: 1.5rem;
}

.recipe-content li {
    margin-bottom: 0.5rem;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

[dir="rtl"] .toast-container {
    right: auto;
    left: 20px;
}

.toast {
    background: var(--primary);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateX(100%);
    opacity: 0;
    animation: slideIn 0.3s forwards, fadeOut 0.3s 3s forwards;
    font-weight: 500;
}

[dir="rtl"] .toast {
    transform: translateX(-100%);
}

@keyframes slideIn {
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

footer {
    margin-top: 3rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}