:root {
    --bg: #f7fafc;
    --card: #ffffff;
    --accent: #2563eb; /* blue-600 */
    --muted: #6b7280; /* gray-500 */
    --text: #0f1724; /* slate-900 */
    --input-border: #e6eaf0;
    --muted-surface: #f1f5f9;
}

html,
body {
    min-height: 100%;
    margin: 0;
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial;
}

/* Put the page background on the html element so it always covers the document height */
html {
    background: linear-gradient(180deg, var(--bg) 0%, #eef2ff 100%);
}

body {
    background: transparent;
    color: var(--text);
    display: flex;
    /* align to top so long pages can scroll normally */
    align-items: flex-start;
    justify-content: center;
    min-height: 100vh;
    padding: 32px 16px;
    box-sizing: border-box;
}

.card {
    background: var(--card);
    border: 1px solid var(--input-border);
    max-width: 800px;
    width: 100%;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 6px 20px rgba(15, 23, 36, 0.06);
}

h1 {
    margin: 0 0 6px 0;
    font-size: 20px;
}

p.lead {
    margin: 0 0 18px 0;
    color: var(--muted);
}

form {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    background: var(--card);
    color: var(--text);
    box-sizing: border-box;
}

textarea {
    min-height: 100px;
    grid-column: span 2;
}

.full {
    grid-column: span 2;
}

.actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
}

button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
}

button.secondary {
    background: transparent;
    border: 1px solid var(--input-border);
    color: var(--text);
}

.note {
    font-size: 13px;
    color: var(--muted);
    margin-top: 12px;
}

@media (max-width: 820px) {
    form {
        grid-template-columns: 1fr;
    }
    textarea {
        min-height: 120px;
    }
}

/* Day / meal styles */
.days {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.day {
    background: var(--muted-surface);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--input-border);
}

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

.day-header h2 {
    margin: 0;
    font-size: 16px;
}

.day-total {
    font-size: 14px;
    color: var(--muted);
}

.meal-types {
    display: grid;
    /* stack meal types vertically (one column) */
    grid-template-columns: 1fr;
    gap: 12px;
}

.meal-type h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
    font-size: 14px;
}

.meals-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.meal-card {
    position: relative;
    border-radius: 8px;
    padding: 10px;
    background: #ffffff;
    border: 1px solid var(--input-border);
    display: grid;
    grid-template-columns: 1fr auto; /* left (select+qty) | right (remove+price) */
    gap: 12px;
    align-items: center;
}

.meal-left { display:flex; gap:8px; align-items:center }
.meal-left .meal-option { flex:1; min-width:0 }
.meal-left .meal-qty { width:70px }

.meal-right { display:flex; gap:10px; align-items:center; justify-self:end }

.meal-price {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}

/* Price layout: show total then a smaller unit×qty under it */
.meal-price {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.meal-price .meal-total {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}
.meal-price .meal-unitqty {
    font-weight: 400;
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

/* Make selects and number inputs consistent height inside meal cards */
.meal-card .meal-option,
.meal-card select,
.meal-card input[type="number"] {
    height: 40px;
    line-height: 1.2;
    padding: 8px 10px;
    box-sizing: border-box;
}

/* Ensure the remove button aligns nicely with inputs */
.meal-card .remove-meal {
    height: 36px;
    align-self: center;
}

.meal-card input[type="number"] {
    width: 70px;
    border: 1px solid var(--input-border);
    padding: 8px;
    border-radius: 6px;
    justify-self: start;
}

.remove-meal {
    background: transparent;
    border: 1px solid var(--input-border);
    color: var(--muted);
    padding: 6px 8px;
    border-radius: 8px;
}

@media (max-width: 720px) {
    .meal-types {
        grid-template-columns: 1fr;
    }
    /* Make meal card flow vertically: select full-width on first row,
       then qty + price + remove on the next row. We use flex-wrap and
       `display: contents` on .meal-left so the select and qty become
       direct flow children and can wrap independently. */
    .meal-card {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        padding: 10px;
    }

    /* Allow the left container's children to participate in the card's layout */
    .meal-left {
        display: contents;
    }

    /* Make the select span the full width on its own row */
    .meal-card .meal-option,
    .meal-card select {
        flex: 1 1 100%;
        min-width: 0;
    }

    /* Quantity input sits on the second row, left side */
    .meal-card .meal-qty,
    .meal-card input[type="number"] {
        flex: 0 0 70px;
        width: 70px;
    }

    /* Right-side area (price + remove) sits to the right on the second row */
    .meal-right {
        display: flex;
        gap: 10px;
        align-items: center;
        justify-content: flex-end;
        flex: 1 1 auto;
    }

    .meal-price {
        justify-self: end;
        align-items: flex-end;
    }
}

/* Floating total widget (bottom-right) */
.floating-total {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: var(--card);
    border: 1px solid var(--input-border);
    padding: 10px 14px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(15,23,36,0.12);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    min-width: 110px;
}
.floating-total .floating-label {
    font-size: 12px;
    color: var(--muted);
}
.floating-total .floating-amount {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}
.floating-total .floating-count {
    font-size: 12px;
    color: var(--muted);
}

@media (max-width: 520px) {
    .floating-total { right: 12px; bottom: 12px; }
}

/* Small submit notice popup (positioned via JS under the submit button) */
.submit-notice {
    background: var(--card);
    border: 1px solid var(--input-border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 6px 18px rgba(15,23,36,0.12);
    white-space: nowrap;
    z-index: 2000;
    transition: opacity 160ms ease, transform 160ms ease;
    opacity: 0;
    /* center horizontally using left + translateX(-50%), then shift slightly up when hidden */
    transform: translateX(-50%) translateY(-6px);
}
.submit-notice.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Modal confirmation (dismissible) shown on successful submit */
.submit-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.38);
    z-index: 3000;
}
.submit-modal-content {
    position: relative;
    background: var(--card);
    color: var(--text);
    padding: 18px 20px;
    border-radius: 10px;
    max-width: 520px;
    width: calc(100% - 40px);
    box-shadow: 0 12px 40px rgba(15,23,36,0.18);
    font-size: 15px;
}
.submit-modal-title {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.submit-modal-body {
    margin: 0 0 16px 0;
    color: var(--muted);
    line-height: 1.4;
}
.submit-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
}
.submit-modal-button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}
.submit-modal-button.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--input-border);
}
.submit-modal-close {
    display: none;
}
.submit-modal-close:focus {
    outline: none;
}