:root {
    --green: #05b84f;
    --green-dark: #008a3a;
    --leaf: #3e741d;
    --green-soft: #eafff2;
    --cream: #fffbea;
    --ink: #172033;
    --muted: #647084;
    --line: #e5e9ef;
    --orange: #ff7a1a;
    --blue: #0b7cff;
    --shadow: 0 14px 34px rgba(23, 32, 51, 0.10);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Nunito", "Quicksand", "Arial Rounded MT Bold", "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background: #f8faf9;
    font-size: 16px;
    scroll-behavior: smooth;
}
::selection {
    background: rgba(5, 184, 79, 0.22);
    color: var(--ink);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 {
    font-family: "Nunito", "Quicksand", "Arial Rounded MT Bold", "Segoe UI", Arial, sans-serif;
    font-weight: 900;
    letter-spacing: 0;
}
.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 6px 24px rgba(23, 32, 51, 0.05);
}
.nav { height: 76px; display: flex; align-items: center; gap: 22px; }
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    min-width: 224px;
}
.brand-logo {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 6px 14px rgba(5, 184, 79, 0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.brand-text {
    color: var(--green);
    font-size: 25px;
    font-weight: 950;
    line-height: 1;
    white-space: nowrap;
}
.brand:hover .brand-logo {
    transform: translateY(-2px) rotate(-2deg);
    box-shadow: 0 10px 20px rgba(5, 184, 79, 0.24);
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    color: #465264;
    font-size: 15px;
    font-weight: 800;
    white-space: nowrap;
}
.nav-links a {
    position: relative;
    padding: 10px 12px;
    border-radius: 999px;
    transition: color 0.18s ease;
}
.nav-links a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 2px;
    height: 2px;
    border-radius: 999px;
    background: var(--green);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.2s ease;
}
.nav-links a:hover {
    color: var(--green-dark);
    background: rgba(5, 184, 79, 0.08);
}
.nav-links a:hover::after {
    transform: scaleX(0);
}
.nav-links a.is-active {
    color: var(--green-dark);
    background: rgba(5, 184, 79, 0.10);
}
.nav-links a.is-active::after {
    transform: scaleX(1);
}
.nav-actions { display: flex; align-items: center; gap: 10px; font-weight: 800; white-space: nowrap; }
.icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.nav-icon-btn,
.nav-action-link {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 999px;
    color: var(--green-dark);
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.nav-icon-btn {
    position: relative;
    width: 44px;
    border: 1px solid rgba(0, 138, 58, 0.18);
    background: #fff;
}
.cart-count-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    display: inline-grid;
    place-items: center;
    border: 2px solid #fff;
    border-radius: 999px;
    background: #ff385c;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 8px 16px rgba(255, 56, 92, 0.24);
}
.nav-action-link {
    padding: 0 12px;
}
.nav-icon-btn:hover,
.nav-action-link:hover {
    transform: translateY(-2px);
    background: var(--green-soft);
    box-shadow: 0 12px 22px rgba(5, 184, 79, 0.12);
}
.register-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
}
.account-menu {
    position: relative;
}
.account-menu summary {
    list-style: none;
}
.account-menu summary::-webkit-details-marker {
    display: none;
}
.user-pill {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 6px;
    border: 1px solid rgba(5, 184, 79, 0.18);
    border-radius: 999px;
    background: linear-gradient(135deg, #ffffff, #f1fff6);
    box-shadow: 0 8px 18px rgba(23, 32, 51, 0.06);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.user-pill:hover,
.account-menu[open] .user-pill {
    transform: translateY(-2px);
    border-color: rgba(5, 184, 79, 0.34);
    box-shadow: 0 14px 28px rgba(5, 184, 79, 0.14);
}
.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--green);
    color: #fff;
    font-weight: 950;
    text-transform: uppercase;
    box-shadow: 0 8px 16px rgba(5, 184, 79, 0.22);
}
.user-avatar.large {
    width: 46px;
    height: 46px;
    font-size: 19px;
}
.user-meta {
    min-width: 0;
    display: grid;
    line-height: 1.1;
}
.user-meta strong {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink);
    font-size: 14px;
}
.user-meta small {
    color: var(--green-dark);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0;
}
.chevron-icon {
    width: 16px;
    height: 16px;
    color: var(--green-dark);
    transition: transform 0.18s ease;
}
.account-menu[open] .chevron-icon {
    transform: rotate(180deg);
}
.account-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 12px);
    width: 286px;
    padding: 14px;
    border: 1px solid rgba(5, 184, 79, 0.14);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 24px 60px rgba(23, 32, 51, 0.16);
    z-index: 20;
    animation: dropdownIn 0.18s ease both;
}
.account-dropdown::before {
    content: "";
    position: absolute;
    right: 28px;
    top: -7px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-left: 1px solid rgba(5, 184, 79, 0.14);
    border-top: 1px solid rgba(5, 184, 79, 0.14);
    transform: rotate(45deg);
}
.account-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 4px 12px;
    border-bottom: 1px solid var(--line);
}
.account-card-head strong,
.account-card-head span {
    display: block;
    max-width: 188px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.account-card-head strong {
    color: var(--ink);
    font-size: 16px;
}
.account-card-head span {
    color: var(--muted);
    font-size: 13px;
    margin-top: 3px;
}
.account-role {
    display: inline-flex;
    margin: 12px 4px 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--green-soft);
    color: var(--green-dark);
    font-size: 12px;
    font-weight: 950;
}
.account-dropdown-link {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    color: #253044;
    background: transparent;
    box-shadow: none;
    font: inherit;
    font-weight: 850;
    text-align: left;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}
.account-dropdown-link:hover {
    transform: translateX(2px);
    background: var(--green-soft);
    color: var(--green-dark);
    box-shadow: none;
}
.account-logout-form {
    margin: 4px 0 0;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}
.logout-link {
    cursor: pointer;
    color: #c93f3f;
}
.logout-link:hover {
    background: #fff2f2;
    color: #b42323;
}

.btn, button {
    position: relative;
    overflow: hidden;
    border: 0;
    border-radius: 14px;
    padding: 12px 20px;
    font-weight: 850;
    cursor: pointer;
    background: var(--green);
    color: #fff;
    box-shadow: 0 8px 16px rgba(5, 184, 79, 0.22);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.btn::before,
button::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.26), transparent);
    transform: translateX(-120%);
    transition: transform 0.45s ease;
}
.btn:hover::before,
button:hover::before {
    transform: translateX(120%);
}
.btn:hover, button:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 24px rgba(5, 184, 79, 0.25);
}
.btn.secondary { background: #fff; color: var(--green-dark); box-shadow: inset 0 0 0 1px var(--line); }
.btn.dark { background: var(--green-dark); }
.btn.danger { background: #ff3b4f; box-shadow: none; }
.btn.small { padding: 9px 14px; border-radius: 12px; font-size: 14px; }

.section { padding: 72px 0; }
.section.soft { background: linear-gradient(180deg, var(--green-soft), #fff); }
.section-title { text-align: center; margin-bottom: 40px; }
.section-title h2 { font-size: 38px; margin: 0 0 12px; color: var(--ink); }
.section-title p { margin: 0; color: var(--muted); font-size: 18px; }

.panel, .auth-card, .product-card, .category-card, .nutrition-card, .stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
.panel { padding: 32px; }
.panel:hover,
.auth-card:hover,
.product-card:hover,
.category-card:hover,
.nutrition-card:hover,
.stat-card:hover {
    border-color: rgba(5, 184, 79, 0.18);
}

input, select, textarea {
    width: 100%;
    border: 1px solid #cfd7e3;
    border-radius: 12px;
    padding: 13px 14px;
    font: inherit;
    color: var(--ink);
    background: #fff;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: rgba(5, 184, 79, 0.55);
    box-shadow: 0 0 0 4px rgba(5, 184, 79, 0.10);
    background: #fff;
}
label { display: block; font-weight: 800; margin-bottom: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.full { grid-column: 1 / -1; }

.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
.table th, .table td { padding: 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { background: var(--green-soft); }
.cart-actions { display: flex; align-items: center; gap: 8px; }
.cart-actions input { width: 78px; }

.footer {
    padding: 34px 0;
    background:
        radial-gradient(circle at 20% 0, rgba(5, 184, 79, 0.08), transparent 30%),
        #fff;
    border-top: 1px solid var(--line);
    text-align: center;
    color: var(--muted);
}
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}
.footer strong {
    color: var(--green-dark);
}
.ai-chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 80;
    font-family: "Segoe UI", Arial, sans-serif;
}
.ai-chat-toggle {
    width: 60px;
    height: 60px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    box-shadow: 0 18px 36px rgba(5, 184, 79, 0.28);
    cursor: pointer;
}
.ai-chat-toggle .icon {
    width: 28px;
    height: 28px;
}
.ai-chat-widget.is-open .ai-chat-toggle {
    transform: scale(0.92);
}
.ai-chat-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: min(360px, calc(100vw - 32px));
    overflow: hidden;
    border: 1px solid rgba(5, 184, 79, 0.16);
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}
.ai-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    background: linear-gradient(135deg, var(--green), #37c86d);
    color: #fff;
}
.ai-chat-head strong,
.ai-chat-head span {
    display: block;
}
.ai-chat-head strong {
    font-size: 17px;
    line-height: 1.2;
}
.ai-chat-head span {
    margin-top: 3px;
    font-size: 13px;
    opacity: 0.88;
}
.ai-chat-close {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.36);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}
.ai-chat-messages {
    height: 330px;
    padding: 16px;
    overflow-y: auto;
    background: linear-gradient(180deg, #fbfffd, #fff);
}
.ai-chat-message {
    width: fit-content;
    max-width: 86%;
    margin-bottom: 10px;
    padding: 11px 13px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
}
.ai-chat-message.bot {
    border-bottom-left-radius: 6px;
    background: var(--green-soft);
    color: var(--ink);
}
.ai-chat-message.user {
    margin-left: auto;
    border-bottom-right-radius: 6px;
    background: var(--green);
    color: #fff;
}
.ai-chat-message.is-loading {
    color: var(--muted);
}
.ai-chat-form {
    display: flex;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid var(--line);
    background: #fff;
}
.ai-chat-form input {
    flex: 1;
    min-width: 0;
    height: 44px;
    border-radius: 999px;
}
.ai-chat-form button {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    cursor: pointer;
}
.ai-chat-form button .icon {
    width: 20px;
    height: 20px;
}
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; background: #fff4df; color: #9a5a00; }
.alert.success { background: var(--green-soft); color: var(--green-dark); }

.reveal-on-scroll {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 0.55s ease, transform 0.55s ease;
}
.reveal-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0);
}
.ripple-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    pointer-events: none;
    transform: translate(-50%, -50%) scale(1);
    animation: rippleOut 0.55s ease-out forwards;
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes rippleOut {
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(18);
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
    .reveal-on-scroll {
        opacity: 1;
        transform: none;
    }
}

@media (max-width: 920px) {
    .nav { height: auto; padding: 14px 0; flex-wrap: wrap; }
    .brand-logo { width: 42px; height: 42px; }
    .brand-text { font-size: 22px; }
    .nav-links { order: 3; width: 100%; overflow-x: auto; padding-bottom: 8px; justify-content: flex-start; }
    .nav-actions {
        margin-left: auto;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .cart-actions { flex-wrap: wrap; }
    .user-meta strong { max-width: 110px; }
    .brand { min-width: auto; }
    .nav-actions { width: 100%; justify-content: space-between; }
    .nav-action-link { padding: 0 8px; }
    .account-menu { margin-left: auto; }
    .account-dropdown {
        right: 0;
        width: min(286px, calc(100vw - 32px));
    }
    .ai-chat-widget {
        right: 16px;
        bottom: 16px;
    }
    .ai-chat-panel {
        bottom: 72px;
    }
}
