:root {
    --terra: #993A31;
    --terra-light: #F2E0DE;
    --sage: #808D86;
    --sage-light: #E8EDEA;
    --cream: #FDF8F0;
    --dark: #2C2C2A;
    --white: #ffffff;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
}

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

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--cream);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3 { font-family: Georgia, serif; color: var(--terra); }
a { color: var(--terra); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Navbar */
.navbar {
    background: var(--white);
    border-bottom: 2px solid var(--sage-light);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 1.5rem;
}
.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.nav-brand {
    font-family: Georgia, serif;
    font-size: 1.4rem;
    color: var(--terra);
    font-weight: bold;
}
.nav-brand:hover { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 1.2rem; margin-left: auto; margin-right: 1rem; }
.nav-link { color: var(--sage); font-size: 0.92rem; font-weight: 500; }
.nav-link:hover { color: var(--terra); text-decoration: none; }
.nav-badge {
    background: var(--terra);
    color: var(--white);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
    vertical-align: middle;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    text-decoration: none;
    transition: all 0.15s;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.82rem; }
.btn-primary { background: var(--terra); color: var(--white); border-color: var(--terra); }
.btn-primary:hover { background: #7e302a; border-color: #7e302a; }
.btn-outline { background: var(--white); color: var(--terra); border-color: var(--terra); }
.btn-outline:hover { background: var(--terra-light); }
.btn-approve { background: #2d7a3a; color: var(--white); border-color: #2d7a3a; }
.btn-approve:hover { background: #236b2f; }
.btn-danger { background: var(--white); color: #c0392b; border-color: #c0392b; }
.btn-danger:hover { background: #fdecea; }

/* Content */
.content { max-width: 1100px; width: 100%; margin: 0 auto; padding: 1.5rem; flex: 1; }

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--sage);
    font-size: 0.85rem;
    border-top: 1px solid var(--sage-light);
    margin-top: 2rem;
}

/* Page Header */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { margin-bottom: 0.25rem; }
.subtitle { color: var(--sage); font-size: 0.95rem; }

/* Search */
.search-bar { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.search-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1.5px solid var(--sage-light);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    outline: none;
}
.search-input:focus { border-color: var(--terra); }

/* Filter Bar */
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.5rem; }
.filter-pill {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 2px solid var(--sage-light);
    background: var(--white);
    color: var(--sage);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.filter-pill:hover { text-decoration: none; border-color: var(--terra); color: var(--terra); }
.filter-pill.active { background: var(--terra); border-color: var(--terra); color: var(--white); }

/* Recipe Grid */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.2rem;
}
.recipe-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
    color: var(--dark);
    display: block;
}
.recipe-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    text-decoration: none;
}
.card-title { font-size: 1.15rem; margin-bottom: 0.3rem; }
.card-meta { font-size: 0.8rem; color: var(--sage); margin-bottom: 0.5rem; }
.card-desc {
    font-size: 0.88rem;
    color: #555;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.6rem;
}

/* Tag Badges */
.tag-row { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tag-badge {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--white);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

/* Empty State */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--sage); }
.empty-state p { font-size: 1.05rem; margin-bottom: 1rem; }

/* Review Queue */
.review-list { display: flex; flex-direction: column; gap: 0.75rem; }
.review-row {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.review-info h3 { font-size: 1.05rem; margin-bottom: 0.15rem; }
.review-meta { font-size: 0.82rem; color: var(--sage); margin-bottom: 0.4rem; }
.review-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Detail Page */
.detail-header {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}
.detail-header h1 { font-size: 1.8rem; margin-bottom: 0.3rem; }
.detail-desc { color: #555; font-size: 1rem; margin-bottom: 0.75rem; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; font-size: 0.85rem; color: var(--sage); }
.meta-item { background: var(--sage-light); padding: 3px 10px; border-radius: 4px; }
.status-badge {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 10px;
    margin-top: 0.75rem;
}
.status-review { background: #FFF3CD; color: #856404; }
.detail-actions { margin-top: 1rem; display: flex; gap: 0.5rem; }

.detail-body { display: grid; grid-template-columns: 1fr 2fr; gap: 1.5rem; }
.detail-ingredients, .detail-steps {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.detail-ingredients h2, .detail-steps h2 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--terra-light);
}
.ingredient-list { list-style: none; }
.ingredient-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--sage-light);
    font-size: 0.92rem;
}
.ingredient-list li:last-child { border-bottom: none; }
.ing-amount { font-weight: 700; color: var(--terra); }
.ing-note { color: var(--sage); font-style: italic; }
.muted { color: var(--sage); }

.step-list { list-style: none; }
.step-list li { display: flex; gap: 0.75rem; margin-bottom: 1rem; align-items: flex-start; }
.step-circle {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    background: var(--terra);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
}
.step-text { flex: 1; font-size: 0.92rem; padding-top: 4px; }

.notes-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 2px solid var(--terra-light);
}
.notes-section h3 { font-size: 1rem; margin-bottom: 0.4rem; }
.notes-section p { font-size: 0.92rem; color: #555; }

.detail-footer { margin-top: 1.5rem; font-size: 0.9rem; }

/* Form */
.recipe-form {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.form-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--terra-light);
}
.form-section:last-of-type { border-bottom: none; }
.form-section h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.form-row { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; }
.form-row.four-col { display: grid; grid-template-columns: repeat(4, 1fr); }
.form-group { display: flex; flex-direction: column; }
.form-group.full { flex: 1; }
.form-group label { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; color: var(--dark); }
.required { color: var(--terra); }
.optional { color: var(--sage); font-weight: 400; }

input[type="text"],
input[type="number"],
input[type="url"],
textarea,
select {
    padding: 0.5rem 0.6rem;
    border: 1.5px solid var(--sage-light);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    width: 100%;
    background: var(--white);
}
input:focus, textarea:focus, select:focus { border-color: var(--terra); }
.status-select { max-width: 200px; }

/* Tag picker */
.tag-picker { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag-pill-label { cursor: pointer; }
.tag-pill-label input[type="checkbox"] { display: none; }
.tag-pill {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    border: 2px solid var(--tag-color, var(--sage));
    color: var(--tag-color, var(--sage));
    background: var(--white);
    transition: all 0.15s;
}
.tag-pill-label input:checked + .tag-pill {
    background: var(--tag-color, var(--sage));
    color: var(--white);
}
.tag-pill:hover { opacity: 0.85; }

/* Dynamic rows */
.ingredient-row { display: flex; gap: 0.4rem; margin-bottom: 0.4rem; align-items: center; }
.ingredient-row .ing-name { flex: 2.5; }
.ingredient-row .ing-amount-input { flex: 0.7; }
.ingredient-row .ing-unit { flex: 0.8; }
.ingredient-row .ing-aisle { flex: 1.5; }
.ingredient-row .ing-notes { flex: 1.5; }
.btn-remove {
    background: none;
    border: none;
    color: #c0392b;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    line-height: 1;
    flex-shrink: 0;
}
.btn-remove:hover { color: #e74c3c; }

.step-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; align-items: flex-start; }
.step-row .step-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: var(--terra);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    margin-top: 6px;
}
.step-row textarea { flex: 1; }

.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }

/* Responsive */
@media (max-width: 768px) {
    .nav-inner { flex-wrap: wrap; height: auto; padding: 0.5rem 0; gap: 0.5rem; }
    .nav-links { gap: 0.6rem; }
    .detail-body { grid-template-columns: 1fr; }
    .form-row.four-col { grid-template-columns: 1fr 1fr; }
    .recipe-grid { grid-template-columns: 1fr; }
    .review-row { flex-direction: column; align-items: flex-start; }
    .ingredient-row { flex-wrap: wrap; }
    .ingredient-row .ing-name { flex: 1 1 100%; }
    .ingredient-row .ing-amount-input,
    .ingredient-row .ing-unit,
    .ingredient-row .ing-aisle,
    .ingredient-row .ing-notes { flex: 1 1 45%; }
}

/* ============================
   PHASE 2: Meal Plans
   ============================ */

/* Plan list */
.new-plan-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}
.new-plan-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}
.new-plan-form .form-group { flex: 1; min-width: 200px; }
.new-plan-form .form-group label { font-size: 0.82rem; font-weight: 600; display: block; margin-bottom: 0.2rem; }

.plan-list { display: flex; flex-direction: column; gap: 0.75rem; }
.plan-row {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.plan-info h3 { font-size: 1.05rem; margin-bottom: 0.15rem; }
.plan-info h3 a { color: var(--terra); }
.plan-info h3 a:hover { text-decoration: underline; }
.plan-meta { font-size: 0.82rem; color: var(--sage); }
.plan-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Plan detail header */
.plan-header-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.2rem;
}
.plan-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.plan-header-top h1 { font-size: 1.5rem; margin-bottom: 0.15rem; }
.plan-header-meta { color: var(--sage); font-size: 0.9rem; }
.plan-header-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-hover);
    min-width: 340px;
    max-width: 500px;
    width: 90%;
}
.modal-card h2 { font-size: 1.2rem; margin-bottom: 0.75rem; }

/* Two-panel planner layout */
.planner-layout {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 1.2rem;
    align-items: start;
}

/* Left panel: Recipe browser */
.planner-browser {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    position: sticky;
    top: 72px;
}
.planner-browser h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.browser-search { display: flex; gap: 0.4rem; margin-bottom: 0.75rem; }
.browser-search .search-input { flex: 1; font-size: 0.85rem; padding: 0.4rem 0.6rem; }

.browser-recipes { display: flex; flex-direction: column; gap: 0.5rem; }
.browser-card {
    border: 1.5px solid var(--sage-light);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.browser-card-info { flex: 1; }
.browser-card-info h4 { font-family: Georgia, serif; color: var(--terra); font-size: 0.92rem; margin-bottom: 0.15rem; }
.browser-card-meta { font-size: 0.75rem; color: var(--sage); margin-bottom: 0.3rem; }
.btn-add {
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid var(--terra);
    color: var(--terra);
    background: var(--white);
    white-space: nowrap;
    transition: all 0.15s;
}
.btn-add:hover { background: var(--terra); color: var(--white); }

/* Right panel: Meal plan */
.planner-plan {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
}
.planner-plan h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }

.day-group { margin-bottom: 0.75rem; }
.day-header {
    background: var(--sage-light);
    padding: 0.35rem 0.75rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--dark);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.day-header-unassigned {
    background: transparent;
    border: 2px dashed var(--sage-light);
    border-bottom: none;
    color: var(--sage);
}
.day-empty {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    color: var(--sage);
    border: 1px solid var(--sage-light);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.plan-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--sage-light);
    border-top: none;
    border-left: 4px solid var(--terra);
    flex-wrap: wrap;
}
.plan-item:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.meal-breakfast { border-left-color: #C17D3B; }
.meal-lunch { border-left-color: var(--sage); }
.meal-dinner { border-left-color: var(--terra); }
.meal-snack { border-left-color: #E5E5E2; }

.plan-item-info { flex: 1; min-width: 120px; }
.plan-item-title { font-weight: 600; font-size: 0.88rem; color: var(--terra); }
.plan-item-title:hover { text-decoration: underline; }

.plan-item-controls {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}
.plan-item-controls select {
    width: auto;
    padding: 0.2rem 0.3rem;
    font-size: 0.78rem;
    border: 1.5px solid var(--sage-light);
    border-radius: 4px;
}
.servings-input {
    width: 48px !important;
    padding: 0.2rem 0.3rem;
    font-size: 0.78rem;
    text-align: center;
    border: 1.5px solid var(--sage-light);
    border-radius: 4px;
}

.unassigned-group { margin-top: 0.5rem; }

.plan-footer-actions { margin-top: 1.2rem; text-align: right; }
.btn-shopping {
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    border: 2px solid var(--sage);
    background: var(--sage);
    color: var(--white);
    cursor: not-allowed;
    opacity: 0.6;
}
.coming-soon { font-weight: 400; font-size: 0.78rem; }

/* Responsive: Planner */
@media (max-width: 900px) {
    .planner-layout { grid-template-columns: 1fr; }
    .planner-browser {
        position: static;
        max-height: 50vh;
    }
    .plan-header-top { flex-direction: column; }
    .plan-row { flex-direction: column; align-items: flex-start; }
    .plan-item { flex-wrap: wrap; }
    .plan-item-controls { width: 100%; }
}

/* ============================
   PHASE 3: Shopping Lists
   ============================ */

/* Active shopping list button on plan page */
.btn-shopping-active {
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    border: 2px solid var(--sage);
    background: var(--sage);
    color: var(--white);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-shopping-active:hover { background: #6b7a73; border-color: #6b7a73; }

/* Shopping list index */
.shopping-list-index { display: flex; flex-direction: column; gap: 0.75rem; }
.shopping-row {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.shopping-row-info { flex: 1; }
.shopping-row-info h3 { font-size: 1.05rem; margin-bottom: 0.15rem; }
.shopping-row-info h3 a { color: var(--terra); }
.shopping-row-meta { font-size: 0.82rem; color: var(--sage); margin-bottom: 0.4rem; }
.shopping-row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.progress-bar-sm {
    height: 5px;
    background: #E5E5E2;
    border-radius: 3px;
    overflow: hidden;
    max-width: 200px;
    margin-top: 0.3rem;
}
.progress-fill-sm { height: 100%; background: var(--sage); border-radius: 3px; transition: width 0.3s; }

/* Shopping detail header */
.shop-header {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.shop-header h1 { font-size: 1.4rem; margin-bottom: 0.1rem; }
.shop-header-meta { color: var(--sage); font-size: 0.88rem; }
.shop-header-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Progress bar */
.progress-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
}
.progress-bar {
    flex: 1;
    height: 8px;
    background: #E5E5E2;
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--sage);
    border-radius: 4px;
    transition: width 0.3s;
}
.progress-complete { background: var(--terra); }
.progress-label { font-size: 0.85rem; font-weight: 600; color: var(--sage); min-width: 36px; }

/* Aisle sections */
.aisle-section { margin-bottom: 0.75rem; }
.aisle-header {
    background: var(--sage-light);
    padding: 0.4rem 0.75rem;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--dark);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 56px;
    z-index: 10;
}
.aisle-count { font-weight: 400; color: var(--sage); font-size: 0.8rem; }
.btn-check-all {
    background: none;
    border: 1.5px solid var(--sage);
    color: var(--sage);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-check-all:hover { background: var(--sage); color: var(--white); }

/* Shopping items */
.shop-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    background: var(--white);
    border: 1px solid var(--sage-light);
    border-top: none;
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
}
.shop-item:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.shop-item:hover { background: #FAFAF8; }
.shop-item:active { background: var(--sage-light); }

.shop-item-checked {
    background: #F5F5F3;
}
.shop-item-checked .shop-item-text { text-decoration: line-through; color: var(--sage); }
.shop-item-checked .shop-amount { color: var(--sage); }

.shop-checkbox { flex-shrink: 0; line-height: 0; }
.shop-item-text { flex: 1; font-size: 0.92rem; }
.shop-amount { font-weight: 700; color: var(--terra); margin-right: 0.25rem; }
.shop-name { color: var(--dark); }

.shop-item-form { display: none; }
noscript .shop-item-form { display: inline; }
.btn-check-fallback {
    padding: 2px 6px;
    font-size: 0.72rem;
    border: 1px solid var(--sage);
    background: var(--white);
    cursor: pointer;
    border-radius: 3px;
}

/* Responsive shopping */
@media (max-width: 768px) {
    .shop-header { flex-direction: column; align-items: flex-start; }
    .shopping-row { flex-direction: column; align-items: flex-start; }
}

/* ============================
   PHASE 1A: PDF Upload
   ============================ */

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.alert-warning { background: #FFF3CD; color: #856404; border: 1px solid #ffeeba; }

.upload-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    max-width: 600px;
    margin: 0 auto;
}
.upload-zone {
    border: 2.5px dashed var(--sage-light);
    border-radius: var(--radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.upload-zone:hover, .upload-zone-hover { border-color: var(--terra); background: var(--terra-light); }
.upload-icon { margin-bottom: 0.75rem; }
.upload-text { font-size: 1rem; font-weight: 600; color: var(--dark); margin-bottom: 0.3rem; }
.upload-hint { font-size: 0.82rem; color: var(--sage); }
.file-input-hidden { display: none; }

.file-list { margin: 1rem 0; }
.file-item {
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    background: var(--sage-light);
    margin-bottom: 0.3rem;
    font-size: 0.88rem;
}
.file-item.file-error { background: #fdecea; color: #c0392b; }
.file-size { color: var(--sage); font-size: 0.78rem; }
.file-err-msg { font-weight: 600; font-size: 0.78rem; }

.upload-actions { margin-top: 1.2rem; text-align: center; }
.upload-note { margin-top: 1rem; font-size: 0.82rem; color: var(--sage); text-align: center; }

.pdf-badge {
    display: inline-block;
    background: var(--terra);
    color: var(--white);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    margin-right: 4px;
    vertical-align: middle;
}


/* ========================================
   Phase 5: Client Meal Log
   ======================================== */

/* Client List */
.client-list { display: flex; flex-direction: column; gap: 1rem; }
.client-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.2rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}
.client-card-main { flex: 1; }
.client-name { font-family: Georgia, serif; margin-bottom: 0.3rem; }
.client-name a { color: var(--terra); text-decoration: none; }
.client-name a:hover { text-decoration: underline; }
.client-notes { font-size: 0.88rem; color: var(--text-light); margin: 0.3rem 0; }
.client-meta { font-size: 0.82rem; color: var(--sage); margin-top: 0.3rem; }
.client-card-actions { display: flex; gap: 0.5rem; flex-shrink: 0; align-items: flex-start; }

/* Client Detail */
.client-profile { margin-bottom: 2rem; }
.client-profile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}
.client-profile-header h1 {
    font-family: Georgia, serif;
    color: var(--terra);
    margin-bottom: 0.3rem;
}
.client-dietary-notes {
    font-size: 0.92rem;
    color: var(--text-light);
    margin: 0.4rem 0;
    font-style: italic;
}
.client-stats { font-size: 0.88rem; color: var(--sage); margin-top: 0.4rem; }
.client-profile-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* Meal History */
.meal-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.meal-history-header h2 { font-family: Georgia, serif; color: var(--terra); }

.month-group { margin-bottom: 1.5rem; }
.month-header {
    font-family: Georgia, serif;
    font-size: 1.05rem;
    color: var(--terra);
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--sage);
    margin-bottom: 0.6rem;
}
.month-count { font-family: -apple-system, sans-serif; font-size: 0.82rem; color: var(--sage); font-weight: 400; margin-left: 0.5rem; }

.delivery-list { display: flex; flex-direction: column; gap: 0.5rem; }
.delivery-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid #eee;
}
.delivery-date {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--sage);
    min-width: 50px;
    flex-shrink: 0;
}
.delivery-info { flex: 1; }
.delivery-recipe-title {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}
.delivery-recipe-title:hover { color: var(--terra); }
.delivery-servings { font-size: 0.85rem; color: var(--text-light); }
.delivery-tags { margin-top: 3px; }
.tag-badge-sm { font-size: 0.68rem; padding: 1px 6px; }
.delivery-note { font-size: 0.85rem; color: var(--text-light); font-style: italic; margin-top: 3px; }
.delivery-delete { flex-shrink: 0; }

.btn-x {
    background: none;
    border: 1px solid #ddd;
    color: #999;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-x:hover { background: #fdecea; color: #c0392b; border-color: #c0392b; }

.back-link { margin-top: 2rem; }
.back-link a { color: var(--sage); text-decoration: none; font-size: 0.92rem; }
.back-link a:hover { color: var(--terra); }

/* Meal Log Form */
.meal-row {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.2rem;
    margin-bottom: 0.8rem;
}
.meal-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}
.meal-row-header h3 { font-size: 0.95rem; color: var(--sage); }

.form-row-inline { display: flex; gap: 1rem; }
.form-group-sm { width: 100px; flex-shrink: 0; }
.form-group-grow { flex: 1; }

.recipe-search {
    margin-bottom: 0.3rem;
}
.recipe-select { max-height: 200px; }

/* Page Header Row (title + action button) */
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* Form Danger Zone */
.form-danger-zone {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}

/* Tag checkboxes (client form) */
.tag-checkboxes { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag-check-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 4px 12px;
    border: 2px solid #ddd;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}
.tag-check-pill input { display: none; }
.tag-check-pill:has(input:checked) {
    border-color: var(--tag-color);
    background: var(--tag-color);
    color: #fff;
}

/* Phase 1B: Web URL Import */
.url-input { font-size: 1rem; }
.processing-msg {
    text-align: center;
    padding: 1.5rem;
    color: var(--sage);
    font-size: 1rem;
    font-style: italic;
}
.import-help {
    margin-top: 2rem;
    padding: 1.2rem 1.5rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.import-help h3 {
    font-family: Georgia, serif;
    color: var(--sage);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}
.import-help ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}
.import-help li { margin-bottom: 0.3rem; font-size: 0.92rem; }
.import-help p { font-size: 0.88rem; color: var(--text-light); margin-top: 0.8rem; }
.import-help a { color: var(--terra); }
.alert-danger {
    background: #fdecea;
    color: #c0392b;
    padding: 0.8rem 1.2rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}
.alert-warning {
    background: #fff8e6;
    color: #856404;
    padding: 0.8rem 1.2rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}


/* User menu dropdown */
.nav-inner { display: flex; align-items: center; }
.nav-user { position: relative; margin-left: auto; }
.nav-user-btn { background: none; border: 1px solid rgba(255,255,255,0.3); border-radius: 50%;
                width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
                cursor: pointer; color: inherit; transition: border-color 0.2s; }
.nav-user-btn:hover { border-color: rgba(255,255,255,0.7); }
.nav-dropdown { display: none; position: absolute; right: 0; top: calc(100% + 8px);
                background: #fff; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.12);
                min-width: 140px; overflow: hidden; z-index: 100; }
.nav-user.open .nav-dropdown { display: block; }
.dropdown-item { display: block; padding: 0.6rem 1rem; color: #333; text-decoration: none;
                 font-size: 0.9rem; transition: background 0.15s; }
.dropdown-item:hover { background: #f5f5f5; }

/* Recipe page header layout */
.page-header-top { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 1rem; }
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
@media (max-width: 768px) {
    .page-header-top { flex-direction: column; }
    .page-actions { width: 100%; }
}

/* Side items in meal plan */
.side-item {
    background: #f0f7f0;
    border-left: 3px solid #6aaa64;
}
.side-badge {
    display: inline-block;
    background: #6aaa64;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 3px;
    margin-right: 0.4rem;
    vertical-align: middle;
}
.side-qty {
    font-weight: 400;
    font-size: 0.8rem;
    color: #666;
}

/* Quick-add side form */
.side-add-card {
    background: #f8f9fa;
    border: 1px dashed #ccc;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-top: 1rem;
}
.side-add-card h3 {
    font-size: 0.85rem;
    margin: 0 0 0.5rem;
    color: #555;
}
.side-add-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}
.side-name-input {
    flex: 2;
    min-width: 140px;
    padding: 0.35rem 0.5rem;
    font-size: 0.82rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.side-amount-input {
    width: 60px;
    padding: 0.35rem 0.4rem;
    font-size: 0.82rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.side-unit-input {
    width: 70px;
    padding: 0.35rem 0.4rem;
    font-size: 0.82rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.side-aisle-input,
.side-day-input {
    padding: 0.35rem 0.4rem;
    font-size: 0.82rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}
@media (max-width: 600px) {
    .side-add-form { flex-direction: column; }
    .side-name-input,
    .side-amount-input,
    .side-unit-input,
    .side-aisle-input,
    .side-day-input { width: 100%; }
}
