:root {
    --bg: #faf7f2;
    --surface: #ffffff;
    --text: #2b2420;
    --muted: #7a6f66;
    --line: #e7dfd5;
    --accent: #e36c0a;
    --accent-soft: #fdeee2;
    --lunch: #b45309;
    --dinner: #1d4ed8;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #171412;
        --surface: #221e1b;
        --text: #f1ebe5;
        --muted: #a89c91;
        --line: #3a332e;
        --accent: #f08a3c;
        --accent-soft: #3a2616;
        --lunch: #f5a35c;
        --dinner: #8fb0ff;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 1rem;
    background: var(--surface);
    border-bottom: 3px solid var(--accent);
}

.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; gap: 1rem; }
.topbar nav a { text-decoration: none; font-weight: 600; }
.logout-form { margin: 0; }
.logout-form button { border: 0; padding: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.topbar nav a.admin { margin-left: auto; padding: .25rem .75rem; border-radius: 8px; background: var(--accent-soft); }

.banner {
    margin: 0;
    padding: .5rem 1rem;
    background: var(--accent-soft);
    font-size: .9rem;
}

main { max-width: 1200px; margin: 0 auto; padding: 1rem; }

h1 { margin: 0; font-size: 1.5rem; }
h2 { margin: 0 0 .5rem; font-size: 1.1rem; }
h2 small { color: var(--muted); font-weight: 400; font-size: .9rem; }

.muted, .empty { color: var(--muted); }
.error { padding: 1rem; border-radius: 8px; background: #fde2e2; color: #7f1d1d; }
.success { padding: 1rem; border-radius: 8px; background: #dcfce7; color: #166534; }

.upload-form { max-width: 500px; }
.upload-form fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; background: var(--surface); }
.upload-form legend { padding: 0 .5rem; font-weight: 600; }
.upload-form input[type="file"] { display: block; margin: 1rem 0; }
.upload-form button { padding: .5rem 1rem; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.upload-form button:hover { opacity: .9; }

.current-file { max-width: 500px; margin-top: 2rem; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.current-file h2 { margin-top: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1rem;
}

.today {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.meals { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; margin: 0; }
.meals dt { color: var(--muted); }
.meals dd { margin: 0; font-weight: 600; }

.month-nav {
    display: grid;
    grid-template-columns: 2.5rem 1fr 2.5rem;
    align-items: center;
    text-align: center;
    margin-bottom: .75rem;
}

.month-nav a {
    font-size: 1.75rem;
    line-height: 1;
    text-decoration: none;
    padding: .25rem;
    border-radius: 8px;
}

.month-nav a:hover { background: var(--accent-soft); }

.calendar {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: var(--surface);
    border: 1px solid var(--line);
}

.calendar th {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    padding: .4rem;
}

.calendar td {
    vertical-align: top;
    border: 1px solid var(--line);
    padding: .4rem;
    height: 6rem;
}

.calendar th.week, .calendar td.week {
    width: 3rem;
    text-align: center;
    color: var(--muted);
    font-size: .85rem;
}

.calendar th.week { color: #fff; }
.calendar td.other { background: var(--bg); }
.calendar td.is-today { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }

.num { display: block; font-weight: 700; margin-bottom: .25rem; }

.meal { display: block; font-size: .9rem; padding-left: .5rem; border-left: 3px solid; margin-bottom: .2rem; }
.meal.lunch { border-color: var(--lunch); }
.meal.dinner { border-color: var(--dinner); }

.legend { display: flex; gap: 1rem; color: var(--muted); }
.legend .meal { display: inline-block; }

.dish-lists {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.dishes { list-style: none; margin: 0; padding: 0; }
.dishes li { padding: .5rem 0; border-top: 1px solid var(--line); }
.dishes li:first-child { border-top: 0; }
.dishes p { margin: .25rem 0 0; font-size: .9rem; }
.dishes a { margin-right: .75rem; font-size: .9rem; }

.tag {
    display: inline-block;
    margin-left: .5rem;
    padding: 0 .5rem;
    border-radius: 999px;
    background: var(--accent-soft);
    font-size: .8rem;
}

/* En el móvil el calendario pasa a ser una lista de días. */
@media (max-width: 720px) {
    .calendar, .calendar tbody, .calendar tr, .calendar td { display: block; width: 100%; }
    .calendar thead, .calendar td.other { display: none; }
    .calendar { border: 0; background: none; }
    .calendar tr { margin-bottom: .75rem; }
    .calendar td.week {
        width: auto;
        text-align: left;
        border: 0;
        height: auto;
        padding: .25rem 0;
    }
    .calendar td.week::before { content: "Semana "; }
    .calendar td:not(.week) { height: auto; background: var(--surface); border-radius: 8px; margin-bottom: .4rem; }
    .calendar td:not(.week) .num { display: none; }
    .calendar td:not(.week)::before { content: attr(data-label); display: block; font-weight: 700; margin-bottom: .25rem; }
}
