/* ============================================================
   龍達化粧品 B2B 經銷商訂購平台
   Design reference: ldab.com.tw
   Primary: #182148 (deep navy) / #365080 (mid blue) / #8094BD (light blue)
   Accent: #c9a96e (gold) / Neutrals: #717071 / #E0E3E3
   Font: Noto Serif TC (headings) + Noto Sans TC (body) — premium feel
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700&family=Noto+Serif+TC:wght@400;600;700&display=swap');

:root {
    --primary-dark: #182148;
    --primary: #365080;
    --primary-light: #4a6899;
    --primary-lighter: #8094bd;
    --primary-pale: #e8ecf4;
    --accent: #c9a96e;
    --accent-hover: #b89245;
    --accent-light: #dfc99e;
    --accent-pale: #f8f3ea;
    --white: #ffffff;
    --bg: #f4f5f9;
    --bg-warm: #fafafa;
    --bg-card: #ffffff;
    --text: #2d2d2d;
    --text-secondary: #555555;
    --text-light: #717071;
    --text-muted: #9e9e9e;
    --border: #dcdfe6;
    --border-light: #eef0f5;
    --success: #3a9d5c;
    --danger: #d9534f;
    --warning: #e8a838;
    --info: #4a90b8;
    --shadow-sm: 0 1px 3px rgba(24, 33, 72, 0.06);
    --shadow: 0 2px 16px rgba(24, 33, 72, 0.07);
    --shadow-md: 0 4px 24px rgba(24, 33, 72, 0.10);
    --shadow-lg: 0 8px 40px rgba(24, 33, 72, 0.14);
    --radius: 8px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-pill: 50px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font-body: 'Noto Sans TC', -apple-system, 'Segoe UI', sans-serif;
    --font-heading: 'Noto Serif TC', 'Noto Sans TC', serif;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    line-height: 1.7;
    min-height: 100vh;
    letter-spacing: 0.01em;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ============================================================
   Typography
   ============================================================ */
h1, h2, h3 {
    font-family: var(--font-heading);
    color: var(--primary-dark);
    line-height: 1.35;
}

/* ============================================================
   Layout
   ============================================================ */
.site-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Header --- */
.site-header {
    background: var(--white);
    color: var(--text);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 1px 12px rgba(24, 33, 72, 0.06);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1260px;
    margin: 0 auto;
    padding: 0 32px;
    height: 68px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--primary-dark);
    font-family: var(--font-heading);
    font-size: 21px;
    font-weight: 700;
    letter-spacing: 2px;
}

.header-logo .logo-sub {
    display: block;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 400;
    color: var(--primary-lighter);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-top: 2px;
}

/* Nav */
.header-nav {
    display: flex;
    align-items: center;
    gap: 2px;
}

.header-nav a {
    color: var(--text-secondary);
    padding: 8px 18px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: var(--transition);
    position: relative;
}

.header-nav a:hover {
    color: var(--primary);
    background: var(--primary-pale);
}

.header-nav a.active {
    color: var(--white);
    background: var(--primary);
}

.header-nav .nav-cart {
    position: relative;
}

.header-nav .cart-count {
    position: absolute;
    top: 0px;
    right: 6px;
    background: var(--accent);
    color: var(--white);
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* User area */
.header-user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: var(--text-light);
}

.header-user .user-name {
    color: var(--primary);
    font-weight: 600;
}

.header-user .btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 6px 16px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: var(--transition);
}

.header-user .btn-logout:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-pale);
}

/* Category bar */
.category-bar {
    background: var(--primary-dark);
}
.catbar-toggle {
    display: none;
}
.catmenu-overlay {
    display: none;
}

.category-bar-inner {
    max-width: 1260px;
    margin: 0 auto;
    display: flex;
    padding: 0 32px;
    gap: 0;
    overflow: visible;
}

.category-bar a {
    color: rgba(255,255,255,0.6);
    padding: 13px 22px;
    font-size: 13.5px;
    font-weight: 400;
    letter-spacing: 1.5px;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
}

.category-bar a:hover {
    color: rgba(255,255,255,0.9);
    border-bottom-color: rgba(255,255,255,0.3);
}

.category-bar a.active {
    color: var(--white);
    border-bottom-color: var(--accent);
}

/* Category menu with sub-levels */
.catmenu {
    position: relative;
}

/* Trigger = 整個分類區塊（名稱 + 箭頭），hover/click 展開 */
.catmenu-trigger {
    display: flex;
    align-items: center;
    gap: 0;
    cursor: pointer;
    padding: 13px 22px;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s;
    -webkit-tap-highlight-color: rgba(255,255,255,0.1);
    user-select: none;
}
.catmenu.open .catmenu-trigger {
    border-bottom-color: rgba(255,255,255,0.3);
}
@media (hover: hover) and (pointer: fine) {
    .catmenu-trigger:hover {
        border-bottom-color: rgba(255,255,255,0.3);
    }
}
.catmenu-trigger.active {
    border-bottom-color: var(--accent);
}

/* 分類名稱文字連結 */
a.catmenu-text {
    color: rgba(255,255,255,0.6) !important;
    font-size: 13.5px !important;
    font-weight: 400;
    letter-spacing: 1.5px;
    padding: 0 !important;
    border-bottom: none !important;
    white-space: nowrap;
}
.catmenu.open a.catmenu-text {
    color: rgba(255,255,255,0.95) !important;
}
@media (hover: hover) and (pointer: fine) {
    .catmenu-trigger:hover a.catmenu-text {
        color: rgba(255,255,255,0.95) !important;
    }
}
.catmenu-trigger.active a.catmenu-text {
    color: var(--white) !important;
}

/* 箭頭 — 明顯、好點、觸控友好 */
.catmenu-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.55);
    font-size: 12px;
    margin-left: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s, transform 0.25s;
    cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
    .catmenu-trigger:hover .catmenu-arrow {
        color: rgba(255,255,255,0.9);
        background: rgba(255,255,255,0.12);
    }
}
.catmenu.open .catmenu-arrow {
    color: var(--accent);
    background: rgba(255,255,255,0.15);
    transform: rotate(180deg);
}

/* 下拉面板 */
.catmenu-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 200;
    padding-top: 4px; /* 滑鼠移動的緩衝區 */
}
.catmenu.open .catmenu-panel {
    display: block;
}
/* 桌面版 hover 展開（觸控裝置由 media query 覆蓋） */
@media (hover: hover) and (pointer: fine) {
    .catmenu:hover .catmenu-panel {
        display: block;
    }
    .catmenu:hover .catmenu-trigger {
        border-bottom-color: rgba(255,255,255,0.3);
    }
    .catmenu:hover a.catmenu-text {
        color: rgba(255,255,255,0.95) !important;
    }
    .catmenu:hover .catmenu-arrow {
        color: rgba(255,255,255,0.9);
        background: rgba(255,255,255,0.12);
    }
}
.catmenu-panel-inner {
    background: var(--white);
    min-width: 250px;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.2);
    padding: 6px 0;
    animation: catPanelIn 0.18s ease;
}
@keyframes catPanelIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 二階分類群組 */
.catmenu-group {
    border-bottom: 1px solid #f0f0f0;
    padding: 4px 0;
}
.catmenu-group:last-child {
    border-bottom: none;
}
a.catmenu-sub {
    display: block;
    padding: 10px 20px;
    color: var(--text) !important;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-bottom: none !important;
    transition: background 0.15s, color 0.15s;
}
a.catmenu-sub:hover {
    background: #f5f7fa;
    color: var(--primary) !important;
}

/* 三階分類 */
a.catmenu-sub3 {
    display: block;
    padding: 8px 20px 8px 36px;
    color: #666 !important;
    font-size: 13px;
    font-weight: 400;
    border-bottom: none !important;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
a.catmenu-sub3::before {
    content: '';
    position: absolute;
    left: 22px;
    top: 50%;
    width: 6px;
    height: 1px;
    background: #ccc;
}
a.catmenu-sub3:hover {
    background: #f5f7fa;
    color: var(--primary) !important;
}
a.catmenu-sub3:hover::before {
    background: var(--primary);
}

/* Main content */
.main-content {
    flex: 1;
    max-width: 1260px;
    width: 100%;
    margin: 0 auto;
    padding: 36px 32px;
}

/* Footer */
.site-footer {
    background: var(--primary-dark);
    color: rgba(255,255,255,0.45);
    text-align: center;
    padding: 28px 32px;
    font-size: 12.5px;
    letter-spacing: 0.5px;
    line-height: 1.9;
    margin-top: auto;
}

.site-footer a {
    color: var(--accent-light);
}

/* ============================================================
   Page Title
   ============================================================ */
.page-title {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 28px;
    padding-bottom: 14px;
    border-bottom: 3px solid var(--accent);
    display: inline-block;
    letter-spacing: 1px;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 28px;
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border-light);
}

.card-header h2 {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 600;
    color: var(--primary-dark);
    letter-spacing: 0.5px;
}

/* ============================================================
   Stats Grid (Dashboard)
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-card .stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-card .stat-icon.blue {
    background: linear-gradient(135deg, #e8ecf4 0%, #d4dbea 100%);
    color: var(--primary);
}

.stat-card .stat-icon.green {
    background: linear-gradient(135deg, #e3f3e8 0%, #c8e6d0 100%);
    color: var(--success);
}

.stat-card .stat-icon.gold {
    background: linear-gradient(135deg, #f8f3ea 0%, #f0e5cf 100%);
    color: var(--accent);
}

.stat-card .stat-icon.red {
    background: linear-gradient(135deg, #fce8e7 0%, #f5d0cf 100%);
    color: var(--danger);
}

.stat-card .stat-info .stat-value {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1.2;
}

.stat-card .stat-info .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1.4;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: var(--white);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: var(--white);
}

.btn-accent:hover {
    background: linear-gradient(135deg, var(--accent-hover) 0%, #a07e30 100%);
    color: var(--white);
    box-shadow: 0 4px 16px rgba(201, 169, 110, 0.35);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #2d8a4e;
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #c9302c;
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-light);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-pale);
}

.btn-sm {
    padding: 7px 16px;
    font-size: 12.5px;
}

.btn-lg {
    padding: 14px 36px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 1px;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 7px;
    letter-spacing: 0.3px;
}

.form-group label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 11px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text);
    transition: var(--transition);
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-lighter);
    box-shadow: 0 0 0 4px rgba(54, 80, 128, 0.08);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23717071' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

textarea.form-control {
    resize: vertical;
    min-height: 88px;
}

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

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

/* ============================================================
   Tables
   ============================================================ */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 13px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 13.5px;
}

.table th {
    background: var(--bg);
    color: var(--primary);
    font-weight: 600;
    font-size: 12.5px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: #f8f9fd;
}

.table .text-right { text-align: right; }
.table .text-center { text-align: center; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: 0.3px;
}

.badge-primary { background: var(--primary-pale); color: var(--primary); }
.badge-success { background: #e3f3e8; color: var(--success); }
.badge-warning { background: #fef5e0; color: #8a6d1b; }
.badge-danger { background: #fce8e7; color: var(--danger); }
.badge-info { background: #e4f0f8; color: var(--info); }
.badge-secondary { background: #eef0f5; color: #6c757d; }

/* ============================================================
   Flash Messages
   ============================================================ */
.flash-message {
    padding: 14px 22px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.flash-success {
    background: #e3f3e8;
    color: #1a5c2e;
    border-left: 4px solid var(--success);
}

.flash-error {
    background: #fce8e7;
    color: #7a1f1a;
    border-left: 4px solid var(--danger);
}

.flash-warning {
    background: #fef5e0;
    color: #8a6d1b;
    border-left: 4px solid #d05318;
}

.flash-info {
    background: #e4f0f8;
    color: #1a5275;
    border-left: 4px solid var(--info);
}

/* ============================================================
   Product Grid
   ============================================================ */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
    gap: 22px;
}

.product-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow: hidden;
    position: relative;
    transition: var(--transition);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-lighter);
}

.product-card .product-image {
    width: 100%;
    height: 230px;
    object-fit: contain;
    object-position: center;
    padding: 12px;
    box-sizing: border-box;
    background: linear-gradient(135deg, #f5f6fa 0%, #eaecf2 100%);
    display: block;
    transition: transform 0.3s ease;
}
.product-card:hover .product-image {
    transform: scale(1.04);
}

.product-card .product-info {
    padding: 18px 20px 20px;
}

.product-card .product-category {
    font-size: 11px;
    color: var(--primary-lighter);
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.product-card .product-name {
    font-family: var(--font-heading);
    font-size: 15.5px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.product-card .product-subtitle {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 14px;
    letter-spacing: 0.3px;
}

.product-card .product-pricing {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 14px;
}

.product-card .product-price {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}

.product-card .product-original-price {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: line-through;
}

.product-card .product-sku {
    font-size: 11.5px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.product-card .product-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.product-card .product-actions .btn {
    flex: 1;
    font-size: 12.5px;
    padding: 8px 12px;
}

/* Sale badge */
.sale-badge {
    display: inline-block;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    letter-spacing: 1px;
}
.product-card .sale-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
}

/* 原價銷售 badge（金色） */
.no-discount-badge {
    display: inline-block;
    background: linear-gradient(135deg, #c9a96e, #b8954d);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    letter-spacing: 1px;
    box-shadow: 0 2px 6px rgba(201,169,110,0.3);
}
.product-card .no-discount-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
}

/* 庫存狀態 badge */
.stock-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    letter-spacing: 0.5px;
    color: #fff;
}
.stock-badge.stock-low { background: linear-gradient(135deg, #ef8044, #d05318); }
.stock-badge.stock-sold_out { background: #777; }
.product-card .stock-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
}
/* 商品卡片內的庫存文字 */
.stock-line {
    display: inline-block;
    margin-left: 8px;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.3px;
}
.stock-line-normal { color: #2D8A4E; }
.stock-line-low    { color: #D05318; }
.stock-line-sold_out { color: #D9534F; }

.product-stock.stock-line {
    display: block;
    margin-left: 0;
}

/* 庫存膠囊 — 卡片內精緻版,三種狀態 */
.stock-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: transform .15s ease, box-shadow .15s ease;
}
.stock-chip .stock-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.85);
}
.stock-chip .stock-num {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}
.stock-chip-normal {
    background: linear-gradient(135deg, #ecf7f0, #dff0e6);
    color: #1f6b3c;
    border-color: rgba(45,138,78,0.18);
}
.stock-chip-normal .stock-dot {
    background: #2D8A4E;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(45,138,78,0.15);
}
.stock-chip-low {
    background: linear-gradient(135deg, #fff1e3, #ffe1c4);
    color: #a84510;
    border-color: rgba(208,83,24,0.22);
    animation: stockChipPulse 2.4s ease-in-out infinite;
}
.stock-chip-low .stock-dot {
    background: #D05318;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(208,83,24,0.18);
}
.stock-chip-sold_out {
    background: #f1f1f3;
    color: #6e6e74;
    border-color: rgba(0,0,0,0.08);
}
.stock-chip-sold_out .stock-dot {
    background: #9a9aa1;
    box-shadow: 0 0 0 2px #fff;
}
@keyframes stockChipPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(208,83,24,0.0); }
    50%      { box-shadow: 0 0 0 4px rgba(208,83,24,0.10); }
}

/* SKU 那一列改成可橫排放置 chip */
.product-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.product-meta-row .product-sku {
    margin: 0;
}

/* === 商品定價限制徽章(全站共用) === */
/* 1) 不適用折扣券:暖黃,溫和提示 */
.badge-no-coupon {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #8a6914;
    background: #fff3d6;
    border: 1px solid #f0d590;
    border-radius: 10px;
    white-space: nowrap;
    vertical-align: middle;
    letter-spacing: 0.2px;
}
/* 3) 可使用折扣券:柔和綠,正面引導 */
.badge-coupon-eligible {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #1f6b3c;
    background: linear-gradient(135deg, #e6f5ec, #d4ebde);
    border: 1px solid rgba(45,138,78,0.22);
    border-radius: 10px;
    white-space: nowrap;
    vertical-align: middle;
    letter-spacing: 0.2px;
}

/* 2) 原價銷售(全擋):深紅金,更強烈視覺,讓使用者一眼識別 */
.badge-original-price {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 11px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #a8323c, #82252e);
    border: 1px solid rgba(130,37,46,0.35);
    border-radius: 10px;
    white-space: nowrap;
    vertical-align: middle;
    letter-spacing: 0.3px;
    box-shadow: 0 1px 3px rgba(168,50,60,0.25);
}

/* 售完商品卡片 — 變灰並降低彩度 */
.product-card-soldout {
    opacity: 0.65;
    filter: grayscale(0.4);
}
.product-card-soldout:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

/* ============================================================
   Cart
   ============================================================ */
.cart-table .product-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.qty-control {
    display: inline-flex;
    align-items: center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.qty-control button {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.qty-control button:hover {
    background: var(--primary);
    color: var(--white);
}

.qty-control input {
    width: 52px;
    height: 36px;
    border: none;
    border-left: 1.5px solid var(--border);
    border-right: 1.5px solid var(--border);
    text-align: center;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.qty-control input:focus {
    outline: none;
}

/* ============================================================
   Login Page
   ============================================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-dark);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(54,80,128,0.4) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(128,148,189,0.2) 0%, transparent 50%);
    padding: 24px;
}

.login-box {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 52px 44px;
    width: 100%;
    max-width: 430px;
}

.login-box .login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-box .login-logo h1 {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: 3px;
    margin-bottom: 6px;
}

.login-box .login-logo p {
    font-size: 12.5px;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.login-box .form-group {
    margin-bottom: 22px;
}

.login-box .btn-login {
    width: 100%;
    padding: 15px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 2px;
    background: var(--primary-dark);
    border: none;
    color: var(--white);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
}

.login-box .btn-login:hover {
    background: var(--primary);
    box-shadow: 0 6px 24px rgba(24, 33, 72, 0.3);
    transform: translateY(-2px);
}

/* ============================================================
   Order Summary / Checkout
   ============================================================ */
.order-summary {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 22px;
}

.order-summary .summary-row {
    display: flex;
    justify-content: space-between;
    padding: 9px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.order-summary .summary-total {
    border-top: 2px solid var(--primary-dark);
    margin-top: 10px;
    padding-top: 14px;
    font-size: 19px;
    font-weight: 700;
    color: var(--primary-dark);
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
    display: flex;
    gap: 5px;
    justify-content: center;
    margin-top: 28px;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 500;
    border: 1.5px solid var(--border);
    color: var(--text-light);
    transition: var(--transition);
}

.pagination a:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-pale);
}

.pagination .active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* ============================================================
   Print Delivery Note
   ============================================================ */
@media print {
    body * { visibility: hidden; }
    .print-area, .print-area * { visibility: visible; }
    .print-area { position: absolute; left: 0; top: 0; width: 100%; }
    .no-print { display: none !important; }
}

.delivery-note {
    max-width: 800px;
    margin: 0 auto;
    padding: 30px;
    background: white;
    font-size: 13px;
    font-family: var(--font-body);
}

.delivery-note .dn-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 3px solid var(--primary-dark);
    padding-bottom: 18px;
    margin-bottom: 22px;
}

.delivery-note .dn-company {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: 2px;
}

.delivery-note .dn-title {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: 6px;
}

.delivery-note .dn-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 22px;
    font-size: 13px;
}

.delivery-note .dn-info .info-label {
    color: var(--text-muted);
    min-width: 70px;
    display: inline-block;
}

.delivery-note table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.delivery-note table th {
    background: var(--primary-dark);
    color: white;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.delivery-note table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.delivery-note table tfoot td {
    font-weight: 700;
    border-top: 2px solid var(--primary-dark);
}

.delivery-note .dn-footer {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 24px;
    margin-top: 44px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.delivery-note .dn-stamp {
    text-align: center;
    padding-top: 52px;
    border-top: 1px solid var(--text);
    font-size: 13px;
    color: var(--text-light);
    letter-spacing: 2px;
}

/* ============================================================
   Filter Bar
   ============================================================ */
.filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filter-bar .form-control {
    width: auto;
    min-width: 160px;
}

/* ============================================================
   Utilities
   ============================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

/* Actions cell */
.actions-cell {
    display: flex;
    gap: 6px;
}

/* ============================================================
   RWD Layout Classes
   ============================================================ */
.two-col-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.page-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.page-header-actions {
    display: flex;
    gap: 8px;
}

.search-inline {
    display: flex;
    gap: 8px;
}

.search-inline .form-control {
    width: 260px;
}

/* Cart bottom bar */
.cart-bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: 20px;
    flex-wrap: wrap;
    gap: 20px;
}

.cart-bottom-actions {
    display: flex;
    gap: 8px;
}

.cart-summary {
    min-width: 300px;
}

/* Product detail pricing */
/* Key-value detail table (不強制最小寬度) */
.table-detail {
    min-width: auto !important;
}
.td-label {
    width: 100px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Product detail image */
.product-detail-img {
    width: 100%;
    max-height: 480px;
    object-fit: contain;
    background: linear-gradient(135deg, #f5f6fa 0%, #eaecf2 100%);
    padding: 16px;
    box-sizing: border-box;
    border-radius: var(--radius-lg);
}

.product-detail-pricing {
    background: var(--bg);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.product-detail-price-row {
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
}

.product-detail-price {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}

.product-detail-original {
    font-size: 16px;
    color: var(--text-muted);
    text-decoration: line-through;
}

.product-detail-sale-end {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

.product-detail-level {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Product detail action row */
.product-detail-action {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* Product description rich content (from CKEditor) */
.product-description-content {
    line-height: 1.8;
    color: var(--text-light);
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.product-description-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 8px 0;
}
.product-description-content p {
    margin-bottom: 12px;
}
.product-description-content ul,
.product-description-content ol {
    margin-bottom: 12px;
    padding-left: 24px;
}
.product-description-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
}
.product-description-content table td,
.product-description-content table th {
    border: 1px solid var(--border-light);
    padding: 8px;
}
.product-description-content h1,
.product-description-content h2,
.product-description-content h3,
.product-description-content h4 {
    color: var(--primary);
    margin-bottom: 8px;
    margin-top: 16px;
}
.product-description-content blockquote {
    border-left: 4px solid var(--primary);
    margin: 12px 0;
    padding: 8px 16px;
    background: var(--bg);
    color: var(--text-light);
}
.product-description-content a {
    color: var(--accent);
    text-decoration: underline;
}

/* Filter bar scrollable */
.filter-bar-scroll {
    flex-wrap: nowrap;
}

/* Utility classes */
.text-xs { font-size: 12px; }
.text-line-through { text-decoration: line-through; }
.fw-500 { font-weight: 500; }

/* Desktop/Mobile toggle (hidden by default, controlled by media queries) */
.mobile-only { display: none !important; }
.desktop-only { display: block !important; }

/* ============================================================
   Mobile Order Cards
   ============================================================ */
.mobile-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.mobile-order-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
    transition: var(--transition);
}

.mobile-order-card:active {
    background: var(--primary-pale);
}

.mobile-order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}

.mobile-order-body .mobile-order-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13.5px;
}

/* ============================================================
   Mobile Cart Cards
   ============================================================ */
.mobile-cart-card {
    border-bottom: 1px solid var(--border-light);
    padding: 16px 0;
}

.mobile-cart-card:first-child {
    padding-top: 0;
}

.mobile-cart-card:last-child {
    border-bottom: none;
}

.mobile-cart-top {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.mobile-cart-img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    flex-shrink: 0;
}

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

.mobile-cart-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary-dark);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    margin-bottom: 2px;
}

.mobile-cart-price {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 4px;
}

.mobile-cart-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* ============================================================
   Responsive
   ============================================================ */
/* ============================================================
   Product Detail & Checkout Layout (desktop defaults)
   ============================================================ */
.product-detail-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 32px;
}

.checkout-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
}

.checkout-summary-card {
    position: sticky;
    top: 80px;
}

/* ============================================================
   Mobile Menu Button (hidden on desktop)
   ============================================================ */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--primary-pale);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    padding: 0;
    z-index: 10;
    flex-direction: column;
    gap: 5px;
    transition: var(--transition);
}

.mobile-menu-btn:hover,
.mobile-menu-btn:active {
    background: var(--primary);
    border-color: var(--primary);
}

.mobile-menu-btn:hover span,
.mobile-menu-btn:active span {
    background: var(--white);
}

.mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2.5px;
    background: var(--primary-dark);
    border-radius: 2px;
    transition: var(--transition);
}

/* Hamburger → X animation when open */
.mobile-menu-btn.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.mobile-menu-btn.open span:nth-child(2) {
    opacity: 0;
}
.mobile-menu-btn.open span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile Navigation Panel (hidden on desktop) */
.header-mobile-nav {
    display: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.mobile-nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--white);
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    padding: 0 6px;
    margin-left: 4px;
}

/* ============================================================
   Responsive: Tablet (max-width: 1024px)
   ============================================================ */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .product-detail-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
    .checkout-grid { grid-template-columns: 1fr 320px; gap: 20px; }
    .header-nav a { padding: 8px 12px; font-size: 13px; }
    .header-top { padding: 0 20px; }
    .main-content { padding: 28px 20px; }
    .search-inline .form-control { width: 200px; }
}

/* ============================================================
   Responsive: Mobile (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {
    html { font-size: 14px; }

    /* Header */
    .header-top {
        padding: 10px 16px;
        height: auto;
        flex-wrap: nowrap;
    }
    .header-logo { font-size: 17px; gap: 10px; }
    .header-logo .logo-sub { font-size: 9px; letter-spacing: 1.5px; }

    /* 隱藏桌面版導航和使用者區塊 */
    .header-nav { display: none; }
    .header-user { display: none; }

    /* 顯示漢堡選單按鈕 */
    .mobile-menu-btn { display: flex; }

    /* 手機版導航面板 — 固定式抽屜，內部可獨立捲動 */
    .header-mobile-nav {
        display: block;
        position: fixed;
        top: 60px;              /* 由 JS 動態套用實際 header 高度 */
        left: 0;
        right: 0;
        bottom: 0;
        max-height: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        background: var(--white);
        border-top: 1px solid var(--border-light);
        z-index: 999;
        transform: translateY(-12px);
        opacity: 0;
        visibility: hidden;
        transition: transform 0.28s ease, opacity 0.28s ease, visibility 0s linear 0.28s;
    }
    .header-mobile-nav.open {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
        transition: transform 0.28s ease, opacity 0.28s ease, visibility 0s linear 0s;
    }
    body.menu-open {
        overflow: hidden;
    }
    .header-mobile-nav a {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 15px 20px;
        font-size: 15px;
        font-weight: 500;
        color: var(--text-secondary);
        border-bottom: 1px solid var(--border-light);
        transition: background 0.15s, color 0.15s;
    }
    .header-mobile-nav a svg {
        flex-shrink: 0;
        opacity: 0.5;
    }
    .header-mobile-nav a:hover,
    .header-mobile-nav a:active {
        background: var(--primary-pale);
        color: var(--primary);
    }
    .header-mobile-nav a:hover svg,
    .header-mobile-nav a:active svg {
        opacity: 1;
    }
    .header-mobile-nav a.active {
        background: var(--primary);
        color: var(--white);
    }
    .header-mobile-nav a.active svg {
        opacity: 1;
    }
    .mobile-nav-user {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
        background: var(--bg);
    }
    .mobile-nav-user-info {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }
    .mobile-nav-company {
        font-size: 14px;
        font-weight: 600;
        color: var(--primary-dark);
    }
    .mobile-nav-level {
        font-size: 12px;
        color: var(--text-muted);
    }
    .mobile-nav-logout {
        display: inline-flex;
        align-items: center;
        padding: 8px 18px !important;
        background: transparent;
        border: 1.5px solid var(--danger) !important;
        border-radius: var(--radius-pill);
        color: var(--danger) !important;
        font-size: 13px !important;
        font-weight: 500;
        gap: 0 !important;
    }
    .mobile-nav-logout:hover {
        background: var(--danger) !important;
        color: var(--white) !important;
    }

    /* ===== 手機版：隱藏桌面分類列（改用漢堡選單內的分類） ===== */
    .category-bar { display: none !important; }

    /* ===== 手機版漢堡選單內：商品目錄 Accordion ===== */
    .mobile-nav-catalog {
        border-bottom: 1px solid var(--border-light);
    }
    .mobile-nav-catalog-toggle {
        display: flex !important;
        align-items: center;
        gap: 12px;
        padding: 15px 20px;
        font-size: 15px;
        font-weight: 500;
        color: var(--text-secondary);
        cursor: pointer;
        width: 100%;
        border-bottom: none !important;
    }
    .mobile-nav-catalog-toggle span:first-of-type {
        flex: 1;
        text-align: left;
    }
    .mobile-nav-catalog-arrow {
        font-size: 12px;
        transition: transform 0.25s;
        opacity: 0.5;
    }
    .mobile-nav-catalog.open .mobile-nav-catalog-arrow {
        transform: rotate(180deg);
    }
    .mobile-nav-catalog-toggle:hover,
    .mobile-nav-catalog-toggle:active {
        background: var(--primary-pale);
        color: var(--primary);
    }
    .mobile-nav-catalog-toggle.active {
        background: var(--primary);
        color: var(--white);
    }
    .mobile-nav-catalog-toggle.active svg {
        opacity: 1;
    }

    /* 分類面板：accordion 展開 */
    .mobile-nav-catalog-panel {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s ease;
        background: var(--bg);
    }
    .mobile-nav-catalog.open .mobile-nav-catalog-panel {
        max-height: 2000px;
    }

    /* 分類項目 */
    .mobile-cat-item {
        display: block !important;
        padding: 13px 20px 13px 52px !important;
        font-size: 14px !important;
        font-weight: 400 !important;
        color: var(--text-secondary) !important;
        border-bottom: 1px solid var(--border-light) !important;
        min-height: 44px;
        line-height: 1.3;
        gap: 0 !important;
    }
    .mobile-cat-item:active {
        background: var(--primary-pale);
        color: var(--primary) !important;
    }
    .mobile-cat-item.current {
        color: var(--primary) !important;
        font-weight: 600 !important;
        background: rgba(26,54,93,0.04);
    }

    /* 有子分類的父項目 */
    .mobile-cat-parent {
        display: flex;
        align-items: center;
    }
    .mobile-cat-parent .mobile-cat-item {
        flex: 1;
    }
    .mobile-cat-expand {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        min-height: 44px;
        background: transparent;
        border: none;
        border-left: 1px solid var(--border-light);
        border-bottom: 1px solid var(--border-light);
        color: var(--text-muted);
        font-size: 13px;
        cursor: pointer;
        transition: background 0.15s, transform 0.25s;
        flex-shrink: 0;
    }
    .mobile-cat-expand:active {
        background: var(--primary-pale);
    }
    .mobile-cat-expand.open {
        color: var(--primary);
        background: rgba(26,54,93,0.04);
        transform: rotate(180deg);
    }

    /* 子分類面板（共用：第二層／第三層） */
    .mobile-cat-children {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        background: rgba(26,54,93,0.03);
    }
    .mobile-cat-children.open {
        max-height: 3000px;
    }
    /* 第三層 accordion 巢狀於第二層之中，使用更深底色以呈現層級 */
    .mobile-cat-children-l3 {
        background: rgba(26,54,93,0.06);
    }

    /* 二階子分類列（含可展開的第三層） */
    .mobile-cat-parent-l2 {
        display: flex;
        align-items: center;
    }
    .mobile-cat-parent-l2 .mobile-cat-sub {
        flex: 1;
    }
    .mobile-cat-expand-l3 {
        width: 44px;
        min-height: 42px;
    }

    /* 二階子分類 */
    .mobile-cat-sub {
        display: block !important;
        padding: 12px 20px 12px 68px !important;
        font-size: 13.5px !important;
        font-weight: 500 !important;
        color: var(--text-secondary) !important;
        border-bottom: 1px solid var(--border-light) !important;
        min-height: 42px;
        gap: 0 !important;
    }
    .mobile-cat-sub:active {
        background: var(--primary-pale);
        color: var(--primary) !important;
    }

    /* 三階子分類 */
    .mobile-cat-sub3 {
        display: block !important;
        padding: 10px 20px 10px 88px !important;
        font-size: 12.5px !important;
        font-weight: 400 !important;
        color: var(--text-muted) !important;
        border-bottom: 1px solid var(--border-light) !important;
        min-height: 40px;
        position: relative;
        gap: 0 !important;
    }
    .mobile-cat-sub3::before {
        content: '';
        position: absolute;
        left: 76px;
        top: 50%;
        width: 6px;
        height: 1px;
        background: var(--text-muted);
    }
    .mobile-cat-sub3:active {
        background: var(--primary-pale);
        color: var(--primary) !important;
    }

    /* Main content */
    .main-content { padding: 20px 14px; }
    .card { padding: 16px; }

    /* Two column → single column */
    .two-col-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Page header flex → stack */
    .page-header-flex {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .page-header-actions {
        display: flex;
        gap: 8px;
    }

    .page-header-actions .btn {
        flex: 1;
        text-align: center;
    }

    /* Search inline */
    .search-inline {
        width: 100%;
    }

    .search-inline .form-control {
        width: 100%;
        flex: 1;
    }

    /* Product detail: 單欄 */
    .product-detail-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .product-detail-grid > div:first-child {
        max-width: 320px;
        margin: 0 auto;
        text-align: center;
    }
    .product-detail-img {
        max-height: 320px;
        object-fit: contain;
    }
    .product-detail-grid h1 {
        font-size: 20px !important;
    }
    .product-detail-grid .table {
        min-width: auto !important;
        font-size: 13px;
    }

    /* Product detail pricing responsive */
    .product-detail-price {
        font-size: 24px;
    }

    .product-detail-original {
        font-size: 14px;
    }

    /* Product detail action wrap */
    .product-detail-action {
        flex-wrap: wrap;
        gap: 10px;
    }

    .product-detail-action .btn-add-cart {
        width: 100%;
        order: 3;
    }

    /* Checkout: 單欄 */
    .checkout-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .checkout-summary-card {
        position: static;
    }

    /* Form */
    .form-row, .form-row-3 { grid-template-columns: 1fr; }

    /* Product grid - better sizing for mobile */
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .product-card .product-image { height: 170px; padding: 10px; }
    .product-card .product-info { padding: 12px 14px 14px; }
    .product-card .product-name { font-size: 14px; }
    .product-card .product-price { font-size: 17px; }
    .product-card .product-subtitle { font-size: 11.5px; margin-bottom: 8px; }
    .product-card .product-actions { flex-direction: column; gap: 6px; }
    .product-card .product-actions .btn { font-size: 12px; padding: 7px 10px; }

    /* Stats: 2 columns on mobile instead of 1 */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 16px; gap: 12px; }
    .stat-card .stat-icon { width: 42px; height: 42px; }
    .stat-card .stat-info .stat-value { font-size: 20px; }
    .stat-card .stat-info .stat-label { font-size: 12px; }

    /* Tables: 水平捲動 */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-responsive .table { min-width: 600px; }
    .table-detail { min-width: auto !important; font-size: 13px; }
    .td-label { width: 80px; font-size: 12px; }

    /* Show mobile, hide desktop */
    .mobile-only { display: block !important; }
    .desktop-only { display: none !important; }

    /* 按鈕更大方便觸控 */
    .btn, .btn-login, button[type="submit"] { min-height: 44px; }
    .qty-control input { width: 48px; }

    /* Cart bottom bar */
    .cart-bottom-bar {
        flex-direction: column;
        gap: 16px;
    }

    .cart-bottom-actions {
        width: 100%;
    }

    .cart-bottom-actions .btn {
        flex: 1;
    }

    .cart-summary {
        min-width: auto;
        width: 100%;
    }

    /* Filter bar scrollable on mobile */
    .filter-bar-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    .filter-bar-scroll::-webkit-scrollbar { display: none; }
    .filter-bar-scroll .btn { flex-shrink: 0; }

    /* Pagination - compact */
    .pagination { flex-wrap: wrap; gap: 4px; }
    .pagination a, .pagination span { min-width: 34px; height: 34px; padding: 0 8px; font-size: 12px; }

    /* Delivery note */
    .delivery-note .dn-info { grid-template-columns: 1fr; }
    .delivery-note .dn-footer { grid-template-columns: 1fr; }

    /* 頁面標題 */
    .page-title { font-size: 20px; margin-bottom: 20px; padding-bottom: 10px; }

    /* Login box */
    .login-box { padding: 32px 24px; margin: 16px; }

    /* Footer */
    .site-footer { padding: 20px 16px; font-size: 11.5px; }
    .site-footer p { line-height: 1.7; }
}

/* ============================================================
   Responsive: Small phone (max-width: 400px)
   ============================================================ */
@media (max-width: 400px) {
    .header-logo { font-size: 15px; letter-spacing: 1px; }
    .header-logo .logo-sub { display: none; }
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .product-card .product-image { height: 140px; padding: 8px; }
    .product-card .product-info { padding: 10px 10px 12px; }
    .product-card .product-name { font-size: 13px; }
    .product-card .product-price { font-size: 15px; }
    .product-card .product-category { font-size: 10px; }
    .card { padding: 12px; }
    .main-content { padding: 12px 8px; }
    /* 小手機：分類選單更緊湊 */
    .mobile-cat-item { padding: 11px 16px 11px 44px !important; font-size: 13px !important; }
    .mobile-cat-sub { padding: 10px 16px 10px 58px !important; font-size: 12.5px !important; }
    .mobile-cat-sub3 { padding: 9px 16px 9px 72px !important; font-size: 12px !important; }
    .mobile-cat-sub3::before { left: 62px; }

    /* Stats: single column on very small phones */
    .stats-grid { grid-template-columns: 1fr; }

    /* Page title smaller */
    .page-title { font-size: 18px; }

    /* Mobile cart img smaller */
    .mobile-cart-img { width: 60px; height: 60px; }

    /* Product detail */
    .product-detail-price { font-size: 22px; }
    .product-detail-grid > div:first-child { max-width: 240px; }
    .product-detail-img { max-height: 240px; }

    /* Footer even more compact */
    .site-footer { padding: 16px 12px; font-size: 11px; }
}
