:root {
    /* Brand Colors */
    --brand-green: #2E7D32;       /* 穩重的專業綠 */
    --brand-green-light: #E8F5E9; /* 淺綠色背景裝飾 */
    --action-blue: #0288D1;       /* 活力的行動藍 */
    --action-blue-dark: #01579B;  /* 深藍互動態 */
    
    /* Cart Specific Colors */
    --cart-cyan: #00ACC1;         /* Cyan color for cart controls */
    --cart-bg-gray: #F5F5F5;      /* Slightly darker background for cart contrast */
    
    /* Dashboard Colors */
    --card-bg-blue: #E1F5FE;
    --card-text-blue: #0277BD;
    --card-icon-blue: #4FC3F7;
    
    --card-bg-pink: #FFEBEE;
    --card-text-pink: #C62828;
    --card-icon-pink: #E57373;
    
    --card-bg-yellow: #FFFDE7;
    --card-text-yellow: #F9A825;
    --card-icon-yellow: #FFF59D;

    /* 全站貨款提示條（沿用 pink 卡片色系，動作按鈕另用實心紅） */
    --notice-danger-action: #D32F2F;
    --notice-danger-action-hover: #B71C1C;

    /* Neutral Colors */
    --text-primary: #1A1A1A;      /* 深黑灰，比純黑柔和 */
    --text-secondary: #666666;    /* 次要文字 */
    --text-placeholder: #B0BEC5;  /* 輸入框提示字 */
    --bg-body: #F9FAFB;           /* 極淺灰背景，增加層次 */
    --bg-white: #FFFFFF;
    --bg-input: #F0F2F5;          /* 輸入框背景色 */
    
    /* UI Variables */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-pill: 50px;
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.04);
    --shadow-float: 0 4px 12px rgba(46, 125, 50, 0.15);
    --shadow-nav: 0 -4px 20px rgba(0,0,0,0.05);
    
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Navbar Height */
    --nav-height: 60px;
    --safe-area-bottom: env(safe-area-inset-bottom);
    --bottom-nav-offset: calc(var(--nav-height) + var(--safe-area-bottom));
    --floating-ui-page-bottom-obstruction: 0px;
    --floating-ui-blocking-bottom: max(var(--bottom-nav-offset), var(--floating-ui-page-bottom-obstruction));
    --floating-ui-gap: 16px;
    --floating-ui-bottom: calc(var(--floating-ui-blocking-bottom) + var(--floating-ui-gap));
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    /* 系統字優先，Noto Sans TC 非同步載入後再覆蓋，降低首屏字型等待 */
    font-family: 'Noto Sans TC', 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    /* Use dvh (Dynamic Viewport Height) to handle mobile browser bars */
    min-height: 100dvh; 
    font-size: 16px;
    line-height: 1.5;
    /* Basic bottom padding for safe area, overridden if nav exists */
    padding-bottom: env(safe-area-inset-bottom);
}

/* On Mobile, we use Fixed position for navbar, so we need padding on body */
body.has-bottom-nav {
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 20px);
}

/* --- Layout Wrappers --- */
.main-container {
    flex: 1;
    width: 100%;
    max-width: 480px; /* Mobile constraints */
    margin: 0 auto;
    /* Reduced padding for small mobile screens */
    padding: 0px 20px; 
    background-color: var(--bg-white);
    min-height: 100%;
}

.dashboard-container {
    background-color: transparent; /* Dashboard usually sits on gray body, but here main-container is white. */
    padding-top: 10px;
}

/* On Desktop: create a card effect */
@media (min-width: 481px) {
    body.has-bottom-nav {
        /* Reset padding because we use Sticky navbar inside the container, which handles its own space */
        padding-bottom: 40px; 
    }

    .main-container {
        margin: 40px auto;
        min-height: auto;
        border-radius: 24px;
        box-shadow: var(--shadow-card);
        padding: 48px;
        /* Ensure the container is at least tall enough to look good */
        min-height: calc(100vh - 80px); 
    }
    .dashboard-container {
        padding: 48px;
    }
    body {
        justify-content: center;
        min-height: 100vh;
    }
}

/* --- 全站貨款提示條 --- */
/* 由 _Layout 輸出在 .app-top-stack 內，跟著整個置頂區塊一起釘在畫面上方。
   sticky 由外層容器負責：提示條文字換行時高度會變，包在一起就不必動態換算 header 的 top。 */
.unpaid-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    /* .main-container 在手機是滿版白底；提示條落在它外面，因此自己留左右 16px 的邊。 */
    width: calc(100% - 32px);
    max-width: 448px;
    margin: 12px auto;
    padding: 12px 12px 12px 16px;
    background-color: var(--card-bg-pink);
    border-radius: var(--radius-sm);
}

.unpaid-notice__text {
    color: var(--card-text-pink);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.unpaid-notice__action {
    flex-shrink: 0;
    padding: 7px 14px;
    background-color: var(--notice-danger-action);
    color: var(--bg-white);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color var(--transition-fast);
}

.unpaid-notice__action:hover,
.unpaid-notice__action:focus {
    background-color: var(--notice-danger-action-hover);
    color: var(--bg-white);
}

/* 桌機沿用 .main-container 的 480px 外緣寬度；上下留白維持與手機一致，
   避免置頂時在畫面頂端留下一大塊空白。 */
@media (min-width: 481px) {
    .unpaid-notice {
        width: 100%;
        max-width: 480px;
    }
}

/* --- Header Styles --- */
/* 置頂區塊：貨款提示條（若有）＋ 共用 header。整塊一起 sticky，捲動時兩者都留在畫面上。
   背景填白（與 .app-header／.main-container 同色），蓋住提示條四周的留白，
   才不會讓內文在捲動時從縫隙透出來。 */
.app-top-stack {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-white);
}

/* sticky 已交給 .app-top-stack；這裡保持 static，避免巢狀 sticky 造成的計算歧義。
   products.ts 的浮動搜尋列是讀 #app-header 的 getBoundingClientRect().bottom，
   header 被提示條往下推之後仍會自動對齊，不需要額外調整。 */
#app-header {
    position: static;
}

body[data-shared-header-visibility="hidden"] #app-header {
    display: none;
}

.app-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.03);
}

/* logo 是回首頁的連結；沿用原本的排版，並取消瀏覽器預設的連結外觀。 */
.logo-container {
    display: flex;
    align-items: center;
    gap: 8px;
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: opacity var(--transition-fast);
}

.logo-container:active {
    opacity: 0.6;
}

.logo-icon img {
    width: 28px;
    height: 28px;
    fill: var(--brand-green);
    filter: drop-shadow(0 2px 4px rgba(46, 125, 50, 0.2));
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--brand-green);
    letter-spacing: -0.5px;
}

/* --- Typography & Titles --- */
.page-title {
    margin-top: 20px;
    margin-bottom: 40px;
    text-align: left;
}

.page-title h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0;
    letter-spacing: -0.5px;
}

/* --- Form Elements --- */
.registration-form { display: flex; flex-direction: column; gap: 24px; }
.input-group { position: relative; }

input[type="text"], input[type="email"], input[type="number"], input[type="tel"], textarea {
    width: 100%;
    font-size: 16px;
    border: 2px solid transparent;
    background-color: var(--bg-input);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: var(--transition-smooth);
    font-weight: 500;
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
}
input::placeholder, textarea::placeholder { color: var(--text-placeholder); font-weight: 400; }
input:focus, textarea:focus, select:focus {
    background-color: var(--bg-white);
    border-color: var(--action-blue);
    box-shadow: 0 0 0 4px rgba(2, 136, 209, 0.1);
    outline: none;
}

/* Error Message */
.error-message {
    display: block;
    color: #d32f2f;
    font-size: 13px;
    margin-top: 6px;
    font-weight: 500;
}

.error-message:empty {
    display: none;
}

/* Select Style */
.select-wrapper { position: relative; }
select {
    width: 100%;
    padding: 18px 40px 18px 20px;
    font-size: 16px;
    border: 2px solid transparent;
    background-color: var(--bg-input);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    -webkit-appearance: none;
    appearance: none;
    font-weight: 500;
    cursor: pointer;
}
.select-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #9E9E9E;
}

.input-action-group { display: flex; gap: 12px, align-items: stretch; }
.input-action-group input { flex: 1; min-width: 0; }

.btn-action-side {
    padding: 0 20px;
    font-size: 15px;
    font-weight: 500;
    color: white;
    background-color: var(--action-blue);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-smooth);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
}
.btn-action-side:hover { background-color: var(--action-blue-dark); }
.btn-action-side:active { transform: scale(0.96); }

/* Checkbox */
.checkbox-group { margin-top: 8px; display: flex; align-items: center; }
.custom-checkbox {
    display: flex; align-items: center; cursor: pointer; user-select: none;
    font-size: 14px; color: var(--text-secondary); line-height: 1.4;
}
.custom-checkbox input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; }
.checkmark {
    height: 22px; width: 22px; background-color: var(--bg-white);
    border: 2px solid #CFD8DC; border-radius: 6px; margin-right: 12px;
    position: relative; transition: var(--transition-fast); flex-shrink: 0;
}
.custom-checkbox:hover input ~ .checkmark { border-color: var(--text-secondary); }
.custom-checkbox input:checked ~ .checkmark {
    background-color: var(--brand-green); border-color: var(--brand-green);
    box-shadow: 0 2px 5px rgba(46, 125, 50, 0.3);
}
.checkmark:after { content: ""; position: absolute; display: none; }
.custom-checkbox input:checked ~ .checkmark:after { display: block; }
.custom-checkbox .checkmark:after {
    left: 7px; top: 3px; width: 5px; height: 10px; border: solid white;
    border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.label-text a { color: var(--action-blue); text-decoration: none; font-weight: 700; position: relative; padding: 4px 0; }

/* Buttons */
.btn {
    width: 100%; padding: 18px; font-size: 18px; font-weight: 700;
    border: none; border-radius: var(--radius-pill); cursor: pointer;
    transition: all 0.3s ease; margin-top: 32px; letter-spacing: 0.5px;
    position: relative; overflow: hidden; user-select: none;
}
.btn-disabled { background-color: #E0E0E0; color: #9E9E9E; cursor: not-allowed; }
.btn-active {
    background: linear-gradient(135deg, var(--action-blue) 0%, #0277BD 100%);
    color: white; box-shadow: 0 8px 20px rgba(2, 136, 209, 0.3); transform: translateY(0);
    flex-shrink: 0;
}
.btn-active:hover { box-shadow: 0 10px 25px rgba(2, 136, 209, 0.4); transform: translateY(-2px); }
.btn-active:active { transform: translateY(1px); box-shadow: 0 4px 10px rgba(2, 136, 209, 0.2); }
.btn-danger {
    background: linear-gradient(135deg, #e53935 0%, #b71c1c 100%);
    color: white; box-shadow: 0 8px 20px rgba(229, 57, 53, 0.3); transform: translateY(0);
    flex-shrink: 0;
}
.btn-danger:hover { box-shadow: 0 10px 25px rgba(229, 57, 53, 0.4); transform: translateY(-2px); }
.btn-danger:active { transform: translateY(1px); box-shadow: 0 4px 10px rgba(229, 57, 53, 0.2); }

/* Helper Text */
.helper-text { text-align: center; color: var(--text-placeholder); font-size: 13px; margin-top: 16px; font-weight: 400; }
.helper-text-start { color: var(--text-secondary); font-size: 14px; margin-bottom: -12px; }
/* Footer */
.app-footer { padding: 32px; text-align: center; color: var(--text-placeholder); font-size: 12px; background: transparent; }
/* --- HOME PAGE SECTIONS --- */
.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 32px 0 16px 0;
}

.first-section {
    margin-top: 10px;
}

.section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.section-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.info-group-card {
    background-color: #fff;
    border: 1px solid #eee;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.info-row {
    padding: 20px 16px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.info-divider {
    height: 1px;
    background-color: #F0F0F0;
    margin-left: 72px;
    margin-right: 0;
}

.info-icon {
    background-color: #F5F5F5;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.info-content h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.info-content p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.info-content strong {
    color: var(--text-primary);
    font-weight: 700;
}

.trend-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.trend-card {
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.card-blue { background-color: var(--card-bg-blue); }
.card-pink { background-color: var(--card-bg-pink); }
.card-yellow { background-color: var(--card-bg-yellow); }

.card-icon-box {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background-color: rgba(255,255,255,0.6);
}

.box-blue { color: var(--card-text-blue); }
.box-red { color: var(--card-text-pink); }
.box-yellow { color: #FBC02D; }

.card-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-sub {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-price {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.price-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
}

.badge-dark-blue { background-color: #0288D1; color: white; }
.badge-red { background-color: #E53935; color: white; }
.badge-white-red { background-color: #fff; color: #E53935; border: 1px solid rgba(229, 57, 53, 0.2); font-size: 11px; }

.card-arrow { opacity: 0.5; }

/* --- Bottom Navigation --- */
.bottom-navbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(var(--nav-height) + var(--safe-area-bottom));
    background-color: #fff;
    border-top: 1px solid rgba(0,0,0,0.05);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    justify-items: center;
    align-items: center;
    padding-bottom: var(--safe-area-bottom);
    box-shadow: var(--shadow-nav);
    z-index: 1000;
}

@media (min-width: 481px) {
    .bottom-navbar {
        position: sticky;
        bottom: 0;
        left: auto;
        right: auto;
        transform: none;
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 24px 24px 0 0;
        border-top: none;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
    }
}

.nav-item {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #9E9E9E;
    gap: 4px;
    transition: color 0.2s ease;
}

.nav-item:active { background-color: rgba(0,0,0,0.02); }
.nav-item.active { color: var(--action-blue); }

.nav-icon { width: 24px; height: 24px; }
.nav-label { font-size: 12px; font-weight: 500; }

.nav-icon-wrapper { position: relative; display: inline-block; }
.nav-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    background-color: #D32F2F;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- UTILITY CLASSES --- */
.hidden {
    display: none !important;
}

.form-grid-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.form-grid-row .input-group,
.form-grid-row .select-wrapper {
    flex: 1;
}

.form-label {
    display: block;
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
    font-weight: 500;
}

.radio-option-row {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    cursor: pointer;
    user-select: none;
}

.radio-option-row input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-circle {
    width: 22px;
    height: 22px;
    border: 2px solid #B0BEC5;
    border-radius: 50%;
    margin-right: 12px;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s;
}

.radio-option-row input:checked + .radio-circle {
    border-color: var(--action-blue);
}

.radio-option-row input:checked + .radio-circle::after {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 12px; height: 12px;
    background-color: var(--action-blue);
    border-radius: 50%;
}

.radio-label {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 500;
}

.payment-hint-icon {
    margin-right: 6px;
    color: #00c300;
}

/* --- POPOVER API STYLES --- */
[popover] {
    margin: 0;
    padding: 0;
    border: none;
    background: #fff;
    box-shadow: 0 -4px 30px rgba(0,0,0,0.15);
    
    /* Mobile Bottom Sheet Style */
    width: 100%;
    max-width: 480px;
    inset: auto;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    
    border-radius: 24px 24px 0 0;
    
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), display 0.3s allow-discrete;
    
    padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 481px) {
    [popover] {
        position: fixed;
    }
}

[popover]:popover-open {
    transform: translateX(-50%) translateY(0);
    @starting-style {
        transform: translateX(-50%) translateY(100%);
    }
}

[popover]::backdrop {
    background-color: rgba(0, 0, 0, 0.4);
    /* Keep dim overlay but remove blur so SFNotify remains readable */
    backdrop-filter: none;
    opacity: 0;
    transition: opacity 0.3s;
}

[popover]:popover-open::backdrop {
    opacity: 1;
    @starting-style {
        opacity: 0;
    }
}

.popover-header {
    padding: 20px 24px;
    border-bottom: 1px solid #F0F0F0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.popover-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.popover-close {
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.popover-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.popover-content {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Location List Styles */
.location-group-title {
    font-size: 16px;
    font-weight: 700;
    color: #8D1717; /* Dark Red from design */
    margin: 24px 0 12px 0;
    padding-left: 8px;
    border-left: 4px solid #8D1717;
    line-height: 1;
}

.location-group-title:first-child {
    margin-top: 0;
}

.location-card {
    display: flex;
    align-items: center;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s;
}

.location-card:hover {
    border-color: #ddd;
}

.location-card input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.location-info {
    flex: 1;
}

.loc-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.loc-addr {
    font-size: 13px;
    color: var(--text-secondary);
}

.radio-indicator {
    width: 24px;
    height: 24px;
    border: 2px solid #ccc;
    border-radius: 50%;
    margin-left: 12px;
    position: relative;
}

/* Checked State */
.location-card input:checked ~ .radio-indicator {
    border-color: #ccc; 
}

.location-card input:checked ~ .radio-indicator::after {
    content: '';
    position: absolute;
    top: 50%; 
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background-color: #ddd; /* Gray circle per design */
    border-radius: 50%;
}

.popover-footer-simple {
    text-align: center;
    font-size: 12px;
    color: #999;
    padding: 16px;
    background: transparent;
}

/* --- ACCOUNT PAGE SPECIFIC --- */
.account-profile-section {
    background: #fff;
    padding: 24px 20px;
    border-radius: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.profile-row {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    font-size: 16px;
    gap: 8px;
}

.profile-row:last-child {
    margin-bottom: 0;
}

.profile-label {
    width: 90px;
    color: #666;
    font-weight: 500;
    flex-shrink: 0;
}

.wallet-row, .profile-row > div, .wallet-row > div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wallet-row > div {
    flex: 1;
    min-width: 0;
}

/* === Inline-edit：姓名列 view / edit 切換 === */
.name-view {
    display: flex;
    align-items: center;
    gap: 6px;
}

.name-edit {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.btn-inline-edit {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #999;
    display: inline-flex;
    align-items: center;
    border-radius: 4px;
    transition: color 0.15s;
}

.btn-inline-edit:hover {
    color: var(--action-blue);
}

.btn-cancel-name {
    background: none;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.btn-cancel-name:hover {
    border-color: #BDBDBD;
    color: #333;
}

.profile-value-input {
    flex: 1;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 16px;
    color: var(--text-primary);
    min-width: 0;
}

.btn-update-name {
    background-color: #E0E0E0;
    color: #9E9E9E;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: not-allowed;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-update-name:not(:disabled) {
    background-color: var(--action-blue);
    color: white;
    cursor: pointer;
}

.btn-update-name:not(:disabled):hover {
    background-color: var(--action-blue-dark);
}

.btn-update-name:not(:disabled):active {
    transform: scale(0.96);
}

.wallet-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.wallet-row:last-child {
    margin-bottom: 0;
}

.wallet-detail-link {
    font-size: 13px;
    color: #B0BEC5;
    text-decoration: underline;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}

.cc-pill {
    display: flex;
    align-items: center;
    background: #FAFAFA;
    border: 1px solid #EEEEEE;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 14px;
    color: #333;
    width: fit-content;
    gap: 8px;
}

.cc-delete-btn {
    background: #0288D1;
    border: none;
    border-radius: 4px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    font-size: 12px;
}

.cc-add-btn {
    background: #0288D1;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
}

.btn-referral {
    background-color: #00C853;
    color: white;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: none;
    cursor: pointer;
}

.store-selector-container {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.store-select-btn {
    flex: 1;
    background: #fff;
    border: 1px solid #E0E0E0;
    border-radius: 12px;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    color: #333;
}

.store-add-btn-square {
    width: 44px;
    height: 44px;
    background: #0288D1;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    border: none;
    cursor: pointer;
}

.btn-mini-add {
    width: 24px;
    height: 24px;
    background: #00A3D9;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    align-self: center;
}

.manager-tag {
    background: #F5F5F5;
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text-primary);
}

.btn-remove-manager {
    color: #999;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    display: flex;
    align-items: center;
}

.btn-remove-manager:hover {
    color: #F44336;
}

.restaurant-manage-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    position: relative;
    border: 1px solid #F5F5F5;
}

.edit-icon-abs {
    position: absolute;
    top: 16px;
    right: 16px;
    color: #B0BEC5;
    cursor: pointer;
}

.store-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-right: 24px;
}

.store-info-row {
    font-size: 15px;
    color: #555;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
}

.label-gray {
    color: #999;
    margin-right: 4px;
    min-width: 70px;
}

.upload-box {
    width: 60px;
    height: 40px;
    background: #E0E0E0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-left: 8px;
    cursor: pointer;
}

.contact-person-info {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #E0E0E0;
    color: #666;
    font-size: 14px;
    line-height: 1.6;
}

.coupon-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 16px;
}

.coupon-card {
    display: flex;
    align-items: stretch;
    border: 1px solid #E0E0E0;
    border-radius: 12px;
    padding: 16px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    background: #fff;
}

/* 左欄放面額與門檻：門檻是「能不能用」的關鍵，緊貼面額才不會被當成兩件事看 */
.coupon-left {
    flex: 0 0 42%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 12px;
    border-right: 1px solid #E0E0E0;
}

.coupon-amount {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.coupon-threshold {
    font-size: 12px;
    color: #999;
    text-align: center;
}

.coupon-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 0 16px;
}

/* 券種名稱是 DB 自由文字（上限 50 字），一律允許換行避免撐破卡片 */
.coupon-name {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.coupon-expiry {
    font-size: 13px;
    color: #666;
    letter-spacing: 0.5px;
}

.funds-balance-card {
    background: linear-gradient(135deg, #039BE5 0%, #0288D1 100%);
    border-radius: 16px;
    padding: 32px 20px;
    text-align: center;
    color: white;
    margin-bottom: 24px;
    box-shadow: 0 4px 15px rgba(2, 136, 209, 0.3);
}

.funds-balance-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
    font-weight: 500;
}

.funds-balance-amount {
    font-size: 40px;
    font-weight: 700;
    letter-spacing: 1px;
}

.funds-section-title {
    font-size: 14px;
    font-weight: 700;
    color: #999;
    margin-bottom: 12px;
}

.funds-record-item {
    display: flex;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid #F0F0F0;
}

.funds-record-item:last-child {
    border-bottom: none;
}

.funds-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.funds-icon.debit {
    background-color: #F5F5F5;
    color: #757575;
}

.funds-icon.credit {
    background-color: #FFF8E1;
    color: #FBC02D;
}

.funds-info {
    flex: 1;
}

.funds-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.funds-date {
    font-size: 12px;
    color: #999;
}

.funds-amount {
    font-size: 18px;
    font-weight: 700;
}

.funds-amount.debit {
    color: var(--text-primary);
}

.funds-amount.credit {
    color: #0288D1;
}

.funds-view-more {
    text-align: center;
    padding-top: 24px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
}

/* --- SHOP PAGE STYLES --- */
.shop-action-group { margin-bottom: 24px; }
.shop-main-btn {
    width: 100%; background: linear-gradient(90deg, #00A3D9 0%, #0288D1 100%);
    border: none; border-radius: 12px; padding: 16px 20px;
    display: flex; justify-content: space-between; align-items: center;
    color: white; font-size: 18px; font-weight: 500; cursor: pointer;
    box-shadow: 0 4px 15px rgba(2, 136, 209, 0.3); transition: transform 0.2s, box-shadow 0.2s;
}
.shop-main-btn:active { transform: scale(0.98); }
.btn-content { display: flex; align-items: center; gap: 12px; }
.btn-icon { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; }
.btn-arrow { display: flex; align-items: center; }
.shop-display-box {
    margin-top: 12px; border: 1px solid #E0E0E0; border-radius: 12px;
    padding: 16px 20px; font-size: 16px; color: var(--text-placeholder);
    background-color: #fff; min-height: 54px; display: flex; align-items: center;
}
.shop-display-box.selected { color: var(--text-primary); font-weight: 500; }

/* Radio List for Shop */
.radio-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-item {
    display: flex;
    align-items: center;
    border: 2px solid #E0E0E0;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    gap: 12px;
}

.radio-item:hover {
    background-color: #F9F9F9;
    border-color: #D0D0D0;
}

.radio-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-content {
    flex: 1;
}

.radio-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    transition: color 0.2s;
}

.radio-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Check icon (hidden by default) */
.radio-check-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s;
    color: var(--action-blue);
}

/* Selected state */
.radio-item:has(input[type="radio"]:checked) {
    border-color: var(--action-blue);
    background-color: rgba(2, 136, 209, 0.04);
}

.radio-item:has(input[type="radio"]:checked) .radio-title {
    color: var(--action-blue);
}

.radio-item:has(input[type="radio"]:checked) .radio-check-icon {
    opacity: 1;
}

/* Calendar Styles */
.calendar {
    padding-bottom: 20px;
}

.calendar-header {
    margin-bottom: 20px;
}

.calendar-month {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    color: #999;
    font-size: 14px;
    margin-bottom: 12px;
    font-weight: 500;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    row-gap: 20px;
    text-align: center;
}

.cal-day {
    font-size: 16px;
    color: var(--text-primary);
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    border-radius: 50%;
    width: 40px;
    margin: 0 auto;
    transition: background-color 0.2s;
}

.cal-day.active {
    background-color: #FFC107; /* Yellow */
    color: white;
    font-weight: 700;
}

.cal-day.closed {
    color: #E53935; /* Red */
    cursor: default;
}

.cal-day.closed .sub-text {
    font-size: 9px;
    line-height: 1;
    margin-top: 2px;
}

@media (hover: hover) {
    .cal-day:not(.closed):not(.active):hover {
        background-color: #f5f5f5;
    }
}

.popover-close-btn {
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.popover-close-btn:hover {
    background-color: #e0e0e0;
}

.popover-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    flex: 1;
}

/* --- Credit Card Input Grid --- */
.cc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.cc-input {
    width: 100%;
    padding: 14px 10px !important;
    font-size: 18px !important;
    font-weight: 600;
    text-align: center;
    letter-spacing: 2px;
    border: 2px solid transparent !important;
    background-color: var(--bg-input) !important;
    border-radius: 12px !important;
    color: var(--text-primary) !important;
    transition: var(--transition-smooth) !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

.cc-input::placeholder {
    color: var(--text-placeholder);
    font-weight: 400;
}

.cc-input:focus {
    background-color: var(--bg-white) !important;
    border-color: var(--action-blue) !important;
    box-shadow: 0 0 0 4px rgba(2, 136, 209, 0.1) !important;
    outline: none !important;
}

/* --- LINE Share Button --- */
.line-share-button {
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-pill);
    background-color: #00B900;
    color: white;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(0, 185, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: 0.5px;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.line-share-button:hover {
    background-color: #009600;
    box-shadow: 0 6px 16px rgba(0, 185, 0, 0.4);
    transform: translateY(-2px);
}

.line-share-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(0, 185, 0, 0.2);
}

.line-share-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.line-share-button:active::before {
    left: 100%;
}

/* --- Popover Form Note Text --- */
.popover-note-text {
    font-size: 12px;
    color: #999;
    margin-top: 12px;
    margin-bottom: 0;
    line-height: 1.5;
    font-weight: 400;
}

/* --- Popover Form Spacing Override --- */
.popover-content .registration-form {
    gap: 12px;
}

.popover-content .form-label {
    margin-bottom: 6px;
}

.popover-content .input-group {
    margin-bottom: 0;
}

/* Reduce padding for inputs in popovers to ensure consistent spacing */
.popover-content input[type="text"],
.popover-content input[type="email"],
.popover-content input[type="tel"],
.popover-content select {
    padding: 14px 16px !important;
}

.popover-content select {
    padding: 14px 36px 14px 16px !important;
}

/* --- Inline Confirm Dialog --- */
.inline-confirm {
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: stretch;
    gap: 6px;
    margin-top: 12px;
    padding: 12px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    box-sizing: border-box;
    cursor: default;
}

.inline-confirm-text {
    font-size: 14px;
    color: #333;
    line-height: 1.4;
    text-align: left;
    font-weight: 500;
}

.inline-confirm-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.inline-confirm-yes,
.inline-confirm-no {
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    flex: 1;
    height: 36px;
    margin-top: 0;
    transition: var(--transition-fast);
}

.inline-confirm-yes {
    background: #dc3545;
    color: #fff;
    border: none;
}

.inline-confirm-yes:hover {
    background: #c82333;
}

.inline-confirm-yes:active {
    background: #bd2130;
}

.inline-confirm-no {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #dee2e6;
}

.inline-confirm-no:hover {
    background: #e9ecef;
}

.inline-confirm-no:active {
    background: #dde0e3;
}

/* --- Busy Overlay（處理中遮罩：取消訂單等需等待後端/第三方 API 的操作） --- */
.sf-busy-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    /* 介於 navbar / bottom bar（1000）與 toast（9999）之間，確保成功/失敗 toast 仍可顯示在最上層。 */
    z-index: 1500;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* 蓋住指定容器（例如單張訂單卡片）。 */
.sf-busy-overlay--contained {
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

/* 蓋住整個視窗（例如訂單明細頁，按鈕分散在固定底部操作列）。 */
.sf-busy-overlay--fixed {
    position: fixed;
    inset: 0;
}

.sf-busy-overlay__spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(0, 0, 0, 0.12);
    border-top-color: var(--brand-green, #2e7d32);
    border-radius: 50%;
    animation: sf-busy-overlay-spin 0.8s linear infinite;
}

.sf-busy-overlay__text {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

@keyframes sf-busy-overlay-spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- PRODUCTS PAGE STYLES --- */

.products-page-layout {
    --products-page-bottom-gap: 16px;
    --products-view-cart-reserved-space: 0px;
    display: flex;
    flex-direction: column;
}

/* Inner area: header + product list */
.products-scroll-area {
    display: flex;
    flex-direction: column;
}

/* Transfer floating cart button reserved space to footer bottom */
body:has(.products-page-layout) #app-footer {
    padding-bottom: var(--products-view-cart-reserved-space);
}

/* Reserved space for fixed bottom action bar on Checkout page */
body:has(.checkout-page-layout) #app-footer {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

.sticky-header-container {
    flex-shrink: 0;
    z-index: 90;
    background-color: var(--bg-body);
    margin-left: -20px;
    margin-right: -20px;
    padding: 16px 20px 8px 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

@media (min-width: 481px) {
    .sticky-header-container {
        margin-left: -48px;
        margin-right: -48px;
        padding: 24px 48px 16px 48px;
    }
}

.filter-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.filter-btn {
    flex: 1;
    background: #fff;
    border: 1px solid #E0E0E0;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.filter-btn:active {
    background-color: #F5F5F5;
}

.filter-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.product-search {
    position: relative;
    margin-bottom: 16px;
}

.product-search input {
    width: 100%;
    background: #fff;
    border: 1px solid #E0E0E0;
    padding: 12px 40px 12px 42px; /* Right padding increased for clear button */
    border-radius: 12px;
    font-size: 15px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9E9E9E;
}

.search-clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #9E9E9E;
    display: none;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.search-clear-btn.is-visible {
    display: flex;
}

.search-clear-btn:hover {
    color: #666;
}

.search-clear-btn:active {
    transform: translateY(-50%) scale(0.9);
}

.products-page-layout .product-search-wrapper.floating-top {
    position: fixed;
    top: var(--floating-search-top, 0px);
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: var(--bg-body, #e9ecef);
    padding: 12px 20px;
    margin: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    animation: slideDownProductSearch 0.3s ease-out;
}

.products-page-layout .product-search-wrapper.floating-top .product-search {
    margin-bottom: 0;
}

@media (min-width: 481px) {
    .products-page-layout .product-search-wrapper.floating-top {
        padding: 16px 48px;
    }
}

@keyframes slideDownProductSearch {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.category-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -ms-overflow-style: none;
    scrollbar-width: none;
    cursor: grab;
}

.category-tabs.dragging {
    cursor: grabbing;
    user-select: none;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.cat-tab {
    padding: 8px 16px;
    border-radius: 20px;
    background-color: #F0F2F5;
    color: #666;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.cat-tab.active {
    background-color: var(--brand-green);
    color: white;
    box-shadow: 0 4px 10px rgba(46, 125, 50, 0.2);
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: #fff;
    border-radius: 16px;
    margin-top: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.03);
    /* let the parent .products-scroll-area handle scrolling so header scrolls together */
    overflow: visible;
    overflow-x: hidden;
    flex: 0 0 auto;
    min-height: 0;
}

.view-cart-btn {
    position: fixed;
    bottom: var(--floating-ui-bottom);
    left: 50%;
    transform: translateX(-50%);
    background-color: #000;
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 999;
    white-space: nowrap;
}

.view-cart-btn.is-visible {
    display: flex;
}

.view-cart-btn:hover,
.view-cart-btn:active {
    background-color: #333;
    color: #fff;
    text-decoration: none;
}

.product-card {
    padding: 16px;
    border-bottom: 1px solid #F0F0F0;
    background-color: #fff;
}

.product-card:last-child {
    border-bottom: none;
}

.product-card-inner {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.prod-image-box {
    position: relative;
    width: 80px;
    height: 80px;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    border: none;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
    padding: 0;
    cursor: pointer;
}

.prod-spec-badge {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    background-color: #1976d2;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px 3px 5px;
    border-bottom-right-radius: 6px;
    line-height: 1;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.prod-spec-badge.badge-jian,
.prod-spec-badge.badge-yuanjian {
    background-color: #1976d2;
}

.prod-image-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.prod-image-box:focus-visible {
    outline: 2px solid rgba(0, 121, 107, 0.25);
    outline-offset: 2px;
}

.prod-details-box {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.prod-header {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0;
}

.prod-name-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    min-width: 0;
}

.prod-name {
    min-width: 0;
    flex: 1 1 auto;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}

.prod-name-btn {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    color: inherit;
    font: inherit;
    line-height: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prod-name-btn:focus-visible {
    outline: 2px solid rgba(0, 121, 107, 0.25);
    outline-offset: 2px;
}

/* 價格漲跌提示：圖示在商品名稱旁，點擊後於上方展開氣泡說明幅度。
   幅度未達門檻或持平時後端不會輸出這段 markup。 */
.price-trend {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    --price-trend-color: #d64545;
}

.price-trend.is-down {
    --price-trend-color: #1a9fc4;
}

.price-trend-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--price-trend-color);
    border-radius: 6px;
    background: transparent;
    color: var(--price-trend-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.price-trend-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.price-trend-btn:hover {
    background-color: color-mix(in srgb, var(--price-trend-color) 10%, transparent);
}

.price-trend-btn:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--price-trend-color) 40%, transparent);
    outline-offset: 2px;
}

.price-trend-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    border-radius: 16px;
    background-color: var(--price-trend-color);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    /* 未展開時完全不吃事件，避免蓋住底下的商品名稱按鈕。 */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 5;
}

.price-trend-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--price-trend-color);
}

.price-trend.is-open .price-trend-tooltip {
    opacity: 1;
    visibility: visible;
}

/* .product-list 設了 overflow-x: hidden，依 CSS 規範垂直方向也會跟著從 visible 變成可裁切，
   因此第一張卡片往上展開的氣泡會被切掉；只有這一列改為往下展開，箭頭同步翻到上方。 */
.product-card:first-child .price-trend-tooltip {
    top: calc(100% + 8px);
    bottom: auto;
}

.product-card:first-child .price-trend-tooltip::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: var(--price-trend-color);
}

.price-container {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    width: 100%;
}

.prod-sales-unit {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
}

.prod-total-price {
    font-size: 18px;
    font-weight: 700;
    color: #00796B;
}

.price-value-pair {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.price-value-strikethrough {
    color: #9E9E9E;
    text-decoration: line-through;
    text-decoration-thickness: 1.5px;
}

.price-value-highlight {
    color: #D32F2F;
}

.prod-row-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.prod-unit-price {
    font-family: 'Roboto', sans-serif;
    color: var(--text-secondary);
    font-size: 14px;
}

.unit-price-amount {
    color: #007AFF;
    font-weight: 700;
}

.tag-promo {
    background-color: #F3E5F5;
    color: #7B1FA2;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    vertical-align: middle;
    font-weight: 700;
}

.prod-name-wrapper .tag-promo {
    margin-left: 0;
}

/* Base Qty Control */
.qty-control {
    display: flex;
    align-items: center;
    background-color: #fff;
    border: 1px solid #E0E0E0;
    border-radius: 20px;
    height: 30px;
    min-width: 90px;
    justify-content: space-between;
    padding: 0 4px;
    margin-top: 0;
    align-self: auto;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
}

.qty-btn:active {
    background-color: #f5f5f5;
}

.qty-val {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    width: 30px;
    text-align: center;
}

/* Cart Quantity Control (Cyan Theme) */
.qty-control.cart-cyan-theme {
    border: 1px solid var(--cart-cyan);
    color: var(--cart-cyan);
}

.qty-control.cart-cyan-theme .qty-btn {
    color: var(--cart-cyan);
}

.qty-control.cart-cyan-theme .qty-val {
    color: var(--cart-cyan);
}

/* --- CART PAGE STYLES --- */

.cart-page-layout {
    --cart-page-bottom-gap: 16px;
    display: flex;
    flex-direction: column;
}

.cart-scroll-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cart-scroll-area .product-list {
    margin-top: 0;
    overflow: visible;
    flex: 0 0 auto;
}

.cart-scroll-area .cart-summary {
    margin-top: 0;
}

/* Delivery Info Box */
.delivery-info-box {
    border: 1px solid #E0E0E0;
    border-radius: 12px;
    padding: 16px 20px;
    background-color: #F9FAFB;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.delivery-info-box-compact {
    padding: 8px 12px;
}

.delivery-info-box-compact .delivery-info-row {
    font-size: 14px;
}

.delivery-info-row {
    display: flex;
    align-items: center;
    font-size: 15px;
    line-height: 1.5;
}

.info-label {
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 90px;
}

.info-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* Cart Summary */
.cart-summary {
    background-color: #fff;
    border-radius: 16px;
    padding: 20px;
    margin-top: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.03);
    border: 1px solid #F0F0F0;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 20px;
    color: #666;
    font-weight: 700;
}

.summary-row:last-child {
    margin-bottom: 0;
}

.summary-row.discount {
    color: var(--brand-green);
}

.summary-label-group,
.summary-value-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.summary-hint {
    font-size: 16px;
    color: #999;
}

input.discount-input {
    width: 55px;
    max-width: 55px;
    flex: 0 0 55px;
    text-align: right;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.95em;
    line-height: 1.2;
}

.summary-action-btn {
    font-size: 0.75em;
    color: #4CAF50;
    background: none;
    border: 1px solid #4CAF50;
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
}

.cart-checkout-action {
    flex: 0 0 auto;
    padding-bottom: var(--cart-page-bottom-gap);
}

.cart-checkout-btn {
    margin-top: 0;
}

.summary-divider {
    height: 1px;
    background-color: #E0E0E0;
    margin: 16px 0;
}

.summary-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 20px;
    font-weight: 700;
    color: #9E9E9E; /* Label color */
}

.total-amount {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Empty State */
.no-products {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 15px;
}

/* Field Validation Error Highlight */
.input-error {
    border-color: #e74c3c !important;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.15) !important;
}

.select-error select {
    border-color: #e74c3c !important;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.15) !important;
}

/* Floating action buttons */
.floating-actions-container {
    position: fixed;
    left: var(--floating-ui-gap);
    right: auto;
    bottom: var(--floating-ui-bottom);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 999;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.floating-actions-container.dragging {
    cursor: grabbing;
}

.floating-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #eee;
    border-radius: 50%;
    background: linear-gradient(135deg, #009688 0%, #00796B 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.floating-actions-container.dragging .floating-btn {
    cursor: grabbing;
    transition: none;
}

.floating-btn:active {
    transform: scale(0.9);
    background-color: #f5f5f5;
}

.floating-btn svg {
    width: 20px;
    height: 20px;
}

.floating-btn#btn-back-to-top {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.floating-btn#btn-back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

html.font-size-sm body {
    zoom: 0.95;
}

html.font-size-lg body {
    zoom: 1.1;
}

@supports not (zoom: 1) {
    html.font-size-sm {
        font-size: 95%;
    }

    html.font-size-lg {
        font-size: 110%;
    }
}

.font-size-btn {
    position: relative;
}

.font-size-btn .font-indicator {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    color: #00796B;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
}


/* ==========================================================================
   Toast 通知（原 notify.css，2026-08 併入以減少 render-blocking 請求）
   對應 js/notify.js；沿用原本掛在 style.css 之後的載入順序，直接附加於檔尾。
   ========================================================================== */

:root{
  --sf-toast-z: 2147483647;
  --sf-toast-bg: rgba(17,24,39,.96);
  --sf-toast-fg: #fff;
  --sf-toast-success: #16a34a;
  --sf-toast-error: #dc2626;
  --sf-toast-warning: #d97706;
  --sf-toast-info: #2563eb;
}

/* When a popover is open, some browsers blur the page via [popover]::backdrop.
   The toast is outside the popover top-layer so it can look visually blurred.
   We counter by giving the toast its own solid/opaque look and ensuring it
   participates in its own stacking/paint context. */

.sf-toast-container{
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: var(--sf-toast-z);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;

  isolation: isolate;
}

@media (min-width: 480px){
  .sf-toast-container{ left: auto; right: 12px; width: min(360px, calc(100vw - 24px)); }
}

.sf-toast{
  pointer-events: auto;
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;

  /* Force crisp rendering even when underlying page is blurred */
  background: var(--sf-toast-bg);
  color: var(--sf-toast-fg);
  box-shadow: 0 14px 40px rgba(0,0,0,.45);

  /* Prevent any inherited blur/filter scenarios */
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;

  transform: translateY(-8px);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
  font-size: 14px;
  line-height: 1.35;
}

.sf-toast.show{ transform: translateY(0); opacity: 1; }

.sf-toast .bar{ width: 10px; height: 100%; border-radius: 10px; }
.sf-toast.success .bar{ background: var(--sf-toast-success); }
.sf-toast.error .bar{ background: var(--sf-toast-error); }
.sf-toast.warning .bar{ background: var(--sf-toast-warning); }
.sf-toast.info .bar{ background: var(--sf-toast-info); }

.sf-toast .title{ font-weight: 700; margin-right: 6px; }
.sf-toast .msg{ overflow-wrap: anywhere; }

.sf-toast button{
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.85);
  font-size: 18px;
  line-height: 1;
  padding: 6px;
  border-radius: 8px;
}

.sf-toast button:active{ transform: scale(.98); }

.sf-toast button:focus-visible{
  outline: 2px solid rgba(255,255,255,.65);
  outline-offset: 2px;
}
