:root {
    --primary: #006242;
    --primary-dark: #00492f;
    --primary-soft: #e6f3ee;
    --primary-soft-2: #f2faf6;
    --accent: #e22726;
    --bg: #f3f8f5;
    --text: #172033;
    --muted: #526173;
    --border: #dbeae3;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdfc 100%);
    box-shadow: 0 0 40px rgba(0, 98, 66, .10);
    position: relative;
}

.app-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 14px 16px 18px;
    border-bottom-left-radius: 28px;
    border-bottom-right-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: 0 10px 28px rgba(0, 98, 66, .20);
}

.brand-header {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-logo-wrap {
    background: #fff;
    border-radius: 16px;
    padding: 7px 9px;
    width: 48px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(0,0,0,.08);
    flex-shrink: 0;
}

.brand-logo-header {
    max-width: 34px;
    max-height: 34px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.brand-user {
    min-width: 0;
    max-width: 235px;
}

.logout-btn {
    color: var(--primary-dark);
    font-weight: 800;
}

.app-content {
    padding: 18px;
    padding-bottom: 95px;
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: min(480px, 100%);
    height: 74px;
    background: #fff;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    z-index: 10;
    box-shadow: 0 -10px 30px rgba(0, 98, 66, .10);
}

.bottom-nav a {
    text-decoration: none;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
}

.bottom-nav a:hover,
.bottom-nav a:focus {
    color: var(--primary);
}

.bottom-nav span {
    font-size: 11px;
    margin-top: 3px;
}

.auth-card {
    margin-top: 26px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 26px;
    box-shadow: 0 15px 40px rgba(0, 98, 66, .12);
}

.auth-logo {
    display: block;
    width: min(280px, 88%);
    height: auto;
    max-height: 82px;
    object-fit: contain;
    margin: 0 auto 12px;
}

.app-logo {
    width: 72px;
    height: 72px;
    margin: auto;
    border-radius: 24px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
}

.search-box {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.product-list,
.cart-list {
    display: grid;
    gap: 14px;
}

.product-card,
.cart-card,
.history-card {
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 14px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 98, 66, .05);
}

.product-card {
    display: flex;
    gap: 12px;
    align-items: center;
}

.add-cart-form {
    display: grid;
    grid-template-columns: 72px 84px;
    gap: 8px;
    align-items: center;
    justify-content: end;
    min-width: 164px;
}

.add-cart-form .btn {
    padding: 6px 10px;
    font-size: .875rem;
    line-height: 1.2;
}

.add-cart-form .btn-preorder,
.add-cart-form .btn-add-cart {
    grid-column: 1 / -1;
    width: 100%;
}

.qty-input {
    width: 72px;
    text-align: center;
    border-radius: 16px;
}

.empty-state {
    text-align: center;
    background: #fff;
    border: 1px dashed #b8d6c7;
    border-radius: 26px;
    padding: 34px 20px;
}

.scanner-box {
    overflow: hidden;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: #000;
}

.checkout-panel {
    position: sticky;
    bottom: 86px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 14px 34px rgba(0, 98, 66, .14);
    padding: 14px;
    margin-top: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.success-card {
    text-align: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 32px 18px;
    box-shadow: 0 12px 32px rgba(0, 98, 66, .12);
}

.order-number {
    display: inline-block;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 18px;
    padding: 12px 18px;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 1px;
}

.form-control,
.btn {
    font-weight: 600;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .25rem rgba(0, 98, 66, .14);
}

.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
    --bs-btn-active-bg: var(--primary-dark);
    --bs-btn-active-border-color: var(--primary-dark);
}

.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
    --bs-btn-active-bg: var(--primary-dark);
    --bs-btn-active-border-color: var(--primary-dark);
}

.btn-success {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
}

.text-primary { color: var(--primary) !important; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
.alert { font-size: 14px; }
.alert-success { background: var(--primary-soft-2); border-color: #c9e7d8; color: var(--primary-dark); }

.qr-card {
    background: #fff;
    border-radius: 20px;
    padding: 1rem;
    box-shadow: 0 8px 24px rgba(0, 98, 66, .06);
}

.qr-box {
    width: 190px;
    min-height: 190px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    padding: .5rem;
    border: 1px dashed #b8d6c7;
}

.qr-box img,
.qr-box canvas {
    max-width: 100%;
    height: auto;
}

.history-card:hover {
    transform: translateY(-1px);
    transition: all .15s ease-in-out;
}

.discount-note {
    display: inline-block;
    color: var(--primary-dark);
    background: var(--primary-soft);
    border: 1px solid #c3e2d2;
    border-radius: 999px;
    padding: .2rem .55rem;
    font-size: .75rem;
    font-weight: 700;
}

.badge.bg-success,
.bg-success {
    background-color: var(--primary) !important;
}

.text-success {
    color: var(--primary) !important;
}


.portal-shortcut {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    margin: 0 0 14px;
    padding: 12px 14px;
    border-radius: 18px;
    color: var(--primary-dark);
    background: linear-gradient(135deg, var(--primary-soft), #ffffff);
    border: 1px solid #c3e2d2;
    text-decoration: none;
    font-weight: 800;
    box-shadow: 0 8px 22px rgba(0, 98, 66, .08);
}

.portal-shortcut:hover,
.portal-shortcut:focus {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: var(--primary);
}

.portal-shortcut-icon {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #fff;
    flex-shrink: 0;
}

.portal-shortcut-arrow {
    font-size: 16px;
    opacity: .8;
    flex-shrink: 0;
}

@media (max-width: 460px) {
    .brand-logo-wrap {
        width: 46px;
        height: 42px;
        padding: 6px 8px;
    }

    .brand-logo-header {
        max-width: 32px;
        max-height: 32px;
    }

    .brand-user {
        max-width: 210px;
    }
}

@media (max-width: 420px) {
    .product-card { display: block; }

    .add-cart-form {
        margin-top: 12px;
        display: grid;
        grid-template-columns: 72px 84px;
        align-items: center;
        justify-content: start;
    }

    .add-cart-form .btn-preorder,
    .add-cart-form .btn-add-cart { grid-column: 1 / -1; }
    .qty-input { width: 72px; }
    .checkout-panel { display: block; }
    .checkout-panel form { margin-top: 12px; }
    .checkout-panel button { width: 100%; }
}

#loadMoreState {
    min-height: 42px;
}

.product-card .btn-secondary:disabled {
    opacity: .85;
}
