:root {
    --primary: #16a34a;
    --primary-light: #22c55e;
    --primary-dark: #15803d;
    --primary-bg: #f0fdf4;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --blue: #3b82f6;
    --blue-bg: #eff6ff;
    --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;
    --white: #ffffff;
    --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 rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --font-ar: 'Cairo', sans-serif;
    --font-en: 'Inter', sans-serif;
}

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

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

body {
    font-family: var(--font-ar);
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

[dir="ltr"] body { font-family: var(--font-en); }

.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    background: var(--white);
    position: relative;
    box-shadow: var(--shadow-lg);
}

/* Top Bar */
.top-bar {
    background: var(--primary);
    color: var(--white);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.top-bar__title {
    font-size: 1.1rem;
    font-weight: 700;
}

.top-bar__cost {
    display: flex;
    align-items: center;
}

.cost-badge {
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--white);
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

.provider-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    margin-top: 6px;
}

.provider-tag--openai {
    background: #e8f5e9;
    color: #2e7d32;
}

.provider-tag--deepseek {
    background: #e3f2fd;
    color: #1565c0;
}

/* Content */
.content {
    padding: 16px;
    padding-bottom: 90px;
    min-height: calc(100dvh - 56px - 70px);
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-around;
    padding: 8px 4px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--gray-400);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 8px;
    transition: color 0.2s;
    min-width: 56px;
}

.bottom-nav__item svg {
    width: 22px;
    height: 22px;
}

.bottom-nav__item.active {
    color: var(--primary);
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--gray-100);
    box-shadow: var(--shadow-sm);
}

.card--green { border-left: 4px solid var(--primary); }
.card--red { border-left: 4px solid var(--danger); }
.card--blue { border-left: 4px solid var(--blue); }
.card--warning { border-left: 4px solid var(--warning); }

[dir="rtl"] .card--green { border-left: none; border-right: 4px solid var(--primary); }
[dir="rtl"] .card--red { border-left: none; border-right: 4px solid var(--danger); }
[dir="rtl"] .card--blue { border-left: none; border-right: 4px solid var(--blue); }
[dir="rtl"] .card--warning { border-left: none; border-right: 4px solid var(--warning); }

/* Meal Group - Collapsible */
.meal-group {
    background: var(--white);
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    cursor: pointer;
}
.meal-group__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
}
.meal-group__title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gray-700);
}
.meal-group__count {
    background: var(--primary-bg);
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
}
.meal-group__cal {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
}
.meal-group__macros {
    display: flex;
    gap: 12px;
    padding: 0 14px 10px;
    font-size: 0.72rem;
    color: var(--gray-400);
}
.meal-group__arrow {
    transition: transform 0.2s;
    color: var(--gray-400);
    flex-shrink: 0;
}
.meal-group.collapsed .meal-group__arrow {
    transform: rotate(-90deg);
}
[dir="rtl"] .meal-group.collapsed .meal-group__arrow {
    transform: rotate(90deg);
}
.meal-group__items {
    padding: 0 10px 10px;
    cursor: default;
}
.meal-group.collapsed .meal-group__items {
    display: none;
}
.meal-group__items .card {
    margin-bottom: 6px;
}
.meal-group__items .card:last-child {
    margin-bottom: 0;
}

.card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.card__title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gray-700);
}

.card__badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    background: var(--primary-bg);
    color: var(--primary);
}

.card__body {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.card__macros {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--gray-400);
}

.card__macros span { display: flex; align-items: center; gap: 4px; }

.card__delete {
    background: none;
    border: none;
    color: var(--gray-300);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.2s;
}

.card__delete:hover { color: var(--danger); }

/* Calorie Circle */
.calorie-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
}

.calorie-circle__ring {
    position: relative;
    width: 180px;
    height: 180px;
}

.calorie-circle__ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.calorie-circle__ring circle {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
}

.calorie-circle__bg { stroke: var(--gray-100); }
.calorie-circle__progress { stroke: var(--primary); transition: stroke-dashoffset 1s ease; }
.calorie-circle__burned { stroke: var(--danger); transition: stroke-dashoffset 1s ease; }

.calorie-circle__center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.calorie-circle__number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1;
}

.calorie-circle__label {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: 4px;
}

.calorie-circle__stats {
    display: flex;
    gap: 32px;
    margin-top: 16px;
}

.calorie-stat {
    text-align: center;
}

.calorie-stat__value {
    font-size: 1.2rem;
    font-weight: 700;
}

.calorie-stat__label {
    font-size: 0.7rem;
    color: var(--gray-400);
    margin-top: 2px;
}

.calorie-stat--consumed .calorie-stat__value { color: var(--primary); }
.calorie-stat--burned .calorie-stat__value { color: var(--danger); }
.calorie-stat--remaining .calorie-stat__value { color: var(--blue); }

/* Macro Bars */
.macro-bars {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}

.macro-bar {
    flex: 1;
    text-align: center;
}

.macro-bar__label {
    font-size: 0.7rem;
    color: var(--gray-400);
    margin-bottom: 4px;
}

.macro-bar__track {
    height: 6px;
    background: var(--gray-100);
    border-radius: 3px;
    overflow: hidden;
}

.macro-bar__fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.macro-bar--protein .macro-bar__fill { background: var(--blue); }
.macro-bar--carbs .macro-bar__fill { background: var(--warning); }
.macro-bar--fat .macro-bar__fill { background: var(--danger); }

.macro-bar__value {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 4px;
    color: var(--gray-600);
}

/* Section */
.section {
    margin-top: 20px;
}

.section__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.section__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-700);
}

.section__action {
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.form-input::placeholder { color: var(--gray-300); }

select.form-input {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 32px;
}

[dir="ltr"] select.form-input {
    background-position: right 12px center;
    padding-left: 16px;
    padding-right: 32px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    -webkit-appearance: none;
}

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

.btn--primary:hover { background: var(--primary-dark); }
.btn--primary:active { transform: scale(0.98); }

.btn--outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

.btn--outline:hover { background: var(--primary-bg); }

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

.btn--ghost {
    background: transparent;
    color: var(--gray-500);
}

.btn--sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

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

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

.tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.tab.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Meal Type Selector */
.meal-types {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.meal-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    transition: all 0.2s;
}

.meal-type-btn .icon { font-size: 1.5rem; }

.meal-type-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

/* Exercise Grid */
.exercise-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.exercise-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    transition: all 0.2s;
}

.exercise-btn .icon { font-size: 1.5rem; }

.exercise-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

/* Photo Upload */
.photo-upload {
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.photo-upload:hover { border-color: var(--primary); background: var(--primary-bg); }

.photo-upload__icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    color: var(--gray-300);
}

.photo-upload__text {
    font-size: 0.85rem;
    color: var(--gray-400);
}

.photo-upload__preview {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 8px;
    display: none;
}

.photo-upload.has-preview .photo-upload__icon,
.photo-upload.has-preview .photo-upload__text { display: none; }
.photo-upload.has-preview .photo-upload__preview { display: block; }

.photo-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Food Items */
.food-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}
.food-item:last-child { border-bottom: none; }

/* Result Card */
.result-card {
    background: var(--primary-bg);
    border: 1.5px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin: 16px 0;
    display: none;
}

.result-card.show { display: block; animation: slideUp 0.3s ease; }

.result-card__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 12px;
    text-align: center;
}

.result-card__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.result-card__item {
    text-align: center;
    padding: 8px;
    background: var(--white);
    border-radius: 8px;
}

.result-card__item-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-800);
}

.result-card__item-label {
    font-size: 0.7rem;
    color: var(--gray-400);
}

/* Auth Pages */
.auth-page {
    min-height: 100dvh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.auth-card__logo {
    text-align: center;
    margin-bottom: 24px;
}

.auth-card__logo h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-top: 8px;
}

.auth-card__logo .icon {
    font-size: 3rem;
}

.auth-card__footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.auth-card__footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* Steps */
.step { display: none; }
.step.active { display: block; animation: fadeIn 0.3s ease; }

.steps-indicator {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
}

.steps-indicator__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-200);
    transition: all 0.3s;
}

.steps-indicator__dot.active {
    background: var(--primary);
    width: 24px;
    border-radius: 4px;
}

/* Gender Select */
.gender-select {
    display: flex;
    gap: 8px;
}

.gender-btn {
    flex: 1;
    padding: 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    text-align: center;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-500);
    transition: all 0.2s;
}

.gender-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

/* History */
.date-picker-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 8px 0;
}

.date-picker-bar input[type="date"] {
    flex: 1;
    padding: 10px 16px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--gray-700);
}

.day-card {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.day-card:hover { border-color: var(--primary-light); }

.day-card__date {
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.day-card__cals {
    font-weight: 700;
    font-size: 0.9rem;
}

.day-card__cals--ok { color: var(--primary); }
.day-card__cals--over { color: var(--danger); }
.day-card__cals--under { color: var(--warning); }

/* Weekly Chart */
.weekly-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 150px;
    padding: 16px 0;
    gap: 6px;
}

.weekly-chart__bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.weekly-chart__fill {
    width: 100%;
    max-width: 32px;
    border-radius: 6px 6px 0 0;
    background: var(--primary);
    transition: height 0.5s ease;
    min-height: 4px;
}

.weekly-chart__fill--over { background: var(--danger); }

.weekly-chart__label {
    font-size: 0.65rem;
    color: var(--gray-400);
    margin-top: 6px;
    font-weight: 600;
}

.weekly-chart__value {
    font-size: 0.6rem;
    color: var(--gray-500);
    margin-bottom: 4px;
    font-weight: 600;
}

/* Profile */
.profile-header {
    text-align: center;
    padding: 20px 0;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-bg);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    margin: 0 auto 12px;
}

.profile-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-800);
}

.profile-stats {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 12px;
}

.profile-stat {
    text-align: center;
    padding: 8px 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.profile-stat__value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.profile-stat__label {
    font-size: 0.7rem;
    color: var(--gray-400);
}

.profile-menu {
    margin-top: 20px;
}

.profile-menu__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    color: inherit;
}

.profile-menu__item:hover { background: var(--gray-50); }

.profile-menu__item-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
}

.profile-menu__item--danger .profile-menu__item-text { color: var(--danger); }

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gray-800);
    color: var(--white);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

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

/* Autocomplete */
.autocomplete-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
}
.autocomplete-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--gray-100);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item:active {
    background: var(--primary-bg);
}
.dish-ingredient { margin-bottom: 6px; }
.dish-ingredient + .dish-ingredient { padding-top: 6px; border-top: 1px solid var(--gray-100); }
.dish-tag {
    display: inline-block;
    background: var(--blue);
    color: #fff;
    font-size: 0.6rem;
    padding: 1px 6px;
    border-radius: 4px;
    margin-inline-start: 4px;
    vertical-align: middle;
    font-weight: 700;
}
.card__info {
    background: none;
    border: none;
    color: var(--blue);
    cursor: pointer;
    padding: 2px;
    display: flex;
}
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal {
    background: var(--white);
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}
.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 14px 0;
}
.ing-analyze-btn {
    background: var(--primary-bg);
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: var(--primary);
    padding: 6px 8px;
    cursor: pointer;
    flex-shrink: 0;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
}
.ing-analyze-btn:hover { background: var(--primary); color: #fff; }

.cached-preview {
    display: none;
    gap: 8px;
    padding: 6px 8px;
    margin-top: 6px;
    background: var(--primary-bg);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--primary-dark);
    font-weight: 600;
    flex-wrap: wrap;
    align-items: center;
}
.cached-save-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    margin-inline-start: auto;
}

/* Date Navigation */
.date-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    margin-bottom: 4px;
}
.date-nav__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--gray-600);
    text-decoration: none;
    transition: all 0.2s;
}
.date-nav__btn:hover {
    background: var(--gray-100);
    color: var(--primary);
}
.date-nav__btn--disabled {
    color: var(--gray-200);
    pointer-events: none;
}
.date-nav__center {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
    padding: 4px 16px;
    border-radius: var(--radius);
    transition: background 0.2s;
}
.date-nav__center:hover {
    background: var(--gray-50);
}
.date-nav__label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
}
.date-nav__date {
    font-size: 0.7rem;
    color: var(--gray-400);
}

/* Report Card */
.report-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 8px;
}
.report-text {
    font-size: 0.85rem;
    line-height: 1.8;
    color: var(--gray-700);
}
.report-text strong {
    color: var(--gray-800);
}
.report-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-200);
    font-size: 0.72rem;
    color: var(--gray-400);
    font-weight: 600;
}

/* Chat */
.chat-input {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.chat-input .form-input {
    flex: 1;
    padding: 10px 14px;
    font-size: 0.85rem;
}
.chat-input__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--white);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}
.chat-input__btn:hover { background: var(--primary-dark); }
.chat-input__btn:disabled { opacity: 0.5; cursor: not-allowed; }
[dir="rtl"] .chat-input__btn svg { transform: scaleX(-1); }

#chatMessages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    max-height: 400px;
    overflow-y: auto;
}
#chatMessages:empty { display: none; }

.chat-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.7;
    max-width: 88%;
    word-wrap: break-word;
}
.chat-bubble--user {
    background: var(--primary);
    color: var(--white);
    align-self: flex-end;
    border-bottom-right: 4px;
}
[dir="rtl"] .chat-bubble--user {
    border-radius: 14px 14px 4px 14px;
}
[dir="ltr"] .chat-bubble--user {
    border-radius: 14px 14px 4px 14px;
}
.chat-bubble--ai {
    background: var(--gray-100);
    color: var(--gray-700);
    align-self: flex-start;
}
[dir="rtl"] .chat-bubble--ai {
    border-radius: 14px 14px 14px 4px;
}
[dir="ltr"] .chat-bubble--ai {
    border-radius: 14px 14px 14px 4px;
}
.chat-bubble--ai strong {
    color: var(--gray-800);
}
.chat-bubble__cost {
    font-size: 0.65rem;
    color: var(--gray-400);
    margin-top: 4px;
    text-align: end;
}

/* Typing indicator */
.chat-bubble--typing {
    display: flex;
    gap: 4px;
    padding: 12px 18px;
    align-items: center;
}
.chat-bubble--typing span {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gray-400);
    animation: typingDot 1.2s infinite;
}
.chat-bubble--typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-bubble--typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Checkbox */
.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    cursor: pointer;
}
.form-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}
.form-checkbox label {
    font-size: 0.85rem;
    color: var(--gray-600);
    cursor: pointer;
    margin: 0;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--white);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner--dark { border-color: var(--gray-300); border-top-color: transparent; }

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

.empty-state__icon { font-size: 2.5rem; margin-bottom: 8px; }
.empty-state__text { font-size: 0.85rem; }

/* Body Composition Grid */
.bc-item {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 10px 8px;
    text-align: center;
}
.bc-val {
    display: block;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--gray-800);
    line-height: 1.2;
}
.bc-lbl {
    display: block;
    font-size: 0.65rem;
    color: var(--gray-400);
    margin-top: 2px;
    font-weight: 600;
}

/* Suggest Cards */
.suggest-card { transition: transform 0.15s, box-shadow 0.15s; }
.suggest-card:active { transform: scale(0.98); }
@media (hover: hover) {
    .suggest-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
}

/* Modal / Edit form overlay */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal {
    background: var(--white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal__title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    text-align: center;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Utility */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.hidden { display: none !important; }

/* Alert */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 16px;
    font-weight: 600;
}

.alert--error { background: var(--danger-bg); color: var(--danger); }
.alert--success { background: var(--primary-bg); color: var(--primary); }

/* Responsive */
@media (min-width: 481px) {
    .app { border-left: 1px solid var(--gray-200); border-right: 1px solid var(--gray-200); }
}
