:root {
    --primary: #2c3e50;
    --accent: #27ae60;
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #34495e;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, system-ui, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 100px;
}

header {
    background: var(--primary);
    color: white;
    padding: 30px 20px;
    border-radius: 0 0 20px 20px;
    margin: -20px -20px 25px -20px;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
}

header .btn-config {
    position: absolute;
    top: 15px;
    right: 15px;
}

h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 800;
}

p.subtitle {
    margin: 5px 0 0;
    opacity: 0.8;
    font-size: 0.9rem;
}

.tabs {
    display: flex;
    background: var(--card);
    padding: 5px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
}

.tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    font-weight: 600;
    color: #95a5a6;
    cursor: pointer;
    border-radius: 8px;
}

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

.day-card {
    background: var(--card);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
    border-left: 5px solid transparent;
}

.day-card.filled {
    border-left-color: var(--accent);
}

.day-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: 800;
    color: var(--primary);
}

select {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #dfe6e9;
    background: #f8f9fa;
    font-size: 1rem;
    margin-top: 5px;
}

.menu-details {
    background: #fdfdfd;
    border-top: 1px solid #eee;
    margin-top: 10px;
    padding-top: 10px;
    font-size: 0.85rem;
    display: none;
}

.menu-details.visible {
    display: block;
}

.meal-row {
    display: flex;
    margin-bottom: 6px;
    border-bottom: 1px dashed #eee;
    padding-bottom: 4px;
}

.meal-tag {
    font-weight: 700;
    width: 100px;
    color: var(--accent);
    font-size: 0.7rem;
    text-transform: uppercase;
    flex-shrink: 0;
}

.meal-content {
    color: #555;
    flex: 1;
}

.shopping-list-container {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.category-header {
    font-weight: 800;
    color: var(--primary);
    border-bottom: 2px solid #f1f2f6;
    margin: 15px 0 10px 0;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.item-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f9f9f9;
}

.item-qty {
    background: #e8f6ef;
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.9rem;
}

.ritual-card {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.ritual-title {
    font-weight: 800;
    display: block;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.fab-reset {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #e74c3c;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none;
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: #95a5a6;
}

/* --- CHECKLIST STYLES --- */
.btn-clear-checks {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text);
    transition: all 0.2s;
}

.btn-clear-checks:hover {
    background: #e9ecef;
}

.checkbox-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex: 1;
    gap: 10px;
}

.checkbox-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
}

.item-row:hover {
    background: #f8f9fa;
    margin: 0 -10px;
    padding: 10px;
    border-radius: 6px;
}

.item-row.checked {
    opacity: 0.5;
}

.item-row.checked .item-name {
    text-decoration: line-through;
    color: #95a5a6;
}

.item-row.checked .item-qty {
    background: #ecf0f1;
    color: #95a5a6;
}

/* Barra contenedora de macros */
.macros-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    margin: 10px 0;
    justify-content: space-around;
    border: 1px solid #e9ecef;
}

/* Etiquetas individuales */
.macro-tag {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    color: #495057;
    background: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Colores específicos para cada macro */
.macro-tag.kcal {
    color: #e03131;
    border-bottom: 2px solid #e03131;
}

/* Rojo */
.macro-tag.prot {
    color: #1971c2;
    border-bottom: 2px solid #1971c2;
}

/* Azul */
.macro-tag.carb {
    color: #f08c00;
    border-bottom: 2px solid #f08c00;
}

/* Naranja */
.macro-tag.fat {
    color: #2f9e44;
    border-bottom: 2px solid #2f9e44;
}

/* Target comparison styles */
.macro-tag.on-target {
    background: #d3f9d8;
    border-color: #2f9e44 !important;
}

.macro-tag.under-target {
    background: #fff3bf;
    border-color: #f59f00 !important;
}

.macro-tag.over-target {
    background: #ffe3e3;
    border-color: #e03131 !important;
}

/* Config button */
.btn-config {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-config:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 16px;
    padding: 25px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal h2 {
    margin: 0 0 20px 0;
    color: var(--primary);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

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

.btn-cancel {
    background: #e9ecef;
    color: var(--text);
}

.targets-summary {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    font-size: 0.9rem;
}

.targets-summary strong {
    color: var(--primary);
}

/* --- PREP VIEW STYLES --- */
.prep-container {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.prep-section {
    margin-bottom: 25px;
}

.prep-header {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0 0 5px 0;
}

.prep-subtitle {
    font-size: 0.8rem;
    color: #95a5a6;
    margin: 0 0 15px 0;
}

.prep-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.prep-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: #f8f9fa;
    border-left: 4px solid var(--accent);
}

.prep-item.batch {
    border-left-color: #3498db;
}

.prep-item.fresh {
    border-left-color: #e67e22;
}

.prep-task {
    flex: 1;
    font-size: 0.95rem;
}

.prep-count {
    background: #3498db;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.prep-day-card {
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.prep-day-header {
    background: var(--primary);
    color: white;
    padding: 8px 12px;
    font-weight: 700;
    font-size: 0.9rem;
}

.prep-day-content {
    padding: 10px 12px;
}

.prep-mini {
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: var(--text);
}

.no-tasks {
    color: #95a5a6;
    font-size: 0.9rem;
    text-align: center;
    padding: 15px;
}

.prep-config {
    background: #e8f4f8;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.prep-config label {
    font-weight: 700;
    color: var(--primary);
}

.prep-config select {
    flex: 1;
    min-width: 150px;
}

.prep-task-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.prep-for {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-top: 2px;
}

.prep-badge {
    background: var(--accent);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
}

.fresh-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.fresh-list li {
    padding: 4px 0;
    font-size: 0.9rem;
    color: var(--text);
}

.prep-days-selector {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.prep-day-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border-radius: 8px;
    background: white;
    border: 2px solid #ddd;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    font-weight: 600;
}

.prep-day-checkbox input {
    display: none;
}

.prep-day-checkbox:hover {
    border-color: var(--accent);
}

.prep-day-checkbox.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* --- EDITOR MODAL STYLES --- */
.modal-large {
    max-width: 550px;
    width: 95%;
}

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

.modal-header h2 {
    margin: 0;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-close:hover {
    background: #f0f0f0;
}

.editor-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.editor-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    transition: all 0.2s;
}

.editor-tab.active {
    background: var(--primary);
    color: white;
}

.editor-content {
    max-height: 60vh;
    overflow-y: auto;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row .form-group {
    flex: 1;
}

/* Macros Editor */
.macros-editor {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
}

.macros-title {
    font-weight: 700;
    display: block;
    margin-bottom: 10px;
    color: var(--primary);
}

.macros-inputs {
    display: flex;
    gap: 10px;
}

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

.macro-input label {
    font-size: 0.8rem;
    display: block;
    margin-bottom: 5px;
}

.macro-input input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-align: center;
    font-size: 0.95rem;
}

/* Food/Menu List */
.food-list,
.menu-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.food-item,
.menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid var(--accent);
}

.food-info,
.menu-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.food-cat-tag {
    font-size: 0.7rem;
    color: #888;
}

.food-macros-mini,
.menu-summary {
    font-size: 0.8rem;
    color: #666;
}

.food-actions,
.menu-actions {
    display: flex;
    gap: 5px;
}

.btn-icon {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.1);
}

.empty-list {
    text-align: center;
    padding: 30px;
    color: #999;
}

.empty-list .hint {
    font-size: 0.85rem;
    margin-top: 5px;
}

.hint {
    color: #999;
    font-size: 0.85rem;
    font-style: italic;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.form-actions button {
    flex: 1;
}

.btn-secondary {
    background: #e9ecef;
    color: var(--text);
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

/* Data Management Section */
.data-management {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
}

.data-management h3 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    color: var(--primary);
}

.data-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.data-buttons:last-child {
    margin-bottom: 0;
}

.btn-data {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    background: var(--primary);
    color: white;
    transition: all 0.2s;
    position: relative;
}

.btn-data:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-data.btn-secondary {
    background: white;
    color: var(--text);
    border: 1px solid #ddd;
}

.btn-data .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
}

/* Autocomplete */
.autocomplete-wrapper {
    position: relative;
    flex: 2;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.autocomplete-item:hover {
    background: #f8f9fa;
}

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

.ac-cat {
    font-size: 0.75rem;
    color: #888;
}

.ac-name {
    font-weight: 600;
    flex: 1;
}

.ac-unit {
    font-size: 0.75rem;
    color: #888;
}

/* Ingredient Adder */
.ingredient-adder,
.prep-adder {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.ingredient-adder input,
.prep-adder input {
    flex: 1;
    min-width: 80px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.ingredient-adder input[type="number"],
.prep-adder input[type="number"] {
    max-width: 80px;
}

.btn-add {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}

.btn-add:hover {
    opacity: 0.9;
}

/* Ingredient/Prep Chips */
.ingredients-list,
.prep-list-editor {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
}

.ingredient-chip,
.prep-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e8f4f8;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
}

.prep-chip {
    background: #fff3e0;
}

.ingredient-chip button,
.prep-chip button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    color: #e74c3c;
    padding: 0 2px;
}

/* Section headers */
.meals-section h3,
.ingredients-section h3,
.prep-section h3 {
    font-size: 1rem;
    color: var(--primary);
    margin: 20px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

/* Search Box */
.search-box {
    margin-bottom: 15px;
}

.search-box input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

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

/* Search Results */
.search-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
    border-left: 4px solid #ddd;
}

.search-item:hover {
    background: #f0f2f5;
}

.search-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.search-item-cat {
    font-size: 0.7rem;
    color: #888;
}

.search-item-macros {
    font-size: 0.8rem;
    color: #666;
}

.search-item-badges {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.btn-edit-search {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
}

.btn-edit-search:hover {
    opacity: 0.9;
}

/* Badges */
.badge-custom,
.badge-base,
.badge-new,
.badge-override {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-custom {
    background: #fff3cd;
    color: #856404;
}

.badge-base {
    background: #e2e3e5;
    color: #495057;
}

.badge-new {
    background: #d4edda;
    color: #155724;
}

.badge-override {
    background: #cce5ff;
    color: #004085;
    margin-top: 4px;
}

/* Editing Notice */
.editing-notice {
    background: #fff3cd;
    color: #856404;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    border-left: 4px solid #ffc107;
}