*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #e8450a;
    --primary-light: #fff0eb;
    --text: #1a1a1a;
    --text-muted: #888;
    --border: #e8e8e8;
    --bg: #f5f5f5;
    --white: #fff;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(0, 0, 0, .08);
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.page {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--white);
}

/* ── Header ── */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
}

.header h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

.header p {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Section title ── */
.section-title {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 16px 16px 8px;
}

/* ── Product list ── */
.product-list {
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.product-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-name {
    font-size: .95rem;
    font-weight: 500;
}

.product-desc {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-type {
    display: inline-block;
    font-size: .68rem;
    color: var(--primary);
    background: var(--primary-light);
    border-radius: 4px;
    padding: 1px 6px;
    margin-top: 4px;
}

.product-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-left: 12px;
    white-space: nowrap;
}

/* ── Qty control ── */
.qty-ctrl {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid var(--primary);
    background: var(--white);
    color: var(--primary);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}

.qty-btn:active {
    background: var(--primary);
    color: var(--white);
}

.qty-btn.hidden {
    visibility: hidden;
}

.qty-num {
    font-size: .95rem;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

/* ── Cart bar ── */
.cart-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 200;
}

.cart-bar.hidden {
    display: none;
}

.cart-summary {
    flex: 1;
}

.cart-total {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.cart-count {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.btn-checkout {
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 22px;
    padding: 10px 24px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-checkout:active {
    opacity: .85;
}

/* ── Bottom sheet ── */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 300;
}

.overlay.show {
    display: block;
}

.sheet {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: var(--white);
    border-radius: 16px 16px 0 0;
    padding: 20px 16px 32px;
    z-index: 400;
    transition: transform .25s ease;
}

.sheet-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

/* ── Form ── */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    font-size: .82rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: block;
}

.form-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: .95rem;
    outline: none;
    transition: border-color .15s;
}

.form-input:focus {
    border-color: var(--primary);
}

.form-textarea {
    resize: none;
    height: 72px;
}

/* ── Toggle ── */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.toggle-label {
    font-size: .95rem;
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: background .2s;
}

.toggle.on {
    background: var(--primary);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--white);
    transition: transform .2s;
}

.toggle.on::after {
    transform: translateX(20px);
}

/* ── Cart items in sheet ── */
.cart-items {
    margin-bottom: 16px;
    max-height: 180px;
    overflow-y: auto;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: .88rem;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-name {
    flex: 1;
}

.cart-item-qty {
    color: var(--text-muted);
    margin: 0 12px;
}

.cart-item-price {
    font-weight: 600;
}

/* ── Buttons ── */
.btn-primary {
    width: 100%;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 10px;
    padding: 13px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.btn-primary:active {
    opacity: .85;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-secondary {
    width: 100%;
    background: var(--white);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    font-size: .95rem;
    cursor: pointer;
    margin-top: 8px;
}

/* ── Success screen ── */
.success-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
}

.success-screen.show {
    display: flex;
}

.success-mark {
    font-size: 3rem;
    margin-bottom: 16px;
}

.success-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.success-sub {
    font-size: .88rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.pickup-code {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin: 16px 0 4px;
    letter-spacing: .1em;
}

.pickup-label {
    font-size: .78rem;
    color: var(--text-muted);
}

/* ── Query page ── */
.query-wrap {
    padding: 24px 16px;
}

.query-wrap .form-group {
    margin-bottom: 12px;
}

.order-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.order-no {
    font-size: .78rem;
    color: var(--text-muted);
}

.order-status {
    font-size: .75rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.status-placed {
    background: #e8f4ff;
    color: #1677ff;
}

.status-printing {
    background: #fff7e6;
    color: #fa8c16;
}

.status-printed {
    background: #f6ffed;
    color: #52c41a;
}

.status-completed {
    background: #f6ffed;
    color: #389e0d;
}

.status-cancelled {
    background: #f5f5f5;
    color: #999;
}

.status-pending {
    background: #fff0f6;
    color: #eb2f96;
}

.order-items-text {
    font-size: .85rem;
    margin-bottom: 6px;
}

.order-meta {
    font-size: .78rem;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.order-total {
    font-size: .95rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 8px;
}

.detail-btn {
    font-size: .78rem;
    color: var(--primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-top: 6px;
}

/* ── Detail sheet ── */
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: .88rem;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-key {
    color: var(--text-muted);
}

/* ── Empty / error states ── */
.state-msg {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
    font-size: .9rem;
}

/* ── Nav link ── */
.nav-link {
    display: block;
    text-align: center;
    padding: 14px;
    font-size: .85rem;
    color: var(--primary);
    text-decoration: none;
}

/* ── Loading ── */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: .9rem;
}

@media (max-width: 360px) {
    .product-name {
        font-size: .88rem;
    }

    .cart-total {
        font-size: 1rem;
    }
}