:root {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #24352d;
    background: #f4f7f4;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    --green: #286b4c;
    --green-dark: #1d5239;
    --green-light: #e2efe6;
    --border: #e1e8e2;
    --muted: #738078;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 32px 16px;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #a7d4b6;
    outline-offset: 2px;
}

.app {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
}

.app-header {
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--green);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1.8px;
}

h1 {
    margin: 0;
    font-size: clamp(27px, 6vw, 36px);
    line-height: 1.2;
    letter-spacing: -1px;
}

.subtitle {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr 1.25fr;
    gap: 5px;
    padding: 5px;
    margin-bottom: 22px;
    background: #e9eee9;
    border-radius: 14px;
}

.tab {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 10px 6px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #5f6d64;
    font-size: 14px;
    font-weight: 650;
    line-height: 1.3;
    text-align: center;
    overflow-wrap: anywhere;
    transition: background 150ms ease, color 150ms ease;
}

.tab.active {
    background: white;
    color: var(--green-dark);
    box-shadow: 0 1px 4px #1b35251a;
}

.tab:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

#product-form {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 22px;
    margin-bottom: 28px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 5px 20px #1b352508;
}

#add-section #product-form {
    margin-bottom: 0;
}

#products-section,
#shopping-section,
#add-section {
    min-width: 0;
    animation: section-appear 160ms ease-out;
}

@keyframes section-appear {
    from {
        opacity: 0.7;
        transform: translateY(3px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h2 {
    margin: 0;
    font-size: 18px;
}

#product-form h2 {
    margin-bottom: 7px;
}

label {
    margin-top: 4px;
    color: #46564b;
    font-size: 13px;
    font-weight: 650;
}

input,
select,
textarea {
    width: 100%;
    min-width: 0;
    padding: 12px 13px;
    border: 1px solid #dce4dd;
    border-radius: 10px;
    background: #fff;
    color: #24352d;
}

input::placeholder,
textarea::placeholder {
    color: #a0aaa3;
}

textarea {
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-row>div {
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-width: 0;
}

.primary-button {
    min-height: 46px;
    margin-top: 8px;
    padding: 12px 16px;
    border: 0;
    border-radius: 11px;
    background: var(--green);
    color: white;
    font-weight: 700;
    transition: background 150ms ease;
}

.primary-button:hover {
    background: var(--green-dark);
}

.list-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 14px;
}

.list-heading span {
    color: var(--muted);
    font-size: 13px;
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.product-card {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 15px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.product-checkbox {
    width: 21px;
    height: 21px;
    flex-shrink: 0;
    accent-color: var(--green);
    cursor: pointer;
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-name {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.product-details {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.product-notes {
    margin: 6px 0 0;
    color: #596b5e;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.product-card.is-selected {
    border-color: #b9d9c3;
    background: #fbfefb;
}

.card-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.small-button {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: white;
    color: var(--green-dark);
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}

.small-button:hover {
    background: var(--green-light);
}

.delete-button {
    color: #a33c3c;
}

.empty-state {
    padding: 28px 16px;
    border: 1px dashed #ccd8ce;
    border-radius: 14px;
    color: var(--muted);
    text-align: center;
    line-height: 1.5;
}

#status-message {
    min-height: 20px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

#status-message.error {
    color: #b42318;
}

[hidden] {
    display: none !important;
}

@media (max-width: 480px) {
    body {
        padding: 24px 12px;
    }

    #product-form {
        padding: 17px;
    }

    .product-card {
        gap: 10px;
        padding: 12px;
    }

    .small-button {
        padding: 8px;
    }

    .tabs {
        gap: 3px;
        padding: 4px;
    }

    .tab {
        padding: 9px 4px;
        font-size: 12px;
        min-height: 46px;
    }
}