﻿:root {
    --bg: #eef5f1;
    --panel: #ffffff;
    --text: #17231d;
    --muted: #66756d;
    --primary: #2f7d59;
    --primary-dark: #245f45;
    --blue: #2457a6;
    --blue-dark: #1d4584;
    --border: #d9e5de;
    --soft: #f4f8f6;
    --danger-bg: #f7e2e2;
    --danger-text: #9b2424;
    --warning: #b96615;
}

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

body {
    min-height: 100vh;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 24px;
}

.app-shell {
    width: min(1180px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    gap: 18px;
    align-items: start;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 14px 34px rgba(31, 64, 47, 0.12);
}

.header-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 22px;
}

.header-row.compact {
    align-items: center;
    margin-bottom: 16px;
}

.eyebrow,
.section-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

h1,
h2 {
    line-height: 1.15;
    font-weight: 700;
}

h1 {
    font-size: 34px;
}

h2 {
    font-size: 24px;
}

.date-pill,
.meal-badge {
    flex: 0 0 auto;
    background: #e4f0e9;
    color: #254b34;
    border-radius: 999px;
    padding: 8px 11px;
    font-size: 13px;
    font-weight: 700;
}

.goal-section {
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 18px 0;
    margin-bottom: 20px;
}

.goal-topline {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.goal-topline strong,
.remaining-box strong {
    display: block;
    font-size: 28px;
    margin-top: 3px;
}

.remaining-box {
    text-align: right;
}

.remaining-box span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    font-weight: 700;
}

.progress-track {
    height: 10px;
    overflow: hidden;
    background: #e8efe9;
    border-radius: 999px;
    margin: 14px 0;
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--primary);
    border-radius: inherit;
    transition: width 180ms ease;
}

.progress-track span.over-goal {
    background: var(--warning);
}

.goal-form,
.form-grid,
.action-row,
.backup-actions {
    display: grid;
    gap: 10px;
}

.goal-form {
    grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto;
    align-items: end;
}

.entry-form {
    display: grid;
    gap: 12px;
}

.form-grid {
    grid-template-columns: minmax(220px, 1.4fr) minmax(130px, 0.7fr) minmax(140px, 0.7fr);
}

.field-group {
    display: grid;
    gap: 8px;
}

label {
    font-weight: 700;
    font-size: 14px;
    color: #2c4235;
}

input,
select {
    width: 100%;
    min-height: 46px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font-size: 16px;
}

input:focus,
select:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(47, 125, 89, 0.16);
}

button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.add-btn,
.save-btn {
    width: 100%;
    color: #ffffff;
}

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

.add-btn:hover {
    background: var(--primary-dark);
}

.save-btn {
    background: var(--blue);
}

.save-btn:hover {
    background: var(--blue-dark);
}

.secondary-btn {
    background: #edf3ef;
    color: #244132;
    border: 1px solid var(--border);
}

.danger-btn {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid #edc9c9;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 18px 0 14px;
}

.summary-grid div,
.history-stats {
    padding: 14px;
    background: var(--soft);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.summary-grid span,
.food-item span,
.history-list small,
.history-stats span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-top: 3px;
}

.summary-grid strong,
.history-stats strong {
    display: block;
    font-size: 22px;
    margin-top: 3px;
}

.food-list,
.history-list,
.history-detail-list {
    list-style: none;
    display: grid;
    gap: 10px;
}

.food-list {
    max-height: 340px;
    overflow-y: auto;
    padding-right: 2px;
}

.food-item,
.history-item details {
    background: #fbfcfb;
    border: 1px solid #e0e8e3;
    border-radius: 8px;
}

.food-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 13px;
}

.item-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.food-item button {
    min-height: 36px;
    background: var(--danger-bg);
    color: var(--danger-text);
}

.action-row {
    grid-template-columns: 1fr 1fr;
    margin-top: 14px;
}

.backup-actions {
    grid-template-columns: 1fr;
    margin-bottom: 14px;
}

.history-stats {
    margin-bottom: 14px;
}

.history-item details {
    padding: 0;
}

.history-item summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 13px;
    cursor: pointer;
}

.history-detail-list {
    padding: 0 13px 13px;
}

.history-detail-list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 0;
    border-top: 1px solid #e6eee9;
    font-size: 14px;
}

.empty-state {
    padding: 16px;
    text-align: center;
    color: var(--muted);
    background: #f7faf8;
    border: 1px dashed #c9d9d0;
    border-radius: 8px;
}

@media (max-width: 920px) {
    body {
        padding: 14px;
    }

    .app-shell,
    .form-grid,
    .goal-form,
    .summary-grid,
    .action-row {
        grid-template-columns: 1fr;
    }

    .header-row,
    .goal-topline {
        flex-direction: column;
        align-items: stretch;
    }

    .remaining-box {
        text-align: left;
    }

    .date-pill {
        width: fit-content;
    }
}
